local UIDrawStrawsPopUp = UIViewClass() local EventSystem = require('Event/EventSystem') local draw_straws_pb = require 'Proto.draw_straws_pb' ---------------------------------- 系统函数 ----------------------------------- function UIDrawStrawsPopUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_DrawStraws_RefreshTask, self.RefreshTaskRewards) MDL.Reward.SetCloseRewardTipShow(true) --关闭奖励提示 UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_DrawStraws_Title) UIUtils.SetLabel(self.txt_TaskInfo, string.FormatByIdsKey("IDS_DrawStraws_TaskInfo", UTL.Time.GetDiffLocalStrById(1))) self.cfgData = context.cfgData self.UICommonPopUp.loop_Tab:AddData(UIUtils.GetLocalizedTxt(Const_IDS.IDS_DrawStraws_Task), 0) self.UICommonPopUp.loop_Tab:AddData(UIUtils.GetLocalizedTxt(Const_IDS.IDS_DrawStraws_RewardPoolShow), 0) self.UICommonPopUp.loop_Tab:SelectIndex(context.selectIndex) end function UIDrawStrawsPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIDrawStrawsPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIDrawStrawsPopUp:OnClosed() -- 打开奖励提示 MDL.Reward.SetCloseRewardTipShow(false) end function UIDrawStrawsPopUp:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUp.loop_Tab then UIUtils.SetLabel(cellTable.txt_Name_Nomal, data) UIUtils.SetLabel(cellTable.txt_Name_Selected, data) UIUtils.SetActive(cellTable.img_Arrow, false) UIUtils.SetActive(cellTable.img_ArrowS, false) elseif scrollRect == self.loop_DrawProbability then for i, v in ipairs (cellTable.group_ItemInfo) do local itemData = data[i] if itemData then UIUtils.SetActive(v.item.gameObject, true) UTL.Item.SetItemCell(v.item, itemData.ItemID, itemData.ItemNum) else UIUtils.SetActive(v.item.gameObject, false) end end elseif scrollRect == self.loop_DrawTask then local triggerData = DataSheetManager.TriggerID:GetDataByID(data.TriggerID) local rewardState = MDL.DrawStraws.GetTriggerRewardState(data.TriggerID) UIUtils.SetLabel(cellTable.txt_Task, MDL.Unlock.GetDesByTriggerID(triggerData.Unlock_Table[1], rewardState ~= draw_straws_pb.State_NoReach, MDL.DrawStraws.GetTriggerProgress(data.TriggerID))) local taskReward = DataSheetManager.DrawStrawsTaskReward:GetDataByID(data.TaskReward) UTL.Item.SetItemCell(cellTable.item, taskReward.TotalReward_Table[1].ItemId, taskReward.TotalReward_Table[1].ItemCount) if rewardState == draw_straws_pb.State_ReachNoGet then cellTable.UIState:SetState(0) elseif rewardState == draw_straws_pb.State_Get then cellTable.UIState:SetState(2) else local triggerTypeData = DataSheetManager.TriggerType:GetDataByID(triggerData.Unlock_Table[1].UnlockCondition) cellTable.UIState:SetState(triggerTypeData.ItemSourceID > 0 and 1 or 3) end end end function UIDrawStrawsPopUp:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.UICommonPopUp.loop_Tab then UIUtils.SetActive(self.loop_DrawTask, index == 0) UIUtils.SetActive(self.group_Probability, index == 1) UIUtils.SetActive(self.txt_TaskInfo, index == 0) if index == 1 then self:RefrehRewards() elseif index == 0 then self:RefreshTasks() end elseif scrollRect == self.loop_DrawProbability then for i, v in ipairs (cellTable.group_ItemInfo) do if v.item.event_Click == target then local itemData = data[i] if itemData then UTL.ItemTips.ShowCommonTipsById(itemData.ItemID) end break end end elseif scrollRect == self.loop_DrawTask then if target == cellTable.item.event_Click then local taskReward = DataSheetManager.DrawStrawsTaskReward:GetDataByID(data.TaskReward) UTL.ItemTips.ShowCommonTipsById(taskReward.TotalReward_Table[1].ItemId) elseif target == cellTable.btn_Get then MDL.DrawStraws.RequestDrawTaskRewards(data.TriggerID) elseif target == cellTable.btn_Go then local triggerData = DataSheetManager.TriggerID:GetDataByID(data.TriggerID) local triggerTypeData = DataSheetManager.TriggerType:GetDataByID(triggerData.Unlock_Table[1].UnlockCondition) CTL.ItemSources.ExecuteSourceFunctionById(triggerTypeData.ItemSourceID) end end end ------------------------------------------------------------------------------- function UIDrawStrawsPopUp:RefrehRewards() if self.loop_DrawProbability.Count > 0 then return end local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(self.cfgData.RewardShow) local showDataItemTable = DataSheetUtil.GetRewardClientShowItemTable(cfg) self.itemList = {} local itemListCount = 0 local index = 0 for i, v in ipairs (showDataItemTable) do if index == 0 then table.insert(self.itemList, LuaExt.CreateTable(6)) itemListCount = itemListCount + 1 end index = index + 1 local itemDatas = self.itemList[itemListCount] itemDatas[index] = v if index == 6 or not showDataItemTable[i + 1] then index = 0 self.loop_DrawProbability:AddData(itemDatas, 0) end end end function UIDrawStrawsPopUp:RefreshTasks() if self.loop_DrawTask.Count == 0 then for _, v in ipairs (self.cfgData.Trigger_Table) do self.loop_DrawTask:AddData(v, 0) end else self.loop_DrawTask:RefreshCells(false) end end function UIDrawStrawsPopUp:RefreshTaskRewards(rewardItems) if rewardItems then UIManager.OpenView(Const_UI_Lua.UIEnum.UIRewardGainPanel, rewardItems) end self:RefreshTasks() end return UIDrawStrawsPopUp