diff --git a/Yosin_Engine.exe b/Yosin_Engine.exe index 98d5fb4..959f94a 100644 Binary files a/Yosin_Engine.exe and b/Yosin_Engine.exe differ diff --git a/ffi-8.dll b/ffi-8.dll new file mode 100644 index 0000000..fc63a1e Binary files /dev/null and b/ffi-8.dll differ diff --git a/sqr/Core/UI_Class/UI_Widget.nut b/sqr/Core/UI_Class/UI_Widget.nut index 8cf9a09..aadca80 100644 --- a/sqr/Core/UI_Class/UI_Widget.nut +++ b/sqr/Core/UI_Class/UI_Widget.nut @@ -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 { diff --git a/sqr/User/Asset/Item/Equipment.nut b/sqr/User/Asset/Item/Equipment.nut index 7f5c50f..2fe10ad 100644 --- a/sqr/User/Asset/Item/Equipment.nut +++ b/sqr/User/Asset/Item/Equipment.nut @@ -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); } diff --git a/sqr/User/Object/ActiveObject/NpcObjectClass.nut b/sqr/User/Object/ActiveObject/NpcObjectClass.nut index 5669787..9ee725d 100644 --- a/sqr/User/Object/ActiveObject/NpcObjectClass.nut +++ b/sqr/User/Object/ActiveObject/NpcObjectClass.nut @@ -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); } } diff --git a/sqr/User/Stage/TestStage.nut b/sqr/User/Stage/TestStage.nut index 7983c15..ebd078a 100644 --- a/sqr/User/Stage/TestStage.nut +++ b/sqr/User/Stage/TestStage.nut @@ -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); diff --git a/sqr/User/UI/Widget/IMouse.nut b/sqr/User/UI/Widget/IMouse.nut index 13b00bc..1b57ada 100644 --- a/sqr/User/UI/Widget/IMouse.nut +++ b/sqr/User/UI/Widget/IMouse.nut @@ -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) { } diff --git a/sqr/User/UI/Window/5_Inventory.nut b/sqr/User/UI/Window/5_Inventory.nut new file mode 100644 index 0000000..837238f --- /dev/null +++ b/sqr/User/UI/Window/5_Inventory.nut @@ -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); + } + +} \ No newline at end of file diff --git a/sqr/User/UI/Window/5_Inventory/ItemCollect.nut b/sqr/User/UI/Window/5_Inventory/ItemCollect.nut index 6eb4a4d..1b86785 100644 --- a/sqr/User/UI/Window/5_Inventory/ItemCollect.nut +++ b/sqr/User/UI/Window/5_Inventory/ItemCollect.nut @@ -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,10 +187,13 @@ class _ItemCollection extends Yosin_CommonUi { if (CurrentShowItem) { CurrentShowItem.CloseInfo(); } - //显示详细信息 - ItemList[Idx].ShowInfo(MousePos_X - 50, MousePos_Y - 150); - //记录当前显示的对象 - CurrentShowItem = ItemList[Idx]; + //如果当前没有拖拽物品时才打开详细信息窗口 + if (!DragItem) { + //显示详细信息 + ItemList[Idx].ShowInfo(MousePos_X - 50, MousePos_Y - 150); + //记录当前显示的对象 + CurrentShowItem = ItemList[Idx]; + } } } else { //关闭上一个显示的对象 @@ -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(); } }