From d2077de7194d7e104b9226c64ae5237e913a1e09 Mon Sep 17 00:00:00 2001 From: WONIU Date: Sun, 19 Jan 2025 14:09:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8B=89=E4=BC=B8=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=BF=94=E5=9B=9E=E7=94=BB=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqr/Core/UI_Class/UI_Widget.nut | 457 ++++++++++++++----------- sqr/User/UI/Widget/Top_Title.nut | 3 +- sqr/User/UI/Window/233_HUD_Message.nut | 4 +- sqr/User/UI/Window/3_Top_tool.nut | 4 +- 4 files changed, 258 insertions(+), 210 deletions(-) diff --git a/sqr/Core/UI_Class/UI_Widget.nut b/sqr/Core/UI_Class/UI_Widget.nut index 9387eb1..ea74b68 100644 --- a/sqr/Core/UI_Class/UI_Widget.nut +++ b/sqr/Core/UI_Class/UI_Widget.nut @@ -142,24 +142,81 @@ class Yosin_BaseButton extends Yosin_CommonUi { } //三分法拉伸 -class Yosin_EmeStretch extends Yosin_CommonUi { +// class Yosin_EmeStretch extends Yosin_CommonUi { + +// Path = null; +// Idx = null; +// //按钮状态 +// SpriteList = null; + +// constructor(X, Y, W, H, Path, Idx, Direction = true) { +// this.Path = Path; +// this.Idx = Idx; +// base.constructor(X, Y, W, H); + +// // 创建画布 +// local Canvas = CL_CanvasObject(); +// // 重设大小并清空 +// Canvas.ResizeAndClear(W, H); +// // 开始绘制 +// Canvas.BeginDraw(); + +// SpriteList = []; +// SpriteList.push(CL_SpriteObject(Path, Idx)); +// SpriteList.push(CL_SpriteObject(Path, Idx + 1)); +// SpriteList.push(CL_SpriteObject(Path, Idx + 2)); + +// //横向 +// if (Direction) { +// local ScaleW = (W - SpriteList[0].GetSize().w - SpriteList[2].GetSize().w); +// local ScaleRate = ScaleW / SpriteList[1].GetSize().w; + +// SpriteList[1].SetPosition(SpriteList[0].GetSize().w, 0.0); +// SpriteList[1].SetScale(ScaleRate, 1.0); +// SpriteList[2].SetPosition(SpriteList[0].GetSize().w + ScaleW, 0.0); +// } +// //纵向 +// else { +// local ScaleH = (H - SpriteList[0].GetSize().h - SpriteList[2].GetSize().h); +// local ScaleRate = ScaleH / SpriteList[1].GetSize().h; + +// SpriteList[1].SetPosition(0, SpriteList[0].GetSize().h); +// SpriteList[1].SetScale(1.0, ScaleRate); +// SpriteList[2].SetPosition(0, SpriteList[0].GetSize().h + ScaleH); +// } + +// foreach(Child in SpriteList) { +// // Addchild(Child); +// Canvas.DrawSprite(Child); +// } + +// // 结束绘制 +// Canvas.EndDraw(); +// // 添加画布 +// Addchild(Canvas); + +// } +// } + +//三分法拉伸 +class Yosin_EmeStretch extends CL_CanvasObject { Path = null; Idx = null; //按钮状态 SpriteList = null; - constructor(X, Y, W, H, Path, Idx, Direction = true) { + constructor( W, H, Path, Idx, Direction = true) { this.Path = Path; this.Idx = Idx; - base.constructor(X, Y, W, H); + base.constructor(); // 创建画布 - local Canvas = CL_CanvasObject(); + CL_CanvasObject(); // 重设大小并清空 - Canvas.ResizeAndClear(W, H); + ResizeAndClear(W, H); // 开始绘制 - Canvas.BeginDraw(); + BeginDraw(); SpriteList = []; SpriteList.push(CL_SpriteObject(Path, Idx)); @@ -187,224 +244,214 @@ class Yosin_EmeStretch extends Yosin_CommonUi { foreach(Child in SpriteList) { // Addchild(Child); - Canvas.DrawSprite(Child); + DrawSprite(Child); } // 结束绘制 - Canvas.EndDraw(); + EndDraw(); // 添加画布 - Addchild(Canvas); + // Addchild(Canvas); } } // 九宫格拉伸 -function Yosin_NineBoxStretch(width, height, path, imgId) { +// function Yosin_NineBoxStretch(width, height, path, imgId) { - // 创建画布 - local Canvas = CL_CanvasObject(); - // 重设大小并清空 - Canvas.ResizeAndClear(width, height); - // 开始绘制 - Canvas.BeginDraw(); +// // 创建画布 +// local Canvas = CL_CanvasObject(); +// // 重设大小并清空 +// Canvas.ResizeAndClear(width, height); +// // 开始绘制 +// Canvas.BeginDraw(); - // 左上角 - // local backgroundTopLeft = CL_SpriteObject(path, imgId); - local backgroundTopLeft = CL_SpriteObject(path, imgId); - // 上边 - local backgroundTop = CL_SpriteObject(path, imgId + 1); - // 右上角 - local backgroundTopRight = CL_SpriteObject(path, imgId + 2); - // 左边 - local backgroundLeft = CL_SpriteObject(path, imgId + 3); - // 中间 - local backgroundCenter = CL_SpriteObject(path, imgId + 4); - // 右边 - local backgroundRight = CL_SpriteObject(path, imgId + 5); - // 左下角 - local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6); - // 下边 - local backgroundBottom = CL_SpriteObject(path, imgId + 7); - // 右下角 - local backgroundBottomRight = CL_SpriteObject(path, imgId + 8); +// // 左上角 +// // local backgroundTopLeft = CL_SpriteObject(path, imgId); +// local backgroundTopLeft = CL_SpriteObject(path, imgId); +// // 上边 +// local backgroundTop = CL_SpriteObject(path, imgId + 1); +// // 右上角 +// local backgroundTopRight = CL_SpriteObject(path, imgId + 2); +// // 左边 +// local backgroundLeft = CL_SpriteObject(path, imgId + 3); +// // 中间 +// local backgroundCenter = CL_SpriteObject(path, imgId + 4); +// // 右边 +// local backgroundRight = CL_SpriteObject(path, imgId + 5); +// // 左下角 +// local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6); +// // 下边 +// local backgroundBottom = CL_SpriteObject(path, imgId + 7); +// // 右下角 +// local backgroundBottomRight = CL_SpriteObject(path, imgId + 8); - // 左上角 - Canvas.DrawSprite(backgroundTopLeft); +// // 左上角 +// Canvas.DrawSprite(backgroundTopLeft); - local TopLeftSize = backgroundTopLeft.GetSize(); - local TopLeftBottom = TopLeftSize.h; - local TopLeftRight = TopLeftSize.w; +// local TopLeftSize = backgroundTopLeft.GetSize(); +// local TopLeftBottom = TopLeftSize.h; +// local TopLeftRight = TopLeftSize.w; - // 中间图片大小 - local centerImgSize = backgroundCenter.GetSize(); - local centerImgWidth = centerImgSize.w; - local centerImgHeight = centerImgSize.h; +// // 中间图片大小 +// local centerImgSize = backgroundCenter.GetSize(); +// local centerImgWidth = centerImgSize.w; +// local centerImgHeight = centerImgSize.h; - local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w; - local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h; +// local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w; +// local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h; - local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat(); - local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat(); +// local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat(); +// local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat(); - // 上边 - backgroundTop.SetScale(scaleW, 1); - backgroundTop.SetPosition(TopLeftRight, 0); - Canvas.DrawSprite(backgroundTop); +// // 上边 +// backgroundTop.SetScale(scaleW, 1); +// backgroundTop.SetPosition(TopLeftRight, 0); +// Canvas.DrawSprite(backgroundTop); - // 右上角 - backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0); - Canvas.DrawSprite(backgroundTopRight); +// // 右上角 +// backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0); +// Canvas.DrawSprite(backgroundTopRight); - // 左边 - backgroundLeft.SetScale(1, scaleH); - backgroundLeft.SetPosition(0, TopLeftBottom); - Canvas.DrawSprite(backgroundLeft); +// // 左边 +// backgroundLeft.SetScale(1, scaleH); +// backgroundLeft.SetPosition(0, TopLeftBottom); +// Canvas.DrawSprite(backgroundLeft); - // 中间 - backgroundCenter.SetScale(scaleW, scaleH); - // Addchild(backgroundCenter); - backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y); - Canvas.DrawSprite(backgroundCenter); +// // 中间 +// backgroundCenter.SetScale(scaleW, scaleH); +// // Addchild(backgroundCenter); +// backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y); +// Canvas.DrawSprite(backgroundCenter); - // 右边 - backgroundRight.SetScale(1, scaleH); - backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y); - Canvas.DrawSprite(backgroundRight); +// // 右边 +// backgroundRight.SetScale(1, scaleH); +// backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y); +// Canvas.DrawSprite(backgroundRight); - // 左下角 - backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1); - Canvas.DrawSprite(backgroundBottomLeft); +// // 左下角 +// backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1); +// Canvas.DrawSprite(backgroundBottomLeft); - // 下边 - backgroundBottom.SetScale(scaleW, 1); - backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y); - Canvas.DrawSprite(backgroundBottom); +// // 下边 +// backgroundBottom.SetScale(scaleW, 1); +// backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y); +// Canvas.DrawSprite(backgroundBottom); - // 右下角 - backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y); - Canvas.DrawSprite(backgroundBottomRight); - - // 结束绘制 - Canvas.EndDraw(); - // 添加画布 - // Addchild(Canvas); - local Sp = CL_SpriteObject(); - Sp.SetFrame(Canvas.ExportSpriteFrame()); - return Sp; -} - - - -// //九宫格拉伸 -// class Yosin_NineBoxStretch extends Yosin_CommonUi { - -// constructor(X, Y, W, H, Path, Idx) { -// base.constructor(X, Y, W, H); -// DrawBackground(W, H, Path, Idx); -// } - - -// // 绘制 -// function DrawBackground(width, height, path, imgId) { - - -// // 创建画布 -// local Canvas = CL_CanvasObject(); -// // 重设大小并清空 -// Canvas.ResizeAndClear(width, height); -// // 开始绘制 -// Canvas.BeginDraw(); - -// // 左上角 -// // local backgroundTopLeft = CL_SpriteObject(path, imgId); -// local backgroundTopLeft = CL_SpriteObject(path, imgId); -// // 上边 -// local backgroundTop = CL_SpriteObject(path, imgId + 1); -// // 右上角 -// local backgroundTopRight = CL_SpriteObject(path, imgId + 2); -// // 左边 -// local backgroundLeft = CL_SpriteObject(path, imgId + 3); -// // 中间 -// local backgroundCenter = CL_SpriteObject(path, imgId + 4); -// // 右边 -// local backgroundRight = CL_SpriteObject(path, imgId + 5); -// // 左下角 -// local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6); -// // 下边 -// local backgroundBottom = CL_SpriteObject(path, imgId + 7); -// // 右下角 -// local backgroundBottomRight = CL_SpriteObject(path, imgId + 8); - - -// // 左上角 -// Canvas.DrawSprite(backgroundTopLeft); - -// local TopLeftSize = backgroundTopLeft.GetSize(); -// local TopLeftBottom = TopLeftSize.h; -// local TopLeftRight = TopLeftSize.w; - -// // 中间图片大小 -// local centerImgSize = backgroundCenter.GetSize(); -// local centerImgWidth = centerImgSize.w; -// local centerImgHeight = centerImgSize.h; - -// local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w; -// local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h; - - -// local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat(); -// local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat(); - -// // 上边 -// backgroundTop.SetScale(scaleW, 1); -// backgroundTop.SetPosition(TopLeftRight + 1, 0); -// Canvas.DrawSprite(backgroundTop); - -// // 右上角 -// backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w, 0); -// Canvas.DrawSprite(backgroundTopRight); - -// // 左边 -// backgroundLeft.SetScale(1, scaleH); -// backgroundLeft.SetPosition(0, TopLeftBottom + 1); -// Canvas.DrawSprite(backgroundLeft); - -// // 中间 -// backgroundCenter.SetScale(scaleW, scaleH); -// // Addchild(backgroundCenter); -// backgroundCenter.SetPosition(TopLeftRight + 1, backgroundLeft.Y); -// Canvas.DrawSprite(backgroundCenter); - -// // 右边 -// backgroundRight.SetScale(1, scaleH); -// backgroundRight.SetPosition(width - backgroundRight.GetSize().w, backgroundCenter.Y); -// Canvas.DrawSprite(backgroundRight); - -// // 左下角 -// backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h); -// Canvas.DrawSprite(backgroundBottomLeft); - -// // 下边 -// backgroundBottom.SetScale(scaleW, 1); -// backgroundBottom.SetPosition(TopLeftRight + 1, backgroundBottomLeft.Y); -// Canvas.DrawSprite(backgroundBottom); - -// // 右下角 -// backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w, backgroundBottomLeft.Y); -// Canvas.DrawSprite(backgroundBottomRight ); - -// // 结束绘制 -// Canvas.EndDraw(); -// // 添加画布 -// Addchild(Canvas); - -// } +// // 右下角 +// backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y); +// Canvas.DrawSprite(backgroundBottomRight); +// // 结束绘制 +// Canvas.EndDraw(); +// // 添加画布 +// // Addchild(Canvas); +// local Sp = CL_SpriteObject(); +// Sp.SetFrame(Canvas.ExportSpriteFrame()); +// return Sp; // } + + +//九宫格拉伸 +class Yosin_NineBoxStretch extends CL_CanvasObject { + + constructor( width, height, path, imgId) { + base.constructor(); + + // 创建画布 + CL_CanvasObject(); + // 重设大小并清空 + ResizeAndClear(width, height); + + // 开始绘制 + BeginDraw(); + + // 左上角 + local backgroundTopLeft = CL_SpriteObject(path, imgId); + // 上边 + local backgroundTop = CL_SpriteObject(path, imgId + 1); + // 右上角 + local backgroundTopRight = CL_SpriteObject(path, imgId + 2); + // 左边 + local backgroundLeft = CL_SpriteObject(path, imgId + 3); + // 中间 + local backgroundCenter = CL_SpriteObject(path, imgId + 4); + // 右边 + local backgroundRight = CL_SpriteObject(path, imgId + 5); + // 左下角 + local backgroundBottomLeft = CL_SpriteObject(path, imgId + 6); + // 下边 + local backgroundBottom = CL_SpriteObject(path, imgId + 7); + // 右下角 + local backgroundBottomRight = CL_SpriteObject(path, imgId + 8); + + + // 左上角 + DrawSprite(backgroundTopLeft); + + local TopLeftSize = backgroundTopLeft.GetSize(); + local TopLeftBottom = TopLeftSize.h; + local TopLeftRight = TopLeftSize.w; + + // 中间图片大小 + local centerImgSize = backgroundCenter.GetSize(); + local centerImgWidth = centerImgSize.w; + local centerImgHeight = centerImgSize.h; + + local centerWidth = width - backgroundTopLeft.GetSize().w - backgroundTopRight.GetSize().w; + local centerHeight = height - backgroundTopLeft.GetSize().h - backgroundBottomLeft.GetSize().h; + + + local scaleW = (centerWidth - 1).tofloat() / centerImgWidth.tofloat(); + local scaleH = (centerHeight - 1).tofloat() / centerImgHeight.tofloat(); + + // 上边 + backgroundTop.SetScale(scaleW, 1); + backgroundTop.SetPosition(TopLeftRight, 0); + DrawSprite(backgroundTop); + + // 右上角 + backgroundTopRight.SetPosition(width - backgroundTopRight.GetSize().w - 1, 0); + DrawSprite(backgroundTopRight); + + // 左边 + backgroundLeft.SetScale(1, scaleH); + backgroundLeft.SetPosition(0, TopLeftBottom); + DrawSprite(backgroundLeft); + + // 中间 + backgroundCenter.SetScale(scaleW, scaleH); + // Addchild(backgroundCenter); + backgroundCenter.SetPosition(TopLeftRight, backgroundLeft.Y); + DrawSprite(backgroundCenter); + + // 右边 + backgroundRight.SetScale(1, scaleH); + backgroundRight.SetPosition(width - backgroundRight.GetSize().w - 1, backgroundCenter.Y); + DrawSprite(backgroundRight); + + // 左下角 + backgroundBottomLeft.SetPosition(0, height - backgroundBottomLeft.GetSize().h - 1); + DrawSprite(backgroundBottomLeft); + + // 下边 + backgroundBottom.SetScale(scaleW, 1); + backgroundBottom.SetPosition(TopLeftRight, backgroundBottomLeft.Y); + DrawSprite(backgroundBottom); + + // 右下角 + backgroundBottomRight.SetPosition(width - backgroundBottomRight.GetSize().w - 1, backgroundBottomLeft.Y); + DrawSprite(backgroundBottomRight); + + // 结束绘制 + EndDraw(); + } + +} + //拼接按钮 class Yosin_SplicingButton extends Yosin_CommonUi { //按钮状态 @@ -427,14 +474,14 @@ class Yosin_SplicingButton extends Yosin_CommonUi { SpriteList = array(4); //普通态 - SpriteList[0] = Yosin_EmeStretch(0, 0, W, H, Path, Idx, Direction); + SpriteList[0] = Yosin_EmeStretch( W, H, Path, Idx, Direction); //悬停态 - SpriteList[1] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction); + SpriteList[1] = Yosin_EmeStretch( W, H, Path, Idx + (UnavailableFlag ? 4 : 3), Direction); //按下态 - SpriteList[2] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction); + SpriteList[2] = Yosin_EmeStretch( W, H, Path, Idx + (UnavailableFlag ? 8 : 6), Direction); if (UnavailableFlag) { //不可用态 - SpriteList[3] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + 12, Direction); + SpriteList[3] = Yosin_EmeStretch( W, H, Path, Idx + 12, Direction); } } @@ -455,7 +502,7 @@ class Yosin_SplicingButton extends Yosin_CommonUi { RemoveUIChild(SpriteList[SpriteState]); } SpriteState = State; - AddUIChild(SpriteList[SpriteState]); + Addchild(SpriteList[SpriteState]); } } @@ -588,17 +635,17 @@ class Yosin_StretchTitleButton extends Yosin_CommonUi { SpriteList = array(3); //普通态 - SpriteList[0] = Yosin_EmeStretch(0, 0, W, H, Path, Idx); - AddUIChild(SpriteList[0]); + SpriteList[0] = Yosin_EmeStretch( W, H, Path, Idx); + Addchild(SpriteList[0]); //悬停态 - SpriteList[1] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + 3); + SpriteList[1] = Yosin_EmeStretch( W, H, Path, Idx + 3); SpriteList[1].SetVisible(false) - AddUIChild(SpriteList[1]); + Addchild(SpriteList[1]); //按下态 - SpriteList[2] = Yosin_EmeStretch(0, 0, W, H, Path, Idx + 6); + SpriteList[2] = Yosin_EmeStretch( W, H, Path, Idx + 6); SpriteList[2].SetVisible(false) - AddUIChild(SpriteList[2]); + Addchild(SpriteList[2]); // 文字 titleText = FontAssetManager.GenerateNormal(title, true, { diff --git a/sqr/User/UI/Widget/Top_Title.nut b/sqr/User/UI/Widget/Top_Title.nut index 57f9425..105b906 100644 --- a/sqr/User/UI/Widget/Top_Title.nut +++ b/sqr/User/UI/Widget/Top_Title.nut @@ -21,7 +21,8 @@ class Yosin_TopTitle extends Yosin_CommonUi { // 绘制标题背景 local titleX = drawBackground ? 2 : 0; local titleW = drawBackground ? W - 4 : W; - local titleBackground = Yosin_EmeStretch(titleX, 0, titleW, 20, "sprite/interface/lenheartwindowcommon.img", 609); + local titleBackground = Yosin_EmeStretch( titleW, 20, "sprite/interface/lenheartwindowcommon.img", 609); + titleBackground.SetPosition(titleX, 0); titleBackground.SetScale(1, 1.3); Addchild(titleBackground); diff --git a/sqr/User/UI/Window/233_HUD_Message.nut b/sqr/User/UI/Window/233_HUD_Message.nut index 6dcacd2..a7a59e0 100644 --- a/sqr/User/UI/Window/233_HUD_Message.nut +++ b/sqr/User/UI/Window/233_HUD_Message.nut @@ -84,9 +84,9 @@ class _Yosin_MessageBox extends Yosin_Window { Addchild(twoBackground); // 绘制标题背景 - local titleBackground = Yosin_EmeStretch(0, 0, cacheW, 20, "sprite/interface/lenheartwindowcommon.img", 609); + local titleBackground = Yosin_EmeStretch(cacheW, 20, "sprite/interface/lenheartwindowcommon.img", 609); titleBackground.SetScale(1, 1.2); - AddUIChild(titleBackground); + Addchild(titleBackground); // 标题背景光 local BackgroundBright = CL_SpriteObject("sprite/interface/lenheartwindowcommon.img", 483); diff --git a/sqr/User/UI/Window/3_Top_tool.nut b/sqr/User/UI/Window/3_Top_tool.nut index 5f4d742..0c62a12 100644 --- a/sqr/User/UI/Window/3_Top_tool.nut +++ b/sqr/User/UI/Window/3_Top_tool.nut @@ -32,10 +32,10 @@ class _Top_tool extends Yosin_Window { } function RegisterWidget() { - local background = Yosin_EmeStretch(0, 0, 650, 20, "sprite/interface/lenheartwindowcommon.img", 612); + local background = Yosin_EmeStretch( 650, 20, "sprite/interface/lenheartwindowcommon.img", 612); Addchild(background); - local timeBackGround = Yosin_EmeStretch(0, 0, 90, 14, "sprite/interface/lenheartwindowcommon.img", 615); + local timeBackGround = Yosin_EmeStretch( 90, 14, "sprite/interface/lenheartwindowcommon.img", 615); timeBackGround.SetPosition(14, 2); Addchild(timeBackGround); From a9d9468cb5b83633c5fc760843752ca44453d335 Mon Sep 17 00:00:00 2001 From: WONIU Date: Sun, 19 Jan 2025 14:35:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=83=8C=E5=8C=85=20=E8=A3=85=E6=89=AE?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqr/User/Stage/LodingStage.nut | 2 +- sqr/User/UI/Window/5_Inventory.nut | 54 ------------------- .../UI/Window/5_Inventory/5_Inventory.nut | 4 +- .../5_Inventory/Inventory_DressUpPage.nut | 33 +++++++----- 4 files changed, 24 insertions(+), 69 deletions(-) delete mode 100644 sqr/User/UI/Window/5_Inventory.nut diff --git a/sqr/User/Stage/LodingStage.nut b/sqr/User/Stage/LodingStage.nut index 0676cf5..1ba3ff7 100644 --- a/sqr/User/Stage/LodingStage.nut +++ b/sqr/User/Stage/LodingStage.nut @@ -27,7 +27,7 @@ function InitGame() { //初始化控制器 _GameController_(); //初始化顶部工具条UI - // Sq_CreateWindow(_Top_tool, "窗口顶部工具条", 208, 0, 650, 20, 0); + Sq_CreateWindow(_Top_tool, "窗口顶部工具条", 208, 0, 650, 20, 0); //预加载 Animation("ui/charactercreate/dust.ani"); diff --git a/sqr/User/UI/Window/5_Inventory.nut b/sqr/User/UI/Window/5_Inventory.nut deleted file mode 100644 index e011820..0000000 --- a/sqr/User/UI/Window/5_Inventory.nut +++ /dev/null @@ -1,54 +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(0, 0, 80, 25, "sprite/interface/lenheartwindowcommon.img", 160); - item2.SetPos(100, 100); - 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/5_Inventory.nut b/sqr/User/UI/Window/5_Inventory/5_Inventory.nut index cab4ce7..c316016 100644 --- a/sqr/User/UI/Window/5_Inventory/5_Inventory.nut +++ b/sqr/User/UI/Window/5_Inventory/5_Inventory.nut @@ -188,12 +188,12 @@ class _Inventory extends Yosin_Window { // 切换页面 function ChangPage() { - equipmentPage.SetVisible(false); + EquipmentPage.SetVisible(false); DressUpPage.SetVisible(false); if (PageIndex == 0) { - equipmentPage.SetVisible(true); + EquipmentPage.SetVisible(true); permutationBtn.SetPosition(permutationBtn.X, itemSetBtnY); setBtn.SetPosition(setBtn.X, itemSetBtnY); saerchBtn.SetPosition(saerchBtn.X, itemSetBtnY); diff --git a/sqr/User/UI/Window/5_Inventory/Inventory_DressUpPage.nut b/sqr/User/UI/Window/5_Inventory/Inventory_DressUpPage.nut index 757faf1..b6f2d39 100644 --- a/sqr/User/UI/Window/5_Inventory/Inventory_DressUpPage.nut +++ b/sqr/User/UI/Window/5_Inventory/Inventory_DressUpPage.nut @@ -21,6 +21,16 @@ class Inventory_DressUpPage extends Yosin_CommonUi { CharactersDressUp.SetPosition(0, 0); Addchild(CharactersDressUp); + // 镶嵌徽章 + local InsetBadge = Yosin_BaseButton(150, 137, 97, 22, "sprite/interface/newstyle/windows/inventory/inventory.img", 90); + AddUIChild(InsetBadge); + + + //分页按钮 + local titlesBtn = Yosin_RowMoreTitleBtn(2, 180, 250, ["装扮", "徽章"], "sprite/interface/lenheartwindowcommon.img", 160); + AddUIChild(titlesBtn); + + } // 添加按钮 @@ -74,7 +84,6 @@ class Inventory_CharactersDressUp extends CL_CanvasObject { local CharacterLight = CL_SpriteFrameObject("sprite/interface/newstyle/windows/inventory/inventory.img", 178); DrawSpriteFrame(CharacterLight, -10, 4); - } @@ -82,14 +91,14 @@ class Inventory_CharactersDressUp extends CL_CanvasObject { -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 +// 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 From 85586a714cd1e2ad24113656ff84c61582adbd03 Mon Sep 17 00:00:00 2001 From: WONIU Date: Sun, 19 Jan 2025 17:44:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=81=8A=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqr/User/Stage/TestStage.nut | 5 +- sqr/User/UI/Window/6_Message.nut | 281 +++++++++++++++++++++++++++++++ sqr/User/main.nut | 3 +- 3 files changed, 286 insertions(+), 3 deletions(-) create mode 100644 sqr/User/UI/Window/6_Message.nut diff --git a/sqr/User/Stage/TestStage.nut b/sqr/User/Stage/TestStage.nut index ce68a34..d00d5a4 100644 --- a/sqr/User/Stage/TestStage.nut +++ b/sqr/User/Stage/TestStage.nut @@ -9,8 +9,7 @@ function TestStage() { T.SetName("测试舞台"); T.Enter(); - - local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0); + // local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0); // local BackGround = CL_SpriteObject("sprite/loding.img", 0); // T.Addchild(BackGround); @@ -39,6 +38,8 @@ function TestStage() { // local Window = Sq_CreateWindow(_Inventory, "背包窗口", 150, 12, 262, 548, 20); + local MessageWindow = Sq_CreateWindow(_Message, "聊天窗口", 1066, 0, 332, 600, 0); + // Window.equipmentPage.ItemCollection.SetItemList([{ // ItemId = 27675 // }, { diff --git a/sqr/User/UI/Window/6_Message.nut b/sqr/User/UI/Window/6_Message.nut new file mode 100644 index 0000000..406d3fd --- /dev/null +++ b/sqr/User/UI/Window/6_Message.nut @@ -0,0 +1,281 @@ +/* +文件名:6_Message.nut +路径:User/UI/Window/6_Message.nut +创建日期:2025-01-17 19:41 +文件用途: 消息窗口 +*/ + +//主类 +class _Message extends Yosin_Window { + + constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { + base.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); + + local background = Message_Backgournd(); + Addchild(background); + + RegisterWidget(); + } + + function RegisterWidget() { + + // 普通 + local ordinary = Message_SplicingButton(6, 206, 53, 20, 8, "普通", sq_RGBA(255, 255, 255, 255)); + AddUIChild(ordinary); + ordinary.LBDownOnClick = function(btn) { + print(111); + } + ordinary.OnTriangleClick = function(btn) { + print(222); + } + + // 公会 + local notice = Message_SplicingButton(60, 206, 53, 20, 47, "公会", sq_RGBA(254, 77, 245, 255)); + AddUIChild(notice); + notice.LBDownOnClick = function(btn) { + print(111); + } + notice.OnTriangleClick = function(btn) { + print(222); + } + + // 频道 + local channel = Message_SplicingButton(114, 206, 53, 20, 48, "频道", sq_RGBA(221, 153, 197, 255)); + AddUIChild(channel); + channel.LBDownOnClick = function(btn) { + print(111); + } + channel.OnTriangleClick = function(btn) { + print(222); + } + + // 募集 + local raise = Message_SplicingButton(168, 206, 53, 20, 49, "募集", sq_RGBA(105, 212, 238, 255)); + AddUIChild(raise); + raise.LBDownOnClick = function(btn) { + print(111); + } + raise.OnTriangleClick = function(btn) { + print(222); + } + + } + + //逻辑入口 + function Proc(Dt) { + SyncPos(X, Y); + base.Proc(Dt); + + } + + +} + + + +// 背景 +class Message_Backgournd extends CL_CanvasObject { + + constructor() { + base.constructor(); + + DrawBackground(); + + } + + + // 绘制背景 + function DrawBackground() { + + // 创建画布 + CL_CanvasObject(); + // 重设大小并清空 + ResizeAndClear(332, 600); + // 开始绘制 + BeginDraw(); + + + local topLine = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 159); + DrawSpriteFrame(topLine, 0, 0); + + local topBg = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 160); + topBg.SetPosition(0, 2); + topBg.SetScale(1, 28); + DrawSprite(topBg); + + local bimg = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 161); + DrawSpriteFrame(bimg, 0, 30); + + local bottomBg = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 162); + bottomBg.SetPosition(0, 561); + bottomBg.SetScale(1, 38); + DrawSprite(bottomBg); + + local bottomLine = CL_SpriteFrameObject("sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 163); + DrawSpriteFrame(bottomLine, 0, 598); + + // 系统按钮 + local systemBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166); + DrawSprite(systemBtnBackground, 6, 15); + + local systemText = FontAssetManager.GenerateNormal("系统", true, { + color = sq_RGBA(200, 173, 134, 255) + }); + DrawActor(systemText, 18 , 18); + + // 系统 + local SystemBround = Yosin_NineBoxStretch( 321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); + DrawSprite(SystemBround, 6, 35); + + // 喇叭按钮 + local megaphoneBtnBackground = Yosin_EmeStretch(53, 21, "sprite/interface/lenheartwindowcommon.img", 166); + DrawSprite(megaphoneBtnBackground, 6, 109); + + // 喇叭 + local megaphoneext = FontAssetManager.GenerateNormal("喇叭", true, { + color = sq_RGBA(255, 239, 1, 255) + }); + DrawActor(megaphoneext, 18 , 112); + + // 喇叭 + local megaphoneBround = Yosin_NineBoxStretch(321, 72, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); + DrawSprite(megaphoneBround, 6, 130); + + // 消息 + local MessageBround = Yosin_NineBoxStretch(321, 345, "sprite/interface/newstyle/windows/chatting/chatting_ver4.img", 265); + DrawSprite(MessageBround, 6, 225); + + + // 结束绘制 + EndDraw(); + + } + + +} + + + + +// 消息分类按钮 +class Message_SplicingButton extends Yosin_CommonUi { + + //按钮状态 + State = 0; + + Sprite = null; + SpriteState = -1; + FrameList = null; + + select = false; + cacheY = null; + + + LBDownOnClick = null; + OnTriangleClick = null; + + + constructor(X, Y, W, H, Idx, title, titleColor) { + base.constructor(X, Y, W, H); + + cacheY = Y; + FrameList = []; + Sprite = CL_SpriteObject(); + Addchild(Sprite); + + for (local i = 0; i< 3; i++) { + + local canvas = Yosin_EmeStretch(W, H, "sprite/interface/lenheartwindowcommon.img", 160 + i *3); + local Sf = canvas.ExportSpriteFrame(); + FrameList.push(Sf); + } + + // 文字 + local Text = FontAssetManager.GenerateNormal(title, true, { + color = titleColor + }); + Text.SetPosition(12, 1); + Addchild(Text); + + // 三角 + local triangle = CL_SpriteObject("sprite/interface/newstyle/windows/chatting/chatting_new.img", Idx); + triangle.SetPosition(W - 15, 8); + Addchild(triangle); + + // 按钮 + local bigButton = Yosin_BaseButton(0, 0, W - 15, H, "sprite/interface/lenheartwindowcommon.img", 70); + AddUIChild(bigButton); + bigButton.OnClick = function(btn) { + if (LBDownOnClick) { + LBDownOnClick(this); + }; + }.bindenv(this); + + // 三角按钮 + local triangleButton = Yosin_BaseButton(W - 15, 0, 15, H, "sprite/interface/lenheartwindowcommon.img", 70); + AddUIChild(triangleButton); + triangleButton.OnClick = function(btn) { + if (OnTriangleClick) { + OnTriangleClick(this); + }; + }.bindenv(this); + + } + + function ChangeFrame() { + //状态更改 刷新精灵帧 + if (State != SpriteState) { + if (State == 2) { + Y = cacheY - 1; + SyncPos(X, Y); + } else if (SpriteState == 2) { + Y = cacheY; + 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; + } + //悬停 + else if (isInRect) { + State = 1; + } + //普通 + else { + State = 0; + } + } + ChangeFrame(); + } + +} + + + + +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/main.nut b/sqr/User/main.nut index b17a5ae..fcac026 100644 --- a/sqr/User/main.nut +++ b/sqr/User/main.nut @@ -14,7 +14,8 @@ function main(args) { local Game = GameWindow(); Game.title = "Yosin & Kiwano"; Game.bg_color = [255.0, 255.0, 255.0, 255.0]; - Game.size = [1066, 600]; + Game.size = [1398, 600]; + // Game.size = [1066, 600]; Game.v_sync = false; Game.frame_interval = 10000; Game.debug_mode = true;