Rindro-Sqr/Project/OutfitSystem/OutfitSystem.nut

285 lines
9.9 KiB
Plaintext
Raw Normal View History

2026-03-03 15:44:38 +08:00
/*
文件名:OutfitSystem.nut
路径:Project/OutfitSystem/OutfitSystem.nut
创建日期:2026-03-01 03:11
文件用途:
*/
class OutfitSystemC extends LenheartNewUI_Windows {
//调试模式
// DeBugMode = true;
//不是窗口
// NoWindow = true;
//是否可见
Visible = false;
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;
//说明是否悬停
InstructionsIsHover = true;
2026-03-03 15:44:38 +08:00
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);
Rindro_Image_GlobalMap["lenheartui"].DrawPng(469 + (InstructionsIsHover ? 1 : 0), X + 335, Y + 266);
2026-03-03 15:44:38 +08:00
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 TopShow(obj)
{
if(InstructionsIsHover){
local XOffset = 8;
local YOffset = 192;
DrawNineBox(X + XOffset, Y + YOffset, 326, 80, "interface/lenheartwindowcommon.img", 213);
L_sq_DrawCode("①选择对应的标签以配置换装配置", X + XOffset + 8, Y + YOffset + 8, sq_RGBA(230, 200, 155, 255), 0, 1);
L_sq_DrawCode("②点击记录可以保存当前穿戴的装备,点击重置可以清除配置", X + XOffset + 8, Y + YOffset + 8 + 16, sq_RGBA(230, 200, 155, 255), 0, 1);
L_sq_DrawCode("③在对话窗口输入//HZ 1 可以换装1号标签的配置", X + XOffset + 8, Y + YOffset + 8 + 32, sq_RGBA(230, 200, 155, 255), 0, 1);
L_sq_DrawCode("④设置快捷喊话可以方便一键切换", X + XOffset + 8, Y + YOffset + 8 + 48, sq_RGBA(230, 200, 155, 255), 0, 1);
}
}
2026-03-03 15:44:38 +08:00
//逻辑入口
function Proc(obj) {
LenheartNewUI_Windows.SyncPos(X, Y);
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X + 335, Y + 266, 16, 16)) {
InstructionsIsHover = true;
} else {
InstructionsIsHover = false;
}
2026-03-03 15:44:38 +08:00
}
//读取自身装备并显示在装备槽位
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);