local UIChannelChatMember = UIViewClass() local EventSystem = require('Event/EventSystem') function UIChannelChatMember:OnOpened(context) self:InitInfo(context) self:RegistSystemEvent(EventID.UI_ChannelChat_RefreshChatMemberUI,self.RefreshShow) end function UIChannelChatMember:InitInfo(context) self:ShowScouts() self:CloseChoosePanel() end function UIChannelChatMember:RefreshShow(isCloseMembers) self:ShowScouts() if isCloseMembers then self:CloseChoosePanel() else if self.ShowChoose then self:ShowMembers() end end end --显示斥候列表 function UIChannelChatMember:ShowScouts() self.ManagePanel.gameObject:SetActive(true) self.LoopScroll_Scouts:ClearCells() local scoursList=MDL.GuildWar.GetScoutsList() if scoursList~=nil then for i, v in ipairs(scoursList) do local temp={} temp.acid=v.headInfo.acid temp.name=v.headInfo.name temp.mainHeroId=v.headInfo.mainHeroId temp.roomType=v.roomType temp.isSelf= temp.acid== PlayerInfoManager.AcID temp.isCaptain=self:IsCaptain(temp.acid) temp.hasData=true temp.portraitId = v.headInfo.PortraitId temp.frameId = v.headInfo.FrameId self.LoopScroll_Scouts:AddData(temp,0) end end --不足10个的,显示点击加入补齐 local count =self.LoopScroll_Scouts.Count if count< 10 then for i = count+1, 10 do self.LoopScroll_Scouts:AddData({hasData=false},0) end end end --显示候选成员列表 function UIChannelChatMember:ShowMembers() self.ChoosePanel.gameObject:SetActive(true) self.LoopScroll_Player:ClearCells() for i, v in MDL.Guild.GetGuildMembersIterator(true) do local temp = {} temp.acid = v.roleInfo.acid temp.name = v.roleInfo.name temp.mainHeroId = v.roleInfo.mainHeroId temp.roomType = MDL.GuildWar.GetRoomTypeByAcid(temp.acid) temp.isSelf = temp.acid == PlayerInfoManager.AcID temp.isScout = MDL.GuildWar.IsScouts(temp.acid) temp.isCaptain = self:IsCaptain(temp.acid) temp.isCommander = MDL.GuildWar.IsBattleCommand(v.jobTitle) --是否为指挥 temp.portraitId = v.roleInfo.PortraitId temp.frameId = v.roleInfo.FrameId self.LoopScroll_Player:AddData(temp,0) end end --是否为战场团长 function UIChannelChatMember:IsCaptain(acid) return MDL.GuildWar.IsBattleLeader(acid) end function UIChannelChatMember:OnCellInit(scrollRect, index, cellTable, data) --显示斥候信息 if scrollRect == self.LoopScroll_Scouts then self:OnScoutsCellInit(cellTable,data, index) end --显示候选信息 if self.ShowChoose and scrollRect == self.LoopScroll_Player then self:OnPlayerCellInit(cellTable,data, index) end end --候选格子信息 function UIChannelChatMember:OnPlayerCellInit(cellTable,data, index) cellTable.txt_Name.text=data.name cellTable.txt_Position.text=self:GetShowRoomByType(data.roomType) CTL.Character.SetPortraitAndFrame(cellTable.UIHeroHead150, data.portraitId, data.frameId) cellTable.group_Self.gameObject:SetActive(data.isSelf) cellTable.group_Captain.gameObject:SetActive(data.isCaptain) cellTable.btn_Added.gameObject:SetActive(false) if data.isCommander then--指挥 cellTable.btn_Add.gameObject:SetActive(false) cellTable.txt_Tip.gameObject:SetActive(true) cellTable.txt_Tip.text=UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_Commander) elseif not self:IsBattleRoom(data.roomType) then --无战场 cellTable.btn_Add.gameObject:SetActive(false) cellTable.txt_Tip.gameObject:SetActive(false) elseif data.isScout then --斥候 cellTable.btn_Add.gameObject:SetActive(false) cellTable.txt_Tip.gameObject:SetActive(true) cellTable.txt_Tip.text=UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_AlreadyAppointed) else local hasRight=CTL.ChannelChat.IsCanConvene() cellTable.txt_Tip.gameObject:SetActive(false) cellTable.btn_Add.gameObject:SetActive(hasRight) end end --斥候格子信息 function UIChannelChatMember:OnScoutsCellInit(cellTable,data, index) --无斥候数据 if data.hasData == false then cellTable.group_Join.gameObject:SetActive(true) cellTable.group_Info.gameObject:SetActive(false) else -- 有斥候数据 cellTable.group_Join.gameObject:SetActive(false) cellTable.group_Info.gameObject:SetActive(true) cellTable.txt_Name.text=data.name cellTable.txt_Position.text=self:GetShowRoomByType(data.roomType) CTL.Character.SetPortraitAndFrame(cellTable.UIHeroHead150, data.portraitId, data.frameId) cellTable.btn_Leave.gameObject:SetActive(CTL.ChannelChat.IsCanConvene()) cellTable.group_Self.gameObject:SetActive(data.isSelf) cellTable.group_Captain.gameObject:SetActive(data.isCaptain) end end --是否有战场 function UIChannelChatMember:IsBattleRoom(roomType) if roomType ==1 or roomType ==2 or roomType ==3 or roomType ==4 or roomType == 5 then --主战场 return true else --无战场 return false end end function UIChannelChatMember:GetShowRoomByType(roomType) if roomType ==1 then --主战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName1) elseif roomType ==2 then -- 码头战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName3) elseif roomType == 3 then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName6) elseif roomType == 4 then --支援战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName7) elseif roomType == 5 then --支援战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName8) else --无战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_TargetNotInGroup) end end function UIChannelChatMember:OnCellClicked(scrollRect, index, cellTable, target, data) --斥候格子点击 if scrollRect == self.LoopScroll_Scouts then if data.hasData == false then self:ShowAddScouts() else --有权限,取消任命,无权限,提示 local hasRight=CTL.ChannelChat.IsCanConvene() if hasRight then local func=function() local hasRight2=CTL.ChannelChat.IsCanConvene() if hasRight2 then MDL.GuildWar.SendCancelGuildWarScouts(data.acid) --取消任命 else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) end end UTL.MessageBox.ShowOKCancelBox("", string.FormatByIdsId(Const_IDS.IDS_WarChannel_DismissScoutConfirm, data.name),func, nil) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) end end end --候选格子点击 if self.ShowChoose and scrollRect == self.LoopScroll_Player and target.name=="btn_Add" then --任命斥候 local hasRight=CTL.ChannelChat.IsCanConvene() if hasRight then local hasReachMax= MDL.GuildWar.IsScoutsReachMax() if hasReachMax then CTL.Tips.AddTipsMsg(Const_IDS.IDS_WarChannel_ScoutNumLimit) return end local func=function() local hasRight2=CTL.ChannelChat.IsCanConvene() if hasRight2 then local hasReachMax2= MDL.GuildWar.IsScoutsReachMax() if hasReachMax2 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_WarChannel_ScoutNumLimit) return end local isScout= MDL.GuildWar.IsScouts(data.acid) --判断已经被其他人任命为斥候的情况 if not isScout then MDL.GuildWar.SendAppointGuildWarScouts(data.acid) else --已经是斥候的提示 CTL.Tips.AddTipsMsg(Const_IDS.IDS_WarChannel_TargetAlreadyScout) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) end end UTL.MessageBox.ShowOKCancelBox("", string.FormatByIdsId(Const_IDS.IDS_WarChannel_AppointConfirm, data.name),func, nil) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) end end end --显示点击加入 function UIChannelChatMember:ShowAddScouts() MDL.Guild.GetGuildInfoReq() self.ShowChoose=true self:ShowMembers() end function UIChannelChatMember:CloseChoosePanel() self.ChoosePanel.gameObject:SetActive(false) self.ShowChoose=false end function UIChannelChatMember:OnClosed() EventSystem.Dispatch(EventID.UI_ChannelChat_ShowScoutViewBtn) end function UIChannelChatMember:OnButtonClicked(obj) if(obj==self.btn_Close) then self:CloseView() elseif obj==self.btn_Arrow then self:CloseChoosePanel() end end return UIChannelChatMember