local UIGuildMain = UIViewClass() local SHOW_DISCUSSIONGROUP_LENGTH = 7 -- 议事群最长显示长度 local EventSystem = require('Event/EventSystem') function UIGuildMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_Guild_GuildInfoRefresh, self.ShowInfo) self:RegistSystemEvent(EventID.UI_Guild_GuildRecruitRefresh,self.SetCDTime) self:RegistSystemEvent(EventID.New_Day_Refresh, MDL.Guild.GetGuildInfoReq) self:RegistSystemEvent(EventID.UI_Guild_SelfInfoRefresh, self.RefreshCurrency) MDL.Guild.GetGuildInfoReq() UIUtils.SetActive(self.img_Back, false) end function UIGuildMain:ShowInfo(data) self.myGuildInfo = data self.memberList = {} self.txt_TitleGuildName.text = self.myGuildInfo.listInfo.emblemContent UTL.Item.SetAtlasSprite(self.ico_GuildBg, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(self.myGuildInfo.listInfo.emblemFrame).Image) self.lab_Number.text = self.myGuildInfo.listInfo.showId self.txt_CEPresent.text = self:GetGS(self.myGuildInfo.members) local activeness = 3 local activenessArray = DataSheetManager.ConstData:GetDataByID("GuildActivityValueRange").IntListValue for i, v in ipairs(activenessArray) do if self.myGuildInfo.listInfo.activeness<= v then activeness = i - 1 break end end self.lights:SetState(activeness) if CTL.Guild.IsGuildCommunityFunctionOpen() then UIUtils.SetActive(self.group_DiscussionGroup, true) if string.isNilOrEmpty(self.myGuildInfo.groupChatNum) then UIUtils.SetLabelText(self.txt_DiscussionNumber,Const_IDS.IDS_Guild_BlankContent) UIUtils.SetActive(self.img_GroupImage, false) UIUtils.SetActive(self.img_Copy, false) else local chatValues = string.split(self.myGuildInfo.groupChatNum,":") self.discussionNumberCache = chatValues[2] if UTL.String.GetStrCharCount(chatValues[2], 1) > SHOW_DISCUSSIONGROUP_LENGTH then UIUtils.SetLabel(self.txt_DiscussionNumber, UTL.String.CutStrByLength(chatValues[2], SHOW_DISCUSSIONGROUP_LENGTH).."...") else UIUtils.SetLabel(self.txt_DiscussionNumber, chatValues[2]) end UIUtils.SetActive(self.img_GroupImage, true) local imgPath = DataSheetManager.GuildCommunity:GetDataByID(tonumber(chatValues[1] + 1)).ImageSource UIUtils.SetImageByAssetBundle(self.img_GroupImage, imgPath) UIUtils.SetActive(self.img_Copy, true) end else UIUtils.SetActive(self.group_DiscussionGroup, false) end self.txt_Number.text = string.FormatByIdsId(Const_IDS.IDS_GuildMainpage_Label12,MDL.Guild.GetOnlineCount(self.myGuildInfo.members), self.myGuildInfo.listInfo.memberCount, self.myGuildInfo.listInfo.memberCountLimit) self:SetFame() self:RefreshCurrency() if string.isNilOrEmpty(self.myGuildInfo.notice) then UIUtils.SetLabelText(self.txt_GuildAnn, Const_IDS.IDS_Guild_InitialNotice) else self.txt_GuildAnn.text = self.myGuildInfo.notice end self.lab_Name.text = self.myGuildInfo.listInfo.name self.jobList = {} for i,v in ipairs(data.members) do if v.jobTitle > 0 and v.jobTitle < MDL.Guild.JobEnum.Common then self.jobList[v.jobTitle] = v end end self:SetMemberImage(self.group_Jobs[2],self.jobList[MDL.Guild.JobEnum.Leader]) self:SetMemberImage(self.group_Jobs[4],self.jobList[MDL.Guild.JobEnum.RenshiElder]) self:SetMemberImage(self.group_Jobs[5],self.jobList[MDL.Guild.JobEnum.NeishiElder]) self:SetMemberImage(self.group_Jobs[6],self.jobList[MDL.Guild.JobEnum.JunshiElder]) self:SetJobText(self.group_Jobs[2],MDL.Guild.JobEnum.Leader) self:SetJobText(self.group_Jobs[4],MDL.Guild.JobEnum.RenshiElder) self:SetJobText(self.group_Jobs[5],MDL.Guild.JobEnum.NeishiElder) self:SetJobText(self.group_Jobs[6],MDL.Guild.JobEnum.JunshiElder) self.memberList[2] = self.jobList[MDL.Guild.JobEnum.Leader] self.memberList[4] = self.jobList[MDL.Guild.JobEnum.RenshiElder] self.memberList[5] = self.jobList[MDL.Guild.JobEnum.NeishiElder] self.memberList[6] = self.jobList[MDL.Guild.JobEnum.JunshiElder] UIUtils.SetLabelText(self.group_Jobs[1].lab_PositionTitle,Const_IDS.IDS_Guild_Warlord) UIUtils.SetLabelText(self.group_Jobs[3].lab_PositionTitle,Const_IDS.IDS_Guild_Goddess) self.group_Jobs[2].pre_icon.gameObject:SetActive(self.myGuildInfo.hasLeaderChange) local identityList = {} for i,v in ipairs(data.members) do for _,id in ipairs(v.identity) do if MDL.Guild.IdentityEnum.Warlord == id then identityList[MDL.Guild.IdentityEnum.Warlord] = v end if MDL.Guild.IdentityEnum.Goddess == id then identityList[MDL.Guild.IdentityEnum.Goddess] = v end end end self.memberList[1] = identityList[MDL.Guild.IdentityEnum.Warlord] self.memberList[3] = identityList[MDL.Guild.IdentityEnum.Goddess] self:SetMemberImage(self.group_Jobs[1],identityList[MDL.Guild.IdentityEnum.Warlord]) self:SetMemberImage(self.group_Jobs[3],identityList[MDL.Guild.IdentityEnum.Goddess]) self:SetCDTime() local time = UTL.Time.GetServerTimestamp() - self.myGuildInfo.createTime local length = DataSheetManager.ConstData:GetDataByID("GuildEvaluationTime").IntValue * UTL.Time.TotalSecondsOneMinute if time < length and not self.myGuildInfo.isEndTrialRun then UIUtils.SetActive(self.img_Clock, true) self:StopRepeatFunc(self.OnUpdateClockFun) self:StartRepeatFunc(self.OnUpdateClockFun,length - time) else UIUtils.SetActive(self.img_Clock, false) end end function UIGuildMain:OnUpdateClockFun(deltaTime, timeSinceUpdate) UIUtils.SetActive(self.img_Clock, false) end function UIGuildMain:RefreshCurrency() local myGuildInfo = MDL.Guild.GetMyGuildInfo() self.txt_LYNum.text = myGuildInfo and myGuildInfo.goldIngot or 0 self.txt_Money.text = myGuildInfo and myGuildInfo.fund or 0 end function UIGuildMain:GetGS(members) local value = 0 for i,v in ipairs(members) do value = value + v.roleInfo.gsSum end return value end function UIGuildMain:SetFame() local totalValue = 0 for i=1,self.myGuildInfo.listInfo.fameLevel do totalValue = totalValue + DataSheetManager.GuildReputation:GetDataByID(i).Value end local data = DataSheetManager.GuildReputation:GetDataByID(self.myGuildInfo.listInfo.fameLevel)--self.myGuildInfo.listInfo.fameLevel local nextLevel = self.myGuildInfo.listInfo.fameLevel+1 --下一个等级的是可能为空的 local __, nextData = DataSheetManager.GuildReputation:TryGetDataByID(nextLevel) self.txt_GuileHoner.text = UTL.Color.FormatTextByColor(data.Color,UIUtils.GetLocalizedTxt(Const_IDS[data.Name])) self.txt_GuileHonerNum.text = self.myGuildInfo.listInfo.fameValue + totalValue if data.Num > 0 then self.txt_GuileLevel.text = data.Num UIUtils.SetActive(self.img_bg, true) else UIUtils.SetActive(self.img_bg, false) end if nextData then UIUtils.SetLabel(self.txt_XP, string.FormatByIdsId(Const_IDS.IDS_GuildMainpage_Label7,nextData.Value - self.myGuildInfo.listInfo.fameValue)) self.slider_XP.value = self.myGuildInfo.listInfo.fameValue/nextData.Value else UIUtils.SetLabelText(self.txt_XP, Const_IDS["IDS_Handbook_Hero_LevelUp_Max"]) self.slider_XP.value = 0 end self.group_Fame.gameObject:SetActive(true) UnityEngine.UI.LayoutRebuilder.MarkLayoutForRebuild(self.group_Fame) end function UIGuildMain:SetMemberImage(collection,info) UIUtils.SetCanvasSortingOrderByMainCanvas(collection.UIHeroHead190.effectUpCanvas, collection.UpCanvas, CTL.Character.UpOrder.Common) if info then CTL.Character.SetPortraitAndFrame(collection.UIHeroHead190, info.roleInfo.PortraitId, info.roleInfo.FrameId, info.roleInfo.level) collection.lab_HeroName.text = info.roleInfo.name if info.roleInfo.isOnline then collection.img_Point:SetState(0) else collection.img_Point:SetState(1) end UIUtils.SetActive(collection.img_Point, true) CTL.Player.OperateGenderImage(collection.image_Gender, info.roleInfo.sex) else CTL.Character.SetHeadEmpty(collection.UIHeroHead190) UIUtils.SetActive(collection.UIHeroHead190.img_PlayerAvatarFrame, false) UIUtils.SetLabelText(collection.lab_HeroName,Const_IDS.IDS_GuildApply_Label7) UIUtils.SetActive(collection.img_Point, false) UIUtils.SetActive(collection.image_Gender, false) end end function UIGuildMain:SetJobText(collection,jobId) local jobData = DataSheetManager.GuildJob:GetDataByID(jobId) UIUtils.SetLabelText(collection.lab_PositionTitle,Const_IDS[jobData.JobName]) end function UIGuildMain:SetCDTime() local time = CTL.Guild.GetCdTime() if time then local length = DataSheetManager.ConstData:GetDataByID("GuildRecruitCD").IntValue if UTL.Time.GetServerTimestamp() - time < length then local timeStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_TeamUI_Myteam_RecruitingTime) local diff = length - (UTL.Time.GetServerTimestamp() - time) self.cd_time:ResetAndBeginCustomTimer(false,diff ,0,timeStr,1) UIUtils.SetGray(self.img_Recruit,true) self:StopRepeatFunc(self.OnUpdateRecruitFun) self:StartRepeatFunc(self.OnUpdateRecruitFun,diff) self.isInCd = true return end end UIUtils.SetGray(self.img_Recruit,false) self.isInCd = false end function UIGuildMain:OnUpdateRecruitFun(deltaTime, timeSinceUpdate) UIUtils.SetGray(self.img_Recruit,false) self.isInCd = false end function UIGuildMain:OnButtonClicked(comp) if comp == self.btn_LevelEdit then self:EditNotice() elseif comp == self.btn_Set then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildMainSetPanel,self.myGuildInfo) elseif comp == self.img_Copy then self.discussionNumberCache = self.discussionNumberCache and self.discussionNumberCache or "" UIUtils.GetSystemCopyText(self.discussionNumberCache) CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_Copy) elseif comp == self.img_FameInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel,{text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildMainpage_Tip2)}) elseif comp == self.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildCheckPanel) elseif comp == self.btn_Mail then if self:CheckAuthority(MDL.Guild.AuthorityEnum.GuildMail) then if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GuildMail) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildNoticePanel,{mailCount = self.myGuildInfo.sendedNotificationCount, privateChatCount = self.myGuildInfo.sendGuildBroadCastCount}) else local excelData = DataSheetManager.FuctionUnlock:GetDataByFucID(MDL.Unlock.FunctionType.GuildMail) CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildMail_FuncionNotOpen,CTL.Guild.GetGuildLevelStr(excelData.Unlock_Table[1].UnlockConditionParam)) end end elseif comp == self.btn_Recruit then if self.isInCd then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildRecruit_CoolDown) elseif MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildRecruit) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildRecruitManifestoPanel) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) end elseif comp == self.img_Clock then local time = UTL.Time.GetServerTimestamp() - self.myGuildInfo.createTime local length = DataSheetManager.ConstData:GetDataByID("GuildEvaluationTime").IntValue * UTL.Time.TotalSecondsOneMinute UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildMainCountPanel,{time = (length- time)}) elseif comp == self.btn_Plus then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildContribute) elseif comp == self.btn_Diary then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildDiary) elseif comp == self.group_Jobs[2].pre_icon then self:OpenLeaderPreView() elseif comp == self.btn_Enter then if CTL.GuildParty.CanGotoGuildPartyScene(true) then if CTL.GuildParty.GoToGuildPartyScene() then EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIGuildBasePanel) end end elseif comp == self.Btn_CE then UIUtils.SetLabelText(self.txt_Info,Const_IDS.IDS_GuildApply_Label4) self:SetTipsPanel(true, Const_IDS.IDS_Guild_TotalBR, self.Btn_CE) elseif comp == self.Btn_GuildFame then self:SetTipsPanel(true, Const_IDS.IDS_Guild_TotalReputation, self.Btn_GuildFame) elseif comp == self.Btn_Member then self:SetTipsPanel(true, Const_IDS.IDS_Guild_TotalMember, self.Btn_Member) elseif comp == self.Btn_Prosperity then self:SetTipsPanel(true, Const_IDS.IDS_Guild_TotalActive, self.Btn_Prosperity) elseif comp == self.img_Back then self:SetTipsPanel(false) else self:ClickAppoint(comp) end end function UIGuildMain:SetTipsPanel(flag, ids, parentNode) if flag then UIUtils.SetParent(self.group_TipsPanel, parentNode) UIUtils.SetLabelText(self.txt_Info, ids) local x = self.group_TipsPanel.gameObject.transform:GetAnchoredPosition() self.group_TipsPanel.gameObject.transform:SetAnchoredPosition(x, 0) end UIUtils.SetActive(self.group_TipsPanel, flag) UIUtils.SetActive(self.img_Back, flag) end function UIGuildMain:ClickAppoint(comp) for i, v in ipairs(self.group_Jobs) do if v.UIHeroHead190.empty_Bg == comp then if not self:CheckPower(i) then --~= MDL.Guild.JobEnum.Leader then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildAppointPanel,{jobData = self:GetJobByIndex(i), members = self.myGuildInfo.members} ) end elseif v.UIHeroHead190.img_PlayerAvatarBg == comp then if i == 1 then MDL.Guild.CurClickIdentityId = MDL.Guild.IdentityEnum.Warlord MDL.Guild.CurClickJobId = nil if self.memberList[i].roleInfo.acid == BattleDataGetter.GetAcID() then CTL.Guild.OpenSelfFireView(self.memberList[i]) else CTL.PlayerInteract.OpenFriendInteractView(self.memberList[i].roleInfo.acid, MDL.PlayerInteract.OccasionType.GuildMainView) end elseif i == 3 then MDL.Guild.CurClickIdentityId = MDL.Guild.IdentityEnum.Goddess MDL.Guild.CurClickJobId = nil if self.memberList[i].roleInfo.acid == BattleDataGetter.GetAcID() then CTL.Guild.OpenSelfFireView(self.memberList[i]) else CTL.PlayerInteract.OpenFriendInteractView(self.memberList[i].roleInfo.acid, MDL.PlayerInteract.OccasionType.GuildMainView) end else MDL.Guild.CurClickIdentityId = nil MDL.Guild.CurClickJobId = self:GetJobByIndex(i).id if self.memberList[i].roleInfo.acid == BattleDataGetter.GetAcID() and i ~= 2 and MDL.Guild.GetMyGuildInfo().jobTitle == MDL.Guild.JobEnum.Leader then CTL.Guild.OpenSelfFireView(self.memberList[i]) else CTL.PlayerInteract.OpenFriendInteractView(self.memberList[i].roleInfo.acid, MDL.PlayerInteract.OccasionType.GuildMainView) end end end end end function UIGuildMain:CheckPower(index) if index == 1 or index == 3 then if MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildAppoint2) then return true end return false end if MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildAppoint1) and not self:IsSameLevel(index) then return true end return false end function UIGuildMain:IsSameLevel(index) local myJobData = DataSheetManager.GuildJob:GetDataByID( MDL.Guild.GetMyGuildInfo().jobTitle) local desJobData = DataSheetManager.GuildJob:GetDataByID(self:GetJobByIndex(index).id) if myJobData.Level == desJobData.Level then return true end return false end function UIGuildMain:GetJobByIndex(index) --根据点击哪个头像 返回职位或者身份和id if index == 1 then return {type = 1, id = MDL.Guild.IdentityEnum.Warlord} elseif index == 2 then return {type = 2, id = MDL.Guild.JobEnum.Leader} elseif index == 3 then return {type = 1, id = MDL.Guild.IdentityEnum.Goddess} elseif index == 4 then return {type = 2, id = MDL.Guild.JobEnum.RenshiElder} elseif index == 5 then return {type = 2, id = MDL.Guild.JobEnum.NeishiElder} elseif index == 6 then return {type = 2, id = MDL.Guild.JobEnum.JunshiElder} end end function UIGuildMain:CheckAuthority(permission) if not MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,permission) then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) return false end return true end function UIGuildMain:EditNotice() local info = MDL.Guild.GetMyGuildMemberInfo() if MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle, MDL.Guild.AuthorityEnum.GuildNotice) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildPublicNotice, {text = self.myGuildInfo.notice, isNotice = true}) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonFail4) end end function UIGuildMain:OpenLeaderPreView() --五点刷新时间换算时区 local time = 5 * UTL.Time.TotalSecondsOneHour + UTL.Time.GetDisplayDiffLocalTimeZone() local str = string.FormatByIdsId(Const_IDS.IDS_Guild_LeaderPreChangeTip, os.date(UTL.Time.FormatDateEnum.MDHM, self.myGuildInfo.leaderChangeTime)) --UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel,{target = self.btn_Info, posType = LuaConst.DescriptionPanelType.RightUpper, text = UIUtils.GetLocalizedTxt(Const_IDS["IDS_GuildAllies_VisitIntroTips"])}) UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel,{target = self.group_Jobs[2].img_GuildHeroHead, posType = LuaConst.DescriptionPanelType.RightLower,text = str}) end return UIGuildMain