local UIGachaRewardLimit = UIViewClass() local ProgressStr = "(%s/%s)" -------------------------------- 系统函数 ------------------------------------------- function UIGachaRewardLimit:OnOpened(context) self.activityId = context.activityId self.poolId = context.poolId self.curRewardIndex = context.curRewardIndex self.curDrawCount = context.curDrawCount self:RegistSystemEvent(EventID.UI_GachaLimit_Refresh, self.RefreshDrawRewardList) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:InitView() self:RefreshDrawRewardList() end function UIGachaRewardLimit:InitView() UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_SuperGoldHeroActivity_DrawCard_Hint_13) self.descIDS = Const_IDS.IDS_DrawCard_LimitAccumulativeRewardHint3 end function UIGachaRewardLimit:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIGachaRewardLimit:RefreshDrawRewardList() if self.loop_RewardList.Count > 0 then self.loop_RewardList:ClearCells() end for i, v in DataSheetManager.DrawCardReward:GetDataByID_ChildID(self.poolId) do if i > self.curRewardIndex then self.loop_RewardList:AddData(v, 0) end end for i, v in DataSheetManager.DrawCardReward:GetDataByID_ChildID(self.poolId) do if i > self.curRewardIndex then return end self.loop_RewardList:AddData(v, 0) end end function UIGachaRewardLimit:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIGachaRewardLimit:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIGachaRewardLimit:SetRewardItem(cellTable, data) UTL.Item.SetItemCell(cellTable.Item, data.Item_Table[1].ItemID, data.Item_Table[1].ItemNum) end function UIGachaRewardLimit:OnClickRewardItem(cellTable, target, data) if cellTable.Item.event_Click == target then UTL.ItemTips.ShowCommonTipsById(data.Item_Table[1].ItemID) end end function UIGachaRewardLimit:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_RewardList then local needDrawNum = data.DrawNum UIUtils.SetLabel(cellTable.txt_CumulativeRecruitment, string.FormatByIdsId(self.descIDS, needDrawNum)) local itemId, countInBag = CTL.ActivityGacha.GetConsumeItemInfos(self.poolId) UTL.Item.SetCurrencyImageIcon(cellTable.img_RecruitIcon, itemId) if data.ChildID <= self.curRewardIndex then cellTable.state_Reward:SetState(2) else if self.curDrawCount >= needDrawNum then cellTable.state_Reward:SetState(1) else cellTable.state_Reward:SetState(0) end end if cellTable.slider_Score then cellTable.slider_Score.value = self.curDrawCount / needDrawNum end if self.curDrawCount >= needDrawNum then UIUtils.SetLabel(cellTable.txt_RecruitNum, string.format(ProgressStr, UTL.Color.FormatGreenColor(needDrawNum), needDrawNum)) else UIUtils.SetLabel(cellTable.txt_RecruitNum, string.format(ProgressStr, self.curDrawCount, needDrawNum)) end self:SetRewardItem(cellTable, data) end end function UIGachaRewardLimit:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_RewardList then self:OnClickRewardItem(cellTable, target, data) end end return UIGachaRewardLimit