Rindro-Sqr/Base/UI/Lenheart_Each_Class.nut

244 lines
6.3 KiB
Plaintext
Raw Normal View History

2024-10-01 10:12:27 +08:00
/*
文件名: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)) {
NPC_ButtonMap[NPC_Index](this);
}
this.Visible = true;
}
function AddEachForNpc(Index, Func) {
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(winobj in Childrens) {
// winobj.X = Info.X;
// winobj.Y = Info.Y + (21 * Info.Count);
// }
}
}
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);
// Rindro_Haker.LoadHook(0x10041D0, ["int", "int", "int"],
// function(args) {
// if (getroottable().rawin("L_Each_Obj")) {
// getroottable()["L_Each_Obj"].BottomShow();
// }
// return null;
// },
// function(args) {
// return null;
// });