Rindro-Sqr/Base/UI/Lenheart_Event_Class.nut

374 lines
11 KiB
Plaintext
Raw Normal View History

2024-09-16 17:09:36 +08:00
/*
文件名:Lenheart_Event_Class.nut
路径:Base/UI/Lenheart_Event_Class.nut
创建日期:2024-08-11 09:47
文件用途:活动图标
*/
class LenheartNewUI_EventButton extends LenheartNewUI_CommonUi {
State = 0;
BaseIdx = 29;
DWidth = null;
Path = null;
Idx = null;
BindObj = null;
Timer = 0;
EffFlag = true;
ShowName = null;
constructor(X, Y, Path, Idx) {
this.DWidth = 20;
this.Path = Path;
this.Idx = Idx;
LenheartNewUI_CommonUi.constructor(X, Y, 20, 20);
Timer = Clock();
}
function SetFrame(gPath, gIdx) {
if (gPath) Path = gPath;
Idx = gIdx;
}
function Show(obj) {
T_DrawDynamicAni(obj, "common/yosinevent/eventsystemeff.ani", X, Y, "EventIcon" + ObjectId);
//不可用
if (State == 8) {
L_sq_DrawImg(Path, Idx + 3, X, Y + 1);
} else {
//按下
if (isLBDown) {
L_sq_DrawImg(Path, Idx + 1, X, Y);
}
//悬停
else if (isInRect) {
L_sq_DrawImg(Path, Idx, X, Y);
}
//普通
else {
L_sq_DrawImg(Path, Idx, X, Y);
}
}
}
//鼠标左键按下回调
function OnMouseLbDown(MousePos_X, MousePos_Y) {
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, X, Y, Width, Height)) isLBDown = true;
}
//鼠标左键弹起回调 overr
function OnMouseLbUp(MousePos_X, MousePos_Y) {
if (isLBDown && OnClick) {
local obj = sq_getMyCharacter();
obj.sq_PlaySound("CLICK_BUTTON1");
OnClick(this);
}
isLBDown = false;
}
}
class Rindro_Event extends LenheartNewUI_Windows {
//调试模式
// DeBugMode = true;
EventFlag = true;
//不是窗口
NoWindow = true;
//显示标志位
PosIdx = null;
//闪烁透明度
Alpha = 250;
//闪烁模式
BlinkMode = false;
//时间
Timer = 0;
//是否可见
Visible = true;
2025-05-27 21:24:22 +08:00
//主要Button
MainButton = null;
2024-09-16 17:09:36 +08:00
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
Childrens = [];
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
Timer = Clock();
}
//绘制主界面
function DrawMain(obj) {
local RT = Clock() - Timer;
//根据模式调整透明度
if (!BlinkMode) Alpha = sq_GetUniformVelocity(250, 130, RT, 500);
else Alpha = sq_GetUniformVelocity(130, 250, RT, 500);
//转换模式
if (RT >= 500) {
Timer = Clock();
BlinkMode = !BlinkMode;
}
L_sq_SetDrawImgModel(2, 0);
L_sq_DrawImg("interface2/yosin/eventsystemeff.img", 0, X, Y, 1, sq_RGBA(255, 255, 255, Alpha), 1.0, 1.0);
L_sq_ReleaseDrawImgModel();
}
function Show(obj) {
// DrawMain(obj);
// LenheartNewUI_Windows.Show(obj);
}
function EventShow(obj) {
DrawMain(obj);
LenheartNewUI_Windows.Show(obj);
}
function TopShow(obj) {
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, 20, 20)) {
2025-05-27 21:24:22 +08:00
local XposOffset = 0;
local Len = LenheartTextClass.GetStringLength(MainButton.ShowName);
local Count = ((Len - 10) / 15) + 1;
XposOffset = (-(10 + Count * 15) / 2) + 10;
L_sq_DrawImg("interface2/yosin/eventsystem.img", 0, X + XposOffset, Y - 24);
for (local i = 0; i< Count; i++) {
L_sq_DrawImg("interface2/yosin/eventsystem.img", 1, X + XposOffset + 5 + (15 * i), Y - 24);
2024-09-16 17:09:36 +08:00
}
2025-05-27 21:24:22 +08:00
L_sq_DrawImg("interface2/yosin/eventsystem.img", 2, X + XposOffset + 5 + (15 * Count), Y - 24);
L_sq_DrawCode(MainButton.ShowName, X - Len / 2 + 12, Y - 17, sq_RGBA(255, 255, 255, 250), 0, 1);
2024-09-16 17:09:36 +08:00
}
}
function SyncEventIcon() {
local Count = L_sq_RA(L_sq_RA(0x1A39C2C) + 0x6c);
X = EventList_Obj.X + (((Count + PosIdx) % 8) * 20);
Y = EventList_Obj.Y - ((Count + PosIdx) / 8) * 20;
}
//逻辑入口
function Proc(obj) {
//同步图标位置
SyncEventIcon();
LenheartNewUI_Windows.SyncPos(X, Y);
}
}
class Rindro_EventList {
X = 0;
Y = 0;
//活动数组
Events = null;
2025-05-27 21:24:22 +08:00
EventsMap = null;
2024-09-16 17:09:36 +08:00
function YosinEventIconInfoCallBack(Chunk) {
local Jso = Json.Decode(Chunk);
X = Jso.YosinEventIconInfoXpos;
Y = Jso.YosinEventIconInfoYpos;
getroottable()["LenheartEventOffset"] <- {
x = X - 456,
y = Y
};
2024-09-27 14:04:23 +08:00
L_sq_RefreshEventIcon();
2024-09-16 17:09:36 +08:00
}
constructor() {
Events = [];
2025-05-27 21:24:22 +08:00
EventsMap = {};
2024-09-16 17:09:36 +08:00
Pack_Control.rawset(30002, YosinEventIconInfoCallBack.bindenv(this));
}
//添加活动
function AddEvent(Name, Idx, WindowObject, ...) {
2025-05-27 21:24:22 +08:00
if (EventsMap.rawin(Name)) return EventsMap.rawget(Name);
2024-09-16 17:09:36 +08:00
local Window = LenheartNewUI_CreateWindow(Rindro_Event, Name, 0, 0, 20, 20, 0)
local Flag = Events.len();
local ImgPath = "interface2/yosin/eventsystemlist.img";
if (vargc == 1) ImgPath = vargv[0];
local ButtonBuf = LenheartNewUI_EventButton(0, 0, ImgPath, Idx);
ButtonBuf.BindObj = WindowObject;
ButtonBuf.ShowName = Name;
ButtonBuf.OnClick = function(B_obj) {
if (B_obj.BindObj) B_obj.BindObj.OpenCallBack();
}.bindenv(this);
Window.AddChild(ButtonBuf);
Window.PosIdx = Events.len();
2025-05-27 21:24:22 +08:00
Window.MainButton = ButtonBuf;
2024-09-16 17:09:36 +08:00
Events.append(Window);
2025-05-27 21:24:22 +08:00
EventsMap.rawset(Name, Window);
return Window;
2024-09-16 17:09:36 +08:00
}
//检测是否悬停活动图标
function CheckInEvent(MousePos_X, MousePos_Y) {
if (sq_GetPopupWindowMainCotrol(244)) return;
foreach(Window in Events) {
if (sq_IsIntersectRect(MousePos_X, MousePos_Y, 1, 1, Window.X, Window.Y, Window.Width, Window.Height)) {
getroottable().WindowsShowABFlag <- true;
}
}
}
}
getroottable().rawdelete("EventList_Obj")
function Lenheart_EventList_Fun(obj) {
local RootTab = getroottable();
if (!RootTab.rawin("EventList_Obj")) {
RootTab.rawset("EventList_Obj", Rindro_EventList());
}
}
//获取活动图标坐标 在活动图标变动时会被调用
function Sq_Get_Event_Pos_X() {
if (getroottable().rawin("LenheartEventOffset")) {
return getroottable()["LenheartEventOffset"].x;
} else {
getroottable()["LenheartEventOffset"] <- {
x = 277,
y = 530
};
return getroottable()["LenheartEventOffset"].x;
}
}
function Sq_Get_Event_Pos_Y() {
if (getroottable().rawin("LenheartEventOffset")) {
return getroottable()["LenheartEventOffset"].y;
} else {
getroottable()["LenheartEventOffset"] <- {
x = 277,
y = 530
};
return getroottable()["LenheartEventOffset"].y;
}
}
/*
//活动图标类
class Rindro_EventIcon extends LenheartNewUI_CommonUi {
//Key
Key = null;
//活动图标文字
EventStr = null;
//活动图标Ani编号
EventFrame = null;
//绑定对象
BandObject = null;
//图标img路径
ImgPath = "interface2/yosin/eventsystemlist.img";
x = null;
y = null;
constructor(gEventStr, gEventFrame, gKey, gBandObject) {
this.EventStr = gEventStr;
this.EventFrame = gEventFrame;
this.Key = gKey;
this.BandObject = gBandObject;
local RootTab = getroottable();
if (RootTab.rawin("YosinEventSystem")) {
local Arr = RootTab["YosinEventSystem"];
local TryAppend = true;
local wpos;
foreach(pos, value in Arr) {
if (value.Key == this.Key) {
TryAppend = false;
wpos = pos;
}
}
if (TryAppend) {
Arr.append(this);
RootTab.rawset("YosinEventSystem", Arr);
} else {
Arr[wpos] = this;
RootTab.rawset("YosinEventSystem", Arr);
}
} else {
local Arr = [];
Arr.append(this);
RootTab.rawset("YosinEventSystem", Arr);
}
}
function Show(obj, X, Y) {
x = X;
y = Y;
//绘制框
T_DrawDynamicAni(obj, "common/yosinevent/eventsystemeff.ani", X, Y, "YosinEventIconEffA");
try {
if (isLBDown()) {
//绘制活动图标
L_sq_DrawImg(ImgPath, EventFrame, X, Y + 1);
//T_DrawStayAni(obj, "common/yosinevent/eventsystemlist.ani", X, Y + 1, EventFrame, "YosinEventIconKey" + Key);
} else {
//绘制活动图标
L_sq_DrawImg(ImgPath, EventFrame, X, Y);
}
} catch (exception) {
if (isLBDown()) {
//绘制活动图标
T_DrawStayAni(obj, "common/yosinevent/eventsystemlist.ani", X, Y + 1, EventFrame, "YosinEventIconKey" + Key);
} else {
//绘制活动图标
T_DrawStayAni(obj, "common/yosinevent/eventsystemlist.ani", X, Y, EventFrame, "YosinEventIconKey" + Key);
}
}
}
function StrShow(obj, X, Y) {
//悬停
if (isInRect() && EventStr) {
local count = EventStr.len() / 3;
T_DrawStayAni(obj, "common/yosinevent/eventsystem.ani", X - (count * 7), Y - 24, 0, "YosinEventIconStrEffL");
for (local i = 0; i< count; i++) {
T_DrawStayAni(obj, "common/yosinevent/eventsystem.ani", X - (count * 7) + 5 + (i * 15), Y - 24, 1, "YosinEventIconStrEffZ");
}
T_DrawStayAni(obj, "common/yosinevent/eventsystem.ani", X - (count * 7) + 5 + (count * 15), Y - 24, 2, "YosinEventIconStrEffR");
L_sq_DrawCode(EventStr, X - (count * 4), Y - 17, sq_RGBA(255, 255, 255, 250), 0, 1);
}
if (isLBActive()) {
BandObject.MainState = true;
BandObject.OpenClassCallBack();
}
}
//悬停状态
function isInRect() {
if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, x, y, 20, 20)) return true;
else return false;
}
//左键按下状态
function isLBDown() {
if (isInRect() && Mobj.Lb == 1) return true;
else return false;
}
//左键弹起状态
function isLBUp() {
if (isInRect() && Mobj.Lb == 0) return true;
else return false;
}
//左键单击状态
function isLBActive() {
if (isInRect() && Mobj.LbEvent) return true;
else return false;
}
}
*/