From 85586a714cd1e2ad24113656ff84c61582adbd03 Mon Sep 17 00:00:00 2001 From: WONIU Date: Sun, 19 Jan 2025 17:44:38 +0800 Subject: [PATCH] =?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;