diff --git a/Base/UI/Lenheart_Each_Class.nut b/Base/UI/Lenheart_Each_Class.nut index 657a273..44d428e 100644 --- a/Base/UI/Lenheart_Each_Class.nut +++ b/Base/UI/Lenheart_Each_Class.nut @@ -40,19 +40,19 @@ class LenheartNewUI_Each_BaseButton extends LenheartNewUI_CommonUi { if (isLBDown) { L_sq_DrawImg(Path, Idx + 1, X, Y); if (Icon) L_sq_DrawImg(Icon, IconIdx, X + 3, Y + 2); - if (Str) L_sq_DrawCode(Str, X + 60 - LenheartTextClass.GetStringLength(Str) / 2, Y + 5, StrColor, 0, 1); + if (Str) L_sq_DrawCode(Str, X + 61 - LenheartTextClass.GetStringLength(Str) / 2, Y + 5, StrColor, 0, 1); } //悬停 else if (isInRect) { L_sq_DrawImg(Path, Idx, X, Y); if (Icon) L_sq_DrawImg(Icon, IconIdx, X + 3, Y + 1); - if (Str) L_sq_DrawCode(Str, X + 60 - LenheartTextClass.GetStringLength(Str) / 2, Y + 4, StrColor, 0, 1); + if (Str) L_sq_DrawCode(Str, X + 61 - LenheartTextClass.GetStringLength(Str) / 2, Y + 4, StrColor, 0, 1); } //普通 else { L_sq_DrawImg(Path, 0, X, Y); if (Icon) L_sq_DrawImg(Icon, IconIdx, X + 3, Y + 1); - if (Str) L_sq_DrawCode(Str, X + 60 - LenheartTextClass.GetStringLength(Str) / 2, Y + 4, StrColor, 0, 1); + if (Str) L_sq_DrawCode(Str, X + 61 - LenheartTextClass.GetStringLength(Str) / 2, Y + 4, StrColor, 0, 1); } } } diff --git a/FileConfig.json b/FileConfig.json index 50a1884..bc70422 100644 --- a/FileConfig.json +++ b/FileConfig.json @@ -57,6 +57,19 @@ "CSBase/Interface.nut" ], "ProjectScript": { + "换装系统": { + "Private": true, + "Script": [ + "Project/OutfitSystem/OutfitSystem_Component.nut", + "Project/OutfitSystem/OutfitSystem.nut" + ], + "info": { + "ProjectAuthor": "官方 (期限:月)", + "ProjectVersion": "1.0.0", + "ProjectDescribe": "换装系统", + "ImageMini": "http://49.234.27.222:8651/dps/download2/Image:chengjiu.png" + } + }, "黄金哥布林袖珍罐": { "Private": true, "Script": [ diff --git a/Project/OutfitSystem/OutfitSystem.nut b/Project/OutfitSystem/OutfitSystem.nut new file mode 100644 index 0000000..1886c89 --- /dev/null +++ b/Project/OutfitSystem/OutfitSystem.nut @@ -0,0 +1,290 @@ +/* +文件名:OutfitSystem.nut +路径:Project/OutfitSystem/OutfitSystem.nut +创建日期:2026-03-01 03:11 +文件用途: +*/ +class OutfitSystemC extends LenheartNewUI_Windows { + //调试模式 + // DeBugMode = true; + + //不是窗口 + // NoWindow = true; + + //是否可见 + Visible = false; + + /* + + 武器偏移 "3038" + 称号偏移 "303C" + 上衣偏移 "3040" + 头肩偏移 "3044" + 裤子偏移 "3048" + 鞋子偏移 "304C" + 腰带偏移 "3050" + 项链偏移 "3054" + 手镯偏移 "3058" + 戒指偏移 "305C" + 左曹偏移 "3060" + 右曹偏移 "3064" + 时装帽子偏移 "3008" + 时装头部偏移 "300C" + 时装脸部偏移 "3010" + 时装上衣偏移 "3014" + 时装下衣偏移 "3018" + 时装鞋子偏移 "301C" 原来3020正确的是301C + 时装胸部偏移 "3020" + 时装腰带偏移 "3024" + 时装皮肤偏移 "3028" + 时装光圈偏移 "302C" + 时装武器偏移 "3030" + 宠物偏移 "3068" + + */ + Img = Rindro_Image("interface2/buffswitching/buffswitching.img"); + + ItemSlotPos = [ + [9, 154, 0x3044], //护肩 + [9, 186, 0x3048], //下装 + [9, 218, 0x304C], //鞋子 + [41, 154, 0x3040], //上衣 + [41, 186, 0x3050], //腰带 + [73, 154, 0x3038], //武器 + [73, 186, 0x3058], //手镯 + [73, 218, 0x3060], //辅助装备 + [73, 250, null], //耳环 + [105, 154, 0x303C], //称号 + [105, 186, 0x3054], //项链 + [105, 218, 0x305C], //戒指 + [105, 250, 0x3064], //魔法石 + [148, 153, null], //武器装扮 + [148, 186, 0x3034], //光环 + [181, 153, 0x3014], //头部 + [181, 186, 0x3028], //胸部 + [181, 220, 0x302C], //腰部 + [214, 153, 0x3010], //帽子 + [214, 186, 0x301C], //上衣 + [214, 220, 0x3020], //下装 + [247, 153, 0x3018], //脸部 + [247, 186, 0x3030], //皮肤 + [247, 220, 0x3024], //鞋 + [305, 165, 0x3068] //宠物 + ]; + ItemSlotList = null; + + //当前选中 + CurrentSelect = null; + + + constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { + Childrens = []; + //注册控件 + RegisterWidget(); + + LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); + + local EachManager = Lenheart_Get_EachObj(); + EachManager.AddEachForNpc(2, function(SThis) { + //关闭按钮 + local ApplyEngagementButton = LenheartNewUI_Each_BaseButton(0, 0, 100, 21, "interface2/popup_menu/popup_back.img", 3); + ApplyEngagementButton.Icon = "interface2/popup_menu/popup_icon_cn.img"; + ApplyEngagementButton.IconIdx = 52; + ApplyEngagementButton.Str = "换装配置"; + ApplyEngagementButton.Data = SThis.NPC_Index; + ApplyEngagementButton.OnClick = function(Button) { + + InitWindow(); + Button.Parent.CloseAllEach(); + Button.Parent.CloseWindow(); + ResetFocus(); + R_Utils.PlaySound("WINDOW_SHOW"); + }.bindenv(this); + ApplyEngagementButton.SetCallBackFunc(function(Button) {}) + SThis.AddChild(ApplyEngagementButton); + }.bindenv(this)); + + //成功回包 + Pack_Control.rawset(21015004, function(Chunk) { + foreach(SlotObj in ItemSlotList) { + SlotObj.RemoveItem(); + } + local Jso = Json.Decode(Chunk); + if (Jso.EquipInfo == null) return; + foreach(_Index, Equip in Jso.EquipInfo) { + if (Equip[0] == 0) continue; + local ItemId = Equip[0]; + local Upgrade = Equip[1]; + local Amplification = Equip[2]; + local Forging = Equip[3]; + local Enchanting = Equip[4]; + + local ItemObject = Rindro_Item(); + ItemObject.LoadById(ItemId); + ItemObject.SetUpgrade(Upgrade); + ItemObject.SetAmplification(Amplification); + ItemObject.SetForging(Forging); + ItemObject.SetEnchanting(Enchanting); + ItemSlotList[_Index.tointeger()].SetItem(ItemObject); + } + }.bindenv(this)); + } + + function RegisterWidget() { + //关闭按钮 + local CloseButton = LenheartNewUI_BaseButton(340, 2, 11, 12, "interface/lenheartwindowcommon.img", 276); + CloseButton.OnClick = function() { + this.Visible = false; + }.bindenv(this); + Childrens.append(CloseButton); + + local SaveButton = LenheartNewUI_ButtonText(310, 52, 15, "记录"); + SaveButton.DWidth = -19; + SaveButton.Width = 36; + SaveButton.SetTextOffset(-12, 1); + SaveButton.OnClick = function() { + if (CurrentSelect == null) { + return; + } + SendPackEx({ + op = 21015001, + EquipInfo = ReadSelfEquip(), + Slot = CurrentSelect, + }) + }.bindenv(this); + Childrens.append(SaveButton); + + local ResetButton = LenheartNewUI_ButtonText(310, 84, 15, "重置"); + ResetButton.DWidth = -19; + ResetButton.Width = 36; + ResetButton.SetTextOffset(-12, 1); + ResetButton.OnClick = function() { + if (CurrentSelect == null) { + return; + } + SendPackEx({ + op = 21015005, + Slot = CurrentSelect, + }) + foreach(SlotObj in ItemSlotList) { + SlotObj.RemoveItem(); + } + }.bindenv(this); + Childrens.append(ResetButton); + + for (local i = 0; i< 20; i++) { + local Obtn = OutfitSystemC_Button(10 + (i % 10) * 30, 56 + (i / 10) * 30, 3, i); + Obtn.OnClickEx = function(Obj, Idx) { + CurrentSelect = Idx; + SendPackEx({ + op = 21015003, + Slot = Idx + }) + }.bindenv(this); + AddChild(Obtn); + } + + ItemSlotList = []; + local ItemObject = Rindro_Item(); + ItemObject.LoadById(3037); + for (local i = 0; i< ItemSlotPos.len(); i++) { + local XPos = ItemSlotPos[i][0]; + local YPos = ItemSlotPos[i][1]; + local ItemSlot = LenheartNewUI_ItemSlot(XPos, YPos); + // ItemSlot.SetItem(ItemObject); + ItemSlotList.append(ItemSlot); + AddChild(ItemSlot); + } + } + + //绘制主界面 + function DrawMain(obj) { + Img.DrawPng(0, X, Y); + L_sq_DrawCode("换装配置", X + 152, Y + 3, sq_RGBA(230, 200, 155, 255), 0, 1); + + L_sq_DrawCode("装备槽位", X + 48, Y + 135, sq_RGBA(150, 150, 150, 255), 0, 1); + L_sq_DrawCode("时装槽位", X + 188, Y + 135, sq_RGBA(150, 150, 150, 255), 0, 1); + L_sq_DrawCode("宠物", X + 308, Y + 135, sq_RGBA(150, 150, 150, 255), 0, 1); + + if (CurrentSelect != null) { + Rindro_Image_GlobalMap["lenheartui"].DrawPng(425, X + 12 + (CurrentSelect % 10) * 30, Y + 38 + (CurrentSelect / 10) * 30); + } + } + + function Show(obj) { + DrawMain(obj); + LenheartNewUI_Windows.Show(obj); + } + + //逻辑入口 + function Proc(obj) { + LenheartNewUI_Windows.SyncPos(X, Y); + } + + //读取自身装备并显示在装备槽位 + function ReadSelfEquip() { + local EquiList = []; + for (local i = 0; i< ItemSlotPos.len(); i++) { + local Offset = ItemSlotPos[i][2]; + if (Offset != null) { + local EquipAddress = GetEquip(Offset); + if (EquipAddress != null) { + local ItemObject = Rindro_Item(); + ItemObject.LoadByAddress(EquipAddress); + ItemSlotList[i].SetItem(ItemObject); + local Info = [ + ItemObject.GetIndex(), + ItemObject.GetUpgrade(), + ItemObject.GetAmplification(), + ItemObject.GetForging(), + ItemObject.GetEnchanting() + ] + EquiList.append(Info); + } else { + EquiList.append([0, 0, 0, 0, 0]); + } + } else { + EquiList.append([0, 0, 0, 0, 0]); + } + } + return EquiList; + } + + function GetEquip(Offset) { + local ObjAddress = NativePointer(0x1AB7CDC).readInt(); + local EquipAddress = NativePointer(ObjAddress + Offset).readInt(); + if (EquipAddress != 0) { + local Index = NativePointer(EquipAddress + 0x1C).readInt(); + return EquipAddress; + } + return null; + } + + function InitWindow() { + this.CurrentSelect = null; + this.Visible = true; + foreach(SlotObj in ItemSlotList) { + SlotObj.RemoveItem(); + } + } + +} + + +L_Windows_List <- []; +getroottable().rawdelete("LenheartPluginsInitFlag"); +getroottable().rawdelete("EventList_Obj") +getroottable().rawdelete("OutfitSystem_Obj"); +getroottable().rawdelete("L_Each_Obj"); + + + +function Lenheart_OutfitSystem_Fun(obj) { + local RootTab = getroottable(); + if (!RootTab.rawin("OutfitSystem_Obj")) { + RootTab.rawset("OutfitSystem_Obj", true); + LenheartNewUI_CreateWindow(OutfitSystemC, "换装系统窗口", 60, 150, 356, 286, 18); + } +} + +getroottable()["LenheartFuncTab"].rawset("OutfitSystemFuncN", Lenheart_OutfitSystem_Fun); \ No newline at end of file diff --git a/Project/OutfitSystem/OutfitSystem_Component.nut b/Project/OutfitSystem/OutfitSystem_Component.nut new file mode 100644 index 0000000..f362596 --- /dev/null +++ b/Project/OutfitSystem/OutfitSystem_Component.nut @@ -0,0 +1,66 @@ +/* +文件名:OutfitSystem_Component.nut +路径:Project/OutfitSystem/OutfitSystem_Component.nut +创建日期:2026-03-02 03:39 +文件用途: +*/ +class OutfitSystemC_Button extends LenheartNewUI_CommonUi { + State = 0; + BaseIdx = 29; + DWidth = null; + Img = Rindro_Image("interface2/buffswitching/buffswitchingp.img"); + Idx = 172; + FillWidth = 2; + FirstWidth = 11; + + + constructor(X, Y, W, gIdx) { + this.DWidth = W; + this.Idx = gIdx; + LenheartNewUI_CommonUi.constructor(X, Y, W + 11 * 2, 13); + } + + function Show(obj) { + //不可用 + if (State == 8) { + // L_sq_DrawButton(X, Y + 1, this.DWidth, Path, Idx + 9, FillWidth, FirstWidth); + } else { + //按下 + if (isLBDown) { + // L_sq_DrawButton(X, Y + 1, this.DWidth, Path, Idx + 3, FillWidth, FirstWidth); + Img.DrawPng(this.Idx, X, Y + 1); + L_sq_SetDrawImgModel(2, 0); + L_sq_DrawButton(X, Y + 1, this.DWidth, "interface/lenheartwindowcommon.img", 258, FillWidth, FirstWidth); + L_sq_ReleaseDrawImgModel(); + } + //悬停 + else if (isInRect) { + // L_sq_DrawButton(X, Y, this.DWidth, Path, Idx + 3, FillWidth, FirstWidth); + Img.DrawPng(this.Idx, X, Y); + L_sq_SetDrawImgModel(2, 0); + L_sq_DrawButton(X, Y, this.DWidth, "interface/lenheartwindowcommon.img", 258, FillWidth, FirstWidth); + L_sq_ReleaseDrawImgModel(); + } + //普通 + else { + Img.DrawPng(this.Idx, X, Y); + } + } + } + + //鼠标左键弹起回调 + function OnMouseLbUp(MousePos_X, MousePos_Y) { + if (isLBDown) { + if (OnClickEx) OnClickEx(this, this.Idx); + } + isLBDown = false; + } +} + + + +L_Windows_List <- []; +getroottable().rawdelete("LenheartPluginsInitFlag"); +getroottable().rawdelete("EventList_Obj") +getroottable().rawdelete("OutfitSystem_Obj"); +getroottable().rawdelete("L_Each_Obj"); \ No newline at end of file