local UIFightThroneMain = UIViewClass() function UIFightThroneMain:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_ActivityName_FightThrone) UIUtils.SetLabelText(self.txt_Go, Const_IDS.IDS_RebelStrike_GoNow) self:InitInfo() self:RefreshEntryRedPoint() end function UIFightThroneMain:InitInfo() self.activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.FightThrone) UIUtils.SetActive(self.btn_ExtraInfo, false) --活动时间 if #self.activityData.Time_Table <= 0 then UIUtils.SetLabelText(self.txt_TimeA, Const_IDS.IDS_Activity_TimeShow01) self.txt_TimeB.text = nil else local date, time, extra = CTL.Activities.GetDetailsTimeDesc(self.activityData) self.activityExtra = extra self.txt_TimeA.text = date self.txt_TimeB.text = time UIUtils.SetActive(self.btn_ExtraInfo, extra ~= nil) end --奖励展示 self:RegistSystemEvent(EventID.WarZone_TimeRewardFresh, self.RefreshRewardScroll) self:RefreshRewardScroll() --活动入口关闭倒计时 self:UpdateEntry() end function UIFightThroneMain:RefreshEntryRedPoint() if MDL.Activities.GetRedPointByID(LuaConst.ActivityType.FightThrone) then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.FightThrone, 1, true, LuaConst.ActivityType.FightThrone) end end function UIFightThroneMain:UpdateEntry() local state, offset = CTL.FightThrone.GetEntryState() if state == CTL.FightThrone.EntryState.Opening then self.btn_Go:SetGray(false) UIUtils.SetGray(self.txt_Go, false) self.cdTimer:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS.IDS_FightThrone_CloseNotice), 1, 5) self.cdTimer:ResetAndBeginTimer(false, offset) self:StartRepeatFunc(self.UpdateEntry, offset, 1) else --活动开启前N分钟,在立即前往按钮上方显示活动开启倒计时,走活动配置 local activityState = CTL.Activities.GetState(LuaConst.ActivityType.FightThrone) if activityState == CTL.Activities.ActivityState.NotOpen or activityState == CTL.Activities.ActivityState.End then self.btn_Go:SetGray(true) UIUtils.SetGray(self.txt_Go, true) local openTime if MDL.GuildWar.GuildWarIsFirstSign() then openTime = activityState == CTL.Activities.ActivityState.NotOpen and CTL.FightThrone.GetFakeThroneNextOpenTime(true) or CTL.FightThrone.GetFakeThroneNextOpenTime(false) else openTime = activityState == CTL.Activities.ActivityState.NotOpen and CTL.Activities.GetTimeToOpen(LuaConst.ActivityType.FightThrone) or CTL.Activities.GetNextTimeToOpen(LuaConst.ActivityType.FightThrone) end local noticeTime = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.FightThrone).Notice if openTime <= noticeTime then self.cdTimer:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS.IDS_RebelStrike_Countdown), 1, 2) self.cdTimer:ResetAndBeginTimer(false, openTime) self:StartRepeatFunc(self.UpdateEntry, openTime + 1, 1) else self.cdTimer:EndTimer() self:StartRepeatFunc(self.UpdateEntry, openTime - noticeTime + 1, 1) end else --在活动期间,但是入口已关闭,此时按钮不置灰 self.btn_Go:SetGray(false) UIUtils.SetGray(self.txt_Go, false) self.cdTimer:EndTimer() local closeTime = CTL.Activities.GetTimeToClose(LuaConst.ActivityType.FightThrone) self:StartRepeatFunc(self.UpdateEntry, closeTime, 1) end end end function UIFightThroneMain:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data[1].ItemID, data[1].ItemNum, false, data[1].TagType) end function UIFightThroneMain:OnCellClicked(scrollRect, index, cellTable, target, data) UTL.ItemTips.ShowCommonTipsById(data[1].ItemID) end function UIFightThroneMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIFightThroneMain:OnButtonClicked(comp) if comp == self.btn_Go then MDL.FightThrone.EnterBattle() elseif comp == self.btn_RewardInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UIFightThroneRewardPreviewPopUp) elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.FightThrone }) elseif comp == self.btn_ExtraInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, {target = comp, posType = LuaConst.DescriptionPanelType.Center, text = self.activityExtra}) end end function UIFightThroneMain:RefreshRewardScroll() local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(self.activityData.RewardShow) local rewardData = DataSheetUtil.GetRewardClientShowItemTable(cfg) local displayItem = DataSheetManager.ConstData:GetDataByID("ActivityRewardDisplayItem").IntListValue if self.scroll_Reward.Count > 0 then self.scroll_Reward:ClearCells() end for _, RewardClientItem in ipairs(rewardData) do local itemData = DataSheetManager.ItemData:GetDataByID(RewardClientItem.ItemID) -- 金品质及以上可见拍卖奖励根据服务器数据显示 if itemData.Color >= LuaConst.QualityColor.Gold then local firstRewardTable = MDL.FightThrone.GetAuctionPoolRewardArray(DataSheetManager.FightThroneGuildRank:GetDataByID(1)) for _, serverItemID in ipairs(firstRewardTable) do if RewardClientItem.ItemID == serverItemID.ItemID then self:AddCellFunc(RewardClientItem) break end end for _, itemID in ipairs(displayItem) do if RewardClientItem.ItemID == itemID then self:AddCellFunc(RewardClientItem) break end end else self:AddCellFunc(RewardClientItem) end end end function UIFightThroneMain:AddCellFunc(RewardClientItem) local cellData = {RewardClientItem, RewardClientItem.FristGothrough} if cellData then self.scroll_Reward:AddData(cellData, 0) end end return UIFightThroneMain