/* 文件名:Lenheart_Each_Class.nut 路径:Base/UI/Lenheart_Each_Class.nut 创建日期:2024-09-30 14:46 文件用途:交互界面类 */ class LenheartNewUI_Each_BaseButton extends LenheartNewUI_CommonUi { State = 0; BaseIdx = 29; DWidth = null; Path = null; Idx = null; SetFlag = null; SetIndex = null; Icon = null; IconIdx = null; Str = null; StrColor = sq_RGBA(189, 159, 126, 250); constructor(X, Y, W, H, Path, Idx) { this.DWidth = W; this.Path = Path; this.Idx = Idx; LenheartNewUI_CommonUi.constructor(X, Y, W, H); } function SetFrame(gPath, gIdx) { if (gPath) Path = gPath; Idx = gIdx; } function Show(obj) { //不可用 if (State == 8) { // L_sq_DrawImg(Path, Idx + 3, X, Y); } else { //按下 if (isLBDown) { L_sq_DrawImg(Path, Idx + 1, X, Y); if (Icon) L_sq_DrawImg(Icon, IconIdx, X + 3, Y + 2); if (Str) L_sq_DrawCode(Str, X + 60 - LenheartTextClass.GetStringLength(Str) / 2, Y + 5, StrColor, 0, 1); } //悬停 else if (isInRect) { L_sq_DrawImg(Path, Idx, X, Y); if (Icon) L_sq_DrawImg(Icon, IconIdx, X + 3, Y + 1); if (Str) L_sq_DrawCode(Str, X + 60 - LenheartTextClass.GetStringLength(Str) / 2, Y + 4, StrColor, 0, 1); } //普通 else { L_sq_DrawImg(Path, 0, X, Y); if (Icon) L_sq_DrawImg(Icon, IconIdx, X + 3, Y + 1); if (Str) L_sq_DrawCode(Str, X + 60 - LenheartTextClass.GetStringLength(Str) / 2, Y + 4, StrColor, 0, 1); } } } //鼠标左键弹起回调 function OnMouseLbUp(MousePos_X, MousePos_Y) { if (isLBDown && OnClick) { OnClick(this); } isLBDown = false; } } class Lenheart_EachC extends LenheartNewUI_Windows { //调试模式 // DeBugMode = true; //不是窗口 NoWindow = true; //是否可见 // Visible = false; Info = null; NPC_Index = null; NPC_Flag = false; NPC_ButtonMap = null; constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { Childrens = []; NPC_ButtonMap = {}; //注册控件 RegisterWidget(); LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); } function RegisterWidget() { } function Show(obj) { } function TopShow(obj) { if (NPC_Index) { SyncPos(); LenheartNewUI_Windows.Show(obj); } } function DrawMain(obj) { // if (Info) { // local NPC_Index = Rindro_BaseToolClass.GetEachNpcId(); // } } // function BottomShow() {} //初始化NPC按钮 function InitNpcButton() { Childrens = []; if (NPC_ButtonMap.rawin(NPC_Index)) { foreach(Func in NPC_ButtonMap[NPC_Index]) { Func(this); } } this.Visible = true; } function AddEachForNpc(Index, Func) { if (NPC_ButtonMap.rawin(Index)) { NPC_ButtonMap[Index].append(Func); return; } NPC_ButtonMap.rawset(Index, [Func]); } function RemoveEachForNpc(Index) { NPC_ButtonMap.rawdelete(Index); } //逻辑入口 function Proc(obj) { LenheartNewUI_Windows.SyncPos(X, Y); NPC_Index = Rindro_BaseToolClass.GetEachNpcId(); if (NPC_Index) { if (!NPC_Flag) { NPC_Flag = true; InitNpcButton(); } } else { NPC_Flag = false; } } function CloseAllEach() { local EachClassObject = L_sq_RA(0x1ADE0E0); if (EachClassObject) { local FristChildOffset = (EachClassObject + 0x68); for (local i = 0; i< 74; i++) { local AddressBuf = FristChildOffset + (4 * i); local ChildAddress = L_sq_RA(AddressBuf); if (ChildAddress) { local OpenFlag = L_sq_RA(ChildAddress + 0xC); if (OpenFlag = 257) L_sq_WA(ChildAddress + 0xC, 256); } } } } function Lenheart_Get_Each_Info() { local EachCount = 0; local Xpos = 0; local Ypos = 0; local EachClassObject = L_sq_RA(0x1ADE0E0); if (EachClassObject) { local FristChildOffset = (EachClassObject + 0x68); for (local i = 0; i< 74; i++) { local AddressBuf = FristChildOffset + (4 * i); local ChildAddress = L_sq_RA(AddressBuf); if (ChildAddress) { local OpenFlag = L_sq_RA(ChildAddress + 0xC); if (OpenFlag == 257) EachCount++; } //第0个的时候记录一下坐标 if (i == 0) { Xpos = L_sq_RA(ChildAddress + 0x14); Ypos = L_sq_RA(ChildAddress + 0x18); } } } return { Count = EachCount, X = Xpos, Y = Ypos }; } //override //鼠标左键弹起回调 function OnMouseLbUp(MousePos_X, MousePos_Y) { //调用原生方法 LenheartNewUI_Windows.OnMouseLbUp(MousePos_X, MousePos_Y); } function SyncPos() { //读取交互坐标数据 Info = Lenheart_Get_Each_Info(); X = Info.X; Y = Info.Y + (21 * Info.Count); //宽度 Width = 100; //高度 Height = (21 * Childrens.len()); //同步子对象坐标 foreach(pos, winobj in Childrens) { winobj.X = Info.X; winobj.Y = Info.Y + (21 * (Info.Count + pos)); } } } function Lenheart_Each_Fun(obj) { local RootTab = getroottable(); if (!RootTab.rawin("L_Each_Obj")) { RootTab.rawset("L_Each_Obj", LenheartNewUI_CreateWindow(Lenheart_EachC, "玩家与NPC交互界面窗口", 0, 0, 0, 0, 0)); } } getroottable()["LenheartFuncTab"].rawset("Lenheart_EachN", Lenheart_Each_Fun); class Lenheart_PlayerEachC extends LenheartNewUI_Windows { //调试模式 // DeBugMode = true; //不是窗口 NoWindow = true; //是否可见 // Visible = false; Info = null; Basic = null; //当前交互角色姓名 PlayerEach_Name = null; PlayerEach_Flag = false; PlayerEach_ButtonMap = null; //通用按钮 PlayerEach_CommonButtonMap = null; constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { Childrens = []; PlayerEach_ButtonMap = {}; PlayerEach_CommonButtonMap = {}; //注册控件 RegisterWidget(); LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); } function RegisterWidget() {} function Show(obj) {} function TopShow(obj) {} function DrawMain(obj) {} function MySelfShow() { if (PlayerEach_Name) { local obj = sq_getMyCharacter(); LenheartNewUI_Windows.Show(obj); } } //初始化NPC按钮 function InitNpcButton() { Childrens = []; if (PlayerEach_ButtonMap.rawin(PlayerEach_Name)) { foreach(Func in PlayerEach_ButtonMap[PlayerEach_Name]) { Func(this); } } foreach(Func in PlayerEach_CommonButtonMap) { Func(this); } this.Visible = true; } function AddEachForCommon(Index, Func) { PlayerEach_CommonButtonMap.rawset(Index, Func); } function RemoveEachForCommon(Index) { PlayerEach_CommonButtonMap.rawdelete(Index); } function AddEachForPlayerName(Index, Func) { if (PlayerEach_ButtonMap.rawin(Index)) { PlayerEach_ButtonMap[Index].append(Func); return; } PlayerEach_ButtonMap.rawset(Index, [Func]); } function RemoveEachForPlayerName(Index) { PlayerEach_ButtonMap.rawdelete(Index); } function CloseAllEach() { if (Basic) { L_sq_WA(L_sq_P2I(Basic) + 0xC, 256); } } //逻辑入口 function Proc(obj) { LenheartNewUI_Windows.SyncPos(X, Y); local Str = L_Sq_GetPlayerEachName(); if (Str.len() > 0) { PlayerEach_Name = Str; } if (PlayerEach_Name) { if (!PlayerEach_Flag) { PlayerEach_Flag = true; InitNpcButton(); } } else { PlayerEach_Flag = false; } } //override //鼠标左键弹起回调 function OnMouseLbUp(MousePos_X, MousePos_Y) { LenheartNewUI_Windows.OnMouseLbUp(MousePos_X, MousePos_Y); } function SelfSyncPos(gInfo) { //读取交互坐标数据 Info = gInfo; Basic = gInfo.BasicAdd; X = Info.X; Y = Info.Y + (21 * Info.Count); //宽度 Width = 100; //高度 Height = (21 * Childrens.len()); //同步子对象坐标 foreach(pos, winobj in Childrens) { winobj.X = Info.X; winobj.Y = Info.Y + (21 * (Info.Count + pos)); } } } RindroPlayerEachDrawFlag <- false; RindroPlayerEachDrawCountBuffer <- 0; RindroPlayerEachDrawCount <- 0; Rindro_Haker.LoadHook(0x10002A0, ["pointer", "int", "int"], function(args) { if (L_Sq_GetPlayerEachName().len() <= 0) return; local Xpos = L_sq_RA(L_sq_P2I(args[0]) + 0x14); local Ypos = L_sq_RA(L_sq_P2I(args[0]) + 0x18); if (!RindroPlayerEachDrawFlag) { local RootTab = getroottable(); RindroPlayerEachDrawFlag = true; if (RootTab.rawin("L_PlayerEach_Obj")) { RootTab["L_PlayerEach_Obj"].SelfSyncPos({ X = Xpos, Y = Ypos, Count = RindroPlayerEachDrawCount, BasicAdd = args[0] }); RootTab["L_PlayerEach_Obj"].MySelfShow(); } } RindroPlayerEachDrawCountBuffer++; // print(args[0]); return null; }, function(args) { return null; }); function Lenheart_PlayerEach_Fun(obj) { local RootTab = getroottable(); RindroPlayerEachDrawFlag = false; RindroPlayerEachDrawCount = RindroPlayerEachDrawCountBuffer; RindroPlayerEachDrawCountBuffer = 0; if (!RootTab.rawin("L_PlayerEach_Obj")) { RootTab.rawset("L_PlayerEach_Obj", LenheartNewUI_CreateWindow(Lenheart_PlayerEachC, "玩家与玩家交互界面窗口", 0, 0, 0, 0, 0)); } } getroottable()["LenheartFuncTab"].rawset("Lenheart_PlayerEachN", Lenheart_PlayerEach_Fun);