111
This commit is contained in:
139
Project/OnlineAnnouncement/OnlineAnnouncement.nut
Normal file
139
Project/OnlineAnnouncement/OnlineAnnouncement.nut
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
文件名:OnlineAnnouncement.nut
|
||||
路径:Project/OnlineAnnouncement/OnlineAnnouncement.nut
|
||||
创建日期:2024-08-24 23:15
|
||||
文件用途:上线公告
|
||||
*/
|
||||
class OnlineAnnouncementC extends LenheartNewUI_Windows {
|
||||
//调试模式
|
||||
// DeBugMode = true;
|
||||
|
||||
//不是窗口
|
||||
NoWindow = true;
|
||||
|
||||
//是否可见
|
||||
// Visible = false;
|
||||
|
||||
//公告数组
|
||||
NotiArr = null;
|
||||
//包时间
|
||||
Timer = null;
|
||||
|
||||
//收到信息包
|
||||
function LaunchAnnouncementCallBack(Chunk) {
|
||||
local Jso = Json.Decode(Chunk).announ;
|
||||
local T = {
|
||||
NotiStrR = Jso["NotiStrR"],
|
||||
NotiStrG = Jso["NotiStrG"],
|
||||
NotiStrB = Jso["NotiStrB"],
|
||||
NotiStrA = Jso["NotiStrA"],
|
||||
NotiStrXpos = Jso["NotiStrXpos"],
|
||||
NotiStrYpos = Jso["NotiStrYpos"],
|
||||
//对应的话语
|
||||
NotiStr = Jso["NotiStr"],
|
||||
//对应话语渐入时间
|
||||
NotiStrUpTime = Jso["NotiStrUpTime"],
|
||||
//对应话语显示时间
|
||||
NotiStrPrintTime = Jso["NotiStrPrintTime"],
|
||||
//对应话语渐出时间
|
||||
NotiStrDownTime = Jso["NotiStrDownTime"],
|
||||
//对应出现的Img路径
|
||||
ImgPath = Jso["ImgPath"],
|
||||
//对应出现的Img帧数
|
||||
ImgFrame = Jso["ImgFrame"],
|
||||
ImgXpos = Jso["ImgXpos"],
|
||||
ImgYpos = Jso["ImgYpos"],
|
||||
//对应出现的Img渐入时间
|
||||
ImgUpTime = Jso["ImgUpTime"],
|
||||
//对应出现的Img渐出时间
|
||||
ImgDownTime = Jso["ImgDownTime"],
|
||||
}
|
||||
NotiArr.append(T);
|
||||
}
|
||||
|
||||
constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
|
||||
Childrens = [];
|
||||
NotiArr = [];
|
||||
//注册控件
|
||||
RegisterWidget();
|
||||
|
||||
LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
|
||||
|
||||
//回包
|
||||
Pack_Control.rawset(20075002, LaunchAnnouncementCallBack.bindenv(this));
|
||||
}
|
||||
|
||||
function RegisterWidget() {
|
||||
// //关闭按钮
|
||||
// local CloseButton = LenheartNewUI_BaseButton(278, 0, 11, 12, "interface/lenheartwindowcommon.img", 276);
|
||||
// CloseButton.OnClick = function() {
|
||||
// this.Visible = false;
|
||||
// }.bindenv(this);
|
||||
// Childrens.append(CloseButton);
|
||||
|
||||
}
|
||||
|
||||
//绘制主界面
|
||||
function DrawMain(obj) {
|
||||
if (NotiArr.len() > 0) {
|
||||
if (Timer == null) Timer = Clock();
|
||||
local T = NotiArr[0];
|
||||
local RealT = Clock() - Timer;
|
||||
|
||||
local Ani = null;
|
||||
if (T.ImgFrame == 99999999) {
|
||||
Ani = T_DrawDynamicAni(obj, T.ImgPath, T.ImgXpos, T.ImgYpos, T.ImgPath);
|
||||
}
|
||||
|
||||
//播放完成
|
||||
if (RealT >= (T.NotiStrPrintTime + T.NotiStrUpTime + T.NotiStrDownTime)) {
|
||||
NotiArr.remove(0);
|
||||
Timer = null;
|
||||
if (Ani) sq_Rewind(Ani);
|
||||
return;
|
||||
}
|
||||
|
||||
local AlaphValue;
|
||||
//如果时间小于 文字渐入时间
|
||||
if (RealT <= T.NotiStrUpTime) {
|
||||
AlaphValue = sq_GetUniformVelocity(0, T.NotiStrA, RealT, T.NotiStrUpTime);
|
||||
}
|
||||
if (RealT > T.NotiStrUpTime && RealT <= (T.NotiStrPrintTime + T.NotiStrUpTime)) {
|
||||
AlaphValue = T.NotiStrA;
|
||||
}
|
||||
if (RealT > (T.NotiStrPrintTime + T.NotiStrUpTime) && RealT <= (T.NotiStrPrintTime + T.NotiStrUpTime + T.NotiStrDownTime)) {
|
||||
AlaphValue = sq_GetUniformVelocity(T.NotiStrA, 0, RealT, (T.NotiStrPrintTime + T.NotiStrUpTime + T.NotiStrDownTime));
|
||||
}
|
||||
|
||||
local RgbaValue = sq_RGBA(T.NotiStrR, T.NotiStrG, T.NotiStrB, AlaphValue);
|
||||
L_sq_DrawCode(T.NotiStr, T.NotiStrXpos, T.NotiStrYpos, RgbaValue, 1, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function Show(obj) {
|
||||
LenheartNewUI_Windows.Show(obj);
|
||||
|
||||
}
|
||||
|
||||
function TopShow(obj) {
|
||||
DrawMain(obj);
|
||||
}
|
||||
|
||||
//逻辑入口
|
||||
function Proc(obj) {
|
||||
LenheartNewUI_Windows.SyncPos(X, Y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function Lenheart_OnlineAnnouncement_Fun(obj) {
|
||||
local RootTab = getroottable();
|
||||
if (!RootTab.rawin("OnlineAnnouncement_Obj")) {
|
||||
RootTab.rawset("OnlineAnnouncement_Obj", true);
|
||||
LenheartNewUI_CreateWindow(OnlineAnnouncementC, "上线公告窗口", 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
getroottable()["LenheartFuncTab"].rawset("OnlineAnnouncementFuncN", Lenheart_OnlineAnnouncement_Fun);
|
||||
Reference in New Issue
Block a user