226 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			226 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:DungeonRank.nut
 | |
| 路径:Plugins/DungeonRank/DungeonRank.nut
 | |
| 创建日期:2023-09-18	12:08
 | |
| 文件用途:副本排行
 | |
| */
 | |
| class DungeonRankWindow extends BasicsDrawTool {
 | |
|     //宽度
 | |
|     Width = null;
 | |
|     //高度
 | |
|     Height = null;
 | |
|     //标题高度
 | |
|     TitleH = null;
 | |
| 
 | |
|     //X坐标
 | |
|     X = null;
 | |
|     B_X = null;
 | |
|     //Y坐标
 | |
|     Y = null;
 | |
|     B_Y = null;
 | |
| 
 | |
|     YMouseSw = true;
 | |
|     DeBugMode = false;
 | |
| 
 | |
|     Mobj = null;
 | |
|     M_Xpos = null;
 | |
|     M_Ypos = null;
 | |
| 
 | |
| 
 | |
|     constructor(gX, gY, gWidth, gHeight, gTitleH) {
 | |
|         //宽度
 | |
|         Width = gWidth;
 | |
|         //高度
 | |
|         Height = gHeight;
 | |
|         //标题高度
 | |
|         TitleH = gTitleH;
 | |
| 
 | |
|         //X坐标
 | |
|         X = gX;
 | |
|         //Y坐标
 | |
|         Y = gY;
 | |
| 
 | |
|         if (getroottable().rawin("MouseObject")) Mobj = getroottable()["MouseObject"];
 | |
|     }
 | |
| 
 | |
|     //设定鼠标逻辑
 | |
|     function LockMouse() {
 | |
|         if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, Width, Height)) {
 | |
|             IMouse.LockMouseClick();
 | |
|             YMouseSw = false;
 | |
|         } else {
 | |
|             if (YMouseSw == false && sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, 0, 0, 800, 600)) {
 | |
|                 IMouse.ReleaseMouseClick();
 | |
|                 YMouseSw = true;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|     }
 | |
| 
 | |
|     //设定窗口拖动逻辑
 | |
