控件框架基础引入
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
创建日期:2025-10-18 20:54
|
||||
文件用途:窗口节点类
|
||||
*/
|
||||
_SYS_UI_SCENE_Instance_ <- null;
|
||||
_SYS_WINDOW_LIST_ <- [];
|
||||
class WindowNode extends Actor {
|
||||
//演出状态
|
||||
PerformanceState = false;
|
||||
@@ -20,6 +22,13 @@ class WindowNode extends Actor {
|
||||
//销毁Flag
|
||||
DestroyFlag = false;
|
||||
|
||||
//X坐标
|
||||
X = null;
|
||||
B_X = null;
|
||||
//Y坐标
|
||||
Y = null;
|
||||
B_Y = null;
|
||||
|
||||
function _typeof() {
|
||||
return "WindowNode";
|
||||
}
|
||||
@@ -33,10 +42,85 @@ class WindowNode extends Actor {
|
||||
|
||||
function SetVisible(Flag) {
|
||||
Visible = Flag;
|
||||
base.SetVisible(Flag);
|
||||
}
|
||||
|
||||
function AddChild(Act) {
|
||||
if (!(Act instanceof WindowNode)) base.AddChild(Act);
|
||||
base.AddChild(Act);
|
||||
Childrens.push(Act);
|
||||
}
|
||||
|
||||
function Proc(Dt){
|
||||
if (UpdateFunc != null) this.UpdateFunc(Dt);
|
||||
SetPos(X, Y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {any} WindowName
|
||||
* @param {GameWindow} WindowClass
|
||||
* @returns {any}
|
||||
*/
|
||||
function sq_CreaterWindowInstance(WindowName, WindowClass, gX, gY, gWidth, gHeight, gTitleHeight) {
|
||||
foreach (idx, val in _SYS_WINDOW_LIST_) {
|
||||
if (val.WindowName == WindowName) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
local NewWindow = WindowClass(WindowName, gX, gY, gWidth, gHeight, gTitleHeight);
|
||||
getroottable()._SYS_WINDOW_LIST_.push(NewWindow);
|
||||
return NewWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {float} Dt
|
||||
* @returns {void}
|
||||
*/
|
||||
function _Global_Windows_Logic_(Dt) {
|
||||
if (_SYS_UI_SCENE_Instance_) {
|
||||
for (local i = 0; i < _SYS_WINDOW_LIST_.len(); i++) {
|
||||
local Window = _SYS_WINDOW_LIST_[i];
|
||||
//如果窗口不可见并且 处于演出状态
|
||||
if (!Window.Visible && Window.PerformanceState) {
|
||||
Window.PerformanceState = false;
|
||||
_SYS_UI_SCENE_Instance_.RemoveChild(Window);
|
||||
if (Window.DestroyFlag) {
|
||||
_SYS_WINDOW_LIST_.remove(i);
|
||||
i--;
|
||||
}
|
||||
} else if (Window.Visible && !Window.PerformanceState) {
|
||||
_SYS_UI_SCENE_Instance_.AddChild(Window);
|
||||
Window.PerformanceState = true;
|
||||
}
|
||||
//无论窗口是否显示都需要调用Proc
|
||||
Window.Proc(Dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _Global_Windows_Events_(EventType, EventData) {
|
||||
//先传递鼠标事件
|
||||
local IMouse = Game_Cursor.GetInstance();
|
||||
IMouse.Event(EventType, EventData);
|
||||
//事件是否被响应Flag
|
||||
local EventInteractiveFlag = false;
|
||||
for (local i = _SYS_WINDOW_LIST_.len() - 1; i > -1; i--) {
|
||||
local Window = _SYS_WINDOW_LIST_[i];
|
||||
if (Window.Visible) {
|
||||
if (EventType == UI_EVENT.MOUSEMOTION || EventType == UI_EVENT.MOUSEBUTTONDOWN || EventType == UI_EVENT.MOUSEBUTTONUP) {
|
||||
Window.OnMouseEvent(EventType, EventData, EventInteractiveFlag);
|
||||
} else if (EventType == UI_EVENT.KEYDOWN || EventType == UI_EVENT.KEYUP) {
|
||||
Window.OnKeyEvent(EventType, EventData, EventInteractiveFlag);
|
||||
}
|
||||
if (Math.IsIntersectRect(IMouse.MouseX, IMouse.MouseY, 1, 1, Window.X, Window.Y, Window.Width, Window.Height)) {
|
||||
EventInteractiveFlag = Window;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user