445 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			445 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| /*
 | |
| 文件名:FiendwarHall.nut
 | |
| 路径:Plugins/Fiendwar/FiendwarHall.nut
 | |
| 创建日期:2024-03-11	12:54
 | |
| 文件用途:超时空之战大厅
 | |
| */
 | |
| 
 | |
| class FiendwarHallTeamC extends LenheartNewUI_CommonUi {
 | |
|     X = 0;
 | |
|     Y = 0;
 | |
|     Width = null;
 | |
|     Height = null;
 | |
|     TeamObj = null;
 | |
|     //选中状态
 | |
|     SelectState = false;
 | |
|     //攻坚状态
 | |
|     OffensiveState = 0;
 | |
| 
 | |
|     constructor(gTeamObj) {
 | |
|         TeamObj = gTeamObj;
 | |
|         this.Width = 458;
 | |
|         this.Height = 21;
 | |
| 
 | |
|         this.OnClick = function() {
 | |
|             local Win = LenheartNewUI_CreateWindow(FiendwarHallC, "超时空攻坚队伍列表", 320, 40, 478, 434, 18);
 | |
|             //还原其他 选中自己
 | |
|             foreach(Obj in Win.PartyList) {
 | |
|                 Obj.SelectState = false;
 | |
|             }
 | |
|             SelectState = !SelectState;
 | |
|             local T = {
 | |
|                 op = 20063013,
 | |
|                 teamsId = TeamObj.TeamId
 | |
|             }
 | |
|             BasicsDrawTool.SendPackEx(T);
 | |
|         }
 | |
|         LenheartNewUI_CommonUi.constructor(10, 82, this.Width, this.Height);
 | |
|     }
 | |
| 
 | |
|     function Show(obj) {
 | |
|         //绘制底槽
 | |
|         L_sq_DrawImg("hud/fiendwarl.img", 4, X, Y);
 | |
| 
 | |
|         //绘制队伍编号
 | |
|         L_sq_DrawCode(TeamObj.TeamId, X + 22 - LenheartTextClass.GetStringLength(TeamObj.TeamId) / 2, Y + 5, sq_RGBA(134, 120, 79, 255), 0, 1);
 | |
|         //绘制队长头像
 | |
|         L_sq_DrawImg("interface/lenheartwindowcommon.img", 55, X + 52, Y + 7);
 | |
|         try {
 | |
|             local channel_index = FiendwarTotal.GetInstance().BaseConfig.channel_index;
 | |
|             channel_index = channel_index.slice(channel_index.len() - 2, channel_index.len());
 | |
|             //绘制频道信息
 | |
|             L_sq_DrawCode(channel_index, X + 102 - LenheartTextClass.GetStringLength(channel_index) / 2, Y + 5, sq_RGBA(134, 120, 79, 255), 0, 1);
 | |
|         } catch (exception) {
 | |
| 
 | |
|         }
 | |
|         //绘制攻坚队名称
 | |
|         L_sq_DrawCode(TeamObj.TeamName, X + 130, Y + 5, sq_RGBA(134, 120, 79, 255), 0, 1);
 | |
|         //绘制攻坚队攻坚状态
 | |
|         L_sq_DrawImg("hud/fiendwarl.img", 6 + TeamObj.State, X + 314, Y + 2);
 | |
| 
 | |
|         local PartyPlayerCountStr = TeamObj.TeamPlayerCount + " / " + 8;
 | |
|         //绘制攻坚队队员数量
 | |
|         L_sq_DrawCode(PartyPlayerCountStr, X + 434 - LenheartTextClass.GetStringLength(PartyPlayerCountStr) / 2, Y + 5, sq_RGBA(134, 120, 79, 255), 0, 1);
 | |
| 
 | |
|         if (SelectState) {
 | |
|             L_sq_DrawImg("hud/fiendwarl.img", 5, X, Y);
 | |
|         }
 | |
| 
 | |
|         if (isInRect) {
 | |
|             L_sq_DrawImg("hud/fiendwarl.img", 5, X, Y);
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| class FiendwarHallC extends LenheartNewUI_Windows {
 | |
| 
 | |
|     // DeBugMode = true;
 | |
|     WindowObj = null; //窗口对象
 | |
|     MainState = false; //主状态
 | |
|     X = 320;
 | |
|     Y = 40;
 | |
|     Visible = false;
 | |
| 
 | |
| 
 | |
|     PartyList = null;
 | |
| 
 | |
|     function GetInstance() {
 | |
|         return getroottable()["FiendwarHallCObj"];
 | |
|     }
 | |
| 
 | |
|     function GetAllTeamCallBack(Chunk) {
 | |
|         // Sout("收到包 : \n %L", Chunk);
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         //清除原来的List
 | |
|         PartyList = [];
 | |
|         foreach(CIndex, Child in Childrens) {
 | |
|             if (Child instanceof FiendwarHallTeamC) {
 | |
|                 Childrens.remove(CIndex);
 | |
|             }
 | |
|         }
 | |
|         foreach(TeamsSimple in Jso.TeamSimList) {
 | |
|             local T = {
 | |
|                 TeamId = TeamsSimple.TeamId.tostring(),
 | |
|                 TeamName = TeamsSimple.TeamName,
 | |
|                 TeamPlayerCount = TeamsSimple.TeamPlayerCount,
 | |
|                 State = TeamsSimple.State
 | |
|             }
 | |
|             local TeamBuf = FiendwarHallTeamC(T);
 | |
|             Childrens.append(TeamBuf);
 | |
|             PartyList.append(TeamBuf);
 | |
|         }
 | |
| 
 | |
|         local Win = LenheartNewUI_CreateWindow(FiendwarHallMyPartyC, "超时空我的队伍窗口", 430, 15, 354, 290, 18);
 | |
|         Win.Visible = false;
 | |
|     }
 | |
| 
 | |
|     //获取攻坚队信息回调
 | |
|     function GetTeamInfoCallBack(Chunk) {
 | |
|         Sout("收到包 : \n %L", Chunk);
 | |
| 
 | |
|         local Jso = Json.Decode(Chunk);
 | |
|         local Win = LenheartNewUI_CreateWindow(FiendwarHallMyPartyC, "超时空我的队伍窗口", 430, 15, 354, 290, 18);
 | |
|         Win.Visible = true;
 | |
|         Win.ResetFocus();
 | |
| 
 | |
|         Win.MembersList = [];
 | |
|         Win.TeamName = Jso.team.TeamName;
 | |
|         Win.TeamID = Jso.team.TeamId;
 | |
|         foreach(_index, MemberObj in Jso.team.characNum) {
 | |
|             //说明我在这个攻坚队里
 | |
|             if (Jso.cid == MemberObj.CID) {
 | |
|                 Win.IsMyTeam = true;
 | |
|                 //存个全局
 | |
|                 getroottable().rawset("FiendwarHallMyPartyTeamId", Jso.team.TeamId);
 | |
|             }
 | |
|             local T = {
 | |
|                 PartyId = Jso.team.TeamId,
 | |
|                 TeamId = MemberObj.characNum + 1,
 | |
|                 Level = MemberObj.PlayerLevel.tostring(),
 | |
|                 Name = MemberObj.PlayerName,
 | |
|                 JobName = MemberObj.PlayerGrowTypeJob,
 | |
|                 Job = MemberObj.PlayerJob,
 | |
|                 StkHasFlag = MemberObj.isPrepare,
 | |
|                 EquVos = MemberObj.equVos,
 | |
|                 Captain = MemberObj.CaptainBool,
 | |
|                 Cid = MemberObj.CID,
 | |
|                 PlayerSession = MemberObj.PlayerSession
 | |
|             }
 | |
|             local TeamBuf = FiendwarHallMyPartyMemberC(T);
 | |
|             Win.Childrens.append(TeamBuf);
 | |
|             Win.MembersList.append(TeamBuf);
 | |
|         }
 | |
| 
 | |
|         local Fo = FiendwarTotal.GetInstance();
 | |
|         Fo.MyCid = Jso.cid;
 | |
|         //说明是队长
 | |
|         if (Jso.cid == Jso.team.captainCid) {
 | |
|             Win.IsCaptain = true;
 | |
|             Fo.IsCaptain = true;
 | |
|         }
 | |
|         //刷新界面
 | |
|         Win.RegisterWidget();
 | |
|     }
 | |
| 
 | |
|     function GetAllTeamCall() {
 | |
|         local Jso = {
 | |
|             op = 20063011
 | |
|         }
 | |
|         SendPack(Jso);
 | |
|     }
 | |
| 
 | |
|     constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH) {
 | |
|         Childrens = [];
 | |
|         //注册控件
 | |
|         RegisterWidget();
 | |
| 
 | |
| 
 | |
|         PartyList = [];
 | |
|         Pack_Control.rawset(20063002, GetAllTeamCallBack.bindenv(this));
 | |
|         Pack_Control.rawset(20063004, GetTeamInfoCallBack.bindenv(this));
 | |
|         GetAllTeamCall();
 | |
| 
 | |
|         LenheartNewUI_Windows.constructor(gObjectId, gX, gY, gWidth, gHeight, gTitleH);
 | |
| 
 | |
|         //测试数据
 | |
|         // for (local i = 0; i< 20; i++) {
 | |
|         //     local T = {
 | |
|         //         TeamId = i.tostring(),
 | |
|         //         TeamName = "Name " + i,
 | |
|         //         TeamPlayerCount = i,
 | |
|         //         State = 0
 | |
|         //     }
 | |
|         //     local TeamBuf = FiendwarHallTeamC(T);
 | |
|         //     Childrens.append(TeamBuf);
 | |
|         //     PartyList.append(TeamBuf);
 | |
|         // }
 | |
| 
 | |
| 
 | |
|     }
 | |
| 
 | |
|     OnlyPreparingBtn = null;
 | |
|     OnlyPreparingFlag = 1;
 | |
|     InputObject = null;
 | |
| 
 | |
|     function RegisterWidget() {
 | |
|         //关闭按钮
 | |
|         local CloseButton = LenheartNewUI_BaseButton(457, 0, 11, 12, "interface/lenheartwindowcommon.img", 276);
 | |
|         CloseButton.OnClick = function() {
 | |
|             CloseWindow();
 | |
|         }.bindenv(this);
 | |
|         Childrens.append(CloseButton);
 | |
| 
 | |
|         //我的频道复选框
 | |
|         local MyChannelBtn = LenheartNewUI_SwitchButtonText(16, 30, "我的频道");
 | |
|         MyChannelBtn.State = 1;
 | |
|         MyChannelBtn.ImgIndex = 358;
 | |
|         MyChannelBtn.SetTextPos(12, 2);
 | |
|         MyChannelBtn.Width = 76;
 | |
|         MyChannelBtn.Height = 16;
 | |
|         Childrens.append(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);
 | |
|         Childrens.append(OnlyPreparingBtn);
 | |
| 
 | |
|         //搜索队伍输入框
 | |
|         InputObject = LenheartNewUI_BaseInput(260, 31, 80, 20);
 | |
|         Childrens.append(InputObject);
 | |
| 
 | |
|         //搜索按钮
 | |
|         local FindButton = LenheartNewUI_ButtonText(348, 28, 5, "搜索");
 | |
|         FindButton.SetTextOffset(0, 1);
 | |
|         FindButton.OnClick = function() {
 | |
|             if (InputObject.str.len() > 0) {
 | |
| 
 | |
|             }
 | |
|         }.bindenv(this);
 | |
|         Childrens.append(FindButton);
 | |
| 
 | |
|         //重置按钮
 | |
|         local ResetButton = LenheartNewUI_ButtonText(408, 28, 5, "重置");
 | |
|         ResetButton.SetTextOffset(0, 1);
 | |
|         ResetButton.OnClick = function() {
 | |
|             InputObject.str = "";
 | |
|         }.bindenv(this);
 | |
|         Childrens.append(ResetButton);
 | |
| 
 | |
|         //编号按钮
 | |
|         local ModelButton = LenheartNewUI_ButtonText(9, 56, -18, "编号");
 | |
|         ModelButton.Idx = 163;
 | |
|         ModelButton.DWidth = -8;
 | |
|         ModelButton.SetTextOffset(-9, 1);
 | |
|         Childrens.append(ModelButton);
 | |
| 
 | |
|         //状态按钮
 | |
|         local StateButton = LenheartNewUI_ButtonText(51, 56, -18, "状态");
 | |
|         StateButton.Idx = 163;
 | |
|         StateButton.DWidth = -8;
 | |
|         StateButton.SetTextOffset(-9, 1);
 | |
|         Childrens.append(StateButton);
 | |
| 
 | |
|         //频道按钮
 | |
|         local ChannelButton = LenheartNewUI_ButtonText(93, 56, -18, "频道");
 | |
|         ChannelButton.Idx = 163;
 | |
|         ChannelButton.DWidth = -8;
 | |
|         ChannelButton.SetTextOffset(-9, 1);
 | |
|         Childrens.append(ChannelButton);
 | |
| 
 | |
|         //攻坚队名称按钮
 | |
|         local PartyNameButton = LenheartNewUI_ButtonText(135, 56, 100, "攻坚队名称");
 | |
|         PartyNameButton.Idx = 163;
 | |
|         PartyNameButton.DWidth = 223;
 | |
|         PartyNameButton.FillWidth = 1;
 | |
|         PartyNameButton.FirstWidth = 21;
 | |
|         PartyNameButton.SetTextOffset(26, 1);
 | |
|         Childrens.append(PartyNameButton);
 | |
| 
 | |
|         //阶段按钮
 | |
|         local StageButton = LenheartNewUI_ButtonText(289, 56, 52, "阶段");
 | |
|         StageButton.Idx = 163;
 | |
|         StageButton.DWidth = 140;
 | |
|         StageButton.FillWidth = 1;
 | |
|         StageButton.FirstWidth = 21;
 | |
|         StageButton.SetTextOffset(26, 1);
 | |
|         Childrens.append(StageButton);
 | |
| 
 | |
|         //队员数量按钮
 | |
|         local TeammembersButton = LenheartNewUI_ButtonText(402, 56, 50, "队员数量");
 | |
|         TeammembersButton.Idx = 163;
 | |
|         TeammembersButton.FillWidth = 1;
 | |
|         TeammembersButton.FirstWidth = 21;
 | |
|         TeammembersButton.DWidth = 47;
 | |
|         TeammembersButton.SetTextOffset(-8, 1);
 | |
|         Childrens.append(TeammembersButton);
 | |
| 
 | |
|         //创建攻坚队按钮
 | |
|         local CreateOrMyPartyStr = "创建攻坚队";
 | |
|         local MyPartyButton = LenheartNewUI_ButtonText(15, 395, 30, CreateOrMyPartyStr);
 | |
|         MyPartyButton.SetTextOffset(-6, 1);
 | |
|         MyPartyButton.OnClick = function() {
 | |
|             local Win = LenheartNewUI_CreateWindow(FiendwarHallCreatePartyC, "超时空创建队伍窗口", 290, 220, 284, 154, 18);
 | |
|             Win.Visible = true;
 | |
|             Win.ResetFocus();
 | |
|         }.bindenv(this);
 | |
|         Childrens.append(MyPartyButton);
 | |
| 
 | |
|         //左翻页按钮
 | |
|         local LeftButton = LenheartNewUI_BaseButton(160, 400, 15, 15, "interface/lenheartwindowcommon.img", 34);
 | |
|         LeftButton.OnClick = function() {
 | |
|             if (Page > 0) Page--;
 | |
|         }.bindenv(this);
 | |
|         Childrens.append(LeftButton);
 | |
| 
 | |
|         //右翻页按钮
 | |
|         local RightButton = LenheartNewUI_BaseButton(220, 400, 15, 15, "interface/lenheartwindowcommon.img", 38);
 | |
|         RightButton.OnClick = function() {
 | |
|             if (Page<(((PartyList.len() / PageMaxCount)))) Page++;
 | |
|         }.bindenv(this);
 | |
|         Childrens.append(RightButton);
 | |
| 
 | |
|         //进入待机按钮
 | |
|         local FQButton = LenheartNewUI_ButtonText(300, 394, 20, "进入待机");
 | |
|         FQButton.SetTextOffset(-5, 2);
 | |
|         FQButton.State = 8;
 | |
|         Childrens.append(FQButton);
 | |
| 
 | |
|         //刷新按钮
 | |
|         local RefreshButton = LenheartNewUI_BaseButton(410, 395, 25, 25, "interface/lenheartwindowcommon.img", 366);
 | |
|         RefreshButton.OnClick = function() {
 | |
|             GetAllTeamCall();
 | |
|         }.bindenv(this);
 | |
|         Childrens.append(RefreshButton);
 | |
| 
 | |
|         //设置按钮
 | |
|         local SettingButton = LenheartNewUI_BaseButton(440, 394, 15, 15, "interface/lenheartwindowcommon.img", 362);
 | |
|         SettingButton.State = 8;
 | |
|         Childrens.append(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) {
 | |
|             //在甲板
 | |
|             if (FiendwarTotal.GetInstance().BaseConfig && FiendwarTotal.GetInstance().BaseConfig.channel_index.find("20") && L_sq_GetTownIndex() == FiendwarTotal.GetInstance().BaseConfig.town_index && L_sq_GetRegionIndex() == 1) {
 | |
|                 if (!MainButton) {
 | |
|                     MainButton = LenheartBaseButton(0, 350, 100, 179, "hud/fiendwarl.img", 0);
 | |
|                 } else {
 | |
|                     MainButton.Show();
 | |
|                     if (MainButton.isLBActive()) {
 | |
|                         this.Visible = true;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         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);
 | |
|     }
 | |
| } |