From 8ad4476076eb691714bbd4c637e43c72cfa0dd93 Mon Sep 17 00:00:00 2001 From: WONIU Date: Fri, 3 Jan 2025 19:47:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF=20?= =?UTF-8?q?=E8=83=8C=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqr/Core/UI_Class/UI_Widget.nut | 207 +++++++++++++++++++++++++- sqr/User/Stage/LodingStage.nut | 4 +- sqr/User/UI/Window/4_PersonalInfo.nut | 89 +---------- sqr/User/UI/Window/5_Inventory.nut | 53 +++++++ sqr/folder-alias.json | 6 + 5 files changed, 267 insertions(+), 92 deletions(-) create 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 6a60869..434bbaf 100644 --- a/sqr/Core/UI_Class/UI_Widget.nut +++ b/sqr/Core/UI_Class/UI_Widget.nut @@ -165,7 +165,8 @@ class Yosin_EmeStretch extends Yosin_CommonUi { local ScaleRate = ScaleW / SpriteList[1].GetSize().w; local ScaleRateH = H / SpriteList[1].GetSize().h; - SpriteList[1].SetPosition(SpriteList[0].GetSize().w, 0); + SpriteList[1].SetPosition(SpriteList[0].GetSize().w, -30); + SpriteList[1].SetScale(ScaleRate, ScaleRateH); SpriteList[2].SetPosition(SpriteList[0].GetSize().w + ScaleW, 0); if (H != SpriteList[1].GetSize().h) { @@ -317,7 +318,7 @@ class Yosin_SplicingButton extends Yosin_CommonUi { //悬停态 SpriteList[1] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction); //按下态 - SpriteList[2] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 8 : 3), Direction); + SpriteList[2] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction); if (UnavailableFlag) { //不可用态 SpriteList[3] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + 12, Direction); @@ -395,17 +396,213 @@ class Yosin_TopTitle extends Yosin_CommonUi { // 标题 local titleTextActor = FontAssetManager.GenerateNormal(title, true, { - color = sq_RGBA(206, 189, 140, 255), - alignment = TextAlign.Center, + color = sq_RGBA(206, 189, 140, 255) }); local titleX = W / 2 - titleTextActor.GetSize().w / 2; // 绘制标题 titleTextActor.SetPosition(titleX, 2); Addchild(titleTextActor); + local closeBtn = Yosin_BaseButton(W - 20, 4, 12, 12, "sprite/interface/lenheartwindowcommon.img", 544); + closeBtn.DownSimulateOffset = false; + closeBtn.OnClick = function(btn) { + + } + AddUIChild(closeBtn); + + local topBtn = Yosin_BaseButton(W - 40, 2, 13, 13, "sprite/interface/lenheartwindowcommon.img", 455); + topBtn.DownSimulateOffset = false; + topBtn.OnClick = function(btn) { + + } + AddUIChild(topBtn); } -} \ No newline at end of file +} + + + +// 标题按钮 +class titleButton extends Yosin_BaseButton { + + index = null; + select = false; + cacheSelect = false; + cacheY = null; + + LBDownOnClick = null; + + constructor(X, Y, W, H, Path, Idx, title) { + base.constructor(X, Y, W, H, Path, Idx); + + cacheY = Y; + DownSimulateOffset = false; + + local backText = FontAssetManager.GenerateNormal( title , true, { + color = sq_RGBA(130, 114, 84, 255) + }); + backText.SetUpdateFunc(function(Text, Dt) { + if (select == cacheSelect) return; + if (select) { + Text.SetFillColor(sq_RGBA(187,176,149, 255)); + } else { + Text.SetFillColor(sq_RGBA(130,114,84, 255)); + } + cacheSelect = select; + }) + + backText.SetPosition(9, 2); + Addchild(backText); + + } + + function ChangeFrame() { + //状态更改 刷新精灵帧 + if (State != SpriteState) { + if (State == 2) { + Y -= 1; + SyncPos(X, Y); + } else if (SpriteState == 2) { + Y += 1; + SyncPos(X, Y); + } + SpriteState = State; + Sprite.SetFrame(FrameList[SpriteState]); + Sprite.SetPosition(0, 0); + } + } + + function Proc(Dt) { + + if (select) return; + + //不可用 + if (State == 3) { + + } else { + //按下 + if (isLBDown) { + State = 2; + select = true; + if (LBDownOnClick != null) { + LBDownOnClick(this); + } + } + //悬停 + else if (isInRect) { + State = 1; + } + //普通 + else { + State = 0; + } + } + ChangeFrame(); + } + +} + + +// 拉伸标题按钮 +class Yosin_StretchTitleButton extends Yosin_SplicingButton { + + index = null; + select = false; + cacheSelect = false; + LBDownOnClick = null; + + titleText = null; + + constructor(X, Y, W, H, Path, Idx, title,) { + base.constructor(X, Y, W, H, Path, Idx, true, false) + + titleText = FontAssetManager.GenerateNormal( title , true, { + color = sq_RGBA(130, 114, 84, 255) + }); + titleText.SetUpdateFunc(function(Text, Dt) { + if (select == cacheSelect) return; + if (select) { + Text.SetFillColor(sq_RGBA(187,176,149, 255)); + } else { + Text.SetFillColor(sq_RGBA(130,114,84, 255)); + } + cacheSelect = select; + }) + + titleText.SetPosition(9, 2); + Addchild(titleText); + + } + + function Proc(Dt) { + if (select) return; + + if (State != 3 && isLBDown) { + State = 2; + select = true; + if (LBDownOnClick != null) { + LBDownOnClick(this); + } + } + if (State == 2) { + Y -= 1; + SyncPos(X, Y); + } else if (SpriteState == 2) { + Y += 1; + SyncPos(X, Y); + } + + base.Proc(Dt); + } + +} + + +// 横向多个标题单选按钮 +class Yosin_RowMoreTitleBtn extends Yosin_CommonUi { + + LBDownOnClick = null; + btns = []; + tests = []; + + constructor(X, Y, titles, baseWidth = 44, path = "sprite/interface/lenheartwindowcommon.img", idx = 160) { + this.tests = titles; + local btnX = 0; + for(local i = 0; i < titles.len(); i++) { + + local textW = FontAssetManager.GenerateNormal(titles[i], true).GetSize().w + 20; + local btnW = baseWidth + 20; + btnW = textW > btnW ? textW : btnW ; + + local titleBtn = Yosin_StretchTitleButton(btnX, 1, btnW, 19, path, idx, titles[i]); + titleBtn.index = i; + + titleBtn.LBDownOnClick = function (btn) { + btn.Parent.LBDownOnClick(this, btn.index); + + for (local i = 0; i < btn.Parent.btns.len(); i++) { + btn.Parent.btns[i].select = false; + btn.Parent.btns[i].titleText.SetFillColor(sq_RGBA(130,114,84, 255)); + } + + btn.select = true; + btn.Parent.btns[btn.index].titleText.SetFillColor(sq_RGBA(187,176,149, 255)); + + }; + + btns.push(titleBtn); + btnX += btnW + 1; + } + + base.constructor(X, Y, btnX, 21); + + for (local i = 0; i < btns.len(); i++) { + AddUIChild(btns[i]); + } + + } + +} diff --git a/sqr/User/Stage/LodingStage.nut b/sqr/User/Stage/LodingStage.nut index 1e6555d..b2868da 100644 --- a/sqr/User/Stage/LodingStage.nut +++ b/sqr/User/Stage/LodingStage.nut @@ -10,8 +10,8 @@ function InitGame() { // MySocket("127.0.0.1", 19666); //设定全局默认音量 - _Globa_Audio_Volume_ = 0.1; - _Globa_Sound_Volume_ = 0.3; + _Globa_Audio_Volume_ = 0; + _Globa_Sound_Volume_ = 0; Script(); diff --git a/sqr/User/UI/Window/4_PersonalInfo.nut b/sqr/User/UI/Window/4_PersonalInfo.nut index 6895d1f..b1438a9 100644 --- a/sqr/User/UI/Window/4_PersonalInfo.nut +++ b/sqr/User/UI/Window/4_PersonalInfo.nut @@ -5,7 +5,7 @@ 文件用途: 个人信息 */ -// 个人信息 286, 530 +// 个人信息 250, 60, 286, 530 class _PersonalInfo extends Yosin_Window { roleTitleBtn = null; @@ -233,7 +233,7 @@ class roleInfo extends Yosin_Window { Addchild(separationOne); // 决斗信息 // 根据决斗场等级 显示 sprite/interface2/pvp02/pvprank_icon/tier_icon.img 24 - local duelInfo = otherButton(battleAnalysis.right() + 1, battleAnalysis.Y, 18, "决斗信息", true); + local duelInfo = otherButton(battleAnalysis.right() + 1, battleAnalysis.Y, 14, "决斗信息", true); AddUIChild(duelInfo); duelInfo.OnClick = function (btn) { //todo 打开面板 @@ -261,83 +261,6 @@ class roleInfo extends Yosin_Window { } - -// 标题按钮 -class titleButton extends Yosin_BaseButton { - - select = false; - cacheY = null; - - LBDownOnClick = null; - - constructor(X, Y, W, H, Path, Idx, title) { - base.constructor(X, Y, W, H, Path, Idx); - - cacheY = Y; - DownSimulateOffset = false; - - local backText = FontAssetManager.GenerateNormal( title , true, { - color = sq_RGBA(130, 114, 84, 255) - }); - backText.SetUpdateFunc(function(Text, Dt) { - if (select) { - Text.SetFillColor(sq_RGBA(187,176,149, 255)); - } else { - Text.SetFillColor(sq_RGBA(130,114,84, 255)); - } - }) - - backText.SetPosition(9, 2); - Addchild(backText); - - } - - function ChangeFrame() { - //状态更改 刷新精灵帧 - if (State != SpriteState) { - if (State == 2) { - Y -= 1; - SyncPos(X, Y); - } else if (SpriteState == 2) { - Y += 1; - SyncPos(X, Y); - } - SpriteState = State; - Sprite.SetFrame(FrameList[SpriteState]); - Sprite.SetPosition(0, 0); - } - } - - function Proc(Dt) { - - if (select) return; - - //不可用 - if (State == 3) { - - } else { - //按下 - if (isLBDown) { - State = 2; - select = true; - if (LBDownOnClick != null) { - LBDownOnClick(this); - } - } - //悬停 - else if (isInRect) { - State = 1; - } - //普通 - else { - State = 0; - } - } - ChangeFrame(); - } - -} - // 属性项 class roleInfoPropertyItem extends Yosin_CommonUi { @@ -399,13 +322,9 @@ class otherButton extends Yosin_CommonUi { property.SetPosition( 32 - property.GetSize().w / 2 , 45 ); Addchild(property); - - local path = pvp? "sprite/oldimageforreplay/interface2/pvp02/pvprank_icon/tier_icon.img" : "sprite/interface2/profile/profile.img"; + local path = pvp? "sprite/interface2/profile/profile_pvp_icon.img" : "sprite/interface2/profile/profile.img"; local icon = CL_SpriteObject(path, enabled ? idx : idx +1 ); - if (pvp){ - icon.SetScale(0.7, 0.7); - } - icon.SetPosition(32 - icon.GetSize().w / 2, property.Y - icon.GetSize().h - 5); + icon.SetPosition(32 - icon.GetSize().w / 2, 45/2 - icon.GetSize().h / 2 + 3 ); Addchild(icon); diff --git a/sqr/User/UI/Window/5_Inventory.nut b/sqr/User/UI/Window/5_Inventory.nut new file mode 100644 index 0000000..0170568 --- /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/folder-alias.json b/sqr/folder-alias.json index 2abc671..898ebbf 100644 --- a/sqr/folder-alias.json +++ b/sqr/folder-alias.json @@ -238,5 +238,11 @@ }, "User/UI/Window/3_Top_tool.nut": { "description": "顶部工具条" + }, + "User/UI/Window/5_Inventory.nut": { + "description": "背包窗口" + }, + "User/UI/Window/4_PersonalInfo.nut": { + "description": "个人信息窗口" } } \ No newline at end of file