725 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			725 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:UiClassTool.nut
 | |
| 路径:Tool/UiClassTool.nut
 | |
| 创建日期:2024-03-20	11:27
 | |
| 文件用途:UI
 | |
| */
 | |
| //基础窗口类
 | |
| class LenheartNewUI_BaseWindow extends BasicsDrawTool {
 | |
| 
 | |
|     //子控件
 | |
|     Childrens = null;
 | |
|     constructor() {
 | |
|         //子控件
 | |
|         // Childrens = [];
 | |
|     }
 | |
|     //鼠标事件回调
 | |
|     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 {
 | |
|     //MyObjectId
 | |
|     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;
 | |
| 
 | |
|     YMouseSw = true;
 | |
|     //焦点
 | |
|     Focus = true;
 | |
| 
 | |
|     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
 | |
|         ObjectId = gObjectId;
 | |
|         //宽度
 | |
|         Width = gWidth;
 | |
|         //高度
 | |
|         Height = gHeight;
 | |
|         //标题高度
 | |
|         TitleH = gTitleH;
 | |
| 
 | |
|         //X坐标
 | |
|         X = gX;
 | |
|         //Y坐标
 | |
|         Y = gY;
 | |
| 
 | |
|         Init();
 | |
| 
 | |
|         //调用原生方法
 | |
|         LenheartNewUI_BaseWindow.constructor();
 | |
|     }
 | |
| 
 | |
|     function ResetFocus() {
 | |
|         foreach(Index, WindowObj in L_Windows_List) {
 | |
|             if (WindowObj.ObjectId == this.ObjectId) L_Windows_List.remove(Index);
 | |
|             WindowObj.Focus = false;
 | |
|         }
 | |
|         this.Focus = true;
 | |
|         L_Windows_List.append(this);
 | |
|     }
 | |
| 
 | |
|     //加入窗口队列
 | |
|     function Init() {
 | |
|         ResetFocus();
 | |
|     }
 | |
| 
 | |
|     //设定鼠标逻辑
 | |
|     function LockMouse(MousePos_X, MousePos_Y) {
 | |
|         if (!Visible) return;
 | |
|         if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X, Y, Width, Height)) {
 | |
|             IMouse.LockMouseClick();
 | |
|             YMouseSw = false;
 | |
|             L_sq_WA(0x1b46898, 1);
 | |
|             IMouse.LockState <- true;
 | |
|         } else {
 | |
|             if (YMouseSw == false && sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, 0, 0, 800, 600) && !MoveFlag) {
 | |
|                 IMouse.ReleaseMouseClick();
 | |
|                 YMouseSw = true;
 | |
|                 L_sq_WA(0x1b46898, 0);
 | |
|                 IMouse.LockState <- false;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     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);
 | |
|     }
 | |
| 
 | |
|     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 (!MoveFlag) LockMouse(MousePos_X, MousePos_Y);
 | |
|         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) {
 | |
|             // WindowObj.Visible = true;
 | |
|             return WindowObj;
 | |
|         }
 | |
|     }
 | |
|     return ClassName(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
 | |
| }
 | |
| 
 | |
| 
 | |
| //遍历窗口查询是否有悬停在新窗口中
 | |
| function CheackMouseInNewWindows(MousePos_X, MousePos_Y) {
 | |
|     local Flag = false;
 | |
|     foreach(Window in L_Windows_List) {
 | |
|         if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, Window.X, Window.Y, Window.Width, Window.Height)) {
 | |
|             Flag = true;
 | |
|             return Flag;
 | |
|         }
 | |
|     }
 | |
|     return Flag;
 | |
| }
 | |
| 
 | |
| 
 | |
| //鼠标事件
 | |
| /*
 | |
| a1
 | |
| 常规状态  200
 | |
| 左键点击 201
 | |
| 左键松开 202
 | |
| 右键点击 204
 | |
| 右键松开 205
 | |
| 滚轮滚动事件 20a
 | |
| 看a2 如果是ff880000 向下   如果是780000 向上
 | |
| 中建按下没有事件
 | |
| 
 | |
| 鼠标事件为200 并且a2 = 1  为左键拖动  a2=2为右键拖动  中建按下拖动a2 =10
 | |
| 
 | |
| a2=3的时候代表2个键一起按下 事件代表后按下的键*/
 | |
| 
 | |
| //如果根空间没有选定AB层的Flag 就新建一个 默认是false 渲染在下层
 | |
