修复九宫格空隙 背包拖拽系统完成
This commit is contained in:
parent
f4bd95e9d1
commit
bb56b687ea
BIN
Yosin_Engine.exe
BIN
Yosin_Engine.exe
Binary file not shown.
|
|
@ -157,7 +157,7 @@ class Yosin_EmeStretch extends Yosin_CommonUi {
|
|||
// 创建画布
|
||||
local Canvas = CL_CanvasObject();
|
||||
// 重设大小并清空
|
||||
Canvas.ResizeAndClear( W, H);
|
||||
Canvas.ResizeAndClear(W, H);
|
||||
// 开始绘制
|
||||
Canvas.BeginDraw();
|
||||
|
||||
|
|
@ -253,41 +253,41 @@ function Yosin_NineBoxStretch(X, Y, width, height, path, imgId) {
|
|||
|
||||
// 上边
|
||||
backgroundTop.SetScale(scaleW, 1);
|
||||
backgroundTop.SetPosition(TopLeftRight + 1, 0);
|
||||
backgroundTop.SetPosition(TopLeftRight, 0);
|
||||
Canvas.DrawSprite(backgroundTop);
|
||||
|
||||
// 右上角
|
||||
backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w, 0);
|
||||
backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0);
|
||||
Canvas.DrawSprite(backgroundTopRight);
|
||||
|
||||
// 左边
|
||||
backgroundLeft.SetScale(1, scaleH);
|
||||
backgroundLeft.SetPosition(0, TopLeftBottom + 1);
|
||||
backgroundLeft.SetPosition(0, TopLeftBottom);
|
||||
Canvas.DrawSprite(backgroundLeft);
|
||||
|
||||
// 中间
|
||||
backgroundCenter.SetScale(scaleW, scaleH);
|
||||
// Addchild(backgroundCenter);
|
||||
backgroundCenter.SetPosition(TopLeftRight + 1, backgroundLeft.Y);
|
||||
backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y);
|
||||
Canvas.DrawSprite(backgroundCenter);
|
||||
|
||||
// 右边
|
||||
backgroundRight.SetScale(1, scaleH);
|
||||
backgroundRight.SetPosition(width - backgroundRight.GetSize().w, backgroundCenter.Y);
|
||||
backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y);
|
||||
Canvas.DrawSprite(backgroundRight);
|
||||
|
||||
// 左下角
|
||||
backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h);
|
||||
backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1);
|
||||
Canvas.DrawSprite(backgroundBottomLeft);
|
||||
|
||||
// 下边
|
||||
backgroundBottom.SetScale(scaleW, 1);
|
||||
backgroundBottom.SetPosition(TopLeftRight + 1, backgroundBottomLeft.Y);
|
||||
backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y);
|
||||
Canvas.DrawSprite(backgroundBottom);
|
||||
|
||||
// 右下角
|
||||
backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y);
|
||||
Canvas.DrawSprite(backgroundBottomRight );
|
||||
backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y);
|
||||
Canvas.DrawSprite(backgroundBottomRight);
|
||||
|
||||
// 结束绘制
|
||||
Canvas.EndDraw();
|
||||
|
|
@ -298,6 +298,7 @@ function Yosin_NineBoxStretch(X, Y, width, height, path, imgId) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// //九宫格拉伸
|
||||
// class Yosin_NineBoxStretch extends Yosin_CommonUi {
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class GameItem.EquipmentInfo extends Yosin_Window {
|
|||
|
||||
Init();
|
||||
|
||||
local background = Yosin_NineBoxStretch(0, 0, 208, RealCanvasHeight + 10, "sprite/interface/lenheartwindowcommon.img", 213);
|
||||
local background = Yosin_NineBoxStretch(0, 0, 211, RealCanvasHeight + 10, "sprite/interface/lenheartwindowcommon.img", 213);
|
||||
background.SetZOrder(-1);
|
||||
Addchild(background);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class GameObject.NPC extends GameObject.BaseClass {
|
|||
//设置Ani描边
|
||||
Ani.SetOutline(true, sq_RGBA(155, 255, 0, 250));
|
||||
//设置鼠标
|
||||
Yosin_Cursor.ChangeActive(120, 4);
|
||||
IMouse.ChangeActive(120, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ class GameObject.NPC extends GameObject.BaseClass {
|
|||
IsHover = false;
|
||||
Ani.SetOutline(false);
|
||||
//设置鼠标
|
||||
Yosin_Cursor.Change(0);
|
||||
IMouse.Change(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ function TestStage() {
|
|||
|
||||
// local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0);
|
||||
|
||||
|
||||
// local BackGround = CL_SpriteObject("sprite/loding.img", 0);
|
||||
// T.Addchild(BackGround);
|
||||
|
||||
// local Equ = GameItem.Equipment(27675);
|
||||
// local Window = Equ.GetEquipmentInfoWindow();
|
||||
|
|
@ -29,6 +30,12 @@ function TestStage() {
|
|||
// Window.SetPosition(580, 80);
|
||||
// Window.ResetFocus();
|
||||
|
||||
|
||||
local TownObj = Town(1);
|
||||
local Charc = GameObject.CreateCharacter(0, [101590007, 27675, 601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]);
|
||||
TownObj.AddObject(Charc, true);
|
||||
ClientCharacter = Charc;
|
||||
|
||||
local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 257, 555, 20);
|
||||
|
||||
Window.equipmentPage.Item.ItemCollection.SetItemList([{
|
||||
|
|
@ -52,10 +59,6 @@ function TestStage() {
|
|||
// NPCobj.SetPosition(400, 400, 0);
|
||||
// T.Addchild(NPCobj);
|
||||
|
||||
// local TownObj = Town(1);
|
||||
// local Charc = GameObject.CreateCharacter(0, [101590007, 27675, 601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]);
|
||||
// TownObj.AddObject(Charc, true);
|
||||
// ClientCharacter = Charc;
|
||||
|
||||
|
||||
// local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
|
||||
|
|
|
|||
|
|
@ -18,8 +18,12 @@ class _IMouse_ extends _Yosin_Cursor {
|
|||
//动态帧 Timer
|
||||
ActiveFrameTimer = 0;
|
||||
|
||||
//挂载的对象List
|
||||
AttachObjList = null;
|
||||
|
||||
constructor() {
|
||||
NormalC = [];
|
||||
AttachObjList = {};
|
||||
base.constructor();
|
||||
getroottable().IMouse <- this;
|
||||
|
||||
|
|
@ -61,6 +65,26 @@ class _IMouse_ extends _Yosin_Cursor {
|
|||
this.ActiveCurrentFrame = 0;
|
||||
}
|
||||
|
||||
//挂载一个对象位于鼠标下
|
||||
function AttachObjectBottom(KeyName, Obj) {
|
||||
AttachObjList.rawset(KeyName, {
|
||||
Object = Obj,
|
||||
ZOrder = Obj.GetZOrder
|
||||
});
|
||||
Obj.SetZOrder(-1);
|
||||
Addchild(Obj);
|
||||
}
|
||||
|
||||
//移除一个挂载的对象
|
||||
function RemoveObject(KeyName) {
|
||||
if (AttachObjList.rawin(KeyName)) {
|
||||
local Obj = AttachObjList[KeyName].Object;
|
||||
Obj.SetZOrder(AttachObjList[KeyName].ZOrder);
|
||||
Removechild(Obj);
|
||||
AttachObjList.rawdelete(KeyName);
|
||||
}
|
||||
}
|
||||
|
||||
function OnMouseProc(MousePos_X, MousePos_Y) {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
文件名:5_Inventory.nut
|
||||
路径:User/UI/Window/5_Inventory.nut
|
||||
创建日期:2025-01-02 12:37
|
||||
文件用途: 背包窗口
|
||||
*/
|
||||
|
||||
class _Inventory extends Yosin_Window {
|
||||
|
||||
item = null;
|
||||
dressUpTitleBtn = null;
|
||||
petTitleBtn = null;
|
||||
stoneTitleBtn = null;
|
||||
|
||||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||||
base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||||
|
||||
local title = Yosin_TopTitle(gWidth, gHeight, "装备栏(I)");
|
||||
AddUIChild(title);
|
||||
|
||||
local item2 = Yosin_EmeStretch(100, 100, 80, 25, "sprite/interface/lenheartwindowcommon.img", 160);
|
||||
Addchild(item2);
|
||||
|
||||
//注册控件
|
||||
RegisterWidget();
|
||||
}
|
||||
|
||||
function RegisterWidget() {
|
||||
|
||||
//, "装扮", "宠物", "护石"
|
||||
local titlesBtn = Yosin_RowMoreTitleBtn(10, 25, ["物品栏"]);
|
||||
AddUIChild(titlesBtn);
|
||||
|
||||
titlesBtn.LBDownOnClick = function(btns, index) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
local item = Yosin_SplicingButton(10, 50, 80, 25, "sprite/interface/lenheartwindowcommon.img", 160, true, false);
|
||||
AddUIChild(item);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//逻辑入口
|
||||
function Proc(Dt) {
|
||||
SyncPos(X, Y);
|
||||
base.Proc(Dt);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -73,6 +73,10 @@ class _ItemCollection extends Yosin_CommonUi {
|
|||
CurrentShowItem = null;
|
||||
//当前鼠标指向的位置
|
||||
ItemPos = null;
|
||||
//拖拽中的物品对象
|
||||
DragItem = null;
|
||||
//拖拽物品原来的位置
|
||||
DragItemPos = null;
|
||||
|
||||
|
||||
constructor(x, y, rowNum) {
|
||||
|
|
@ -117,18 +121,7 @@ class _ItemCollection extends Yosin_CommonUi {
|
|||
|
||||
//设置道具列表
|
||||
function SetItemList(gItemList) {
|
||||
//如果不存在则构造画布
|
||||
if (!TopCanvas) {
|
||||
// 创建画布
|
||||
TopCanvas = CL_CanvasObject();
|
||||
// 添加画布
|
||||
Addchild(TopCanvas);
|
||||
}
|
||||
|
||||
// 重设大小并清空
|
||||
TopCanvas.ResizeAndClear(239, this.RowNum * 30);
|
||||
// 开始绘制
|
||||
TopCanvas.BeginDraw();
|
||||
//创建道具
|
||||
foreach(Index, ItemObject in gItemList) {
|
||||
local ItemId = ItemObject.ItemId;
|
||||
|
|
@ -138,6 +131,22 @@ class _ItemCollection extends Yosin_CommonUi {
|
|||
ItemList[Index].SetItem(Item);
|
||||
}
|
||||
|
||||
RefreshItemList();
|
||||
}
|
||||
|
||||
//刷新道具列表
|
||||
function RefreshItemList() {
|
||||
//如果不存在则构造画布
|
||||
if (!TopCanvas) {
|
||||
// 创建画布
|
||||
TopCanvas = CL_CanvasObject();
|
||||
// 添加画布
|
||||
Addchild(TopCanvas);
|
||||
}
|
||||
// 重设大小并清空
|
||||
TopCanvas.ResizeAndClear(239, this.RowNum * 30);
|
||||
// 开始绘制
|
||||
TopCanvas.BeginDraw();
|
||||
foreach(pos, ItemObj in ItemList) {
|
||||
if (ItemObj) {
|
||||
local XPos = (pos % 8) * 30;
|
||||
|
|
@ -146,7 +155,6 @@ class _ItemCollection extends Yosin_CommonUi {
|
|||
TopCanvas.DrawSprite(ItemObj.ItemIcon, XPos, YPos);
|
||||
}
|
||||
}
|
||||
|
||||
// 结束绘制
|
||||
TopCanvas.EndDraw();
|
||||
}
|
||||
|
|
@ -179,11 +187,14 @@ class _ItemCollection extends Yosin_CommonUi {
|
|||
if (CurrentShowItem) {
|
||||
CurrentShowItem.CloseInfo();
|
||||
}
|
||||
//如果当前没有拖拽物品时才打开详细信息窗口
|
||||
if (!DragItem) {
|
||||
//显示详细信息
|
||||
ItemList[Idx].ShowInfo(MousePos_X - 50, MousePos_Y - 150);
|
||||
//记录当前显示的对象
|
||||
CurrentShowItem = ItemList[Idx];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//关闭上一个显示的对象
|
||||
if (CurrentShowItem) {
|
||||
|
|
@ -195,6 +206,7 @@ class _ItemCollection extends Yosin_CommonUi {
|
|||
HoverEffect.SetVisible(true);
|
||||
HoverEffect.SetPosition(row * 30, column * 30);
|
||||
} else {
|
||||
ItemPos = null;
|
||||
HoverEffect.SetVisible(false);
|
||||
//关闭所有详细信息显示
|
||||
foreach(ItemObj in ItemList) {
|
||||
|
|
@ -215,10 +227,35 @@ class _ItemCollection extends Yosin_CommonUi {
|
|||
CurrentShowItem.CloseInfo();
|
||||
}
|
||||
|
||||
if (ItemPos) {
|
||||
local Item = ItemList[ItemPos];
|
||||
if (ItemPos != null && ItemList[ItemPos]) {
|
||||
DragItem = ItemList[ItemPos];
|
||||
DragItemPos = ItemPos;
|
||||
ItemList[ItemPos] = null;
|
||||
local IconBuffer = DragItem.Item.GetEquipmentIconSprite();
|
||||
IconBuffer.SetPosition(-15, -15);
|
||||
IMouse.AttachObjectBottom("ItemCollectDragItem", IconBuffer);
|
||||
RefreshItemList();
|
||||
}
|
||||
}
|
||||
|
||||
//override
|
||||
//鼠标左键弹起回调
|
||||
function OnMouseLbUp(MousePos_X, MousePos_Y) {
|
||||
if (!Visible) return;
|
||||
base.OnMouseLbUp(MousePos_X, MousePos_Y);
|
||||
|
||||
if (DragItem) {
|
||||
//如果这个格子不是空的 要把他放回交换的位置
|
||||
if (ItemList[ItemPos] != null) {
|
||||
local Temp = ItemList[ItemPos];
|
||||
ItemList[DragItemPos] = Temp;
|
||||
DragItemPos = null;
|
||||
}
|
||||
|
||||
ItemList[ItemPos] = DragItem;
|
||||
DragItem = null;
|
||||
IMouse.RemoveObject("ItemCollectDragItem");
|
||||
RefreshItemList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue