328 lines
10 KiB
Plaintext
328 lines
10 KiB
Plaintext
/*
|
||
文件名:ItemFusion.nut
|
||
路径:Project/ItemTool/ItemFusion/ItemFusion.nut
|
||
创建日期:2025-12-06 10:07
|
||
文件用途:
|
||
*/
|
||
|
||
class ItemFusionC_ItemSlot extends LenheartNewUI_CommonUi {
|
||
|
||
WindowImg = Rindro_Image("interface2/itemtoolwindow/itemfusion/itemfusion.img");
|
||
|
||
Item = null;
|
||
|
||
//覆写悬停Flag
|
||
HoverFlag = false;
|
||
|
||
//UseFlag
|
||
UseFlag = true;
|
||
|
||
constructor(X, Y) {
|
||
LenheartNewUI_CommonUi.constructor(X, Y, 46, 47);
|
||
}
|
||
|
||
|
||
function Show(obj) {
|
||
WindowImg.DrawPng(9, X, Y);
|
||
|
||
|
||
//如果槽里面有道具 绘制道具
|
||
if (Item) {
|
||
if (Item.rawin("itemAddress")) Parent.TemporaryDrawItemAddress = Item.itemAddress;
|
||
Parent.DrawItemBase(X + 9, Y + 10, Item.itemId, 1);
|
||
}
|
||
|
||
CheckInRect();
|
||
|
||
|
||
}
|
||
|
||
function CheckInRect() {
|
||
local MousePos_X = IMouse.GetXPos();
|
||
local MousePos_Y = IMouse.GetYPos();
|
||
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X + 9, Y + 10, 24, 24)) {
|
||
//绘制悬停框
|
||
L_sq_SetDrawImgModel(2, 0);
|
||
Rindro_Image_GlobalMap["lenheartui"].DrawPng(353, X + 8, Y + 8);
|
||
L_sq_ReleaseDrawImgModel();
|
||
HoverFlag = true;
|
||
} else HoverFlag = false;
|
||
}
|
||
|
||
//override
|
||
function OnMouseProc(Flag, MousePos_X, MousePos_Y) {
|
||
if (!Visible) return;
|
||
//调用原生方法
|
||
LenheartNewUI_CommonUi.OnMouseProc(Flag, MousePos_X, MousePos_Y);
|
||
}
|
||
|
||
function DiscardItem(info) {
|
||
if (HoverFlag) {
|
||
if (info) {
|
||
Item = info;
|
||
|
||
}
|
||
return true;
|
||
}
|
||
}
|
||
|
||
|
||
//鼠标右键按下回调
|
||
function OnMouseRbDown(MousePos_X, MousePos_Y) {
|
||
if (!UseFlag) return;
|
||
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X + 9, Y + 10, 24, 24)) {
|
||
Item = null;
|
||
if (Parent.ItemInfoDrawS) {
|
||
L_Sq_CallFunc(0xE6B2B0, "int", FFI_THISCALL, ["int", "int", "int", "char"], 0x1ADE090, 0x113, 0xFFFFFFFF, 0x0);
|
||
Parent.ItemInfoDrawS = null;
|
||
Parent.ResetFocus();
|
||
}
|
||
if (Parent.Slot[2].Item != null) {
|
||
Parent.Msg = 0;
|
||
Parent.Slot[2].Item = null;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
class ItemFusionC extends LenheartNewUI_Windows {
|
||
//调试模式
|
||
// DeBugMode = true;
|
||
|
||
//不是窗口
|
||
// NoWindow = true;
|
||
|
||
//是否可见
|
||
// Visible = false;
|
||
|
||
Slot = null;
|
||
|
||
//Ani任务队列
|
||
AniQueue = null;
|
||
//动画播放Flag
|
||
AniFlag = false;
|
||
SoundFlag = false;
|
||
|
||
|
||
Msg = 0;
|
||
|
||
WindowImg = Rindro_Image("interface2/itemtoolwindow/itemfusion/itemfusion.img");
|
||
|
||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||
Childrens = [];
|
||
AniQueue = QuestQueue();
|
||
//注册控件
|
||
RegisterWidget();
|
||
|
||
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||
|
||
DiscardItemCallBackFunc.rawset("RecoveryC", DiscardItem.bindenv(this));
|
||
|
||
Pack_Control.rawset(21006002, function(Chunk) {
|
||
local Jso = Json.Decode(Chunk);
|
||
Msg = Jso.msg;
|
||
if (Jso.rawin("value")) {
|
||
Slot[2].Item = {
|
||
itemId = Jso.value[0]
|
||
}
|
||
}
|
||
}.bindenv(this));
|
||
|
||
Pack_Control.rawset(21006004, function(Chunk) {
|
||
local Jso = Json.Decode(Chunk);
|
||
if (Jso.rawin("error")) {
|
||
foreach(value in Slot) {
|
||
value.Item = null;
|
||
}
|
||
Msg = 0;
|
||
} else {
|
||
AniQueue.AddQuest("装备融合特效动画", function(Name, Time) {
|
||
local AniPath = "etc/rindro/itemtool/itemfusion/itemfusioneffect.ani";
|
||
local Ani = DrawAniEx(X + 8, Y + 120, AniPath, "装备融合特效1");
|
||
if (sq_GetAnimationFrameIndex(Ani) == 10 && !SoundFlag) {
|
||
R_Utils.PlaySound("RANK_UP");
|
||
SoundFlag = true;
|
||
}
|
||
if (sq_GetAnimationFrameIndex(Ani) == 40) {
|
||
sq_Rewind(Ani);
|
||
AniQueue.RemoveQuest(Name);
|
||
foreach(value in Slot) {
|
||
value.Item = null;
|
||
}
|
||
Msg = 0;
|
||
SoundFlag = false;
|
||
}
|
||
}.bindenv(this));
|
||
}
|
||
}.bindenv(this));
|
||
}
|
||
|
||
function RegisterWidget() {
|
||
//关闭按钮
|
||
local CloseButton = LenheartNewUI_BaseButton(228, 5, 11, 12, "interface/lenheartwindowcommon.img", 276);
|
||
CloseButton.OnClick = function() {
|
||
this.Visible = false;
|
||
}.bindenv(this);
|
||
Childrens.append(CloseButton);
|
||
|
||
//确认按钮
|
||
local ConfirmButton = LenheartNewUI_ButtonText(85, 250, 15, "确认融合");
|
||
ConfirmButton.DWidth = 18;
|
||
ConfirmButton.Width = 74;
|
||
ConfirmButton.SetTextOffset(-4, 1);
|
||
ConfirmButton.OnClickEx = function(Btn) {
|
||
if (!Btn.Visible) return;
|
||
local T = {
|
||
op = 21006003,
|
||
}
|
||
SendPackEx(T);
|
||
}.bindenv(this);
|
||
ConfirmButton.SetCallBackFunc(function(Btn) {
|
||
// if (mode >= 1 && mode< 3) {
|
||
// Btn.Visible = true;
|
||
// } else {
|
||
// Btn.Visible = false;
|
||
// }
|
||
}.bindenv(this));
|
||
AddChild(ConfirmButton);
|
||
|
||
//创建槽
|
||
Slot = [ItemFusionC_ItemSlot(49, 58), ItemFusionC_ItemSlot(150, 58), ItemFusionC_ItemSlot(99, 182)];
|
||
foreach(value in Slot) {
|
||
AddChild(value);
|
||
}
|
||
Slot[2].UseFlag = false;
|
||
}
|
||
|
||
//绘制主界面
|
||
function DrawMain(obj) {
|
||
|
||
//背景框
|
||
DrawNineBox(X, Y, 244, 294, "interface/lenheartwindowcommon.img", 213);
|
||
|
||
DrawWindowTitle(247);
|
||
//绘制标题名
|
||
L_sq_DrawCode("装备融合", X + 100, Y + 6, sq_RGBA(230, 200, 155, 255), 0, 1);
|
||
|
||
DrawNineBox(X + 5, Y + 27, 235, 260, "interface/lenheartwindowcommon.img", 97);
|
||
|
||
local SlotEnableCount = 0;
|
||
for (local i = 0; i< 2; i++) {
|
||
local value = Slot[i];
|
||
if (value.Item != null) SlotEnableCount++;
|
||
}
|
||
WindowImg.DrawPng(0 + SlotEnableCount, X + 8, Y + 30);
|
||
WindowImg.DrawPng(3, X + 8, Y + 32);
|
||
WindowImg.DrawPng(8, X + 112, Y + 70);
|
||
|
||
if (Msg == 2 && Slot[1].Item != null && Slot[0].Item != null) {
|
||
WindowImg.DrawPng(7, X + 5, Y + 240);
|
||
L_sq_DrawCode("不是可以融合的装备!", X + 72, Y + 246, sq_RGBA(255, 255, 255, 255), 0, 1);
|
||
}
|
||
|
||
// local Co = [
|
||
// 0xFFFF64A0, // 起始色: (160,100,255,255)
|
||
// 0xFFEB6EAA, // 过渡色1
|
||
// 0xFFDB78B4, // 过渡色2
|
||
// 0xFFDB82BE, // 过渡色3
|
||
// 0xFFAF8CC8, // 过渡色4
|
||
// 0xFF9B96D2, // 过渡色5
|
||
// 0xFF8BDCDC, // 过渡色6(修正格式:0xFF8BDCDC)
|
||
// 0xFF7BB4E6, // 过渡色7
|
||
// 0xFF6FBEE0, // 过渡色8
|
||
// 0xFF4BC8FA, // 过渡色9(修正格式:0xFF4BC8FA)
|
||
// 0xFF37D2F4, // 过渡色10
|
||
// 0xFF00B1FF // 结束色: (255,177,0,255)
|
||
// ];
|
||
// DrawText("测试文本", X + 30, Y + 40, Co);
|
||
}
|
||
|
||
// function DrawText(Str, XPos, YPos, Color) {
|
||
// if (typeof Color == "array") {
|
||
// for (local i = 0; i< 12; i++) {
|
||
// local clipBottom = YPos + (13 - i);
|
||
// setClip(0, YPos - 1, getroottable().Rindro_Scr_Width, clipBottom); //开始裁切
|
||
// L_sq_DrawCode(Str, XPos, YPos, Color[i], 0, 1);
|
||
// releaseClip(); //裁切结束
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
function Show(obj) {
|
||
DrawMain(obj);
|
||
LenheartNewUI_Windows.Show(obj);
|
||
AniQueue.Run();
|
||
}
|
||
|
||
//逻辑入口
|
||
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 {
|
||
local info = FindItemPosByForeachInven(ItemAddress);
|
||
for (local i = 0; i< 2; i++) {
|
||
local Value = Slot[i];
|
||
local Ret = Value.DiscardItem(info);
|
||
if (Ret) {
|
||
R_Utils.PlaySound("CHANGE_ALERT");
|
||
if (Slot[0].Item && Slot[1].Item) {
|
||
local T = {
|
||
op = 21006001,
|
||
item1 = Slot[0].Item,
|
||
item2 = Slot[1].Item,
|
||
}
|
||
SendPackEx(T);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//遍历背包查找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),
|
||
itemAddress = FindAddress
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
}
|
||
|
||
L_Windows_List <- [];
|
||
getroottable().rawdelete("LenheartPluginsInitFlag");
|
||
getroottable().rawdelete("EventList_Obj")
|
||
getroottable().rawdelete("ItemFusion_Obj");
|
||
|
||
function Lenheart_ItemFusion_Fun(obj) {
|
||
local RootTab = getroottable();
|
||
if (!RootTab.rawin("ItemFusion_Obj")) {
|
||
RootTab.rawset("ItemFusion_Obj", true);
|
||
LenheartNewUI_CreateWindow(ItemFusionC, "装备改造-融合装备", 100, 120, 246, 292, 24);
|
||
}
|
||
}
|
||
|
||
getroottable()["LenheartFuncTab"].rawset("ItemFusionFuncN", Lenheart_ItemFusion_Fun); |