406 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
		
		
			
		
	
	
			406 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
|  | /* | ||
|  | 文件名:FiendwarHall.nut | ||
|  | 路径:Plugins/Fiendwar/FiendwarHall.nut | ||
|  | 创建日期:2024-03-11	12:54 | ||
|  | 文件用途:超时空之战大厅 | ||
|  | */ | ||
|  | class FiendwarHallC extends LenheartNewUI_Windows { | ||
|  | 
 | ||
|  |     // DeBugMode = true; | ||
|  | 
 | ||
|  |     WindowObj = null; //窗口对象 | ||
|  |     MainState = false; //主状态 | ||
|  |     X = 320; | ||
|  |     Y = 40; | ||
|  |     //默认显示状态需要是关闭 因为要通过按钮打开 | ||
|  |     Visible = false; | ||
|  |     //攻坚队List | ||
|  |     PartyList = null; | ||
|  | 
 | ||
|  | 
 | ||
|  |     function GetInstance() { | ||
|  |         return getroottable()["FiendwarHallCObj"]; | ||
|  |     } | ||
|  | 
 | ||
|  |     //获取所有队伍回调包 | ||
|  |     function GetAllTeamCallBack(Chunk) { | ||
|  |         local Jso = Json.Decode(Chunk); | ||
|  |         //清除原来的List PartyList可以直接清除  但是Childrens中的窗口需要调用底层方法清除队伍类 | ||
|  |         PartyList = []; | ||
|  |         // this.RemoveChilds(FiendwarHallPartyC); | ||
|  |         //遍历包构造攻坚队UI对象 | ||
|  |         foreach(TeamsSimple in Jso.TeamSimList) { | ||
|  |             local T = { | ||
|  |                 TeamId = TeamsSimple.TeamId.tostring(), | ||
|  |                 TeamName = TeamsSimple.TeamName, | ||
|  |                 TeamPlayerCount = TeamsSimple.TeamPlayerCount, | ||
|  |                 State = TeamsSimple.State | ||
|  |             } | ||
|  |             local TeamBuf = FiendwarHallPartyC(T); | ||
|  |             AddChild(TeamBuf); | ||
|  |             PartyList.append(TeamBuf); | ||
|  |         } | ||
|  |         //收到刷新队伍列表包时需要将队伍窗口关闭 | ||
|  |         if ("Close" in Jso) LenheartNewUI_DestoryWindow("超时空我的队伍窗口"); | ||
|  |         // RemoveChilds(FiendwarHallPartyC, false); | ||
|  |     } | ||
|  | 
 | ||
|  |     //获取攻坚队信息回调 | ||
|  |     function GetTeamInfoCallBack(Chunk) { | ||
|  |         // Sout("收到包 : \n %L", Chunk); | ||
|  | 
 | ||
|  |         local Jso = Json.Decode(Chunk); | ||
|  |         LenheartNewUI_DestoryWindow("超时空我的队伍窗口"); | ||
|  |         local Win = LenheartNewUI_CreateWindow(FiendwarPartyInfoC, "超时空我的队伍窗口", 430, 15, 354, 290, 18); | ||
|  |         FiendwarTotal.GetInstance().MyTeam = Win; | ||
|  |         Win.Visible = false; | ||
|  | 
 | ||
|  |         if (!("Close" in Jso)) { | ||
|  |             //开启队伍窗口显示 | ||
|  |             Win.Visible = true; | ||
|  |             //设置置顶 | ||
|  |             Win.ResetFocus(); | ||
|  |         } | ||
|  |         //清空成员对象集合 | ||
|  |         Win.MembersList = []; | ||
|  |         //清空是否为我的队伍状态 | ||
|  |         Win.IsMyTeam = false; | ||
|  |         //清空是否为队长状态 | ||
|  |         Win.IsCaptain = false; | ||
|  |         //赋值队伍名称 | ||
|  |         Win.TeamName = Jso.team.TeamName; | ||
|  |         //赋值队伍ID | ||
|  |         Win.TeamID = Jso.team.TeamId; | ||
|  |         //遍历Team包 用于构造队伍窗口中的每一位成员 | ||
|  |         foreach(_index, MemberObj in Jso.team.characNum) { | ||
|  |             //说明我在这个攻坚队里 | ||
|  |             if (Jso.cid == MemberObj.CID) { | ||
|  |                 Win.IsMyTeam = true; | ||
|  | 
 | ||
|  |                 local Fo = FiendwarTotal.GetInstance(); | ||
|  |                 //向全局类存入我的攻坚队伍ID | ||
|  |                 Fo.MyPartyId = Jso.team.TeamId; | ||
|  |                 //存入我的CID | ||
|  |                 Fo.MyCid = Jso.cid; | ||
|  |                 //说明是队长 | ||
|  |                 if (Jso.cid == Jso.team.captainCid) { | ||
|  |                     Win.IsCaptain = true; | ||
|  |                     //存入我是攻坚队队长 | ||
|  |                     Fo.IsCaptain = true; | ||
|  |                 } | ||
|  |             } | ||
|  |             local T = { | ||
|  |                 PartyId = Jso.team.TeamId, //攻坚队ID | ||
|  |                 TeamId = MemberObj.characNum + 1, //小队编号 | ||
|  |                 Level = MemberObj.PlayerLevel.tostring(), //等级 | ||
|  |                 Name = MemberObj.PlayerName, //名字 | ||
|  |                 JobName = MemberObj.PlayerGrowTypeJob, //职业名 | ||
|  |                 Job = MemberObj.PlayerJob, //职业编号 | ||
|  |                 StkHasFlag = MemberObj.isPrepare, //是否拥有攻坚材料 | ||
|  |                 EquVos = MemberObj.equVos, //装备List 用于显示头像 | ||
|  |                 Captain = MemberObj.CaptainBool, //是否为攻坚队队长 | ||
|  |                 Cid = MemberObj.CID, //Cid | ||
|  |                 OnlineState = MemberObj.onLineStart, //在线状态 | ||
|  |                 ExitTime = MemberObj.exitTime, //离队时间 | ||
|  |                 PlayerSession = MemberObj.PlayerSession, //玩家在世界中的Session 用于进行原生用户操作 | ||
|  |                 ClearanceCount = MemberObj.ClearanceCount, //通关次数 | ||
|  |                 ClearanceCountMax = Jso.ClearanceCountMax, //总通关次数 | ||
|  |             } | ||
|  |             //通过类构造并添加队伍成员UI对象 | ||
|  |             local TeamBuf = FiendwarPartyInfoMemberC(T); | ||
|  |             Win.AddChild(TeamBuf); | ||
|  |             Win.MembersList.append(TeamBuf); | ||
|  |         } | ||
|  | 
 | ||
|  |         //刷新界面 | ||
|  |         Win.RegisterWidget(); | ||
|  |         //刷新自己的界面 | ||
|  |         RegisterWidget(); | ||
|  |     } | ||
|  |     //获取所有队伍 | ||
|  |     function GetAllTeamCall() { | ||
|  |         local Jso = { | ||
|  |             op = 20063011 | ||
|  |         } | ||
|  |         SendPack(Jso); | ||
|  |     } | ||
|  |     //退出队伍回调 | ||
|  |     function ExitPartyCallBack(Chunk) { | ||
|  |         LenheartNewUI_DestoryWindow("超时空我的队伍窗口"); | ||
|  |         FiendwarTotal.GetInstance().ClearInfo(); | ||
|  | 
 | ||
|  |         local Win = LenheartNewUI_CreateWindow(FiendwarHallC, "超时空攻坚队伍列表", 320, 40, 478, 434, 18); | ||
|  |         Win.CloseWindow(); | ||
|  |         RegisterWidget(); | ||
|  |     } | ||
|  | 
 | ||
|  |     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) { | ||
|  |         Childrens = []; | ||
|  |         PartyList = []; | ||
|  | 
 | ||
|  |         //注册控件 | ||
|  |         RegisterWidget(); | ||
|  |         //注册回调包 | ||
|  |         Pack_Control.rawset(20063002, GetAllTeamCallBack.bindenv(this)); | ||
|  |         Pack_Control.rawset(20063004, GetTeamInfoCallBack.bindenv(this)); | ||
|  |         Pack_Control.rawset(20063008, ExitPartyCallBack.bindenv(this)); | ||
|  | 
 | ||
|  |         GetAllTeamCall(); | ||
|  | 
 | ||
|  |         LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH); | ||
|  |     } | ||
|  | 
 | ||
