/* 文件名:SignIn.nut 路径:Plugins/SignIn/SignIn.nut 创建日期:2023-05-06 15:28 文件用途: */ //HudPro按钮类 class SIGNINButtonPro extends BasicsDrawTool // obj -- 按钮名称 -- X坐标 -- Y坐标 -- Ani调用路径 -- 宽度 -- 高度 { obj = null; //Obj对象 State = 0; //按钮状态 ClickEnble = false; //点击效果 ButtonDynamic = false; //动态按钮效果 BaseFrame = null; CustomClickEnble = false; //自定义点击效果 CustomClickAnifile = null; //自定义点击效果Ani路径 CustomButtonName = null; //自定义点击效果名称 CustomClickFrame = null; //自定义点击效果Ani编号 CustomClickx = null; //自定义点击效果X坐标 CustomClicky = null; //自定义点击效果Y坐标 RectEnble = false; //悬停效果 RectButtonName = null; //悬停名称 RectBaseAnifile = null; //悬停Ani路径 RectFrame = null; //非动态按钮的悬停调用Ani编号 Rectx = null; //悬停X坐标 Recty = null; //悬停Y坐标 ButtonName = null; //按钮名称 x = null; //X坐标 y = null; //Y坐标 BaseAnifile = null; //调用Ani路径 width = null; //可点击宽度 length = null; //可点击高度 Mobj = null; //鼠标对象 //构造函数 constructor(gObj, gButtonName, gX, gY, gAnifile, gWidth, gLength, gBaseFrame) { obj = gObj; ButtonName = gButtonName; x = gX; y = gY; BaseAnifile = gAnifile; width = gWidth; length = gLength; BaseFrame = gBaseFrame; if (getroottable().rawin("MouseObject")) Mobj = getroottable()["MouseObject"]; } //绘制按钮 function Show() { if (ClickEnble) //是否开启点击效果 { if (isLBDown() && State == 0) //按下左键并且按钮处于弹起状态 { State = 1; //按键进入按下状态 ++y; } if (!isLBDown() && State == 1) //按下左键并且按钮处于弹起状态 { State = 0; //按键进入弹起状态 --y; } } if (CustomClickEnble) //是否开启自定义点击效果 { if (isLBDown()) //按下左键并且按钮处于弹起状态 { if (!ButtonDynamic) T_DrawStayAni(obj, CustomClickAnifile, CustomClickx, CustomClicky, CustomClickFrame, CustomButtonName); else T_DrawDynamicAni(obj, CustomClickAnifile, CustomClickx, CustomClicky, CustomButtonName); } } if (RectEnble) //开启悬停效果时 { if ((isInRect() && !isLBDown()) || (isInRect() && !CustomClickEnble)) //如果鼠标悬停的时候 并且没有点击的时候 { //IMouse.SetMouseTask(44); if (!ButtonDynamic) T_DrawStayAni(obj, RectBaseAnifile, Rectx, Recty, RectFrame, RectButtonName); else T_DrawDynamicAni(obj, RectBaseAnifile, Rectx, Recty, RectButtonName); } } if (!isInRect()) //如果鼠标没有悬停的时候 { //IMouse.SetMouseTask(0); if (!ButtonDynamic) T_DrawStayAni(obj, BaseAnifile, x, y, BaseFrame, ButtonName); else T_DrawDynamicAni(obj, BaseAnifile, x, y, ButtonName); } } //设置自定义点击效果 function SetCustomClickEnble(bool, gButtonName, gX, gY, gAnifile, gFrame) { CustomClickEnble = bool; //自定义点击效果 CustomClickAnifile = gAnifile; //自定义点击效果Ani路径 CustomButtonName = gButtonName; //自定义点击效果名称 CustomClickFrame = gFrame; //自定义点击效果Ani编号 CustomClickx = gX; //自定义点击效果X坐标 CustomClicky = gY; //自定义点击效果Y坐标 } //设置悬停效果 function SetRectEnble(bool, gButtonName, gX, gY, gAnifile, gFrame) { RectEnble = bool; //悬停效果 RectButtonName = gButtonName; //悬停名称 RectBaseAnifile = gAnifile; //悬停Ani路径 RectFrame = gFrame; //非动态按钮的悬停调用Ani编号 Rectx = gX; //悬停X坐标 Recty = gY; //悬停Y坐标 } //设置动态按钮 function SetClickEnble(bool) { ButtonDynamic = bool; } //设置点击效果 function SetClickEnble(bool) { ClickEnble = bool; } //悬停状态 function isInRect() { if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 5, 5, x, y, width, length)) 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; } } class SIGNINC extends BasicsDrawTool { WindowObj = null; //窗口对象 MainState = false; //主状态 X = 124; Y = 66; NowClearanceCount = 0; RewardDayCount = 0; TodayState = 0; ExSignDate = null; BaseItemArr = null; ExItemArr = null; //ItemInfo ItemInfoObject = null; ItemInfoDrawS = null; //查询玩家信息 function CheckPlayerInfo() { local T = { op = 20051001, } local str = Json.Encode(T); L_sq_SendPackType(130); L_sq_SendPackWChar(str); L_sq_SendPack(); } //玩家信息收包回调 function CheckPlayerInfoCallBack(Chunk) { // Sout("收到包内容为 \n %L", Chunk); local Buffer = Json_STL("SignIn_Item_CheckPlayerInfo_CallBack"); Buffer.Parse(Chunk, 0, false); local RootTab = getroottable(); if (RootTab.rawin("SIGNINCObj")) { //通关次数 NowClearanceCount = Buffer.Get("PlayerInfo->NowClearanceCount"); //已签到天数 RewardDayCount = Buffer.Get("PlayerInfo->RewardDayCount"); //今日是否签到 TodayState = Buffer.Get("PlayerInfo->TodayState"); //特殊签到天数信息 ExSignDate = null; ExSignDate = []; for (local q = 0; q< 3; q++) { ExSignDate.append(Buffer.Get("ExSignDate->" + q)); } //常规道具数组 BaseItemArr = null; BaseItemArr = []; for (local i = 0; i< 28; i++) { local a = Buffer.Get("BaseItemArr->" + i + "->id"); local b = Buffer.Get("BaseItemArr->" + i + "->num"); local T = { id = a, count = b, } BaseItemArr.append(T); } //特殊道具数组 ExItemArr = null; ExItemArr = []; for (local z = 0; z< 3; z++) { local a = Buffer.Get("ExItemArr->" + z + "->id"); local b = Buffer.Get("ExItemArr->" + z + "->num"); local T = { id = a, count = b, } ExItemArr.append(T); } local ItemGetArray = {}; foreach(P, V in BaseItemArr) { local ItemId = V.id; if (!ItemInfoObject.rawin(ItemId)) { if (!ItemGetArray.rawin(ItemId)) ItemGetArray.rawset(ItemId, true); } } foreach(P, V in ExItemArr) { local ItemId = V.id; if (!ItemInfoObject.rawin(ItemId)) { if (!ItemGetArray.rawin(ItemId)) ItemGetArray.rawset(ItemId, true); } } if (ItemGetArray.len() > 0) { local arr = []; foreach(Key, Value in ItemGetArray) { arr.append(Key); } local T = { op = 20231010, realop = 20051004, itemId = arr, Type = 2, } SendPack(T); } } } function CheckItemInfoCallBack(Chunk) { local Jso = Json.Decode(Chunk); foreach(Pos, Value in Jso.itemInfo) { if (Value.Name2.len() == 0) Value.Name2 = "Yosin-Team"; ItemInfoObject.rawset(Jso.itemId[Pos], Value); } } constructor() { //查询玩家信息回调 Pack_Control.rawset(20051002, CheckPlayerInfoCallBack.bindenv(this)); //查询道具信息回调 Pack_Control.rawset(20051004, CheckItemInfoCallBack.bindenv(this)); ItemInfoObject = {}; //查询玩家信息 CheckPlayerInfo(); } //绘制道具带道具信息 function DrawItemEx(X, Y, Id, Count) { L_Sq_DrawItem(X, Y, Id, Count, 0, 0, 0); if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, 24, 24)) { ItemInfoDrawS = {}; ItemInfoDrawS.X <- X; ItemInfoDrawS.Y <- Y; ItemInfoDrawS.ItemId <- Id; } } //绘制道具相信信息 ItemObject = null; function DrawItemInfo(obj) { if (ItemInfoDrawS) { if (!ItemObject) { local ItemId = ItemInfoDrawS.ItemId; if (ItemInfoObject.rawin(ItemId)) { ItemObject = ItemInfoClass(ItemInfoObject[ItemId]); } } ItemObject.Show(ItemInfoDrawS.X, ItemInfoDrawS.Y - ItemObject.PageLength); } else { ItemObject = null; } } //绘制主界面 function DrawMain(obj) { //主界面背景框 T_DrawStayAni(obj, "common/signin/main.ani", X - 6, Y - 28, 9, "SignInSystemMainBackGround"); //主界面背景 T_DrawStayAni(obj, "common/signin/main.ani", X, Y, 0, "SignInSystemMain"); //通关次数Max T_DrawStayAni(obj, "common/signin/main.ani", X + 194, Y + 101, 4, "SignInSystemMainMax"); //当前通关次数 T_DrawStayAni(obj, "common/signin/main.ani", X + 167, Y + 101, NowClearanceCount + 2, "SignInSystemMainNow"); ItemInfoDrawS = null; //绘制奖励道具 if (BaseItemArr) { for (local z = 0; z< 28; z++) { local Item = BaseItemArr[z]; DrawItemEx(X + 22 + ((z % 7) * 55), Y + 154 + ((z / 7) * 65), Item.id, Item.count); } } if (ExItemArr) { for (local y = 0; y< 3; y++) { local Item = ExItemArr[y]; DrawItemEx(X + 457, Y + 166 + (y * 72), Item.id, Item.count); } } if (TodayState == 0 && NowClearanceCount == 2) { local Button = SIGNINButtonPro(obj, "SignIn", X + 401, Y + 397, "common/signin/main.ani", 140, 40, 5); Button.SetRectEnble(true, "SignInr", X + 401, Y + 397, "common/signin/main.ani", 6); Button.SetCustomClickEnble(true, "SignInc", X + 401, Y + 397, "common/signin/main.ani", 7); Button.Show(); //签到按钮按下 if (Button.isLBActive()) { local T = { op = 20051005, } local str = Json.Encode(T); L_sq_SendPackType(130); L_sq_SendPackWChar(str); L_sq_SendPack(); } } //签到绘制标签 for (local i = 0; i< RewardDayCount; i++) { T_DrawStayAni(obj, "common/signin/main.ani", X + 13 + ((i % 7) * 55), Y + 145 + ((i / 7) * 66), 1, "SignInSystemMainSignDay" + i); for (local p = 0; p< 3; p++) { if (i == ExSignDate[p] - 1) { T_DrawStayAni(obj, "common/signin/main.ani", X + 450, Y + 159 + (p * 72), 1, "SignInSystemMainSignDay" + i + p); } } } //绘制累计签到日期 if (ExSignDate) { for (local r = 0; r< 3; r++) { local Date = ExSignDate[r]; local len = Date.tostring().len(); if (len == 1) { T_DrawStayAni(obj, "common/signin/num.ani", X + 484, Y + 144 + (r * 72), Date, "SignInSystemMainExSignDay" + r); } else { T_DrawStayAni(obj, "common/signin/num.ani", X + 480, Y + 144 + (r * 72), Date.tostring().slice(0, 1).tointeger(), "SignInSystemMainExSignDay" + r); T_DrawStayAni(obj, "common/signin/num.ani", X + 488, Y + 144 + (r * 72), Date.tostring().slice(1, 2).tointeger(), "SignInSystemMainExSignDay" + r); } } } } function OpenClassCallBack() { L_NewWindows("Lenheart", 170, 0x65535); local W = sq_GetPopupWindowMainCotrol(170); W.SetVisible(false); W.SetEnable(false); //查询玩家信息 CheckPlayerInfo(); } function Draw(obj) { if (MainState) { if (WindowObj) { DrawMain(obj); WindowObj.Show(obj); X = WindowObj.X + 6; Y = WindowObj.Y + 28; DrawItemInfo(obj); } else { WindowObj = LenheartWindow(X - 6, Y - 28, 631 - 70, 535 - 48, 28); //坐标 大小 标题栏高度 //WindowObj.DeBugMode = true; } } else { if (WindowObj && WindowObj.YMouseSw == false) { IMouse.ReleaseMouseClick(); WindowObj.YMouseSw = true; WindowObj = null; } } } function Proc(obj) { if (KeyPressNB.isKeyPress(48, "SignIn")) { MainState = false; } } } function SignIn_New_Lenheart(obj) { local RootTab = getroottable(); if (!RootTab.rawin("SIGNINCObj")) { local Cobj = SIGNINC(); RootTab.rawset("SIGNINCObj", Cobj); EventIcon("签到活动", 91, 1, Cobj); } else { RootTab["SIGNINCObj"].Proc(obj); RootTab["SIGNINCObj"].Draw(obj); } } if (getroottable().rawin("LenheartFuncTab")) { getroottable()["LenheartFuncTab"].rawset("SignIn_New_LenheartFunc", SignIn_New_Lenheart); } else { local T = {}; T.rawset("SignIn_New_LenheartFunc", SignIn_New_Lenheart); getroottable().rawset("LenheartFuncTab", T); }