|     function MoveWindow() {
 | |
|         if (sq_IsIntersectRect(IMouse.GetXPos(), IMouse.GetYPos(), 1, 1, X, Y, Width, TitleH)) {
 | |
| 
 | |
|             if (Mobj.Lb == 1) {
 | |
|                 if (!M_Xpos) M_Xpos = IMouse.GetXPos(); //原始鼠标位置数据
 | |
|                 if (!M_Ypos) M_Ypos = IMouse.GetYPos();
 | |
|                 if (!B_X) B_X = X; //原始窗口位置
 | |
|                 if (!B_Y) B_Y = Y;
 | |
| 
 | |
|                 X = B_X - (M_Xpos - IMouse.GetXPos());
 | |
|                 Y = B_Y - (M_Ypos - IMouse.GetYPos());
 | |
| 
 | |
|             } else if (Mobj.Lb == 0) {
 | |
|                 M_Xpos = null;
 | |
|                 M_Ypos = null;
 | |
|                 B_X = null;
 | |
|                 B_Y = null;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function Show(obj) {
 | |
|         if (DeBugMode) sq_DrawBox(X, Y, Width, Height, 0xffffffff);
 | |
| 
 | |
|         //设定鼠标逻辑
 | |
|         LockMouse();
 | |
| 
 | |
|         //设定窗口拖动逻辑
 | |
|         MoveWindow();
 | |
| 
 | |
|     }
 | |
| }
 | |
| 
 | |
| class DungeonRankC extends BasicsDrawTool {
 | |
|     WindowObj = null; //窗口对象
 | |
|     MainState = false; //主状态
 | |
|     X = 129;
 | |
|     Y = 20;
 | |
| 
 | |
|     Info = null;
 | |
| 
 | |
| 
 | |
|     function GetDungeonRankInfo() {
 | |
|         local T = {
 | |
|             op = 20054003,
 | |
|         };
 | |
|         SendPack(T);
 | |
|     }
 | |
| 
 | |
|     function GetDungeonRankInfoCallBack(Chunk) {
 | |
|         local Buffer = Json_STL("GetDungeonRankInfoCallBackBuffer");
 | |
|         Buffer.Parse(Chunk, 0, false);
 | |
|         Info = [];
 | |
| 
 | |
|         for (local i = 0; i< 10; i++) {
 | |
|             local gjob = Buffer.Get("DungeonS->" + i + "->job");
 | |
|             if (gjob) {
 | |
|                 local gdungeonTime = Buffer.Get("DungeonS->" + i + "->dungeonTime");
 | |
|                 local gname = Buffer.Get("DungeonS->" + i + "->name");
 | |
|                 local T = {
 | |
|                     Job = gjob,
 | |
|                     DungronTime = gdungeonTime,
 | |
|                     Name = gname,
 | |
|                 };
 | |
|                 Info.append(T);
 | |
|             }
 | |
|         }
 | |
|         /*
 | |
|         local RootTab = getroottable();
 | |
|         if (RootTab.rawin("CollectBooksCObj")) {
 | |
|             local Tobj = RootTab["CollectBooksCObj"];
 | |
|             Tobj.CollectAttributeObject = [];
 | |
|             for (local i = 0; i < 22; i++) {
 | |
|                 Tobj.CollectAttributeObject.append(Buffer.Get("buffs->" + i));
 | |
|             }
 | |
|         }
 | |
|         */
 | |
|     }
 | |
| 
 | |
|     constructor() {
 | |
| 
 | |
|         //注册获取收集信息回调
 | |
|         Pack_Control.rawset(20054004, GetDungeonRankInfoCallBack.bindenv(this));
 | |
|     }
 | |
| 
 | |
|     //绘制主界面
 | |
|     function DrawMain(obj) {
 | |
|         //绘制主界面
 | |
|         L_sq_DrawImg("dungeon/rankmain.img", 0, X, Y);
 | |
| 
 | |
|         L_sq_DrawCode("排名", X + 24, Y + 297, sq_RGBA(230, 200, 155, 250), 1, 1);
 | |
|         L_sq_DrawCode("玩家角色名", X + 24 + 98, Y + 297, sq_RGBA(230, 200, 155, 250), 1, 1);
 | |
|         L_sq_DrawCode("玩家职业", X + 24 + 98 + 152, Y + 297, sq_RGBA(230, 200, 155, 250), 1, 1);
 | |
|         L_sq_DrawCode("通关时间", X + 24 + 98 + 152 + 155, Y + 297, sq_RGBA(230, 200, 155, 250), 1, 1);
 | |
| 
 | |
|         if (Info) {
 | |
|             foreach(Pos, Value in Info) {
 | |
|                 L_sq_DrawCode("" + Pos, X + 32, Y + 316 + (Pos * 17), sq_RGBA(255, 247, 107, 250), 1, 1);
 | |
|                 L_sq_DrawCode("" + Value.Name, X + 32 + 98, Y + 316 + (Pos * 17), sq_RGBA(255, 247, 107, 250), 1, 1);
 | |
|                 L_sq_DrawCode("" + Value.Job, X + 32 + 98 + 152, Y + 316 + (Pos * 17), sq_RGBA(255, 247, 107, 250), 1, 1);
 | |
|                 L_sq_DrawCode("" + Value.DungronTime, X + 32 + 98 + 152 + 120, Y + 316 + (Pos * 17), sq_RGBA(255, 247, 107, 250), 1, 1);
 | |
|             }
 | |
| 
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //开启界面回调
 | |
|     function OpenClassCallBack() {
 | |
| 
 | |
|         L_NewWindows("Lenheart", 170, 0x65535);
 | |
|         local W = sq_GetPopupWindowMainCotrol(170);
 | |
|         W.SetVisible(false);
 | |
|         W.SetEnable(false);
 | |
| 
 | |
|         GetDungeonRankInfo();
 | |
|     }
 | |
| 
 | |
|     //绘制入口
 | |
|     function Draw(obj) {
 | |
|         if (MainState) {
 | |
|             if (WindowObj) {
 | |
|                 DrawMain(obj);
 | |
|                 WindowObj.Show(obj);
 | |
|                 X = WindowObj.X;
 | |
|                 Y = WindowObj.Y;
 | |
|             } else {
 | |
|                 WindowObj = DungeonRankWindow(X, Y, 542, 512, 28); //坐标 大小 标题栏高度
 | |
|                 // WindowObj.DeBugMode = true;
 | |
|             }
 | |
|         } else {
 | |
|             if (WindowObj && WindowObj.YMouseSw == false) {
 | |
|                 IMouse.ReleaseMouseClick();
 | |
|                 WindowObj.YMouseSw = true;
 | |
|                 WindowObj = null;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     //逻辑入口
 | |
|     function Proc(obj) {
 | |
|         if (KeyPressNB.isKeyPress(48, "DungeonRankCloseKey")) {
 | |
|             MainState = false;
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| function DungeonRank(obj) {
 | |
|     local RootTab = getroottable();
 | |
|     if (!RootTab.rawin("DungeonRankCObj")) {
 | |
|         local Cobj = DungeonRankC();
 | |
|         RootTab.rawset("DungeonRankCObj", Cobj);
 | |
|         EventIcon("副本排行", 55, 55, Cobj);
 | |
|     } else {
 | |
|         RootTab["DungeonRankCObj"].Proc(obj);
 | |
|         RootTab["DungeonRankCObj"].Draw(obj);
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| if (getroottable().rawin("LenheartFuncTab")) {
 | |
|     getroottable()["LenheartFuncTab"].rawset("DungeonRankFunc", DungeonRank);
 | |
| } else {
 | |
|     local T = {};
 | |
|     T.rawset("DungeonRankFunc", DungeonRank);
 | |
|     getroottable().rawset("LenheartFuncTab", T);
 | |
| } |