From 383b43b39bb050cfcec22e6a9ba6651198d78e03 Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Tue, 7 Jan 2025 20:52:28 +0800 Subject: [PATCH] no message --- sqr/Core/UI_Class/UI_Widget.nut | 84 +++++++++++-------- sqr/SquirrelFileConfig.cfg | 5 +- sqr/User/Stage/TestStage.nut | 26 +++--- sqr/User/UI/Widget/Top_Title.nut | 4 +- sqr/User/UI/Window/5_Inventory.nut | 53 ------------ .../5_Inventory/Inventory_EquipmentPage.nut | 20 ++--- .../UI/Window/5_Inventory/ItemCollect.nut | 18 ++-- 7 files changed, 89 insertions(+), 121 deletions(-) delete mode 100644 sqr/User/UI/Window/5_Inventory.nut diff --git a/sqr/Core/UI_Class/UI_Widget.nut b/sqr/Core/UI_Class/UI_Widget.nut index b97ddf3..9f71c3f 100644 --- a/sqr/Core/UI_Class/UI_Widget.nut +++ b/sqr/Core/UI_Class/UI_Widget.nut @@ -372,15 +372,15 @@ class titleButton extends Yosin_BaseButton { cacheY = Y; DownSimulateOffset = false; - local backText = FontAssetManager.GenerateNormal( title , true, { + local backText = FontAssetManager.GenerateNormal(title, true, { color = sq_RGBA(130, 114, 84, 255) }); backText.SetUpdateFunc(function(Text, Dt) { - if (select == cacheSelect) return; + if (select == cacheSelect) return; if (select) { - Text.SetFillColor(sq_RGBA(187,176,149, 255)); + Text.SetFillColor(sq_RGBA(187, 176, 149, 255)); } else { - Text.SetFillColor(sq_RGBA(130,114,84, 255)); + Text.SetFillColor(sq_RGBA(130, 114, 84, 255)); } cacheSelect = select; }) @@ -475,30 +475,30 @@ class Yosin_StretchTitleButton extends Yosin_CommonUi { AddUIChild(SpriteList[2]); // 文字 - titleText = FontAssetManager.GenerateNormal( title , true, { + titleText = FontAssetManager.GenerateNormal(title, true, { color = sq_RGBA(130, 114, 84, 255) }); titleText.SetUpdateFunc(function(Text, Dt) { - if (select == cacheSelect) return; + if (select == cacheSelect) return; if (select) { - Text.SetFillColor(sq_RGBA(187,176,149, 255)); + Text.SetFillColor(sq_RGBA(187, 176, 149, 255)); } else { - Text.SetFillColor(sq_RGBA(130,114,84, 255)); + Text.SetFillColor(sq_RGBA(130, 114, 84, 255)); } cacheSelect = select; }) - titleText.SetPosition(W / 2 - titleText.GetSize().w/ 2, 2); + titleText.SetPosition(W / 2 - titleText.GetSize().w / 2, 2); Addchild(titleText); } // 设置为选中状态 function SetSelect(select) { - if (select){ + if (select) { State = 2; ChangeFrame(); - }else{ + } else { State = 0; ChangeFrame(); } @@ -510,12 +510,12 @@ class Yosin_StretchTitleButton extends Yosin_CommonUi { if (State != uiState) { if (State == 2) { SyncPos(X, cecheY - 1); - }else{ + } else { SyncPos(X, cecheY); } uiState = State; - for (local i = 0; i < SpriteList.len(); i++) { + for (local i = 0; i< SpriteList.len(); i++) { SpriteList[i].SetVisible(i == uiState); } } @@ -526,7 +526,7 @@ class Yosin_StretchTitleButton extends Yosin_CommonUi { //按下 if (isLBDown) { - if (LBDownOnClick!= null) { + if (LBDownOnClick != null) { LBDownOnClick(this); } State = 2; @@ -556,25 +556,25 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi { this.tests = titles; btns = []; local btnX = 0; - for(local i = 0; i < titles.len(); i++) { + for (local i = 0; i< titles.len(); i++) { local textW = FontAssetManager.GenerateNormal(titles[i], true).GetSize().w + 10; local btnW = baseWidth + 10; - btnW = textW > btnW ? textW : btnW ; + btnW = textW > btnW ? textW : btnW; local titleBtn = Yosin_StretchTitleButton(btnX, 1, btnW, 19, path, idx, titles[i]); titleBtn.index = i; - titleBtn.LBDownOnClick = function (btn) { + titleBtn.LBDownOnClick = function(btn) { btn.Parent.LBDownOnClick(this, btn.index); - for (local i = 0; i < btn.Parent.btns.len(); i++) { + for (local i = 0; i< btn.Parent.btns.len(); i++) { btn.Parent.btns[i].SetSelect(false); - btn.Parent.btns[i].titleText.SetFillColor(sq_RGBA(130,114,84, 255)); + btn.Parent.btns[i].titleText.SetFillColor(sq_RGBA(130, 114, 84, 255)); } btn.SetSelect(true); - btn.Parent.btns[btn.index].titleText.SetFillColor(sq_RGBA(187,176,149, 255)); + btn.Parent.btns[btn.index].titleText.SetFillColor(sq_RGBA(187, 176, 149, 255)); }; @@ -584,7 +584,7 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi { base.constructor(X, Y, btnX, 21); - for (local i = 0; i < btns.len(); i++) { + for (local i = 0; i< btns.len(); i++) { AddUIChild(btns[i]); } @@ -598,22 +598,40 @@ class Yosin_RowMoreTitleBtn extends Yosin_CommonUi { // 进度显示 class Yosin_Schedule extends Yosin_CommonUi { + //背景 + BgSprite = null; + //条 + BarSprite = null; + // schedule 进度比例0-1 - constructor(X, Y, W, H, path, idx, schedulePercent) { + constructor(X, Y, W, H, path, idx) { 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 = CL_SpriteObject(path, idx + 1); + Addchild(BgSprite); + BarSprite = CL_SpriteObject(path, idx); + Addchild(BarSprite); } + function SetPercentage(Rate) { + local barSize = BarSprite.GetSize(); + local barW = barSize.w * Rate; + + BarSprite.SetCropRect(BarSprite.X, BarSprite.Y, barW, barSize.h); + BarSprite.SetSize(barW, barSize.h); + } } + + +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/SquirrelFileConfig.cfg b/sqr/SquirrelFileConfig.cfg index eff823f..4cf035c 100644 --- a/sqr/SquirrelFileConfig.cfg +++ b/sqr/SquirrelFileConfig.cfg @@ -81,13 +81,16 @@ l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Widget\InputBox.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Widget\Drag_Button.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Widget\Scroll_Bar.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Widget\Text_Button.nut +l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Widget\Top_Title.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\0_Login.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\1_Select_Character.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\2_create_Character.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\3_Top_tool.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\4_PersonalInfo.nut -l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\5_Inventory.nut +l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\5_Inventory\Inventory_EquipmentPage.nut +l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\5_Inventory\ItemCollect.nut +l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\5_Inventory\5_Inventory.nut l:\Yosin_Engine\Yosin&Kiwano_DOF\sqr\User\UI\Window\233_HUD_Message.nut diff --git a/sqr/User/Stage/TestStage.nut b/sqr/User/Stage/TestStage.nut index f724ae5..1503c09 100644 --- a/sqr/User/Stage/TestStage.nut +++ b/sqr/User/Stage/TestStage.nut @@ -13,21 +13,23 @@ function TestStage() { // local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0); - local Equ = GameItem.Equipment(27675); - local Window = Equ.GetEquipmentInfoWindow(); - Window.SetPosition(100, 80); - Window.ResetFocus(); - local Equ = GameItem.Equipment(101020048); - local Window = Equ.GetEquipmentInfoWindow(); - Window.SetPosition(350, 80); - Window.ResetFocus(); + // local Equ = GameItem.Equipment(27675); + // local Window = Equ.GetEquipmentInfoWindow(); + // Window.SetPosition(100, 80); + // Window.ResetFocus(); - local Equ = GameItem.Equipment(24144); - local Window = Equ.GetEquipmentInfoWindow(); - Window.SetPosition(580, 80); - Window.ResetFocus(); + // local Equ = GameItem.Equipment(101020048); + // local Window = Equ.GetEquipmentInfoWindow(); + // Window.SetPosition(350, 80); + // Window.ResetFocus(); + // local Equ = GameItem.Equipment(24144); + // local Window = Equ.GetEquipmentInfoWindow(); + // Window.SetPosition(580, 80); + // Window.ResetFocus(); + + local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 257, 555, 20); // local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 257, 555, 20); // //大背景 diff --git a/sqr/User/UI/Widget/Top_Title.nut b/sqr/User/UI/Widget/Top_Title.nut index 5b22936..17e19c9 100644 --- a/sqr/User/UI/Widget/Top_Title.nut +++ b/sqr/User/UI/Widget/Top_Title.nut @@ -12,7 +12,7 @@ class Yosin_TopTitle extends Yosin_CommonUi { base.constructor(0, 0, W, H); //内容背景 - if (drawBackground){ + if (drawBackground) { local background = Yosin_NineBoxStretch(-1, 15, W + 1, H - 15, "sprite/interface/lenheartwindowcommon.img", 97); AddUIChild(background); } @@ -24,7 +24,7 @@ class Yosin_TopTitle extends Yosin_CommonUi { // 标题亮色背景 local BackgroundBright = CL_SpriteObject("sprite/interface/lenheartwindowcommon.img", 483); local scaleW = (W / BackgroundBright.GetSize().w).tofloat(); - BackgroundBright.SetScale( scaleW , 1); + BackgroundBright.SetScale(scaleW, 1); BackgroundBright.SetPosition(0, 1); Addchild(BackgroundBright); diff --git a/sqr/User/UI/Window/5_Inventory.nut b/sqr/User/UI/Window/5_Inventory.nut deleted file mode 100644 index 837238f..0000000 --- a/sqr/User/UI/Window/5_Inventory.nut +++ /dev/null @@ -1,53 +0,0 @@ -/* -文件名: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/Inventory_EquipmentPage.nut b/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut index aa3460b..a9d67a8 100644 --- a/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut +++ b/sqr/User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut @@ -1,4 +1,3 @@ - /* 文件名:Inventory_EquipmentPage.nut 路径:User/UI/Window/5_Inventory/Inventory_EquipmentPage.nut @@ -7,7 +6,7 @@ */ // 背包装备页面 -class Inventory_EquipmentPage extends Yosin_CommonUi{ +class Inventory_EquipmentPage extends Yosin_CommonUi { constructor(x, y, w, h) { base.constructor(x, y, w, h); @@ -28,7 +27,7 @@ class Inventory_EquipmentPage extends Yosin_CommonUi{ // 上半部分 人物装备穿戴 -class Inventory_CharactersEquipment extends Yosin_CommonUi{ +class Inventory_CharactersEquipment extends Yosin_CommonUi { // 展示其他装备 showOtherEquipment = null; @@ -56,24 +55,24 @@ class Inventory_CharactersEquipment extends Yosin_CommonUi{ // 装备栏背景 local equipmentBackground = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 21); - equipmentBackground.SetPosition( 5, 5); + equipmentBackground.SetPosition(5, 5); Addchild(equipmentBackground); // 顶部光线 local topLight = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 178); - topLight.SetPosition( Width / 2 - topLight.GetSize().w/2, 0); + topLight.SetPosition(Width / 2 - topLight.GetSize().w / 2, 0); Addchild(topLight); // todo 角色展示 // 结婚戒指槽位 local ringSlotBg = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory_cn.img", 0); - ringSlotBg.SetPosition( Width / 2 - ringSlotBg.GetSize().w/2, 5); + ringSlotBg.SetPosition(Width / 2 - ringSlotBg.GetSize().w / 2, 5); Addchild(ringSlotBg); // 首饰 - if (showOtherEquipment){ + if (showOtherEquipment) { // 辅助装备 local assist = CL_SpriteObject("sprite/interface/newstyle/windows/inventory/inventory.img", 19); assist.SetPosition(179, 69); @@ -126,12 +125,11 @@ class InventoryItem extends Yosin_CommonUi { Addchild(weight); // 重量进度条 - 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); Addchild(weightSchedule); } -} - - +} \ 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 f1d1436..9366b43 100644 --- a/sqr/User/UI/Window/5_Inventory/ItemCollect.nut +++ b/sqr/User/UI/Window/5_Inventory/ItemCollect.nut @@ -8,7 +8,7 @@ // 物品栏 -class itemCollection extends Yosin_CommonUi{ +class itemCollection extends Yosin_CommonUi { // 行 column = null; @@ -22,7 +22,7 @@ class itemCollection extends Yosin_CommonUi{ columnNum = null; rowNum = null; - constructor(x, y, w, h, columnNum,rowNum ) { + constructor(x, y, w, h, columnNum, rowNum) { base.constructor(x, y, w, h); this.columnNum = columnNum; this.rowNum = rowNum; @@ -36,9 +36,9 @@ class itemCollection extends Yosin_CommonUi{ local itemX = 4; local itemY = 3; - for (local i = 0; i < columnNum; i++) { + for (local i = 0; i< columnNum; i++) { local cells = []; - for (local i = 0; i < rowNum; i++) { + 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); @@ -65,7 +65,7 @@ class itemCollection extends Yosin_CommonUi{ function OnMouseProc(MousePos_X, MousePos_Y) { base.OnMouseProc(MousePos_X, MousePos_Y); - if (isInRect){ + if (isInRect) { local WorldPosition = this.GetWorldPosition(); local xx = MousePos_X - WorldPosition.x; local yy = MousePos_Y - WorldPosition.y; @@ -73,20 +73,20 @@ class itemCollection extends Yosin_CommonUi{ local row = (xx / 30).tointeger(); - local inRadius = column < columnNum && row < rowNum; + local inRadius = column< columnNum && row< rowNum; local change = column != this.column || row != this.row; // 移动到另一个槽 - if ( change && inRadius) { + if (change && inRadius) { this.column = column; this.row = row; rect.SetVisible(true); - rect.SetPosition( row * 30, column * 30); + rect.SetPosition(row * 30, column * 30); } - }else{ + } else { this.column = null; this.row = null; rect.SetVisible(false);