This commit is contained in:
2024-03-26 17:37:58 +08:00
parent af522dcecb
commit 80a89779cd
4 changed files with 648 additions and 186 deletions

View File

@@ -4,38 +4,68 @@
创建日期:2024-03-20 11:27
文件用途:UI
*/
LenheartNewUI <- {}
//基础窗口类
class LenheartNewUI.BaseWindow extends BasicsDrawTool {
class LenheartNewUI_BaseWindow extends BasicsDrawTool {
//子控件
Childrens = null;
constructor() {
//子控件
// Childrens = [];
}
//鼠标事件回调
function OnMouseProc(Flag, MousePos_X, MousePos_Y) {}
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 Show(obj) {
foreach(Window in Childrens) {
Window.Show(obj);
}
}
function SyncPos(X, Y) {
foreach(Window in Childrens) {
Window.SyncPos(X, Y);
}
}
}
class LenheartNewUI.Windows extends LenheartNewUI.BaseWindow {
class LenheartNewUI_Windows extends LenheartNewUI_BaseWindow {
//MyObjectId
ObjectId = null;
//可用性
@@ -68,9 +98,6 @@ class LenheartNewUI.Windows extends LenheartNewUI.BaseWindow {
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
ObjectId = gObjectId;
foreach(Index, WindowObj in L_Windows_List) {
if (WindowObj.ObjectId == this.ObjectId) return;
}
//宽度
Width = gWidth;
//高度
@@ -84,6 +111,9 @@ class LenheartNewUI.Windows extends LenheartNewUI.BaseWindow {
Y = gY;
Init();
//调用原生方法
LenheartNewUI_BaseWindow.constructor();
}
function ResetFocus() {
@@ -120,6 +150,9 @@ class LenheartNewUI.Windows extends LenheartNewUI.BaseWindow {
function Show(obj) {
if (!Visible) return;
// L_sq_DrawImg("interface2/yosin/tbjp.img", 4, X, Y + 1);
//调用原生方法
LenheartNewUI_BaseWindow.Show(obj);
if (DeBugMode) DeBug(obj);
}
@@ -140,6 +173,8 @@ class LenheartNewUI.Windows extends LenheartNewUI.BaseWindow {
Y = B_Y - (M_Ypos - MousePos_Y);
}
}
//调用原生方法
LenheartNewUI_BaseWindow.OnMouseProc(Flag, MousePos_X, MousePos_Y);
}
//override
@@ -158,6 +193,9 @@ class LenheartNewUI.Windows extends LenheartNewUI.BaseWindow {
B_Y = Y;
}
}
//调用原生方法
LenheartNewUI_BaseWindow.OnMouseLbDown(MousePos_X, MousePos_Y);
}
//override
//鼠标左键弹起回调
@@ -170,27 +208,48 @@ class LenheartNewUI.Windows extends LenheartNewUI.BaseWindow {
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(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) {
// WindowObj.Visible = true;
return WindowObj;
}
}
return ClassName(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
}
//遍历窗口查询是否有悬停在新窗口中
@@ -230,7 +289,15 @@ if (!("WindowsShowABFlag" in getroottable())) {
function L_MouseCallBack(MouseState, MouseFlag, MousePos_X, MousePos_Y) {
//如果渲染层级在下级 即A层 或者是 鼠标没有悬停在任何新窗口上时 执行判断 如果悬停在原生窗口 就解除鼠标锁定 如果点击 就改变渲染层级
if (!getroottable().WindowsShowABFlag || !CheackMouseInNewWindows(MousePos_X, MousePos_Y)) {
if (L_sq_RA(0x1A32950) != 92 && L_sq_RA(0x1A32950) != 2396) {
if (L_sq_RA(0x1A32950) != 92 && L_sq_RA(0x1A32950) != 2396
// && L_sq_RA(0x1A32950) != 3877 //小地图
// &&
// L_sq_RA(0x1A32950) != 3878 //小地图
// &&
// L_sq_RA(0x1A32950) != 3873 //小地图
// &&
// L_sq_RA(0x1A32950) != 3874 //小地图
) {
if ("LockState" in IMouse) {
if (IMouse.LockState) {
IMouse.ReleaseMouseClick();
@@ -246,8 +313,7 @@ function L_MouseCallBack(MouseState, MouseFlag, MousePos_X, MousePos_Y) {
//克隆一遍窗口列表
local WindowListF = clone(L_Windows_List);
WindowListF.reverse();
//判断滚石是向上还是向下的
//判断滚轮是向上还是向下的
local Flag = MouseFlag == 0xff880000 ? 0 : 1;
foreach(Window in WindowListF) {
if (Window.Visible) {
@@ -293,16 +359,6 @@ function L_MouseCallBack(MouseState, MouseFlag, MousePos_X, MousePos_Y) {
// if (!getroottable().rawin("L_Windows_List"))
L_Windows_List <- [];
// if (!getroottable().rawin("asdasdasd")) {
// getroottable().asdasdasd <- 1;
// local Win = LenheartNewUI.Windows("测试框",120, 100, 329, 382, 30);
// Win.DeBugMode = true;
// local Win2 = LenheartNewUI.Windows(250, 100, 329, 382, 30);
// Win2.Init();
// local Win3 = LenheartNewUI.Windows(360, 100, 329, 382, 30);
// Win3.Init();
// }
//窗口逻辑入口
function L_WindowsLogic(obj) {
// print(Clock());
@@ -310,8 +366,8 @@ function L_WindowsLogic(obj) {
local WindowExistence = false;
//遍历窗口队列 如果可见则调用Show 只要有一个可见就写入Flag
foreach(Window in L_Windows_List) {
Window.Proc(obj);
if (Window.Visible) {
Window.Proc(obj);
Window.Show(obj);
WindowExistence = true;
}
@@ -334,8 +390,6 @@ function L_WindowsLogic(obj) {
L_sq_WA(0x1b46898, 0);
IMouse.ReleaseMouseClick();
}
}
function L_DrawWindow_A() {
@@ -354,4 +408,241 @@ function L_DrawWindow_B() {
if (getroottable().WindowsShowABFlag) L_WindowsLogic(obj);
//因为图层太高会盖掉鼠标 所以重新画一个
L_sq_DrawImg("interface/newstyle/windows/cursor.img", 0, IMouse.GetXPos(), IMouse.GetYPos());
}
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;
constructor(x, y, width, height) {
this.Localtion_X = x;
this.Localtion_Y = y;
this.Width = width;
this.Height = height;
}
//同步坐标
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;
}
//鼠标左键弹起回调
function OnMouseLbUp(MousePos_X, MousePos_Y) {
if (isLBDown && OnClick) {
OnClick();
}
isLBDown = false;
}
//鼠标右键按下回调
function OnMouseRbDown(MousePos_X, MousePos_Y) {
}
//鼠标右键弹起回调
function OnMouseRbUp(MousePos_X, MousePos_Y) {
}
//鼠标滚轮时间回调
function OnMouseWheel(Flag, MousePos_X, MousePos_Y) {
}
}
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();
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;
}
}
}
}