|  |     OnlyPreparingBtn = null; | ||
|  |     OnlyPreparingFlag = 1; | ||
|  |     InputObject = null; | ||
|  | 
 | ||
|  |     function RegisterWidget() { | ||
|  |         RemoveChilds(FiendwarHallPartyC, false); | ||
|  |         //关闭按钮 | ||
|  |         local CloseButton = LenheartNewUI_BaseButton(457, 0, 11, 12, "interface/lenheartwindowcommon.img", 276); | ||
|  |         CloseButton.OnClick = function() { | ||
|  |             CloseWindow(); | ||
|  |         }.bindenv(this); | ||
|  |         AddChild(CloseButton); | ||
|  | 
 | ||
|  |         //我的频道复选框 | ||
|  |         local MyChannelBtn = LenheartNewUI_SwitchButtonText(16, 30, "我的频道"); | ||
|  |         MyChannelBtn.State = 1; | ||
|  |         MyChannelBtn.ImgIndex = 358; | ||
|  |         MyChannelBtn.SetTextPos(12, 2); | ||
|  |         MyChannelBtn.Width = 76; | ||
|  |         MyChannelBtn.Height = 16; | ||
|  |         AddChild(MyChannelBtn); | ||
|  | 
 | ||
|  |         //只查看招募中的攻坚队 | ||
|  |         OnlyPreparingBtn = LenheartNewUI_SwitchButtonText(110, 30, "只查看招募中的攻坚队"); | ||
|  |         OnlyPreparingBtn.ImgIndex = 358; | ||
|  |         OnlyPreparingBtn.SetTextPos(12, 2); | ||
|  |         OnlyPreparingBtn.Width = 76; | ||
|  |         OnlyPreparingBtn.Height = 16; | ||
|  |         OnlyPreparingBtn.OnClick = function() { | ||
|  |             switch (OnlyPreparingFlag) { | ||
|  |                 case 0: | ||
|  |                     OnlyPreparingFlag = 1; | ||
|  |                     break; | ||
|  |                 case 1: | ||
|  |                     OnlyPreparingFlag = 0; | ||
|  |                     break; | ||
|  |             } | ||
|  |             OnlyPreparingBtn.State = OnlyPreparingFlag; | ||
|  |         }.bindenv(this); | ||
|  |         AddChild(OnlyPreparingBtn); | ||
|  | 
 | ||
|  |         //搜索队伍输入框 | ||
|  |         InputObject = LenheartNewUI_BaseInput(260, 31, 80, 20); | ||
|  |         AddChild(InputObject); | ||
|  | 
 | ||
|  |         //搜索按钮 | ||
|  |         local FindButton = LenheartNewUI_ButtonText(348, 28, 5, "搜索"); | ||
|  |         FindButton.SetTextOffset(0, 1); | ||
|  |         FindButton.OnClick = function() { | ||
|  |             if (InputObject.str.len() > 0) { | ||
|  | 
 | ||
|  |             } | ||
|  |         }.bindenv(this); | ||
|  |         AddChild(FindButton); | ||
|  | 
 | ||
|  |         //重置按钮 | ||
|  |         local ResetButton = LenheartNewUI_ButtonText(408, 28, 5, "重置"); | ||
|  |         ResetButton.SetTextOffset(0, 1); | ||
|  |         ResetButton.OnClick = function() { | ||
|  |             InputObject.str = ""; | ||
|  |         }.bindenv(this); | ||
|  |         AddChild(ResetButton); | ||
|  | 
 | ||
|  |         //编号按钮 | ||
|  |         local ModelButton = LenheartNewUI_ButtonText(9, 56, -18, "编号"); | ||
|  |         ModelButton.Idx = 163; | ||
|  |         ModelButton.DWidth = -8; | ||
|  |         ModelButton.SetTextOffset(-9, 1); | ||
|  |         AddChild(ModelButton); | ||
|  | 
 | ||
|  |         //状态按钮 | ||
|  |         local StateButton = LenheartNewUI_ButtonText(51, 56, -18, "状态"); | ||
|  |         StateButton.Idx = 163; | ||
|  |         StateButton.DWidth = -8; | ||
|  |         StateButton.SetTextOffset(-9, 1); | ||
|  |         AddChild(StateButton); | ||
|  | 
 | ||
|  |         //频道按钮 | ||
|  |         local ChannelButton = LenheartNewUI_ButtonText(93, 56, -18, "频道"); | ||
|  |         ChannelButton.Idx = 163; | ||
|  |         ChannelButton.DWidth = -8; | ||
|  |         ChannelButton.SetTextOffset(-9, 1); | ||
|  |         AddChild(ChannelButton); | ||
|  | 
 | ||
|  |         //攻坚队名称按钮 | ||
|  |         local PartyNameButton = LenheartNewUI_ButtonText(135, 56, 100, "攻坚队名称"); | ||
|  |         PartyNameButton.Idx = 163; | ||
|  |         PartyNameButton.DWidth = 223; | ||
|  |         PartyNameButton.FillWidth = 1; | ||
|  |         PartyNameButton.FirstWidth = 21; | ||
|  |         PartyNameButton.SetTextOffset(26, 1); | ||
|  |         AddChild(PartyNameButton); | ||
|  | 
 | ||
|  |         //阶段按钮 | ||
|  |         local StageButton = LenheartNewUI_ButtonText(289, 56, 52, "阶段"); | ||
|  |         StageButton.Idx = 163; | ||
|  |         StageButton.DWidth = 140; | ||
|  |         StageButton.FillWidth = 1; | ||
|  |         StageButton.FirstWidth = 21; | ||
|  |         StageButton.SetTextOffset(26, 1); | ||
|  |         AddChild(StageButton); | ||
|  | 
 | ||
|  |         //队员数量按钮 | ||
|  |         local TeammembersButton = LenheartNewUI_ButtonText(402, 56, 50, "队员数量"); | ||
|  |         TeammembersButton.Idx = 163; | ||
|  |         TeammembersButton.FillWidth = 1; | ||
|  |         TeammembersButton.FirstWidth = 21; | ||
|  |         TeammembersButton.DWidth = 47; | ||
|  |         TeammembersButton.SetTextOffset(-8, 1); | ||
|  |         AddChild(TeammembersButton); | ||
|  | 
 | ||
|  |         //创建攻坚队按钮 | ||
|  |         local CreateOrMyPartyStr = "创建攻坚队"; | ||
|  |         if (FiendwarTotal.GetInstance().MyPartyId) CreateOrMyPartyStr = "我的攻坚队"; | ||
|  |         local MyPartyButton = LenheartNewUI_ButtonText(15, 395, 30, CreateOrMyPartyStr); | ||
|  |         MyPartyButton.SetTextOffset(-6, 1); | ||
|  |         MyPartyButton.OnClick = function() { | ||
|  |             if (FiendwarTotal.GetInstance().MyPartyId) { | ||
|  |                 //发送查看攻坚队具体信息包 | ||
|  |                 local T = { | ||
|  |                     op = 20063013, | ||
|  |                     teamsId = FiendwarTotal.GetInstance().MyPartyId | ||
|  |                 } | ||
|  |                 Rindro_BaseToolClass.SendPackEx(T); | ||
|  |             } else { | ||
|  |                 local Win = LenheartNewUI_CreateWindow(FiendwarHallCreatePartyC, "超时空创建队伍窗口", 290, 220, 284, 154, 18); | ||
|  |                 Win.Visible = true; | ||
|  |                 Win.ResetFocus(); | ||
|  |             } | ||
|  |         }.bindenv(this); | ||
|  |         AddChild(MyPartyButton); | ||
|  | 
 | ||
|  |         //左翻页按钮 | ||
|  |         local LeftButton = LenheartNewUI_BaseButton(160, 400, 15, 15, "interface/lenheartwindowcommon.img", 34); | ||
|  |         LeftButton.OnClick = function() { | ||
|  |             if (Page > 0) Page--; | ||
|  |         }.bindenv(this); | ||
|  |         AddChild(LeftButton); | ||
|  | 
 | ||
|  |         //右翻页按钮 | ||
|  |         local RightButton = LenheartNewUI_BaseButton(220, 400, 15, 15, "interface/lenheartwindowcommon.img", 38); | ||
|  |         RightButton.OnClick = function() { | ||
|  |             if (Page<(((PartyList.len() / PageMaxCount)))) Page++; | ||
|  |         }.bindenv(this); | ||
|  |         AddChild(RightButton); | ||
|  | 
 | ||
|  |         //进入待机按钮 | ||
|  |         local FQButton = LenheartNewUI_ButtonText(300, 394, 20, "进入待机"); | ||
|  |         FQButton.SetTextOffset(-5, 2); | ||
|  |         FQButton.State = 8; | ||
|  |         AddChild(FQButton); | ||
|  | 
 | ||
|  |         //刷新按钮 | ||
|  |         local RefreshButton = LenheartNewUI_BaseButton(410, 395, 25, 25, "interface/lenheartwindowcommon.img", 366); | ||
|  |         RefreshButton.OnClick = function() { | ||
|  |             GetAllTeamCall(); | ||
|  |         }.bindenv(this); | ||
|  |         AddChild(RefreshButton); | ||
|  | 
 | ||
|  |         //设置按钮 | ||
|  |         local SettingButton = LenheartNewUI_BaseButton(440, 394, 15, 15, "interface/lenheartwindowcommon.img", 362); | ||
|  |         SettingButton.State = 8; | ||
|  |         AddChild(SettingButton); | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     function DrawMainBackGround(obj) { | ||
|  |         //Item信息框一般为211的宽度 | ||
|  |         L_sq_DrawWindow(X, Y + 10, 540 * 0.85, 420 * 0.9, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13); | ||
|  | 
 | ||
|  |         L_sq_DrawWindow(X + 6, Y + 19, 528 * 0.85, 47, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13); | ||
|  | 
 | ||
|  |         //绘制背景框标题栏 | ||
|  |         L_sq_DrawImg("hud/fiendwarl.img", 3, X + 1, Y); | ||
|  | 
 | ||
|  |         L_sq_DrawCode("寻找攻坚队", X + 217, Y + 3, sq_RGBA(179, 169, 135, 255), 0, 1); | ||
|  | 
 | ||
|  |         //绘制队伍List | ||
|  |         DrawPartyList(obj); | ||
|  | 
 | ||
|  |         L_sq_DrawWindow(X + 6, Y + 382, 528 * 0.85, 24, "interface/lenheartwindowcommon.img", 97, 11, 12, 11, 13); | ||
|  | 
 | ||
|  |         //计算页数 | ||
|  |         local PageStr = Page + 1 + " / " + ((PartyList.len() / PageMaxCount) + 1); | ||
|  |         //绘制当前页数 | ||
|  |         L_sq_DrawCode(PageStr, X + 166 + LenheartTextClass.GetStringLength(PageStr) / 2, Y + 402, sq_RGBA(134, 120, 79, 255), 0, 1); | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     Page = 0; | ||
|  |     PageMaxCount = 13; | ||
|  |     //绘制队伍信息 | ||
|  |     function DrawPartyList(obj) { | ||
|  |         if (PartyList.len() <= 0) return; | ||
|  |         //先遍历一遍全部挪走 | ||
|  |         foreach(Index, TeamObj in PartyList) { | ||
|  |             TeamObj.SyncPos(9999, 9999); | ||
|  |         } | ||
|  |         //在遍历需要显示的同步坐标 | ||
|  |         foreach(Index, TeamObj in PartyList.slice((((Page) * PageMaxCount) > 0) ? ((Page) * PageMaxCount) : 0, ((Page + 1) * PageMaxCount) > PartyList.len() ? PartyList.len() : ((Page + 1) * PageMaxCount))) { | ||
|  |             TeamObj.SyncPos(X, Y + 2 + (Index % PageMaxCount) * 23); | ||
|  |             // TeamObj.Show(); | ||
|  |         } | ||
|  |     } | ||
|  | 
 | ||
|  |     //绘制主界面 | ||
|  |     function DrawMain(obj) { | ||
|  |         DrawMainBackGround(obj); | ||
|  |     } | ||
|  | 
 | ||
|  |     //绘制入口 | ||
|  |     function Show(obj) { | ||
|  |         DrawMain(obj); | ||
|  |         LenheartNewUI_Windows.Show(obj); | ||
|  |     } | ||
|  | 
 | ||
|  | 
 | ||
|  |     MainButton = null; | ||
|  |     //逻辑入口 | ||
|  |     function Proc(obj) { | ||
|  |         //界面未打开 | ||
|  |         if (!this.Visible && L_sq_RA(0x1A5FB4C, "0x14+0x28+")< 2) { | ||
|  |             //在甲板 | ||
|  |             if (FiendwarTotal.GetInstance().BaseConfig && FiendwarTotal.GetInstance().BaseConfig.channel_index.find("20") && L_sq_GetTownIndex() == FiendwarTotal.GetInstance().BaseConfig.town_index && L_sq_GetRegionIndex() >= 1) { | ||
|  |                 local PaW = sq_GetPopupWindowMainCotrol(6); | ||
|  |                 if (PaW) { | ||
|  |                     L_sq_UseSkill(DIK_ESCAPE); | ||
|  |                     this.Visible = true; | ||
|  |                     GetAllTeamCall(); | ||
|  |                 } | ||
|  |             } | ||
|  |         } | ||
|  | 
 | ||
|  |         LenheartNewUI_Windows.SyncPos(X, Y); | ||
|  |     } | ||
|  | 
 | ||
|  |     //鼠标滚轮时间回调 | ||
|  |     function OnMouseWheel(Flag, MousePos_X, MousePos_Y) { | ||
|  | 
 | ||
|  |         switch (Flag) { | ||
|  |             //下 | ||
|  |             case 0: { | ||
|  |                 if (Page<(((PartyList.len() / PageMaxCount)))) Page++; | ||
|  |                 break; | ||
|  |             } | ||
|  |             //上 | ||
|  |             case 1: { | ||
|  |                 if (Page > 0) Page--; | ||
|  |                 break; | ||
|  |             } | ||
|  |         } | ||
|  |         LenheartNewUI_Windows.OnMouseWheel(Flag, MousePos_X, MousePos_Y); | ||
|  |     } | ||
|  | } |