From e464fb899d414bbf788356eee3ba8eb596493018 Mon Sep 17 00:00:00 2001 From: WONIU Date: Wed, 8 Jan 2025 01:50:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=8C=E5=8C=85=20=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqr/Core/UI_Class/UI_Widget.nut | 20 -- .../UI/Window/5_Inventory/5_Inventory.nut | 7 +- .../5_Inventory/Inventory_EquipmentPage.nut | 186 +++++++++++++++--- .../UI/Window/5_Inventory/ItemCollect.nut | 28 ++- 4 files changed, 179 insertions(+), 62 deletions(-) diff --git a/sqr/Core/UI_Class/UI_Widget.nut b/sqr/Core/UI_Class/UI_Widget.nut index f3b330c..c360362 100644 --- a/sqr/Core/UI_Class/UI_Widget.nut +++ b/sqr/Core/UI_Class/UI_Widget.nut @@ -246,7 +246,6 @@ class Yosin_NineBoxStretch extends Yosin_CommonUi { Addchild(backgroundTopRight); // 左边 - local backgroundLeft = CL_SpriteObject(path, imgId + 3); backgroundLeft.SetPosition(0, backgroundTopLeft.bottom() + 1); backgroundLeft.SetScale(1, scaleH); Addchild(backgroundLeft); @@ -278,7 +277,6 @@ class Yosin_NineBoxStretch extends Yosin_CommonUi { } - //拼接按钮 class Yosin_SplicingButton extends Yosin_CommonUi { //按钮状态 @@ -598,23 +596,6 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi { // 进度显示 class Yosin_Schedule extends Yosin_CommonUi { -<<<<<<< HEAD - // schedule 进度比例0-1 - constructor(X, Y, W, H, path, idx, schedulePercent) { - base.constructor(X, Y, W, H); - - local schedule = CL_SpriteObject(path, idx + 1); - Addchild(schedule); - - local scheduleBar = CL_SpriteObject(path, idx); - Addchild(scheduleBar); - - local barSize = scheduleBar.GetSize(); - local barW = barSize.w * schedulePercent; - - scheduleBar.SetCropRect(X, Y, barW, 5); - scheduleBar.SetSize( barW , 5); -======= //背景 BgSprite = null; //条 @@ -626,7 +607,6 @@ class Yosin_Schedule extends Yosin_CommonUi { BgSprite = CL_SpriteObject(path, idx + 1); Addchild(BgSprite); ->>>>>>> origin/dong BarSprite = CL_SpriteObject(path, idx); Addchild(BarSprite); diff --git a/sqr/User/UI/Window/5_Inventory/5_Inventory.nut b/sqr/User/UI/Window/5_Inventory/5_Inventory.nut index 9079a48..610c2f8 100644 --- a/sqr/User/UI/Window/5_Inventory/5_Inventory.nut +++ b/sqr/User/UI/Window/5_Inventory/5_Inventory.nut @@ -5,7 +5,7 @@ 文件用途: 背包窗口 */ -//local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 259, 555, 20); +//local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 258, 555, 20); class _Inventory extends Yosin_Window { constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { @@ -14,6 +14,10 @@ class _Inventory extends Yosin_Window { local title = Yosin_TopTitle(gWidth, gHeight, "装备栏(I)"); Addchild(title); + // local dd = Yosin_CanvasDraw.NineBoxStretch(100, 200, "sprite/interface/lenheartwindowcommon.img", 97); + // dd.SetPosition(100, 50); + // Addchild(dd); + //注册控件 RegisterWidget(); } @@ -30,7 +34,6 @@ class _Inventory extends Yosin_Window { //物品栏 装备页 local equipmentPage = Inventory_EquipmentPage( 0, titlesBtn.bottom() + 4, 300, Height - titlesBtn.bottom() - 4); - // local inventoryItem = InventoryItem( 0, titlesBtn.bottom() + 4, 300, 100); AddUIChild(equipmentPage); diff --git a/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut b/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut index 8dfc08f..0c6bdee 100644 --- a/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut +++ b/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut @@ -13,7 +13,7 @@ class Inventory_EquipmentPage extends Yosin_CommonUi { // 人物装备 - local charactersEquipment = Inventory_CharactersEquipment(0, 0); + local charactersEquipment = Inventory_CharactersEquipment(5, 0); AddUIChild(charactersEquipment); // 物品栏 @@ -33,6 +33,8 @@ class Inventory_CharactersEquipment extends Yosin_CommonUi { showOtherEquipment = null; // 允许更换装备 allowChangeEquipment = null; + // 画布 + Canvas = null; constructor(x, y) { local w = 248; @@ -42,53 +44,66 @@ class Inventory_CharactersEquipment extends Yosin_CommonUi { showOtherEquipment = true; allowChangeEquipment = true; - RegisterBackground(); + // 创建画布 + Canvas = CL_CanvasObject(); + // 重设大小并清空 + Canvas.ResizeAndClear(w, h); + // 设置填充画刷 用于绘制边框和线条 + // Canvas.SetFillBrush(sq_RGBA(59, 56, 57, 250)); + // 设置轮廓画刷 用于绘制边框和线条 + // Canvas.SetStrokeBrush(sq_RGBA(59, 56, 57, 250)); + // 开始绘制 + Canvas.BeginDraw(); + + // 绘制背景 + DrawBackground(); + + // 结束绘制 + Canvas.EndDraw(); + // 添加画布 + Addchild(Canvas); } // 背景 - function RegisterBackground() { + function DrawBackground() { + // 背景图 - local bgimg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventorybackground.img", 0); - bgimg.SetPosition(0, 0); - Addchild(bgimg); + local bgimg = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventorybackground.img", 0); + // 画布绘制背景 + Canvas.DrawSpriteFrame(bgimg, 0, 0); // 装备栏背景 - local equipmentBackground = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 21); - equipmentBackground.SetPosition(5, 5); - Addchild(equipmentBackground); + local equipmentBackground = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 21); + Canvas.DrawSpriteFrame(equipmentBackground, 5, 5); // 顶部光线 - local topLight = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 178); - topLight.SetPosition(Width / 2 - topLight.GetSize().w / 2, 0); - Addchild(topLight); + local topLight = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 178); + Canvas.DrawSpriteFrame(topLight, Width / 2 - topLight.GetSize().w / 2, 0); // todo 角色展示 // 结婚戒指槽位 - local ringSlotBg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory_cn.img", 0); - ringSlotBg.SetPosition(Width / 2 - ringSlotBg.GetSize().w / 2, 5); - Addchild(ringSlotBg); + local ringSlotBg = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory_cn.img", 0); + Canvas.DrawSpriteFrame(ringSlotBg, Width / 2 - ringSlotBg.GetSize().w / 2, 5); // 首饰 if (showOtherEquipment) { // 辅助装备 - local assist = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 19); - assist.SetPosition(179, 69); - Addchild(assist); + local assist = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 19); + Canvas.DrawSpriteFrame(assist, 179, 69); // 耳环 - local earrings = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 122); - earrings.SetPosition(179, 102); - Addchild(earrings); + local earrings = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 122); + Canvas.DrawSpriteFrame(earrings, 179, 102); // 魔法石 - local MagicStone = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 20); - MagicStone.SetPosition(211, 101); - Addchild(MagicStone); + local MagicStone = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 20); + Canvas.DrawSpriteFrame(MagicStone, 211, 101); } + } @@ -112,28 +127,139 @@ class InventoryItem extends Yosin_CommonUi { print(index); }; - // 物品栏 local itemCollection = itemCollection(5, itemBtns.bottom(), 247, 244, 7, 8); AddUIChild(itemCollection); + + local itemBottom = itemCollection.bottom(); // 重量 local weight = FontAssetManager.GenerateNormal("重量", true, { color = sq_RGBA(160, 132, 75, 255) }); - weight.SetPosition(itemCollection.X + 8, itemCollection.bottom() - 25); + weight.SetPosition(itemCollection.X + 5, itemBottom - weight.GetSize().h - 2); Addchild(weight); // 重量进度条 -<<<<<<< HEAD - local weightSchedule = Yosin_Schedule(weight.right() + 2, weight.Y + 4 , 125, 10, "sprite/interface/newstyle/windows/inventory/inventory.img", 1, 0.7); -======= local weightSchedule = Yosin_Schedule(weight.right() + 2, weight.Y + 4, 125, 10, "sprite/interface/newstyle/windows/inventory/inventory.img", 1); weightSchedule.SetPercentage(0.6); ->>>>>>> origin/dong Addchild(weightSchedule); + // 搜索 + //登录按钮 + local saerchBtn = Yosin_BaseButton(weightSchedule.right() + 12, itemBottom - 23, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 94); + //点击事件回调 + // saerchBtn.OnClick = function(Button) { + // }.bindenv(this); + AddUIChild(saerchBtn); + + // 设置 + local setBtn = Yosin_BaseButton(saerchBtn.right() + 2, saerchBtn.Y, 18, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 77); + //点击事件回调 + // setBtn.OnClick = function(Button) { + // }.bindenv(this); + AddUIChild(setBtn); + + // 排列按钮 + local permutationBtn = Yosin_BaseButton(setBtn.right(), saerchBtn.Y, 28, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 73); + //点击事件回调 + // permutationBtn.OnClick = function(Button) { + // }.bindenv(this); + AddUIChild(permutationBtn); + + + // 复活币 + local moneyItem = MoneyItem(5, itemBottom + 3, 3); + AddUIChild(moneyItem); + } +} + +// 金币相关数值 +class MoneyItem extends Yosin_CommonUi { + + constructor(x, y, idx) { + local w = 248; + local h = 49; + base.constructor(x, y, w, h); + + local txtColor = sq_RGBA(130, 105, 61, 255); + + local bg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 27); + Addchild(bg); + + // 复活币个数 + local ReviveNum = FontAssetManager.GenerateNormal("23434个", true, { + color = txtColor + }); + ReviveNum.SetPosition(120 - ReviveNum.GetSize().w, 2); + Addchild(ReviveNum); + + + // 胜利的证明 + local winNum = FontAssetManager.GenerateNormal("23434个", true, { + color = txtColor + }); + winNum.SetPosition( 245 - winNum.GetSize().w, 2); + Addchild(winNum); + + + + // 商城 + local storeBtn = Yosin_BaseButton(1, 25, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 3); + // local storeBtn = Yosin_BaseButton(0, 0, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 3); + //点击事件回调 + // storeBtn.OnClick = function(Button) { + // }.bindenv(this); + AddUIChild(storeBtn); + + + // 点券 + local storeNum = FontAssetManager.GenerateNormal("23434点券", true, { + color = txtColor + }); + storeNum.SetPosition(120 - storeNum.GetSize().w, 27); + Addchild(storeNum); + + // 金币按钮 + local moneyBtn = Yosin_BaseButton(126, storeBtn.Y, 23, 23 "sprite/interface/newstyle/windows/inventory/inventory.img", 7); + //点击事件回调 + // moneyBtn.OnClick = function(Button) { + // }.bindenv(this); + AddUIChild(moneyBtn); + + // 金币数量 + local storeNum = FontAssetManager.GenerateNormal("23434金币", true, { + color = txtColor + }); + storeNum.SetPosition(245 - storeNum.GetSize().w, 27); + Addchild(storeNum); + + + + + } + +} + + + + + + + + + +if (!getroottable().rawin("chongzaiflag")) { + getroottable()["chongzaiflag"] <- true; +} else { + //遍历窗口队列 如果可见则调用Show + for (local i = 0; i< _SYS_WINDOW_LIST_.len(); i++) { + local Window = _SYS_WINDOW_LIST_[i]; + Window.Visible = false; + Window.RemoveSelf(); + } + TestStage(); } \ 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 9366b43..9e41c40 100644 --- a/sqr/User/UI/Window/5_Inventory/ItemCollect.nut +++ b/sqr/User/UI/Window/5_Inventory/ItemCollect.nut @@ -14,7 +14,6 @@ class itemCollection extends Yosin_CommonUi { column = null; // 列 row = null; - items = null; // 悬浮时显示的框 rect = null; @@ -22,36 +21,45 @@ class itemCollection extends Yosin_CommonUi { columnNum = null; rowNum = null; + Canvas = null; + constructor(x, y, w, h, columnNum, rowNum) { base.constructor(x, y, w, h); this.columnNum = columnNum; this.rowNum = rowNum; - items = []; - - local background = Yosin_NineBoxStretch(-3, -3, w + 6, h + 6, "sprite/interface/lenheartwindowcommon.img", 97); - AddUIChild(background); + // 创建画布 + Canvas = CL_CanvasObject(); + // 重设大小并清空 + Canvas.ResizeAndClear(w, h); + // 开始绘制 + Canvas.BeginDraw(); + + local background = Yosin_NineBoxStretch(0, 0, w + 6, h + 6, "sprite/interface/lenheartwindowcommon.img", 97); + Canvas.DrawActor(background, 0, 0); local itemX = 4; local itemY = 3; for (local i = 0; i< columnNum; i++) { local cells = []; for (local i = 0; i< rowNum; i++) { - local bg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 49); - bg.SetPosition(itemX, itemY); - Addchild(bg); + local bg = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 49); + Canvas.DrawSpriteFrame(bg, itemX, itemY); itemX += 30; - cells.push(bg); } - items.push(cells); itemX = 3; itemY += 30; } + // 结束绘制 + Canvas.EndDraw(); + // 添加画布 + Addchild(Canvas); + rect = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 131); rect.SetVisible(false);