353 lines
12 KiB
Plaintext
353 lines
12 KiB
Plaintext
|
|
/*
|
||
|
|
文件名:ItemOtherWolrdUpgrade.nut
|
||
|
|
路径:Project/ItemTool/ItemOtherWolrdUpgrade/ItemOtherWolrdUpgrade.nut
|
||
|
|
创建日期:2026-01-13 19:31
|
||
|
|
文件用途:
|
||
|
|
*/
|
||
|
|
class ItemOtherWolrdUpgradeC extends LenheartNewUI_Windows {
|
||
|
|
//调试模式
|
||
|
|
// DeBugMode = true;
|
||
|
|
|
||
|
|
//不是窗口
|
||
|
|
// NoWindow = true;
|
||
|
|
|
||
|
|
//是否可见
|
||
|
|
// Visible = false;
|
||
|
|
|
||
|
|
Img = Rindro_Image("interface2/ui/newitemtool/otherworldup.img");
|
||
|
|
|
||
|
|
//装备
|
||
|
|
Item = null;
|
||
|
|
//装备槽位
|
||
|
|
ItemSlot = null;
|
||
|
|
//注册的NPC列表
|
||
|
|
NPCList = null;
|
||
|
|
//所需的基础材料
|
||
|
|
BasicMaterials = null;
|
||
|
|
//等级倍率
|
||
|
|
LevelRate = null;
|
||
|
|
//品级倍率
|
||
|
|
RarityRate = null;
|
||
|
|
|
||
|
|
//背景动画
|
||
|
|
BackGroundAni = null;
|
||
|
|
|
||
|
|
//错误
|
||
|
|
Error = null;
|
||
|
|
|
||
|
|
//错误信息
|
||
|
|
ErrorMsg = null;
|
||
|
|
//所需材料信息
|
||
|
|
MaterialInfo = null;
|
||
|
|
//所需材料是否足够
|
||
|
|
MaterialIsEnough = false;
|
||
|
|
|
||
|
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||
|
|
Childrens = [];
|
||
|
|
//注册控件
|
||
|
|
RegisterWidget();
|
||
|
|
|
||
|
|
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||
|
|
|
||
|
|
DiscardItemCallBackFunc.rawset("ItemOtherWolrdUpgradeC", DiscardItem.bindenv(this));
|
||
|
|
|
||
|
|
//初始化信息
|
||
|
|
InifPvf();
|
||
|
|
//注册NPC回调
|
||
|
|
RegNpc();
|
||
|
|
|
||
|
|
//初始化背景动画
|
||
|
|
local BallFrameArr = [];
|
||
|
|
for (local i = 0; i< 30; i++) {
|
||
|
|
local T = {
|
||
|
|
ImgIndex = i,
|
||
|
|
Delay = 60,
|
||
|
|
Pos = [0, 0]
|
||
|
|
}
|
||
|
|
BallFrameArr.append(T);
|
||
|
|
}
|
||
|
|
BackGroundAni = Rindro_CustomAnimation("interface2/itemtoolwindow/changeoptions/mastercube.img", BallFrameArr);
|
||
|
|
|
||
|
|
|
||
|
|
Pack_Control.rawset(21010002, function(Chunk) {
|
||
|
|
local Jso = Json.Decode(Chunk);
|
||
|
|
if (Jso.rawin("error")) {
|
||
|
|
ErrorMsg = 1;
|
||
|
|
}
|
||
|
|
if (Jso.rawin("MgInfo")) {
|
||
|
|
MaterialInfo = Jso.MgInfo;
|
||
|
|
//材料是否充足
|
||
|
|
MaterialIsEnough = true;
|
||
|
|
foreach(Info in MaterialInfo) {
|
||
|
|
if (Info.NeedCount > Info.RealCount) {
|
||
|
|
MaterialIsEnough = false;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}.bindenv(this));
|
||
|
|
|
||
|
|
//成功回包
|
||
|
|
Pack_Control.rawset(21010004, function(Chunk) {
|
||
|
|
//清空
|
||
|
|
Item = null;
|
||
|
|
ItemSlot.RemoveItem();
|
||
|
|
ErrorMsg = null;
|
||
|
|
MaterialInfo = null;
|
||
|
|
MaterialIsEnough = false;
|
||
|
|
// R_Utils.PlaySound("CHNUTTREE_BOX");
|
||
|
|
}.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 = 21010003,
|
||
|
|
item = Item
|
||
|
|
});
|
||
|
|
}.bindenv(this);
|
||
|
|
CrossoverButton.SetCallBackFunc(function(Btn) {
|
||
|
|
if (ErrorMsg || !MaterialIsEnough) {
|
||
|
|
Btn.State = 8;
|
||
|
|
} else {
|
||
|
|
Btn.State = 0;
|
||
|
|
}
|
||
|
|
}.bindenv(this));
|
||
|
|
AddChild(CrossoverButton);
|
||
|
|
|
||
|
|
ItemSlot = LenheartNewUI_ItemSlot(132, 100);
|
||
|
|
ItemSlot.SetRemoveCallBack(function(obj) {
|
||
|
|
Item = null;
|
||
|
|
}.bindenv(this));
|
||
|
|
AddChild(ItemSlot);
|
||
|
|
}
|
||
|
|
|
||
|
|
//绘制主界面
|
||
|
|
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);
|
||
|
|
|
||
|
|
|
||
|
|
setClip(X + 8, Y + 32, X + 285, Y + 259);
|
||
|
|
local rate = 0.35;
|
||
|
|
Img.DrawExPng(1, X + 12, Y + 36, 0, sq_RGBA(255, 255, 255, 250), rate, rate);
|
||
|
|
L_sq_SetDrawImgModel(2, 0);
|
||
|
|
BackGroundAni.ShowEx(Duration, X + 12 - 80, Y + 36 - 45, sq_RGBA(255, 255, 255, 250), 0.75, 0.75);
|
||
|
|
L_sq_ReleaseDrawImgModel();
|
||
|
|
releaseClip();
|
||
|
|
|
||
|
|
|
||
|
|
Img.DrawPng(0, X + 8, Y + 32);
|
||
|
|
|
||
|
|
|
||
|
|
// if (MaterialsList) {
|
||
|
|
// foreach(Index, Info in MaterialsList) {
|
||
|
|
// DrawItemBase(X + 31 + 51 * Index, Y + 195, Info.ItemId, Info.ItemCount);
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
//绘制跨界所需材料及数量信息
|
||
|
|
if (MaterialInfo) {
|
||
|
|
for (local i = 0; i< 5; i++) {
|
||
|
|
if (i >= MaterialInfo.len()) {
|
||
|
|
Img.DrawPng(2, X + 31 + 51 * i, Y + 195);
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
local Info = MaterialInfo[i];
|
||
|
|
DrawItemBase(X + 31 + 51 * i, Y + 195, Info.Item, Info.NeedCount);
|
||
|
|
//数量不足绘制遮盖图
|
||
|
|
if (Info.NeedCount > Info.RealCount) {
|
||
|
|
Rindro_Image_GlobalMap["lenheartui"].DrawExPng(257, X + 32 + 51 * i, Y + 196, 0, sq_RGBA(255, 255, 255, 120), 1.0, 1.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
local RealCountStr = Info.RealCount.tostring();
|
||
|
|
local Color = Info.RealCount >= Info.NeedCount ? sq_RGBA(52, 255, 50, 255) : sq_RGBA(255, 60, 47, 255);
|
||
|
|
L_sq_DrawCode(RealCountStr, X + 46 + (51 * i) - LenheartTextClass.GetStringLength(RealCountStr) / 2, Y + 232, Color, 0, 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!MaterialIsEnough) {
|
||
|
|
local str = "升级材料不足!";
|
||
|
|
L_sq_DrawCode(str, X + 148 - LenheartTextClass.GetStringLength(str) / 2, Y + 142, sq_RGBA(255, 60, 48, 255), 0, 1);
|
||
|
|
} else {
|
||
|
|
local str = Item.Name;
|
||
|
|
L_sq_DrawCode(str, X + 148 - LenheartTextClass.GetStringLength(str) / 2, Y + 142, GetRarityColor(Item.Rarity), 0, 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
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;
|
||
|
|
if (!Visible) return true;
|
||
|
|
else {
|
||
|
|
Item = FindItemPosByForeachInven(ItemAddress);
|
||
|
|
if (Item) {
|
||
|
|
local ItemObject = Rindro_Item();
|
||
|
|
ItemObject.LoadByAddress(Item.ItemAddress);
|
||
|
|
ItemSlot.SetItem(ItemObject);
|
||
|
|
|
||
|
|
SendPackEx({
|
||
|
|
op = 21010001,
|
||
|
|
item = Item
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//遍历背包查找Item
|
||
|
|
function FindItemPosByForeachInven(FindAddress) {
|
||
|
|
local Inven = L_sq_RA(0x1A5FB24);
|
||
|
|
local InvenAdd = L_sq_RA(Inven + 56);
|
||
|
|
InvenAdd += 36;
|
||
|
|
for (local z = 0; z< 1; z++) {
|
||
|
|
for (local i = 0; i< 48; i++) {
|
||
|
|
local ItemAdd = L_sq_RA(InvenAdd + ((i + (z * 48)) * 4));
|
||
|
|
if (ItemAdd == FindAddress) {
|
||
|
|
local NamePointer = L_sq_RA(FindAddress + 0x20);
|
||
|
|
if (z != 0) {
|
||
|
|
if (ItemInfoDrawS) {
|
||
|
|
L_Sq_CallFunc(0xE6B2B0, "int", FFI_THISCALL, ["int", "int", "int", "char"], 0x1ADE090, 0x113, 0xFFFFFFFF, 0x0);
|
||
|
|
ItemInfoDrawS = null;
|
||
|
|
ResetFocus();
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
local rRarity = L_sq_RA(FindAddress + 0xF4);
|
||
|
|
//不是异界装备
|
||
|
|
if (rRarity != 5) return;
|
||
|
|
return {
|
||
|
|
Type = z,
|
||
|
|
Pos = i,
|
||
|
|
Vis = false,
|
||
|
|
Count = MemoryTool.DecodeMemoryData(FindAddress + 0x1A4),
|
||
|
|
ItemId = L_sq_RA(FindAddress + 0x1c),
|
||
|
|
ItemAddress = FindAddress,
|
||
|
|
Name = NativePointer(L_sq_I2P(NamePointer)).readUnicodeString(),
|
||
|
|
Rarity = rRarity,
|
||
|
|
Level = L_sq_RA(FindAddress + 0x8)
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
//读取配置
|
||
|
|
function InifPvf() {
|
||
|
|
Rindro_Script.GetFileData("etc/rindro/itemtool/itemotherworldupgrade/itemotherworldupgrade.etc", function(DataTable, Data) {
|
||
|
|
while (!Data.Eof()) {
|
||
|
|
local Fragment = Data.Get();
|
||
|
|
if (Fragment == "[NPC]") {
|
||
|
|
NPCList = [];
|
||
|
|
while (true) {
|
||
|
|
local Fbuf = Data.Get();
|
||
|
|
if (Fbuf == "[/NPC]") {
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
NPCList.append(Fbuf);
|
||
|
|
}
|
||
|
|
} else if (Fragment == "[BASIC MATERIALS]") {
|
||
|
|
BasicMaterials = [];
|
||
|
|
while (true) {
|
||
|
|
local Fbuf = Data.Get();
|
||
|
|
if (Fbuf == "[/BASIC MATERIALS]") {
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
local T = {
|
||
|
|
Item = Fbuf,
|
||
|
|
Count = Data.Get()
|
||
|
|
}
|
||
|
|
BasicMaterials.push(T);
|
||
|
|
}
|
||
|
|
} else if (Fragment == "[LEVEL RATE]") {
|
||
|
|
LevelRate = Data.Get()
|
||
|
|
} else if (Fragment == "[RARITY RATE]") {
|
||
|
|
RarityRate = Data.Get()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function RegNpc() {
|
||
|
|
local EachManager = Lenheart_Get_EachObj();
|
||
|
|
foreach(id in NPCList) {
|
||
|
|
//先清空注册
|
||
|
|
EachManager.AddEachForNpc(id, 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;
|
||
|
|
ItemSlot.RemoveItem();
|
||
|
|
ErrorMsg = null;
|
||
|
|
MaterialInfo = null;
|
||
|
|
MaterialIsEnough = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
L_Windows_List <- [];
|
||
|
|
getroottable().rawdelete("LenheartPluginsInitFlag");
|
||
|
|
getroottable().rawdelete("EventList_Obj")
|
||
|
|
getroottable().rawdelete("ItemOtherWolrdUpgrade_Obj");
|
||
|
|
getroottable().rawdelete("L_Each_Obj");
|
||
|
|
|
||
|
|
|
||
|
|
function Lenheart_ItemOtherWolrdUpgrade_Fun(obj) {
|
||
|
|
local RootTab = getroottable();
|
||
|
|
if (!RootTab.rawin("ItemOtherWolrdUpgrade_Obj")) {
|
||
|
|
RootTab.rawset("ItemOtherWolrdUpgrade_Obj", true);
|
||
|
|
LenheartNewUI_CreateWindow(ItemOtherWolrdUpgradeC, "异界装备升级窗口", ((getroottable().Rindro_Scr_Width - 700) / 2).tointeger(), 160, 292, 290, 28);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
getroottable()["LenheartFuncTab"].rawset("ItemOtherWolrdUpgradeFuncN", Lenheart_ItemOtherWolrdUpgrade_Fun);
|