local UIMonopolyRewardRecord = UIViewClass() local math_ceil = math.ceil local SingLineShowCount = 5 ----------------------------- 系统函数 ----------------------------- function UIMonopolyRewardRecord:OnOpened() self:RegistSystemEvent(EventID.Monopoly_LoopReward_Refresh, self.RefreshPanel) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS["IDS_Gift_RewardPreview"]) self.activityId = self.context.activityId self:RefreshPanel() end function UIMonopolyRewardRecord:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIMonopolyRewardRecord:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIMonopolyRewardRecord:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.Loop_Scroll then local index = 1 for i = data * SingLineShowCount - SingLineShowCount + 1, data * SingLineShowCount do local reward = cellTable.group_Rewards[index] local loopCfg = CTL.Monopoly:GetLoopRewardCfg(i, self.activityId) UIUtils.SetActive(reward.gameObject, loopCfg ~= nil) if loopCfg then UTL.Item.SetItemCell(reward.Item, loopCfg.LoopRewardID, loopCfg.LoopRewardNum) UIUtils.SetLabel(reward.txt_Loop, loopCfg.LoopNum) UIUtils.SetActive(reward.img_Cover, MDL.Monopoly.GetCurMapRound() >= loopCfg.LoopNum) end index = index + 1 end end end function UIMonopolyRewardRecord:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.Loop_Scroll then local index = 1 for i = data * SingLineShowCount - SingLineShowCount + 1, data * SingLineShowCount do local reward = cellTable.group_Rewards[index] local loopCfg = CTL.Monopoly:GetLoopRewardCfg(i, self.activityId) if loopCfg and target == reward.Item.event_Click then UTL.ItemTips.ShowCommonTipsById(loopCfg.LoopRewardID) end index = index + 1 end end end ------------------------------------------------------------------- function UIMonopolyRewardRecord:RefreshPanel(activityId) if activityId and activityId ~= self.activityId then return end local cellCount = math_ceil(CTL.Monopoly:GetLoopRewardCount(self.activityId) / SingLineShowCount) self.Loop_Scroll:ClearCells() for i = 1, cellCount do self.Loop_Scroll:AddData(i, 0) end end return UIMonopolyRewardRecord