350 lines
11 KiB
Plaintext
350 lines
11 KiB
Plaintext
/*
|
|
文件名:Recovery.nut
|
|
路径:Project/Recovery/Recovery.nut
|
|
创建日期:2024-11-17 06:16
|
|
文件用途:回收系统
|
|
*/
|
|
// class RecoveryMaskC extends LenheartNewUI_Windows {
|
|
|
|
// //信息
|
|
// Info = null;
|
|
// //调试模式
|
|
// DeBugMode = true;
|
|
|
|
// constructor(ginfo) {
|
|
// Childrens = [];
|
|
// Info = ginfo;
|
|
|
|
// LenheartNewUI_Windows.constructor(Clock() + "+" + Info.type + Info.pos, 0, 0, 0, 0, 0);
|
|
// }
|
|
|
|
// function Show(obj) {
|
|
// LenheartNewUI_Windows.Show(obj);
|
|
// }
|
|
|
|
// //逻辑入口
|
|
// function Proc(obj) {
|
|
// local Window = sq_GetPopupWindowMainCotrol(64);
|
|
// if (Window) {
|
|
// X = Window.GetXPos() + ((Info.pos % 8) * 30);
|
|
// Y = Window.GetYPos() + 206 + ((Info.pos / 8) * 30);
|
|
// }
|
|
// LenheartNewUI_Windows.SyncPos(X, Y);
|
|
// }
|
|
// }
|
|
class RecoveryC extends LenheartNewUI_Windows {
|
|
|
|
//包头
|
|
Op = 20085000;
|
|
|
|
//调试模式
|
|
// DeBugMode = true;
|
|
|
|
//不是窗口
|
|
// NoWindow = true;
|
|
|
|
//是否可见
|
|
Visible = false;
|
|
|
|
//待回收列表
|
|
RecoveryList = null;
|
|
//待回收绘制列表
|
|
RecoveryDrawList = null;
|
|
|
|
//回收奖励列表
|
|
RecoveryRewardList = null;
|
|
|
|
//当前绘制对象
|
|
DrawItemCurObject = null;
|
|
|
|
//时间对象
|
|
Timer = null;
|
|
|
|
|
|
Img = Rindro_Image("recovery/main.img");
|
|
LenheartUI = Rindro_Image("interface/lenheartwindowcommon.img");
|
|
|
|
//获取配置包
|
|
function GetBaseConfig() {
|
|
local T = {
|
|
op = Op + 1
|
|
}
|
|
SendPackEx(T);
|
|
}
|
|
//配置包
|
|
function BaseConfig(Chunk) {
|
|
local Jso = Json.Decode(Chunk);
|
|
//注册NPC功能
|
|
RegisterNpc(Jso.npc_id);
|
|
}
|
|
|
|
function RefreshRecoveryItemListCallBack(Chunk) {
|
|
local Jso = Json.Decode(Chunk);
|
|
RecoveryRewardList = Jso.reward;
|
|
}
|
|
|
|
//遍历背包查找Item
|
|
function FindItemPosByForeachInven(FindAddress) {
|
|
local Inven = L_sq_RA(0x1A5FB24);
|
|
local InvenAdd = L_sq_RA(Inven + 56);
|
|
InvenAdd += 36;
|
|
for (local z = 0; z< 5; z++) {
|
|
for (local i = 0; i< 48; i++) {
|
|
local ItemAdd = L_sq_RA(InvenAdd + ((i + (z * 48)) * 4));
|
|
if (ItemAdd == FindAddress) return {
|
|
type = z,
|
|
pos = i,
|
|
vis = false,
|
|
count = MemoryTool.DecodeMemoryData(FindAddress + 0x1A4),
|
|
itemId = L_sq_RA(FindAddress + 0x1c)
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
|
Childrens = [];
|
|
RecoveryList = {};
|
|
RecoveryDrawList = [];
|
|
Timer = Clock();
|
|
// RecoveryList.rawset(0x3EA5B400, {});
|
|
//注册控件
|
|
RegisterWidget();
|
|
|
|
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
|
|
|
Pack_Control.rawset(Op + 2, BaseConfig.bindenv(this));
|
|
Pack_Control.rawset(Op + 4, RefreshRecoveryItemListCallBack.bindenv(this));
|
|
DiscardItemCallBackFunc.rawset("RecoveryC", DiscardItem.bindenv(this));
|
|
GetBaseConfig();
|
|
|
|
// local Ret = L_sq_GetWindowById(64);
|
|
// print(Ret);
|
|
}
|
|
|
|
//刷新回收道具列表包
|
|
function RefreshRecoveryItemList() {
|
|
local Arr = [];
|
|
foreach(obj in RecoveryList) {
|
|
Arr.append(obj);
|
|
}
|
|
local T = {
|
|
op = Op + 3
|
|
}
|
|
if (Arr.len() > 0) T.list <- Arr;
|
|
SendPackEx(T);
|
|
}
|
|
|
|
//回收道具回调
|
|
function DiscardItem(ItemAddress) {
|
|
if (!Visible) return true;
|
|
else {
|
|
local info = FindItemPosByForeachInven(ItemAddress);
|
|
if (info) {
|
|
if (!(RecoveryList.rawin(ItemAddress)) && RecoveryList.len()< 60) {
|
|
//绘制列表
|
|
RecoveryDrawList.append(ItemAddress);
|
|
// info.Mask <- RecoveryMaskC(info);
|
|
// AddChild(info.Mask);
|
|
RecoveryList.rawset(ItemAddress, info);
|
|
}
|
|
}
|
|
RefreshRecoveryItemList();
|
|
}
|
|
}
|
|
//移除绘制道具列表中指定Item
|
|
function RemoveDrawItem(ItemAddress) {
|
|
for (local i = 0; i< RecoveryDrawList.len(); i++) {
|
|
if (RecoveryDrawList[i] == ItemAddress) {
|
|
RecoveryDrawList.remove(i);
|
|
break;
|
|
}
|
|
}
|
|
if (RecoveryList.rawin(ItemAddress)) {
|
|
RecoveryList.rawdelete(DrawItemCurObject);
|
|
}
|
|
RefreshRecoveryItemList();
|
|
}
|
|
|
|
function RegisterNpc(id) {
|
|
local EachManager = getroottable()["L_Each_Obj"];
|
|
//先清空注册
|
|
EachManager.RemoveEachForNpc(id);
|
|
|
|
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 = 27;
|
|
ApplyEngagementButton.Str = "回收";
|
|
ApplyEngagementButton.OnClick = function(Button) {
|
|
//打开背包
|
|
L_sq_Open_ExWindow(0x1ADE090, 0, 0, 1);
|
|
Button.Parent.CloseAllEach();
|
|
Button.Parent.CloseWindow();
|
|
Visible = true;
|
|
RecoveryList = {};
|
|
RecoveryDrawList = [];
|
|
RecoveryRewardList = null;
|
|
ResetFocus();
|
|
}.bindenv(this);
|
|
ApplyEngagementButton.SetCallBackFunc(function(Button) {})
|
|
SThis.AddChild(ApplyEngagementButton);
|
|
}.bindenv(this));
|
|
|
|
}
|
|
|
|
function RegisterWidget() {
|
|
// //关闭按钮
|
|
// local CloseButton = LenheartNewUI_BaseButton(278, 0, 11, 12, "interface/lenheartwindowcommon.img", 276);
|
|
// CloseButton.OnClick = function() {
|
|
// this.Visible = false;
|
|
// }.bindenv(this);
|
|
// Childrens.append(CloseButton);
|
|
local CloseButton = LenheartNewUI_ButtonText(100, 381, 5, "确认");
|
|
CloseButton.SetTextOffset(0, 1);
|
|
CloseButton.OnClick = function() {
|
|
if (RecoveryList.len() <= 0) return;
|
|
local T = {
|
|
op = Op + 5
|
|
}
|
|
SendPackEx(T);
|
|
RecoveryList = {};
|
|
RecoveryDrawList = [];
|
|
RecoveryRewardList = null;
|
|
}.bindenv(this);
|
|
AddChild(CloseButton);
|
|
|
|
local CloseButton = LenheartNewUI_ButtonText(240, 381, 5, "取消");
|
|
CloseButton.SetTextOffset(0, 1);
|
|
CloseButton.OnClick = function() {
|
|
this.Visible = false;
|
|
RecoveryList = {};
|
|
RecoveryDrawList = [];
|
|
}.bindenv(this);
|
|
AddChild(CloseButton);
|
|
}
|
|
|
|
//绘制主界面
|
|
function DrawMain(obj) {
|
|
|
|
//Item信息框一般为211的宽度
|
|
L_sq_DrawWindow(X - 5, Y + 14, 400, 356, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13);
|
|
Img.DrawExPng(0, X + 0, Y + 0, 0, sq_RGBA(255, 255, 255, 250), 0.92, 0.92);
|
|
//标题栏
|
|
L_sq_DrawButton(X - 5, Y, 405, "interface/lenheartwindowcommon.img", 609, 2, 7);
|
|
LenheartUI.DrawExPng(425, X + 191, Y + 221, 0, sq_RGBA(255, 255, 255, 250), 0.92, 0.92);
|
|
|
|
foreach(Pos, Object in RecoveryDrawList) {
|
|
local Info = RecoveryList[Object];
|
|
DrawItemCur(Object, Info, X + 13 + ((Pos % 12) * 32), Y + 42 + ((Pos / 12) * 34));
|
|
}
|
|
if (RecoveryRewardList) {
|
|
local drawpos = 0;
|
|
foreach(Index, Count in RecoveryRewardList) {
|
|
DrawItemEx(X + 13 + ((drawpos % 12) * 32), Y + 250 + ((drawpos / 12) * 34), Index.tointeger(), Count);
|
|
drawpos++;
|
|
}
|
|
}
|
|
}
|
|
|
|
//绘制项目
|
|
function DrawItemCur(Object, Info, XPos, Ypos) {
|
|
local Id = L_sq_RA(Object + 0x1C);
|
|
local Rarity = L_sq_RA(Object + 0xF4);
|
|
L_sq_DrawImg("interface2/rindro_reward.img", Rarity, XPos - 3, Ypos - 3);
|
|
L_Sq_DrawItem(XPos, Ypos, Id, Info.count, 0, 0, 0);
|
|
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, XPos, Ypos, 24, 24)) {
|
|
//打开道具信息窗口
|
|
if (!Info.vis) {
|
|
//手动解锁道具信息窗口
|
|
Sq_Memory_WriteByteArr(L_sq_I2P(0xF63DDA), [0x56, 0xE8, 0x10, 0xFE, 0xFF, 0xFF]);
|
|
local ItemDrawInfo = L_Sq_CallFunc(0xE6E070, "int", FFI_THISCALL, ["int", "int", "int", "int"], L_sq_RA(0x1A5FB20), 275, Object, 41);
|
|
//校准道具信息窗口位置
|
|
L_Sq_CallFunc(0xF3B3B0, "int", FFI_THISCALL, ["int", "int", "int", "int", "int"], ItemDrawInfo, IMouse.GetXPos(), IMouse.GetYPos(), 24, 24);
|
|
Info.vis = true;
|
|
//我自己UI打开的道具信息窗口需要把渲染队列改为下层 以显示我打开的道具
|
|
getroottable().WindowsShowABFlag <- false;
|
|
DrawItemCurObject = Object;
|
|
}
|
|
} else {
|
|
if (Info.vis) {
|
|
//关闭道具信息窗口
|
|
L_Sq_CallFunc(0xE6B2B0, "int", FFI_THISCALL, ["int", "int", "int", "char"], 0x1ADE090, 0x113, 0xFFFFFFFF, 0x0);
|
|
Info.vis = false;
|
|
DrawItemCurObject = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
//override
|
|
//鼠标右键按下回调
|
|
function OnMouseRbDown(MousePos_X, MousePos_Y) {
|
|
if (DrawItemCurObject) {
|
|
if (RecoveryList.rawin(DrawItemCurObject)) {
|
|
local Info = RecoveryList[DrawItemCurObject];
|
|
if (Info.vis) {
|
|
//关闭道具信息窗口
|
|
L_Sq_CallFunc(0xE6B2B0, "int", FFI_THISCALL, ["int", "int", "int", "char"], 0x1ADE090, 0x113, 0xFFFFFFFF, 0x0);
|
|
Info.vis = false;
|
|
RemoveDrawItem(DrawItemCurObject);
|
|
DrawItemCurObject = null;
|
|
}
|
|
}
|
|
}
|
|
//调用原生方法
|
|
LenheartNewUI_Windows.OnMouseLbDown(MousePos_X, MousePos_Y);
|
|
}
|
|
|
|
function Show(obj) {
|
|
DrawMain(obj);
|
|
LenheartNewUI_Windows.Show(obj);
|
|
}
|
|
|
|
//逻辑入口
|
|
function Proc(obj) {
|
|
// //接管鼠标设定逻辑
|
|
// if (Visible) {
|
|
// _Rindro_Cusor_.TakeoverFlag = true;
|
|
// } else {
|
|
// _Rindro_Cusor_.TakeoverFlag = false;
|
|
// }
|
|
|
|
|
|
//同步位移窗口逻辑
|
|
local Window = sq_GetPopupWindowMainCotrol(64);
|
|
if (Window) {
|
|
X = Window.GetXPos() - 430;
|
|
Y = Window.GetYPos() + 60;
|
|
}
|
|
|
|
//悬停已回收锁定逻辑
|
|
local SelectItem = L_sq_RA(0x1AE45B4);
|
|
if (SelectItem) {
|
|
if (RecoveryList.rawin(SelectItem)) {
|
|
R_Mouse.Lock();
|
|
_Rindro_Cusor_.ForceLockState = true;
|
|
} else {
|
|
_Rindro_Cusor_.ForceLockState = false;
|
|
}
|
|
} else {
|
|
_Rindro_Cusor_.ForceLockState = false;
|
|
}
|
|
|
|
|
|
LenheartNewUI_Windows.SyncPos(X, Y);
|
|
}
|
|
|
|
}
|
|
getroottable().rawdelete("Recovery_Obj");
|
|
|
|
function Lenheart_Recovery_Fun(obj) {
|
|
local RootTab = getroottable();
|
|
if (!RootTab.rawin("Recovery_Obj")) {
|
|
RootTab.rawset("Recovery_Obj", true);
|
|
LenheartNewUI_CreateWindow(RecoveryC, "回收系统窗口", 43, 128, 420, 412, 0);
|
|
}
|
|
}
|
|
|
|
getroottable()["LenheartFuncTab"].rawset("RecoveryFuncN", Lenheart_Recovery_Fun); |