1142 lines
33 KiB
Plaintext
1142 lines
33 KiB
Plaintext
/*
|
|
文件名:Lenheart_UI_Class.nut
|
|
路径:Base/UI/Lenheart_UI_Class.nut
|
|
创建日期:2024-08-06 18:56
|
|
文件用途:UI
|
|
*/
|
|
|
|
//新窗口队列
|
|
L_Windows_List <- [];
|
|
//渲染窗口的默认层在下层 即A层
|
|
WindowsShowABFlag <- false;
|
|
//左键单击过的Flag 因为要模拟左键单击还原鼠标状态如果存在这个Flag将不响应鼠标消息一次
|
|
Rindro_MouseClickFlag <- false;
|
|
|
|
|
|
//鼠标类
|
|
class R_Mouse {
|
|
//是否锁定鼠标
|
|
function IsLock() {
|
|
return L_sq_RAB(0x1B46886);
|
|
}
|
|
//锁定鼠标
|
|
function Lock() {
|
|
_Rindro_Cusor_.UseState = 1;
|
|
L_sq_WAB(0x1B46886, 1);
|
|
//技能描述窗口
|
|
Sq_Memory_WriteByteArr(L_sq_I2P(0x4CC47E), [0xE9, 0xA0, 0x00, 0x00, 0x00, 0x90]);
|
|
//物品描述窗口
|
|
Sq_Memory_WriteByteArr(L_sq_I2P(0xF63DDA), [0x90, 0x90, 0x90, 0x90, 0x90, 0x90]);
|
|
//buff信息描述窗口
|
|
Sq_Memory_WriteByteArr(L_sq_I2P(0x4BF532), [0x90, 0x90, 0x90, 0x90]);
|
|
//原生商城 个人信息等按钮的悬停
|
|
L_sq_WAB(0x4C4690, 0xC3);
|
|
//活动图标的悬停
|
|
L_sq_WAB(0x11C6510, 0xC3);
|
|
}
|
|
//解锁鼠标
|
|
function UnLock() {
|
|
_Rindro_Cusor_.UseState = 0;
|
|
L_sq_WAB(0x1B46886, 0);
|
|
Sq_Memory_WriteByteArr(L_sq_I2P(0x4CC47E), [0x39, 0x05, 0xE0, 0xF6, 0xA3, 0x01]);
|
|
Sq_Memory_WriteByteArr(L_sq_I2P(0xF63DDA), [0x56, 0xE8, 0x10, 0xFE, 0xFF, 0xFF]);
|
|
Sq_Memory_WriteByteArr(L_sq_I2P(0x4BF532), [0x75, 0x07, 0x32, 0xC0]);
|
|
L_sq_WAB(0x4C4690, 0x55);
|
|
L_sq_WAB(0x11C6510, 0x55);
|
|
}
|
|
//获取鼠标工作类型
|
|
function GetType() {
|
|
return _Rindro_Cusor_.TypeState;
|
|
// return L_sq_RAB(0x1b46898);
|
|
}
|
|
//设置鼠标工作类型
|
|
function SetType(Type) {
|
|
_Rindro_Cusor_.TypeState = Type;
|
|
// L_sq_WAB(0x1b46898, Type);
|
|
}
|
|
//鼠标0状态下是否按下
|
|
function GetBaseState() {
|
|
return _Rindro_Cusor_.SubState;
|
|
// return L_sq_RAB(0x1B46874);
|
|
}
|
|
//鼠标0状态设置是否按下
|
|
function SetBaseState(Flag) {
|
|
_Rindro_Cusor_.SubState = Flag;
|
|
// return L_sq_WAB(0x1B46874, Flag);
|
|
}
|
|
|
|
//还原鼠标
|
|
function Restore() {
|
|
//这里判断是否有锁定鼠标 如果有就解锁
|
|
if (R_Mouse.IsLock()) R_Mouse.UnLock();
|
|
//如果鼠标工作类型不是0则设置为0
|
|
if (R_Mouse.GetType() != 0) R_Mouse.SetType(0);
|
|
//如果鼠标是按下状态则设置为未按下
|
|
if (R_Mouse.GetBaseState() != 0) R_Mouse.SetBaseState(0);
|
|
}
|
|
}
|
|
//基础窗口类 所有UI类继承与本类
|
|
class LenheartNewUI_BaseWindow extends Rindro_BaseToolClass {
|
|
//父控件
|
|
Parent = null;
|
|
//子控件
|
|
Childrens = null;
|
|
//回调事件
|
|
CallBackFunc = null;
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
//鼠标事件回调
|
|
function OnMouseProc(Flag, MousePos_X, MousePos_Y) {
|
|
foreach(Window in Childrens) {
|
|
Window.OnMouseProc(Flag, MousePos_X, MousePos_Y);
|
|
}
|
|
}
|
|
//鼠标左键按下回调
|
|
function OnMouseLbDown(MousePos_X, MousePos_Y) {
|
|
foreach(Window in Childrens) {
|
|
Window.OnMouseLbDown(MousePos_X, MousePos_Y);
|
|
}
|
|
}
|
|
//鼠标左键弹起回调
|
|
function OnMouseLbUp(MousePos_X, MousePos_Y) {
|
|
foreach(Window in Childrens) {
|
|
Window.OnMouseLbUp(MousePos_X, MousePos_Y);
|
|
}
|
|
}
|
|
//鼠标右键按下回调
|
|
function OnMouseRbDown(MousePos_X, MousePos_Y) {
|
|
foreach(Window in Childrens) {
|
|
Window.OnMouseRbDown(MousePos_X, MousePos_Y);
|
|
}
|
|
}
|
|
//鼠标右键弹起回调
|
|
function OnMouseRbUp(MousePos_X, MousePos_Y) {
|
|
foreach(Window in Childrens) {
|
|
Window.OnMouseRbUp(MousePos_X, MousePos_Y);
|
|
}
|
|
}
|
|
//鼠标滚轮时间回调
|
|
function OnMouseWheel(Flag, MousePos_X, MousePos_Y) {
|
|
foreach(Window in Childrens) {
|
|
Window.OnMouseWheel(Flag, MousePos_X, MousePos_Y);
|
|
}
|
|
}
|
|
//设置回调事件
|
|
function SetCallBackFunc(Func) {
|
|
CallBackFunc = Func;
|
|
}
|
|
//显示
|
|
function Show(obj) {
|
|
foreach(Window in Childrens) {
|
|
if (Window.CallBackFunc) Window.CallBackFunc(Window);
|
|
if (!Window.rawin("Visible")) print(Window.ObjectId + " 显示失败");
|
|
if (Window.Visible) {
|
|
Window.Show(obj);
|
|
Window.TopShow(obj);
|
|
}
|
|
}
|
|
}
|
|
//同步坐标
|
|
function SyncPos(X, Y) {
|
|
foreach(Window in Childrens) {
|
|
Window.SyncPos(X, Y);
|
|
}
|
|
}
|
|
}
|
|
|
|
//游戏窗口类
|
|
class LenheartNewUI_Windows extends LenheartNewUI_BaseWindow {
|
|
//窗口名称
|
|
ObjectId = null;
|
|
//可用性
|
|
Visible = true;
|
|
//宽度
|
|
Width = null;
|
|
//高度
|
|
Height = null;
|
|
//标题高度
|
|
TitleH = null;
|
|
|
|
//调试模式
|
|
DeBugMode = false;
|
|
|
|
//X坐标
|
|
X = null;
|
|
B_X = null;
|
|
//Y坐标
|
|
Y = null;
|
|
B_Y = null;
|
|
|
|
M_Xpos = null;
|
|
M_Ypos = null;
|
|
//移动Flag
|
|
MoveFlag = false;
|
|
|
|
//时间片段
|
|
Duration = 0.0;
|
|
DurationFlag = 0.0;
|
|
|
|
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
|
ObjectId = gObjectId;
|
|
//宽度
|
|
Width = gWidth;
|
|
//高度
|
|
Height = gHeight;
|
|
//标题高度
|
|
TitleH = gTitleH;
|
|
|
|
//X坐标
|
|
X = gX;
|
|
//Y坐标
|
|
Y = gY;
|
|
|
|
ResetFocus();
|
|
|
|
//调用原生方法
|
|
LenheartNewUI_BaseWindow.constructor();
|
|
}
|
|
|
|
//切换到最上层窗口 即得到焦点时
|
|
function ResetFocus() {
|
|
//遍历全局窗口数组将自己移除重新添加在末尾
|
|
foreach(Index, WindowObj in L_Windows_List) {
|
|
if (WindowObj.ObjectId == this.ObjectId) L_Windows_List.remove(Index);
|
|
}
|
|
L_Windows_List.append(this);
|
|
//切换上层显示
|
|
getroottable().WindowsShowABFlag <- true;
|
|
}
|
|
|
|
/*
|
|
* @函数作用: 移除子对象
|
|
* @参数 子对象名称
|
|
*/
|
|
function RemoveChild(ChildName) {
|
|
foreach(_Index, _Child in Childrens) {
|
|
if (_Child.ObjectId == ChildName) {
|
|
Childrens.remove(_Index);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
* @函数作用: 移除子对象类
|
|
* @参数 类 如果传入第二个参数false 则移除所有非该类的子对象
|
|
* @返回值
|
|
*/
|
|
function RemoveChilds(ClassName, ...) {
|
|
local RemoveIndexArr = [];
|
|
if (vargc == 1 && vargv[0] == false) {
|
|
foreach(_Index, _Child in Childrens) {
|
|
if (!(_Child instanceof ClassName)) {
|
|
RemoveIndexArr.append(_Index - RemoveIndexArr.len());
|
|
}
|
|
}
|
|
} else {
|
|
foreach(_Index, _Child in Childrens) {
|
|
if (_Child instanceof ClassName) {
|
|
RemoveIndexArr.append(_Index - RemoveIndexArr.len());
|
|
}
|
|
}
|
|
}
|
|
foreach(SaveIndex in RemoveIndexArr) {
|
|
Childrens.remove(SaveIndex);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* @函数作用: 添加子对象
|
|
* @参数 name
|
|
*/
|
|
function AddChild(gChild) {
|
|
this.Childrens.append(gChild);
|
|
gChild.Parent = this;
|
|
}
|
|
|
|
//关闭窗口 -并没有销毁只是隐藏
|
|
function CloseWindow() {
|
|
this.Visible = false;
|
|
//还原鼠标
|
|
R_Mouse.Restore();
|
|
//左键单击还原游戏状态
|
|
// L_sq_MouseClick();
|
|
}
|
|
//销毁窗口
|
|
function DestroyWindow() {
|
|
foreach(Index, WindowObj in L_Windows_List) {
|
|
if (WindowObj.ObjectId == this.ObjectId) L_Windows_List.remove(Index);
|
|
}
|
|
//还原鼠标
|
|
R_Mouse.Restore();
|
|
//左键单击还原游戏状态
|
|
// L_sq_MouseClick();
|
|
}
|
|
|
|
//道具信息窗口地址
|
|
ItemInfoDrawS = null;
|
|
//绘制道具相信信息
|
|
ItemObject = null;
|
|
|
|
//获取道具信息并生成缓存
|
|
function GetItemInfo(Id) {
|
|
if (!Rindro_ItemInfoObject.rawin(Id)) {
|
|
local ItemObject = L_sq_GetItem(Id);
|
|
if (!ItemObject) ItemObject = L_sq_GetItem(3037);
|
|
Rindro_ItemInfoObject.rawset(Id, ItemObject);
|
|
}
|
|
}
|
|
//绘制道具带道具信息 带道具边框
|
|
function DrawItemEx(X, Y, Id, Count) {
|
|
GetItemInfo(Id);
|
|
local Rarity = L_sq_RA(Rindro_ItemInfoObject[Id] + 0xF4);
|
|
L_sq_DrawImg("interface2/rindro_reward.img", Rarity, X - 3, Y - 3);
|
|
DrawItemBase(X, Y, Id, Count);
|
|
}
|
|
//绘制道具带道具信息
|
|
function DrawItemBase(X, Y, Id, Count) {
|
|
GetItemInfo(Id);
|
|
L_Sq_DrawItem(X, Y, Id, Count, 0, 0, 0);
|
|
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, 24, 24)) {
|
|
//打开道具信息窗口
|
|
if (!ItemInfoDrawS) {
|
|
ItemInfoDrawS = L_Sq_CallFunc(0xE6E070, "int", FFI_THISCALL, ["int", "int", "int", "int"], L_sq_RA(0x1A5FB20), 275, Rindro_ItemInfoObject[Id], 41);
|
|
//校准道具信息窗口位置
|
|
L_Sq_CallFunc(0xF3B3B0, "int", FFI_THISCALL, ["int", "int", "int", "int", "int"], ItemInfoDrawS, IMouse.GetXPos(), IMouse.GetYPos(), 28, 28);
|
|
//我自己UI打开的道具信息窗口需要把渲染队列改为下层 以显示我打开的道具
|
|
getroottable().WindowsShowABFlag <- false;
|
|
}
|
|
} else {
|
|
if (ItemInfoDrawS) {
|
|
L_Sq_CallFunc(0xE6B2B0, "int", FFI_THISCALL, ["int", "int", "int", "char"], 0x1ADE090, 0x113, 0xFFFFFFFF, 0x0);
|
|
ItemInfoDrawS = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//生成DT
|
|
function GenerateDt() {
|
|
try {
|
|
local CurT = L_Getmicroseconds();
|
|
Duration = (CurT - DurationFlag);
|
|
DurationFlag = CurT;
|
|
} catch (exception) {
|
|
|
|
}
|
|
}
|
|
|
|
function Show(obj) {
|
|
GenerateDt();
|
|
if (!Visible) return;
|
|
|
|
//调用原生方法
|
|
LenheartNewUI_BaseWindow.Show(obj);
|
|
if (DeBugMode) DeBug(obj);
|
|
|
|
//初始化绘制道具
|
|
// ItemInfoDrawS = null;
|
|
}
|
|
|
|
function TopShow(obj) {
|
|
|
|
}
|
|
|
|
function DeBug(obj) {
|
|
sq_DrawBox(X, Y, Width, Height, 0xffffffff);
|
|
sq_DrawBox(X, Y, Width, TitleH, 0xffffffff);
|
|
}
|
|
|
|
//override
|
|
function OnMouseProc(Flag, MousePos_X, MousePos_Y) {
|
|
if (!Visible) return;
|
|
//设定拖动逻辑
|
|
if (Flag == 1) {
|
|
if (MoveFlag) {
|
|
//左键拖动
|
|
X = B_X - (M_Xpos - MousePos_X);
|
|
Y = B_Y - (M_Ypos - MousePos_Y);
|
|
}
|
|
}
|
|
//调用原生方法
|
|
LenheartNewUI_BaseWindow.OnMouseProc(Flag, MousePos_X, MousePos_Y);
|
|
}
|
|
|
|
//override
|
|
//鼠标左键按下回调
|
|
function OnMouseLbDown(MousePos_X, MousePos_Y) {
|
|
if (!Visible) return;
|
|
//如果点击事件在窗口内
|
|
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X, Y, Width, Height)) {
|
|
ResetFocus();
|
|
//如果点下去在标题栏
|
|
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X, Y, Width, TitleH)) {
|
|
MoveFlag = true;
|
|
M_Xpos = MousePos_X; //原始鼠标位置数据
|
|
M_Ypos = MousePos_Y;
|
|
B_X = X; //原始窗口位置
|
|
B_Y = Y;
|
|
}
|
|
}
|
|
//调用原生方法
|
|
LenheartNewUI_BaseWindow.OnMouseLbDown(MousePos_X, MousePos_Y);
|
|
}
|
|
//override
|
|
//鼠标左键弹起回调
|
|
function OnMouseLbUp(MousePos_X, MousePos_Y) {
|
|
if (!Visible) return;
|
|
if (MoveFlag) {
|
|
MoveFlag = false;
|
|
M_Xpos = null;
|
|
M_Ypos = null;
|
|
B_X = null;
|
|
B_Y = null;
|
|
}
|
|
//调用原生方法
|
|
LenheartNewUI_BaseWindow.OnMouseLbUp(MousePos_X, MousePos_Y);
|
|
}
|
|
//override
|
|
//鼠标右键按下回调
|
|
function OnMouseRbDown(MousePos_X, MousePos_Y) {
|
|
if (!Visible) return;
|
|
//调用原生方法
|
|
LenheartNewUI_BaseWindow.OnMouseRbDown(MousePos_X, MousePos_Y);
|
|
}
|
|
//override
|
|
//鼠标右键弹起回调
|
|
function OnMouseRbUp(MousePos_X, MousePos_Y) {
|
|
if (!Visible) return;
|
|
//调用原生方法
|
|
LenheartNewUI_BaseWindow.OnMouseRbUp(MousePos_X, MousePos_Y);
|
|
}
|
|
//override
|
|
//鼠标滚轮事件回调
|
|
function OnMouseWheel(Flag, MousePos_X, MousePos_Y) {
|
|
if (!Visible) return;
|
|
//调用原生方法
|
|
LenheartNewUI_BaseWindow.OnMouseWheel(Flag, MousePos_X, MousePos_Y);
|
|
}
|
|
}
|
|
|
|
|
|
//创建窗口 如果已存在则返回窗口
|
|
function LenheartNewUI_CreateWindow(ClassName, gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
|
foreach(Index, WindowObj in L_Windows_List) {
|
|
if (WindowObj.ObjectId == gObjectId) {
|
|
return WindowObj;
|
|
}
|
|
}
|
|
return ClassName(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
|
}
|
|
//销毁窗口
|
|
function LenheartNewUI_DestoryWindow(gObjectId) {
|
|
foreach(Index, WindowObj in L_Windows_List) {
|
|
if (WindowObj.ObjectId == gObjectId) {
|
|
L_Windows_List.remove(Index);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
//遍历窗口查询是否有悬停在新窗口中
|
|
function CheackMouseInNewWindows(MousePos_X, MousePos_Y) {
|
|
local Flag = false;
|
|
foreach(Window in L_Windows_List) {
|
|
if (!Window.Visible) continue;
|
|
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, Window.X, Window.Y, Window.Width, Window.Height)) {
|
|
Flag = true;
|
|
// print(Window.ObjectId);
|
|
// Sout("%L",Window.ObjectId);
|
|
return Flag;
|
|
}
|
|
}
|
|
return Flag;
|
|
}
|
|
//遍历是否悬停在原生窗口上
|
|
function CheackMouseInOldWindows() {
|
|
// if (!NotOldWindowsMap.rawin(L_sq_RA(0x1A32950)) && (L_sq_RA(0x1A32950) <= 2390 || L_sq_RA(0x1A32950) >= 2500) && (L_sq_RA(0x1A32950) <= 120 || L_sq_RA(0x1A32950) >= 140)) {
|
|
// return true;
|
|
// }
|
|
// local Id = L_sq_RA(0x1A32950);
|
|
// if (Id == Rindro_Info_Base_Nowindow || Id <= 300) return false;
|
|
// return true;
|
|
|
|
|
|
//城镇基础背景窗口 副本背景 城镇背景 拓展技能按钮 切换技能页按钮
|
|
local OldBaseWindowArr = [0x184D0C4, 0x0184CF6C, 0x15A249C, 0x184D174];
|
|
local WindowAddress = L_sq_RA(0x1B474D4);
|
|
if (WindowAddress) {
|
|
local Flag = L_sq_RA(WindowAddress);
|
|
foreach(value in OldBaseWindowArr) {
|
|
if (Flag == value) {
|
|
// if ((L_sq_RA(WindowAddress + 0x14) == 0 && L_sq_RA(WindowAddress + 0x18) == 0) || Flag == 0x184D0C4) {
|
|
// print(false);
|
|
|
|
// }
|
|
|
|
//空地
|
|
if (Flag == 0x184D0C4 || Flag == 0x0184CF6C) {
|
|
//都为0的时候城镇背景 508是血槽那一块的逻辑 坐标Y是508
|
|
if ((L_sq_RA(WindowAddress + 0x14) == 0 && (L_sq_RA(WindowAddress + 0x18) == 0 || L_sq_RA(WindowAddress + 0x18) == 508))) {
|
|
return false;
|
|
}
|
|
} else return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//设定鼠标逻辑
|
|
function RunMouseLogic(MousePos_X, MousePos_Y) {
|
|
//解锁鼠标 如果鼠标已处于锁定状态 并且没有悬停在任何窗口上 解锁鼠标
|
|
if (R_Mouse.IsLock()) {
|
|
//不在任何新窗口上
|
|
if (!CheackMouseInNewWindows(MousePos_X, MousePos_Y)) {
|
|
//还原鼠标
|
|
R_Mouse.Restore();
|
|
}
|
|
//在任何老窗口上 并且渲染层为A层 也就是下层渲染
|
|
else if (CheackMouseInOldWindows() && !getroottable().WindowsShowABFlag) {
|
|
//还原鼠标
|
|
R_Mouse.Restore();
|
|
}
|
|
}
|
|
//锁定鼠标 如果鼠标处于未锁定状态 并且悬停在任意一个窗口上
|
|
else if (!R_Mouse.IsLock() && CheackMouseInNewWindows(MousePos_X, MousePos_Y)) {
|
|
//如果没有悬停任何原生窗口直接锁
|
|
if (!CheackMouseInOldWindows()) {
|
|
//锁定鼠标
|
|
R_Mouse.Lock();
|
|
//设置鼠标模式
|
|
R_Mouse.SetType(1);
|
|
}
|
|
//如果有悬停原生窗口 就要判断AB层
|
|
else {
|
|
if (getroottable().WindowsShowABFlag) {
|
|
//锁定鼠标
|
|
R_Mouse.Lock();
|
|
//设置鼠标模式
|
|
R_Mouse.SetType(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//鼠标消息回调
|
|
function L_MouseCallBack(MouseState, MouseFlag, MousePos_X, MousePos_Y) {
|
|
|
|
// //获取基础无窗口的位置的值
|
|
// if (!Rindro_Info_Base_Nowindow) {
|
|
// if (!sq_getMyCharacter()) return;
|
|
// if (!Rindro_Info_Base_Nowindow) {
|
|
// IMouse.SetPos((800 * 0.45).tointeger(), (600 * 0.1).tointeger());
|
|
// if (MousePos_X == (getroottable().Rindro_Scr_Width * 0.45).tointeger() && MousePos_Y == (getroottable().Rindro_Scr_High * 0.1).tointeger()) {
|
|
// Rindro_Info_Base_Nowindow = L_sq_RA(0x1A32950);
|
|
// }
|
|
// }
|
|
// }
|
|
//用于抵消Esc造成的点击事件
|
|
// if (Rindro_MouseClickFlag) {
|
|
// Rindro_MouseClickFlag--;
|
|
// return;
|
|
// }
|
|
if (MouseState == 0x200) {
|
|
//常规事件就要设定鼠标是否锁定逻辑
|
|
RunMouseLogic(MousePos_X, MousePos_Y);
|
|
}
|
|
|
|
//判断是否悬停活动图标 没悬停在老窗口上 没在选图界面
|
|
if (getroottable().rawin("EventList_Obj") && !CheackMouseInOldWindows() && sq_GetCurrentModuleType() != 2) EventList_Obj.CheckInEvent(MousePos_X, MousePos_Y);
|
|
|
|
|
|
//如果渲染层级在下级 即A层 或者是 鼠标没有悬停在任何新窗口上时 执行判断 如果悬停在原生窗口 就解除鼠标锁定 如果点击 就改变渲染层级
|
|
if (!getroottable().WindowsShowABFlag || !CheackMouseInNewWindows(MousePos_X, MousePos_Y)) {
|
|
if (CheackMouseInOldWindows()) {
|
|
//如果点击了原生窗口 或者使用了滚轮 就把渲染队列改成下
|
|
if (MouseState == 0x201 || MouseState == 0x20a) {
|
|
getroottable().WindowsShowABFlag <- false;
|
|
}
|
|
if (MouseState != 0x20a) return;
|
|
}
|
|
}
|
|
|
|
//克隆一遍窗口列表
|
|
local WindowListF = clone(L_Windows_List);
|
|
WindowListF.reverse();
|
|
//判断滚轮是向上还是向下的
|
|
local Flag = MouseFlag == 0xff880000 ? 0 : 1;
|
|
foreach(Window in WindowListF) {
|
|
if (Window.Visible) {
|
|
switch (MouseState) {
|
|
//常规或者拖动事件
|
|
case 0x200: {
|
|
Window.OnMouseProc(MouseFlag, MousePos_X, MousePos_Y);
|
|
break;
|
|
}
|
|
//左键点击
|
|
case 0x201: {
|
|
//如果点击了新窗口就把渲染队列改成上
|
|
getroottable().WindowsShowABFlag <- true;
|
|
Window.OnMouseLbDown(MousePos_X, MousePos_Y);
|
|
break;
|
|
|
|
}
|
|
//左键松开
|
|
case 0x202: {
|
|
if (getroottable().WindowsShowABFlag) L_sq_WA(0x1B46874, 0);
|
|
Window.OnMouseLbUp(MousePos_X, MousePos_Y);
|
|
break;
|
|
}
|
|
//右键点击
|
|
case 0x204: {
|
|
Window.OnMouseRbDown(MousePos_X, MousePos_Y);
|
|
break;
|
|
}
|
|
//右键松开
|
|
case 0x205: {
|
|
Window.OnMouseRbUp(MousePos_X, MousePos_Y);
|
|
break;
|
|
}
|
|
//滚轮事件
|
|
case 0x20a: {
|
|
Window.OnMouseWheel(Flag, MousePos_X, MousePos_Y);
|
|
break;
|
|
}
|
|
}
|
|
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, Window.X, Window.Y, Window.Width, Window.Height)) return;
|
|
}
|
|
}
|
|
}
|
|
//打开原生窗口回调
|
|
function L_OpenOldWindowCallBack(WindowIndex) {
|
|
//将新窗口渲染队列改为下层 抵消窗口 Esc窗口 登录可能显示的任务窗口
|
|
if (WindowIndex != 170 && WindowIndex != 176 && WindowIndex != 276 && WindowIndex != 275 && WindowIndex != 278 && WindowIndex != 283 && WindowIndex != 36) {
|
|
getroottable().WindowsShowABFlag <- false;
|
|
}
|
|
}
|
|
|
|
//窗口逻辑入口
|
|
function L_WindowsLogic(obj) {
|
|
//是否存在一个窗口Flag
|
|
local WindowExistence = false;
|
|
//遍历窗口队列 如果可见则调用Show 只要有一个可见就写入Flag
|
|
foreach(Window in L_Windows_List) {
|
|
if (sq_GetCurrentModuleType() != 2) Window.Proc(obj);
|
|
if (Window.Visible) {
|
|
if (sq_GetCurrentModuleType() != 2) Window.Show(obj);
|
|
if (sq_GetCurrentModuleType() != 2) Window.TopShow(obj);
|
|
if (!Window.rawin("NoWindow")) {
|
|
WindowExistence = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
//如果可见 需要调用一个原生窗口抵消ESC
|
|
if (WindowExistence) {
|
|
local W = sq_GetPopupWindowMainCotrol(170);
|
|
if (!W) L_NewWindows("Lenheart", 170, 0x65535);
|
|
else {
|
|
W.SetVisible(false);
|
|
W.SetEnable(false);
|
|
}
|
|
}
|
|
//没有任何新窗口打开 并且原生窗口开启者
|
|
else {
|
|
local W = sq_GetPopupWindowMainCotrol(170);
|
|
if (W) {
|
|
L_sq_UseSkill(DIK_ESCAPE);
|
|
}
|
|
}
|
|
//如果按下ESC键要将所有的窗口关闭
|
|
if (WindowExistence) {
|
|
if (KeyPressNB.isKeyPress(48, "AllLenheartWindows") || sq_GetCurrentModuleType() == 2) {
|
|
local Flag = false;
|
|
foreach(Window in L_Windows_List) {
|
|
if (!Window.rawin("NoWindow")) {
|
|
Flag = true;
|
|
Window.CloseWindow();
|
|
}
|
|
}
|
|
if (Flag) {
|
|
getroottable().WindowsShowABFlag <- false;
|
|
//还原鼠标
|
|
R_Mouse.Restore();
|
|
L_Sq_CallFunc(0x11A8B60, "void", FFI_MS_CDECL, []);
|
|
// L_sq_MouseClick();
|
|
Rindro_MouseClickFlag = 5;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
//绘制下层回调
|
|
function L_DrawWindow_A() {
|
|
local obj = sq_getMyCharacter();
|
|
if (!obj) return;
|
|
|
|
//A层只在下层渲染
|
|
if (getroottable().WindowsShowABFlag == false) L_WindowsLogic(obj);
|
|
}
|
|
//绘制上层回调
|
|
function L_DrawWindow_B() {
|
|
local obj = sq_getMyCharacter();
|
|
if (!obj) return;
|
|
|
|
//B层只在上层渲染
|
|
if (getroottable().WindowsShowABFlag) L_WindowsLogic(obj);
|
|
|
|
local RootTab = getroottable();
|
|
if (RootTab.rawin("LenheartTopFuncTab")) {
|
|
local LenheartFunc = RootTab["LenheartTopFuncTab"];
|
|
foreach(Func in LenheartFunc) {
|
|
Func(obj);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
class LenheartNewUI_CommonUi extends LenheartNewUI_BaseWindow {
|
|
X = 0;
|
|
Y = 0;
|
|
Localtion_X = 0;
|
|
Localtion_Y = 0;
|
|
Width = null;
|
|
Height = null;
|
|
isLBDown = false;
|
|
isInRect = false;
|
|
|
|
OnClick = null;
|
|
OnClickEx = null;
|
|
OnClickSound = null;
|
|
ObjectId = null;
|
|
|
|
Visible = true;
|
|
|
|
TopCallBackFunc = null;
|
|
|
|
Data = null;
|
|
|
|
constructor(x, y, width, height) {
|
|
this.Localtion_X = x;
|
|
this.Localtion_Y = y;
|
|
this.Width = width;
|
|
this.Height = height;
|
|
|
|
ObjectId = Clock();
|
|
}
|
|
|
|
//同步坐标
|
|
function SyncPos(x, y) {
|
|
this.X = Localtion_X + x;
|
|
this.Y = Localtion_Y + y;
|
|
}
|
|
|
|
//鼠标事件回调
|
|
function OnMouseProc(Flag, MousePos_X, MousePos_Y) {
|
|
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X, Y, Width, Height)) isInRect = true;
|
|
else isInRect = false;
|
|
}
|
|
//鼠标左键按下回调
|
|
function OnMouseLbDown(MousePos_X, MousePos_Y) {
|
|
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X, Y, Width, Height)) {
|
|
isLBDown = true;
|
|
if (!OnClickSound) {
|
|
R_Utils.PlaySound("CLICK_BUTTON1");
|
|
} else {
|
|
R_Utils.PlaySound(OnClickSound);
|
|
}
|
|
}
|
|
}
|
|
//鼠标左键弹起回调
|
|
function OnMouseLbUp(MousePos_X, MousePos_Y) {
|
|
if (isLBDown) {
|
|
if (OnClick) OnClick();
|
|
if (OnClickEx) OnClickEx(this);
|
|
}
|
|
isLBDown = false;
|
|
}
|
|
|
|
//鼠标右键按下回调
|
|
function OnMouseRbDown(MousePos_X, MousePos_Y) {
|
|
|
|
}
|
|
//鼠标右键弹起回调
|
|
function OnMouseRbUp(MousePos_X, MousePos_Y) {
|
|
|
|
}
|
|
//鼠标滚轮时间回调
|
|
function OnMouseWheel(Flag, MousePos_X, MousePos_Y) {
|
|
|
|
}
|
|
|
|
function TopShow(obj) {
|
|
if (TopCallBackFunc) TopCallBackFunc(obj, this);
|
|
}
|
|
}
|
|
|
|
class LenheartNewUI_BaseButton extends LenheartNewUI_CommonUi {
|
|
State = 0;
|
|
BaseIdx = 29;
|
|
DWidth = null;
|
|
Path = null;
|
|
Idx = null;
|
|
|
|
|
|
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 + 1);
|
|
} else {
|
|
//按下
|
|
if (isLBDown) {
|
|
L_sq_DrawImg(Path, Idx + 2, X, Y + 1);
|
|
}
|
|
//悬停
|
|
else if (isInRect) {
|
|
L_sq_DrawImg(Path, Idx + 1, X, Y);
|
|
}
|
|
//普通
|
|
else {
|
|
L_sq_DrawImg(Path, Idx, X, Y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class LenheartNewUI_Button extends LenheartNewUI_CommonUi {
|
|
State = 0;
|
|
BaseIdx = 29;
|
|
DWidth = null;
|
|
Path = "interface/lenheartwindowcommon.img";
|
|
Idx = 172;
|
|
FillWidth = 2;
|
|
FirstWidth = 28;
|
|
|
|
|
|
|
|
constructor(X, Y, W) {
|
|
this.DWidth = W;
|
|
LenheartNewUI_CommonUi.constructor(X, Y, W + 28 * 2, 24);
|
|
}
|
|
|
|
function SetFrame(gPath, gIdx) {
|
|
if (gPath) Path = gPath;
|
|
Idx = gIdx;
|
|
}
|
|
|
|
function Show(obj) {
|
|
//不可用
|
|
if (State == 8) {
|
|
L_sq_DrawButton(X, Y + 1, this.DWidth, Path, Idx + 9, FillWidth, FirstWidth);
|
|
} else {
|
|
//按下
|
|
if (isLBDown) {
|
|
L_sq_DrawButton(X, Y + 1, this.DWidth, Path, Idx + 3, FillWidth, FirstWidth);
|
|
}
|
|
//悬停
|
|
else if (isInRect) {
|
|
L_sq_DrawButton(X, Y, this.DWidth, Path, Idx + 3, FillWidth, FirstWidth);
|
|
}
|
|
//普通
|
|
else {
|
|
L_sq_DrawButton(X, Y, this.DWidth, Path, Idx, FillWidth, FirstWidth);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class LenheartNewUI_ButtonText extends LenheartNewUI_Button {
|
|
TextStr = null;
|
|
TextX = null;
|
|
TextY = null;
|
|
TextColor = null;
|
|
TextRColor = null;
|
|
|
|
TextXoffset = null;
|
|
TextYoffset = null;
|
|
|
|
constructor(X, Y, W, Str) {
|
|
LenheartNewUI_Button.constructor(X, Y, W);
|
|
this.TextStr = Str;
|
|
TextColor = sq_RGBA(185, 148, 96, 255);
|
|
TextRColor = sq_RGBA(227, 212, 154, 255);
|
|
|
|
TextXoffset = 19;
|
|
TextYoffset = 3;
|
|
}
|
|
|
|
function SetTextColor(RGBA) {
|
|
TextColor = RGBA;
|
|
}
|
|
|
|
function SetTextOffset(gX, gY) {
|
|
TextXoffset = gX;
|
|
TextYoffset = gY;
|
|
}
|
|
|
|
function Show(obj) {
|
|
LenheartNewUI_Button.Show(obj);
|
|
local Color = TextColor;
|
|
local SY = Y + TextYoffset;
|
|
if (State != 8) {
|
|
if (isLBDown) {
|
|
SY = Y + TextYoffset + 1;
|
|
}
|
|
if (isInRect || State == 1) {
|
|
Color = TextRColor;
|
|
}
|
|
}
|
|
L_sq_DrawCode(TextStr, X + TextXoffset + 19, SY + 5, Color, 0, 1);
|
|
}
|
|
}
|
|
|
|
class LenheartNewUI_BaseInput extends LenheartNewUI_CommonUi {
|
|
State = 0;
|
|
InputState = 0;
|
|
DWidth = null;
|
|
str = "";
|
|
sliceCode = "|";
|
|
BaseTime = 0;
|
|
InputController = null;
|
|
|
|
constructor(X, Y, W, H) {
|
|
this.DWidth = W;
|
|
LenheartNewUI_CommonUi.constructor(X, Y, W, H);
|
|
}
|
|
|
|
function sliceCodeFlicker() {
|
|
local T = Clock();
|
|
if ((T - 500) >= BaseTime) {
|
|
BaseTime = T;
|
|
if (sliceCode.len() > 0) sliceCode = "";
|
|
else if (sliceCode.len() == 0) sliceCode = "|";
|
|
}
|
|
}
|
|
|
|
function Show(obj) {
|
|
//光标闪烁
|
|
if (InputState == 1) sliceCodeFlicker();
|
|
else sliceCode = "";
|
|
|
|
L_sq_DrawImg("interface/lenheartwindowcommon.img", 63, this.X, this.Y);
|
|
for (local i = 0; i< this.Width; i++) {
|
|
L_sq_DrawImg("interface/lenheartwindowcommon.img", 64, this.X + 3 + i, this.Y);
|
|
}
|
|
L_sq_DrawImg("interface/lenheartwindowcommon.img", 65, this.X + 3 + this.Width, this.Y);
|
|
L_sq_DrawCode(str + sliceCode, this.X + 4, this.Y + 3, sq_RGBA(179, 169, 135, 255), 0, 1);
|
|
this.OnClick = function() {
|
|
InputController = L_sq_NewInputBox(this.X, this.Y, this.Width, this.Height, str);
|
|
InputState = 1;
|
|
}
|
|
|
|
|
|
if (InputController) {
|
|
local StrBuf = L_sq_GetInputBoxStr(InputController);
|
|
if (StrBuf != "LenheartNULL") str = StrBuf;
|
|
else {
|
|
InputController = null;
|
|
InputState = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
function SetStr(Value) {
|
|
L_sq_SetInputBoxStr(InputController, Value);
|
|
}
|
|
}
|
|
|
|
//复选框
|
|
class LenheartNewUI_SwitchButton extends LenheartNewUI_CommonUi {
|
|
State = 0;
|
|
ImgIndex = null;
|
|
ImgPath = "interface/lenheartwindowcommon.img";
|
|
|
|
constructor(X, Y) {
|
|
LenheartNewUI_CommonUi.constructor(X, Y, 14, 15);
|
|
}
|
|
|
|
function Show(obj) {
|
|
//不可用
|
|
if (State == 8) {
|
|
L_sq_DrawImg(ImgPath, ImgIndex ? ImgIndex + 3 : 141, X, Y + 1);
|
|
} else {
|
|
//悬停
|
|
if (isLBDown) {
|
|
L_sq_DrawImg(ImgPath, ImgIndex ? ImgIndex + 2 : 140, X, Y + 1);
|
|
}
|
|
//按下
|
|
else if (isInRect) {
|
|
if (State == 0)
|
|
L_sq_DrawImg(ImgPath, ImgIndex ? ImgIndex + 1 : 139, X, Y);
|
|
if (State == 1)
|
|
L_sq_DrawImg(ImgPath, ImgIndex ? ImgIndex + 2 : 140, X, Y);
|
|
}
|
|
//普通
|
|
else {
|
|
if (State == 0)
|
|
L_sq_DrawImg(ImgPath, ImgIndex ? ImgIndex : 138, X, Y);
|
|
if (State == 1)
|
|
L_sq_DrawImg(ImgPath, ImgIndex ? ImgIndex + 2 : 140, X, Y);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class LenheartNewUI_SwitchButtonText extends LenheartNewUI_SwitchButton {
|
|
|
|
TextStr = null;
|
|
TextX = 0;
|
|
TextY = 0;
|
|
TextColor = null;
|
|
TextRColor = null;
|
|
|
|
|
|
constructor(X, Y, Str) {
|
|
LenheartNewUI_SwitchButton.constructor(X, Y);
|
|
this.TextStr = Str;
|
|
TextColor = sq_RGBA(221, 197, 147, 250);
|
|
TextRColor = sq_RGBA(255, 255, 184, 250);
|
|
}
|
|
|
|
function SetTextColor(RGBA) {
|
|
TextColor = RGBA;
|
|
}
|
|
|
|
function SetTextPos(gX, gY) {
|
|
TextX = gX;
|
|
TextY = gY;
|
|
}
|
|
|
|
function Show(obj) {
|
|
LenheartNewUI_SwitchButton.Show(obj);
|
|
local Color = TextColor;
|
|
local SY = Y;
|
|
if (State != 8) {
|
|
if (isLBDown) {
|
|
SY = Y + 1;
|
|
}
|
|
if (isInRect || State == 1) {
|
|
Color = TextRColor;
|
|
}
|
|
}
|
|
L_sq_DrawCode(TextStr, X + 16 + TextX, SY + 1 + TextY, Color, 0, 1);
|
|
}
|
|
}
|
|
|
|
class LenheartNewUI_Tabbars extends LenheartNewUI_CommonUi {
|
|
State = 0;
|
|
Path = "interface/lenheartwindowcommon.img";
|
|
Idx = 29;
|
|
|
|
constructor(X, Y, ...) {
|
|
if (vargc == 2) {
|
|
LenheartNewUI_CommonUi.constructor(X, Y, vargv[0], vargv[1]);
|
|
} else {
|
|
LenheartNewUI_CommonUi.constructor(X, Y, 61, 19);
|
|
}
|
|
}
|
|
|
|
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 + 1);
|
|
}
|
|
//悬停
|
|
else if (isInRect) {
|
|
if (State == 0)
|
|
L_sq_DrawImg(Path, Idx + 1, X, Y);
|
|
if (State == 1)
|
|
L_sq_DrawImg(Path, Idx + 2, X, Y);
|
|
}
|
|
//普通
|
|
else {
|
|
if (State == 0)
|
|
L_sq_DrawImg(Path, Idx, X, Y);
|
|
if (State == 1)
|
|
L_sq_DrawImg(Path, Idx + 2, X, Y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class LenheartNewUI_TabbarsText extends LenheartNewUI_Tabbars {
|
|
TextStr = null;
|
|
TextX = null;
|
|
TextY = null;
|
|
TextColor = null;
|
|
TextRColor = null;
|
|
|
|
TextXoffset = null;
|
|
TextYoffset = null;
|
|
|
|
constructor(X, Y, Str, ...) {
|
|
if (vargc == 2) {
|
|
LenheartNewUI_Tabbars.constructor(X, Y, vargv[0], vargv[1]);
|
|
} else {
|
|
LenheartNewUI_Tabbars.constructor(X, Y);
|
|
}
|
|
this.TextStr = Str;
|
|
TextColor = sq_RGBA(124, 110, 82, 255);
|
|
TextRColor = sq_RGBA(185, 172, 145, 255);
|
|
|
|
TextXoffset = 19;
|
|
TextYoffset = 3;
|
|
}
|
|
|
|
function SetTextColor(RGBA) {
|
|
TextColor = RGBA;
|
|
}
|
|
|
|
function SetTextOffset(gX, gY) {
|
|
TextXoffset = gX;
|
|
TextYoffset = gY;
|
|
}
|
|
|
|
function Show(obj) {
|
|
LenheartNewUI_Tabbars.Show(obj);
|
|
local Color = TextColor;
|
|
local SY = Y + TextYoffset;
|
|
if (State != 8) {
|
|
if (isLBDown) {
|
|
SY = Y + TextYoffset + 1;
|
|
}
|
|
if (isInRect || State == 1) {
|
|
Color = TextRColor;
|
|
}
|
|
}
|
|
if (State == 1)
|
|
L_sq_DrawCode(TextStr, X + TextXoffset, SY, Color, 0, 1);
|
|
if (State == 0 || State == 8)
|
|
L_sq_DrawCode(TextStr, X + TextXoffset, SY + 2, Color, 0, 1);
|
|
}
|
|
} |