232 lines
7.3 KiB
Plaintext
232 lines
7.3 KiB
Plaintext
/*
|
|
文件名:HM_Inherit.nut
|
|
路径:Project/SpecialCustomization/HM_Inherit.nut
|
|
创建日期:2026-02-02 19:24
|
|
文件用途:毁梦继承
|
|
*/
|
|
|
|
|
|
class HM_InheritC extends LenheartNewUI_Windows {
|
|
//调试模式
|
|
// DeBugMode = true;
|
|
|
|
//不是窗口
|
|
// NoWindow = true;
|
|
|
|
//是否可见
|
|
// Visible = false;
|
|
|
|
Img = Rindro_Image("interface2/ui/newitemtool/soulweapon.img");
|
|
|
|
//装备
|
|
Item = null;
|
|
Item2 = null;
|
|
//装备槽位
|
|
ItemSlot = null;
|
|
//灵魂槽位
|
|
ItemSlot2 = null;
|
|
//注册的NPC列表
|
|
NPC = null;
|
|
|
|
|
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
|
Childrens = [];
|
|
//注册控件
|
|
RegisterWidget();
|
|
RegNpc();
|
|
|
|
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
|
|
|
DiscardItemCallBackFunc.rawset("HM_InheritC", DiscardItem.bindenv(this));
|
|
|
|
//成功回包
|
|
Pack_Control.rawset(21013002, function(Chunk) {
|
|
//清空
|
|
Item = null;
|
|
Item2 = null;
|
|
ItemSlot.RemoveItem();
|
|
ItemSlot2.RemoveItem();
|
|
}.bindenv(this));
|
|
}
|
|
|
|
function RegisterWidget() {
|
|
//关闭按钮
|
|
local CloseButton = LenheartNewUI_BaseButton(274, 4, 11, 12, "interface/lenheartwindowcommon.img", 276);
|
|
CloseButton.OnClick = function() {
|
|
this.Visible = false;
|
|
}.bindenv(this);
|
|
Childrens.append(CloseButton);
|
|
|
|
//确认按钮
|
|
local CrossoverButton = LenheartNewUI_ButtonText(109, 260, 15, "确认继承");
|
|
CrossoverButton.DWidth = 18;
|
|
CrossoverButton.Width = 74;
|
|
CrossoverButton.SetTextOffset(-4, 1);
|
|
CrossoverButton.OnClickEx = function(Btn) {
|
|
if (!Btn.Visible) return;
|
|
SendPackEx({
|
|
op = 21013001,
|
|
item = Item,
|
|
item2 = Item2
|
|
});
|
|
}.bindenv(this);
|
|
CrossoverButton.SetCallBackFunc(function(Btn) {
|
|
if (ItemSlot.ItemObject && ItemSlot2.ItemObject) {
|
|
Btn.State = 0;
|
|
} else {
|
|
Btn.State = 8;
|
|
}
|
|
}.bindenv(this));
|
|
AddChild(CrossoverButton);
|
|
|
|
ItemSlot = LenheartNewUI_ItemSlot(66, 97);
|
|
ItemSlot.SetRemoveCallBack(function(obj) {
|
|
Item = null;
|
|
}.bindenv(this));
|
|
AddChild(ItemSlot);
|
|
|
|
ItemSlot2 = LenheartNewUI_ItemSlot(197, 97);
|
|
ItemSlot2.SetRemoveCallBack(function(obj) {
|
|
Item2 = null;
|
|
}.bindenv(this));
|
|
AddChild(ItemSlot2);
|
|
}
|
|
|
|
//绘制主界面
|
|
function DrawMain(obj) {
|
|
//背景框
|
|
DrawNineBox(X, Y, 292, 292, "interface/lenheartwindowcommon.img", 213);
|
|
//标题
|
|
DrawWindowTitle(293);
|
|
//绘制标题名
|
|
L_sq_DrawCode("武器装备继承", X + 110, Y + 5, sq_RGBA(230, 200, 155, 255), 0, 1);
|
|
|
|
Img.DrawPng(1, X + 8, Y + 32);
|
|
Img.DrawPng(3, X + 8, Y + 32);
|
|
|
|
for (local i = 0; i< 5; i++) {
|
|
Img.DrawPng(2, X + 31 + 51 * i, Y + 195);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
function Show(obj) {
|
|
DrawMain(obj);
|
|
LenheartNewUI_Windows.Show(obj);
|
|
|
|
}
|
|
|
|
//逻辑入口
|
|
function Proc(obj) {
|
|
LenheartNewUI_Windows.SyncPos(X, Y);
|
|
}
|
|
|
|
function DiscardItem(ItemAddress) {
|
|
local MousePos_X = IMouse.GetXPos();
|
|
local MousePos_Y = IMouse.GetYPos();
|
|
if (!sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X, Y, Width, Height)) return true;
|
|
local SlotPos = 0;
|
|
|
|
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, ItemSlot.X, ItemSlot.Y, ItemSlot.Width, ItemSlot.Height)) {
|
|
SlotPos = 1;
|
|
} else if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, ItemSlot2.X, ItemSlot2.Y, ItemSlot2.Width, ItemSlot2.Height)) {
|
|
SlotPos = 2;
|
|
} else {
|
|
return null;
|
|
}
|
|
if (!Visible) return true;
|
|
else {
|
|
local ItemBuf = FindItemPosByForeachInven(ItemAddress, SlotPos);
|
|
if (ItemBuf) {
|
|
local ItemObject = Rindro_Item();
|
|
ItemObject.LoadByAddress(ItemBuf.ItemAddress);
|
|
if (SlotPos == 1) {
|
|
ItemSlot.SetItem(ItemObject);
|
|
Item = ItemBuf;
|
|
} else if (SlotPos == 2) {
|
|
ItemSlot2.SetItem(ItemObject);
|
|
Item2 = ItemBuf;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//遍历背包查找Item
|
|
function FindItemPosByForeachInven(FindAddress, SlotPos) {
|
|
local Inven = L_sq_RA(0x1A5FB24);
|
|
local InvenAdd = L_sq_RA(Inven + 56);
|
|
InvenAdd += 36;
|
|
//0是装备 2是任务材料
|
|
local z = 0;
|
|
for (local i = 0; i< 56; i++) {
|
|
local ItemAdd = L_sq_RA(InvenAdd + ((i + (z * 56)) * 4));
|
|
if (ItemAdd == FindAddress) {
|
|
local NamePointer = L_sq_RA(FindAddress + 0x20);
|
|
local rRarity = L_sq_RA(FindAddress + 0xF4);
|
|
local rItemId = L_sq_RA(FindAddress + 0x1c);
|
|
|
|
return {
|
|
Type = z,
|
|
Pos = i,
|
|
Vis = false,
|
|
Count = MemoryTool.DecodeMemoryData(FindAddress + 0x1A4),
|
|
ItemId = rItemId,
|
|
ItemAddress = FindAddress,
|
|
Name = NativePointer(L_sq_I2P(NamePointer)).readUnicodeString(),
|
|
Rarity = rRarity,
|
|
};
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function RegNpc() {
|
|
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 = 53;
|
|
ApplyEngagementButton.Str = "装备继承";
|
|
ApplyEngagementButton.Data = SThis.NPC_Index;
|
|
ApplyEngagementButton.OnClick = function(Button) {
|
|
|
|
InitWindow();
|
|
//打开背包
|
|
L_sq_Open_ExWindow(0x1ADE090, 0, 0, 1);
|
|
Button.Parent.CloseAllEach();
|
|
Button.Parent.CloseWindow();
|
|
ResetFocus();
|
|
R_Utils.PlaySound("WINDOW_SHOW");
|
|
}.bindenv(this);
|
|
ApplyEngagementButton.SetCallBackFunc(function(Button) {})
|
|
SThis.AddChild(ApplyEngagementButton);
|
|
}.bindenv(this));
|
|
}
|
|
|
|
function InitWindow() {
|
|
Visible = true;
|
|
//清空
|
|
Item = null;
|
|
Item2 = null;
|
|
ItemSlot.RemoveItem();
|
|
ItemSlot2.RemoveItem();
|
|
}
|
|
}
|
|
|
|
|
|
L_Windows_List <- [];
|
|
getroottable().rawdelete("LenheartPluginsInitFlag");
|
|
getroottable().rawdelete("EventList_Obj")
|
|
getroottable().rawdelete("HM_Inherit_Obj");
|
|
getroottable().rawdelete("L_Each_Obj");
|
|
|
|
function Lenheart_HM_Inherit_Fun(obj) {
|
|
local RootTab = getroottable();
|
|
if (!RootTab.rawin("HM_Inherit_Obj")) {
|
|
RootTab.rawset("HM_Inherit_Obj", true);
|
|
LenheartNewUI_CreateWindow(HM_InheritC, "装备继承", ((getroottable().Rindro_Scr_Width - 700) / 2).tointeger(), 160, 292, 290, 28);
|
|
}
|
|
}
|
|
|
|
getroottable()["LenheartFuncTab"].rawset("HM_InheritFuncN", Lenheart_HM_Inherit_Fun); |