From 89899a379949dae8cc61ed336d7b3aae3ef223fa Mon Sep 17 00:00:00 2001 From: Lenheart <947330670@qq.com> Date: Sat, 25 Oct 2025 15:51:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=96=87=E6=9C=AC=E7=B2=BE?= =?UTF-8?q?=E7=81=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SquirrelFileConfig.cfg | 1 + Tool/Common.nut | 17 +++++++++++++++++ UI/MainUI.nut | 10 +++++----- UI/ObjectClass/GameWidget.nut | 2 +- UI/ObjectClass/Text.nut | 16 ++++++++++++++++ UI/Windows/System/NotiBox.nut | 15 ++++++++++++++- folder-alias.json | 3 +++ internalInterfaceDoc/func.nut | 1 + main.nut | 12 +++++++++--- 9 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 UI/ObjectClass/Text.nut diff --git a/SquirrelFileConfig.cfg b/SquirrelFileConfig.cfg index c7e795d..ef365f0 100644 --- a/SquirrelFileConfig.cfg +++ b/SquirrelFileConfig.cfg @@ -20,6 +20,7 @@ UI/ObjectClass/Actor.nut UI/ObjectClass/WindowNode.nut UI/ObjectClass/GameWindow.nut UI/ObjectClass/GameWidget.nut +UI/ObjectClass/Text.nut UI/ObjectClass/Sprite.nut UI/ObjectClass/Canvas.nut diff --git a/Tool/Common.nut b/Tool/Common.nut index 777a7c9..4943e6d 100644 --- a/Tool/Common.nut +++ b/Tool/Common.nut @@ -22,3 +22,20 @@ function print(Object) { break; } } + +/** + * 返回颜色的十六进制数 + * @function + * @param {any} R + * @param {any} G + * @param {any} B + * @param {any} A + * @returns {*} + */ +function sq_RGBA(R, G, B, A) { + R = R.tointeger(); + G = G.tointeger(); + B = B.tointeger(); + A = A.tointeger(); + return (A << 24) + (R << 16) + (G << 8) + B; +} \ No newline at end of file diff --git a/UI/MainUI.nut b/UI/MainUI.nut index a8f1875..6f353e0 100644 --- a/UI/MainUI.nut +++ b/UI/MainUI.nut @@ -20,15 +20,15 @@ function _MainUI_Enter_(UI_Scene) { // _SYS_UI_SCENE_Instance_.AddChild(Tc); // Tc.SetPos(400,300); - local NgC = GameWidget_NineGridCav("sprite/interface/lenheartwindowcommon.img", 97, 300, 300); - _SYS_UI_SCENE_Instance_.AddChild(NgC); - NgC.SetPos(400, 300); + // local NgC = GameWidget_NineGridCav("sprite/interface/lenheartwindowcommon.img", 97, 300, 300); + // _SYS_UI_SCENE_Instance_.AddChild(NgC); + // NgC.SetPos(400, 300); // local T = sq_GetPng("sprite/item/avatar/swordman/0sm_acap.img",0); // print(T); - // local Test1 = sq_CreaterWindowInstance("测试窗口", Window_NotiBox, 150, 150, 364, 356, 20); - // Test1.ResetFoucus(); + local Test1 = sq_CreaterWindowInstance("测试窗口", Window_NotiBox, 150, 150, 364, 356, 20); + Test1.ResetFoucus(); // local Canv = Canvas(600, 600); // _SYS_UI_SCENE_Instance_.AddChild(Canv); diff --git a/UI/ObjectClass/GameWidget.nut b/UI/ObjectClass/GameWidget.nut index aa4a6e9..5547412 100644 --- a/UI/ObjectClass/GameWidget.nut +++ b/UI/ObjectClass/GameWidget.nut @@ -65,7 +65,7 @@ class GameWidget extends WindowNode { local IMouse = Game_Cursor.GetInstance(); local Pos = GetWorldPos(); if (isLBDown && Math.IsIntersectRect(IMouse.MouseX, IMouse.MouseY, 1, 1, Pos.x, Pos.y, Width, Height)) { - if (OnClick) this.OnClick(this); + if (OnClick) this.OnClick.call(this,this); if (ClickSound) { //TODO 音效系统 // Sq_PlaySoundEffect(ClickSound); diff --git a/UI/ObjectClass/Text.nut b/UI/ObjectClass/Text.nut new file mode 100644 index 0000000..b56710e --- /dev/null +++ b/UI/ObjectClass/Text.nut @@ -0,0 +1,16 @@ +/* +文件名:Text.nut +路径:UI/ObjectClass/Text.nut +创建日期:2025-10-25 15:40 +文件用途: +*/ +class Text extends Actor { + function _typeof() { + return "Text" + } + + constructor(Str, FontIndex,Color) { + C_Object = sq_CreateText(Str, FontIndex, Color); + sq_RegisterDestruction(C_Object,this); + } +} diff --git a/UI/Windows/System/NotiBox.nut b/UI/Windows/System/NotiBox.nut index 6cab33a..1cd9241 100644 --- a/UI/Windows/System/NotiBox.nut +++ b/UI/Windows/System/NotiBox.nut @@ -6,20 +6,33 @@ */ class Window_NotiBox extends GameWindow { + testvalue = 666; + constructor(Name, gX, gY, gWidth, gHeight, gTitleHeight) { base.constructor(Name, gX, gY, gWidth, gHeight, gTitleHeight); InitSprite(); - InitButton(); + // InitButton(); } function InitSprite() { local Sp = Sprite("sprite/hud/newantonui.img", 0); AddChild(Sp); + + local Textobj = Text("测试文本",0,sq_RGBA(255,255,255,255)); + AddChild(Textobj); + local Textobj2 = Text("测试文本",1,sq_RGBA(255,255,255,255)); + Textobj2.SetPos(0,50); + AddChild(Textobj2); } function InitButton() { local Btn = GameWidget_BaseButton(40, 40, 56, 24, "sprite/interface/lenheartwindowcommon.img", 12); + Btn.OnClick = function(btn){ + // print(testvalue); + print(this); + print(btn); + }.bindenv(this); AddChild(Btn); } } diff --git a/folder-alias.json b/folder-alias.json index b36c879..79c07a5 100644 --- a/folder-alias.json +++ b/folder-alias.json @@ -85,5 +85,8 @@ }, "UI/Windows/Widget/NineGridCav.nut": { "description": "九宫格画布" + }, + "UI/ObjectClass/Text.nut": { + "description": "文本类" } } \ No newline at end of file diff --git a/internalInterfaceDoc/func.nut b/internalInterfaceDoc/func.nut index 909c897..2f750f0 100644 --- a/internalInterfaceDoc/func.nut +++ b/internalInterfaceDoc/func.nut @@ -95,6 +95,7 @@ function sq_CreateActor() {} function sq_RegisterDestruction(a,b) {} function sq_CreateSprite(a,b) {} function sq_CreateCanvas(a,b) {} +function sq_CreateText(a,b,c) {} function sq_AddChild(a,b){} function sq_RemoveChild(a,b){} function sq_SetZOrder(a,b){} diff --git a/main.nut b/main.nut index 7e05ab9..b1ff3fa 100644 --- a/main.nut +++ b/main.nut @@ -1,11 +1,17 @@ +function _InitFont_() { + return [ + { path = "Fonts/VonwaonBitmap-12px.ttf", size = 12 }, + { path = "Fonts/VonwaonBitmap-12px.ttf", size = 24 }, + { path = "Fonts/NotoSansSC-Light.otf", size = 12 } + ]; +} + function main() { //初始化随机数种子 srand(time()); - - local SM = StateMachine.GetInstance(); SM.RegisterState(CHARACTERJOB.SWORDMAN, "Character_Rest", 0); SM.RegisterState(CHARACTERJOB.SWORDMAN, "Character_Move", 1); -} \ No newline at end of file +}