| if (!("WindowsShowABFlag" in getroottable())) {
 | |
|     getroottable().WindowsShowABFlag <- false;
 | |
| }
 | |
| 
 | |
| 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
 | |
|             // && 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();
 | |
|                     IMouse.LockState <- false;
 | |
|                 }
 | |
|             }
 | |
|             //如果点击了原生窗口 就把渲染队列改成下
 | |
|             if (MouseState == 0x201) getroottable().WindowsShowABFlag <- false;
 | |
|             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: {
 | |
|                     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;
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| // if (!getroottable().rawin("L_Windows_List"))
 | |
| L_Windows_List <- [];
 | |
| 
 | |
| //窗口逻辑入口
 | |
| function L_WindowsLogic(obj) {
 | |
|     // print(Clock());
 | |
|     //是否存在一个窗口Flag
 | |
|     local WindowExistence = false;
 | |
|     //遍历窗口队列 如果可见则调用Show 只要有一个可见就写入Flag
 | |
|     foreach(Window in L_Windows_List) {
 | |
|         Window.Proc(obj);
 | |
|         if (Window.Visible) {
 | |
|             Window.Show(obj);
 | |
|             WindowExistence = true;
 | |
|         }
 | |
|     }
 | |
|     //如果可见 需要调用一个原生窗口抵消ESC
 | |
|     if (WindowExistence) {
 | |
|         local W = sq_GetPopupWindowMainCotrol(170);
 | |
|         if (!W) L_NewWindows("Lenheart", 170, 0x65535);
 | |
|         else {
 | |
|             W.SetVisible(false);
 | |
|             W.SetEnable(false);
 | |
|         }
 | |
|     }
 | |
|     //如果按下ESC键要将所有的窗口关闭
 | |
|     if (KeyPressNB.isKeyPress(48, "AllLenheartWindows")) {
 | |
|         foreach(Window in L_Windows_List) {
 | |
|             Window.Visible = false;
 | |
|             Window.YMouseSw = true;
 | |
|         }
 | |
|         L_sq_WA(0x1b46898, 0);
 | |
|         IMouse.ReleaseMouseClick();
 | |
|     }
 | |
| }
 | |
| 
 | |
| function L_DrawWindow_A() {
 | |
|     local obj = sq_GetMyMasterCharacter();
 | |
|     if (!obj) return;
 | |
|     //A层只在下层渲染
 | |
|     if (getroottable().WindowsShowABFlag == false) L_WindowsLogic(obj);
 | |
| }
 | |
| 
 | |
| function L_DrawWindow_B() {
 | |
| 
 | |
|     local obj = sq_GetMyMasterCharacter();
 | |
|     if (!obj) return;
 | |
| 
 | |
|     //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(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;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| //复选框
 | |
| class LenheartNewUI_SwitchButton extends LenheartNewUI_CommonUi {
 | |
|     State = 0;
 | |
|     ImgIndex = null;
 | |
| 
 | |
|     constructor(X, Y) {
 | |
|         LenheartNewUI_CommonUi.constructor(X, Y, 14, 15);
 | |
|     }
 | |
| 
 | |
|     function Show(obj) {
 | |
|         //不可用
 | |
|         if (State == 8) {
 | |
|             L_sq_DrawImg("interface/lenheartwindowcommon.img", ImgIndex ? ImgIndex + 3 : 141, X, Y + 1);
 | |
|         } else {
 | |
|             //悬停
 | |
|             if (isLBDown) {
 | |
|                 L_sq_DrawImg("interface/lenheartwindowcommon.img", ImgIndex ? ImgIndex + 2 : 140, X, Y + 1);
 | |
|             }
 | |
|             //按下
 | |
|             else if (isInRect) {
 | |
|                 if (State == 0)
 | |
|                     L_sq_DrawImg("interface/lenheartwindowcommon.img", ImgIndex ? ImgIndex + 1 : 139, X, Y);
 | |
|                 if (State == 1)
 | |
|                     L_sq_DrawImg("interface/lenheartwindowcommon.img", ImgIndex ? ImgIndex + 2 : 140, X, Y);
 | |
|             }
 | |
|             //普通
 | |
|             else {
 | |
|                 if (State == 0)
 | |
|                     L_sq_DrawImg("interface/lenheartwindowcommon.img", ImgIndex ? ImgIndex : 138, X, Y);
 | |
|                 if (State == 1)
 | |
|                     L_sq_DrawImg("interface/lenheartwindowcommon.img", 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);
 | |
|     }
 | |
| } |