local UIDigForTreasurePanel = UIViewClass() function UIDigForTreasurePanel:OnOpened(context) --local rewardDict = MDL.TeamDungeon.GetDigTreasureRewardDict() self.UICommonPopUpTab.loop_Tab:AddData(0, 0); self.UICommonPopUpTab.loop_Tab:AddData(1, 0); self.digTreasureCount = CTL.TeamDungeon.GetDigTreasureCount() if context then if context.selectIndex then self.UICommonPopUpTab.loop_Tab:SelectIndex(content.selectIndex) else self.digTreasureCount = context.digTreasureCount self.isStop = context.stop self.UICommonPopUpTab.loop_Tab:SelectIndex(0) end else self.UICommonPopUpTab.loop_Tab:SelectIndex(0) end UIUtils.SetLabelText(self.UICommonPopUpTab.txt_Title, Const_IDS.IDS_DigForTreasure_DigTitle) end function UIDigForTreasurePanel:OnClosed() if self.isStop then MDL.TeamDungeon.ClearDigTreasureReward() end end local function SortItem(a, b) local itemDataA = DataSheetManager.ItemData:GetDataByID(a) local itemDataB = DataSheetManager.ItemData:GetDataByID(b) if itemDataA.Color == itemDataB.Color then return a < b else return itemDataA.Color > itemDataB.Color end end function UIDigForTreasurePanel:ShowReward() UIUtils.SetActive(self.Group_Rewards, true) UIUtils.SetActive(self.Group_Set, false) local rewardDict = MDL.TeamDungeon.GetDigTreasureRewardDict() local idList = {} for k,v in pairs(rewardDict) do table.insert(idList, k) end table.sort(idList, SortItem) self.LoopScrollDig:ReloadAll(idList) if self.isStop then UIUtils.SetActive(self.lab, false) self.lab_Set.text = string.FormatByIdsId(Const_IDS.IDS_DigForTreasure_TotalTimes, self.digTreasureCount) else UIUtils.SetActive(self.lab, true) self.lab.text = string.FormatByIdsId(Const_IDS.IDS_DigForTreasure_NumberTimes, self.digTreasureCount) self.lab_Set.text = nil end end function UIDigForTreasurePanel:ShowSetting() local info = MDL.Task.GetTreasureRewardInfo() UIUtils.SetActive(self.lab, false) if MDL.TeamDungeon.CheckUnlockDigForTreasure() then UIUtils.SetActive(self.Group_Rewards, false) UIUtils.SetActive(self.Group_Set, true) local waterBox = MDL.Setting.GetState(LuaConst.BattleSettingEnum.AutoOpenRewardBoxWater) local dirtBox = MDL.Setting.GetState(LuaConst.BattleSettingEnum.AutoOpenRewardBoxDirt) local woodBox = MDL.Setting.GetState(LuaConst.BattleSettingEnum.AutoOpenRewardBoxWood) if waterBox then self.set_toggleGroup:SelectIndex(0) elseif dirtBox then self.set_toggleGroup:SelectIndex(1) elseif woodBox then self.set_toggleGroup:SelectIndex(2) else self.set_toggleGroup:SelectIndex(0) end UIUtils.SetLabelText(self.lab_Set, Const_IDS.IDS_DigForTreasure_SetUpTitle) else self.UICommonPopUpTab.loop_Tab:SelectIndex(0) end end function UIDigForTreasurePanel:OnValueChanged(comp, index) if comp == self.group_Toggle then if index == 0 then self:ShowReward() else self:ShowSetting() end elseif comp == self.set_toggleGroup then self.curSelectBoxIndex = index end end function UIDigForTreasurePanel:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self:CloseView() elseif comp == self.event_Save then if self.curSelectBoxIndex == 0 then CTL.TeamDungeon.SetAutoOpenRewardBox(LuaConst.BattleSettingEnum.AutoOpenRewardBoxWater) CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_SaveSucceed) elseif self.curSelectBoxIndex == 1 then CTL.TeamDungeon.SetAutoOpenRewardBox(LuaConst.BattleSettingEnum.AutoOpenRewardBoxDirt) CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_SaveSucceed) elseif self.curSelectBoxIndex == 2 then CTL.TeamDungeon.SetAutoOpenRewardBox(LuaConst.BattleSettingEnum.AutoOpenRewardBoxWood) CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_SaveSucceed) end end end function UIDigForTreasurePanel:OnCellSelect(scrollRect, index, cellTable, data) end function UIDigForTreasurePanel:OnCellInit(scrollRect, index, cellTable, data) if self.LoopScrollDig == scrollRect then local rewardDict = MDL.TeamDungeon.GetDigTreasureRewardDict() local count = rewardDict[data] UTL.Item.SetItemCell(cellTable.item, data, count) else UIUtils.SetActive(cellTable.img_RedDot, false); UIUtils.SetActive(cellTable.img_Arrow, false) UIUtils.SetActive(cellTable.img_ArrowS, false) UIUtils.SetActive(cellTable.group_SignState, false) UIUtils.SetActive(cellTable.group_SignStateS, false) if index == 0 then UIUtils.SetLabelText(cellTable.txt_Name_Selected, Const_IDS.IDS_DigForTreasure_Reward) UIUtils.SetLabelText(cellTable.txt_Name_Nomal, Const_IDS.IDS_DigForTreasure_Reward) else UIUtils.SetLabelText(cellTable.txt_Name_Nomal, Const_IDS.IDS_DigForTreasure_SetUP) UIUtils.SetLabelText(cellTable.txt_Name_Selected, Const_IDS.IDS_DigForTreasure_SetUP) end end end function UIDigForTreasurePanel:OnCellClicked(scrollRect, index, cellTable, target, data) if self.LoopScrollDig == scrollRect then UTL.ItemTips.ShowCommonTipsById(data) else if index == 0 then self:ShowReward() else self:ShowSetting() end end end return UIDigForTreasurePanel