新增画布类,三联,九宫格控件
This commit is contained in:
@@ -17,4 +17,18 @@ class Window_hud extends GameWindow {
|
||||
Sp.SetPos((1280 - 403) / 2, 720 - 75);
|
||||
AddChild(Sp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 鼠标事件重载函数
|
||||
* @function override
|
||||
* @param {any} Type
|
||||
* @param {any} Data
|
||||
* @param {boolean} EventInteractiveFlag
|
||||
* @returns {void}
|
||||
*/
|
||||
function OnMouseEvent(Type, Data, EventInteractiveFlag) {
|
||||
base.OnMouseEvent(Type, Data, EventInteractiveFlag)
|
||||
if(Type == UI_EVENT.MOUSEBUTTONDOWN) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ class Game_Cursor extends GameWindow {
|
||||
CurrentMouseTaskId = 0;
|
||||
|
||||
//鼠标X坐标
|
||||
MouseX = 0;
|
||||
MouseX = -100;
|
||||
//鼠标Y坐标
|
||||
MouseY = 0;
|
||||
MouseY = -100;
|
||||
|
||||
constructor() {
|
||||
if (getroottable().rawin("__Game_Cursor__")) {
|
||||
@@ -64,7 +64,13 @@ class Game_Cursor extends GameWindow {
|
||||
MouseSprite[CurrentMouseTaskId].SetPos(MouseX, MouseY);
|
||||
}
|
||||
|
||||
//事件
|
||||
/**
|
||||
* 鼠标窗口是独立的事件函数
|
||||
* @function
|
||||
* @param {any} EventType
|
||||
* @param {any} EventData
|
||||
* @returns {void}
|
||||
*/
|
||||
function Event(EventType, EventData) {
|
||||
if (EventType == UI_EVENT.MOUSEMOTION) {
|
||||
MouseX = EventData[0];
|
||||
|
||||
63
UI/Windows/Widget/NineGridCav.nut
Normal file
63
UI/Windows/Widget/NineGridCav.nut
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
文件名:NineGridCav.nut
|
||||
路径:UI/Windows/Widget/NineGridCav.nut
|
||||
创建日期:2025-10-25 00:35
|
||||
文件用途:九宫格画布
|
||||
*/
|
||||
class GameWidget_NineGridCav extends Canvas {
|
||||
/**
|
||||
*
|
||||
* @function
|
||||
* @param {string} ImgPath Img路径
|
||||
* @param {integer} ImgStart Img起始索引
|
||||
* @param {integer} Width 总宽度
|
||||
* @param {integer} Height 总高度
|
||||
* @returns {gamewidget_ninegridcav}
|
||||
*/
|
||||
constructor(ImgPath, ImgStart, Width, Height) {
|
||||
//获取九宫格各部分原始尺寸
|
||||
local topLeft = sq_GetPng(ImgPath, ImgStart);
|
||||
local topMid = sq_GetPng(ImgPath, ImgStart + 1);
|
||||
local topRight = sq_GetPng(ImgPath, ImgStart + 2);
|
||||
local midLeft = sq_GetPng(ImgPath, ImgStart + 3);
|
||||
local midMid = sq_GetPng(ImgPath, ImgStart + 4);
|
||||
local midRight = sq_GetPng(ImgPath, ImgStart + 5);
|
||||
local bottomLeft = sq_GetPng(ImgPath, ImgStart + 6);
|
||||
local bottomMid = sq_GetPng(ImgPath, ImgStart + 7);
|
||||
local bottomRight = sq_GetPng(ImgPath, ImgStart + 8);
|
||||
|
||||
//初始化画布尺寸
|
||||
base.constructor(Width, Height);
|
||||
|
||||
//计算中间拉伸区域尺寸
|
||||
local midWidth = Width - topLeft.Width - topRight.Width;
|
||||
local midHeight = Height - topLeft.Height - bottomLeft.Height;
|
||||
|
||||
//绘制左上角
|
||||
DrawImg(ImgPath, ImgStart, 0, 0);
|
||||
|
||||
//绘制上中(横向拉伸)
|
||||
DrawImgRect(ImgPath, ImgStart + 1, topLeft.Width, 0, midWidth, topMid.Height);
|
||||
|
||||
//绘制右上角
|
||||
DrawImg(ImgPath, ImgStart + 2, Width - topRight.Width, 0);
|
||||
|
||||
//绘制左中(纵向拉伸)
|
||||
DrawImgRect(ImgPath, ImgStart + 3, 0, topLeft.Height, midLeft.Width, midHeight);
|
||||
|
||||
//绘制中间(双向拉伸)
|
||||
DrawImgRect(ImgPath, ImgStart + 4, topLeft.Width, topLeft.Height, midWidth, midHeight);
|
||||
|
||||
//绘制右中(纵向拉伸)
|
||||
DrawImgRect(ImgPath, ImgStart + 5, Width - midRight.Width, topLeft.Height, midRight.Width, midHeight);
|
||||
|
||||
//绘制左下角
|
||||
DrawImg(ImgPath, ImgStart + 6, 0, Height - bottomLeft.Height);
|
||||
|
||||
//绘制下中(横向拉伸)
|
||||
DrawImgRect(ImgPath, ImgStart + 7, topLeft.Width, Height - bottomMid.Height, midWidth, bottomMid.Height);
|
||||
|
||||
//绘制右下角
|
||||
DrawImg(ImgPath, ImgStart + 8, Width - bottomRight.Width, Height - bottomRight.Height);
|
||||
}
|
||||
}
|
||||
30
UI/Windows/Widget/TripleCav.nut
Normal file
30
UI/Windows/Widget/TripleCav.nut
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
文件名:TripleCav.nut
|
||||
路径:UI/Windows/Widget/TripleCav.nut
|
||||
创建日期:2025-10-24 23:15
|
||||
文件用途:三联画布
|
||||
*/
|
||||
class GameWidget_TripleCav extends Canvas {
|
||||
/**
|
||||
* 创建三联图画布
|
||||
* @function
|
||||
* @param {string} ImgPath Img路径
|
||||
* @param {integer} ImgStart Img起始索引
|
||||
* @param {integer} Width 总宽度
|
||||
* @returns {gamewidget_triplecav}
|
||||
*/
|
||||
constructor(ImgPath, ImgStart, Width) {
|
||||
local Left_Width = sq_GetPng(ImgPath, ImgStart).Width;
|
||||
local Height = sq_GetPng(ImgPath, ImgStart).Height;
|
||||
local Right_Width = sq_GetPng(ImgPath, ImgStart + 2).Width;
|
||||
|
||||
base.constructor(Width, Height);
|
||||
|
||||
//绘制左侧
|
||||
DrawImg(ImgPath, ImgStart, 0, 0);
|
||||
//绘制中间
|
||||
DrawImgRect(ImgPath, ImgStart + 1, Left_Width, 0, Width - Left_Width - Right_Width, Height);
|
||||
//绘制右侧
|
||||
DrawImg(ImgPath, ImgStart + 2, Width - Right_Width, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user