local UIMaterialLevelMainPanel = UIViewClass() local Image_Path = ConstAssetPathConfig.Image_Path1 local EventSystem = require('Event/EventSystem') function UIMaterialLevelMainPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_MaterialLevel_Refresh,self.RefreshCell) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.RefreshAutoRefineKey) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_ResourcesChapter_Title_1"]) self.resourcesChapterList = { LuaConst.ActivityType.ResourcesChapterChild1, LuaConst.ActivityType.ResourcesChapterChild2, LuaConst.ActivityType.ResourcesChapterChild3, } if CTL.WinLogin.IsGameStreamerPackage() then table.insert(self.resourcesChapterList, LuaConst.ActivityType.ResourcesChapterChild205) end table.insert(self.resourcesChapterList, LuaConst.ActivityType.ResourcesChapterChild4) for i = 1, #self.resourcesChapterList do self.scroll_MaterialLevel:AddData(self.resourcesChapterList[i],0) end -- 一键洗练 self:RefreshAutoRefineKey(MDL.Unlock.FunctionType.MaterialLevelAutoRefine, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.MaterialLevelAutoRefine)) end function UIMaterialLevelMainPanel:RefreshAutoRefineKey(funcID, isUnlock) if funcID == MDL.Unlock.FunctionType.MaterialLevelAutoRefine then if isUnlock then MDL.MaterialLevel.GetSweepResourceLevelConfigReq() end UIUtils.SetActive(self.btn_Sweep, isUnlock) UIUtils.SetActive(self.btn_Set, isUnlock) end end function UIMaterialLevelMainPanel:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) EventSystem.Dispatch(EventID.UI_Activity_Refresh_ListOrder) end function UIMaterialLevelMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIMaterialLevelMainPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.btn_Sweep then if MDL.MaterialLevel.CheckAutomateSweep() then MDL.MaterialLevel.OneKeySweepResourceLevelReq() end elseif comp == self.btn_Set then UIManager.OpenView(Const_UI_Lua.UIEnum.UIMaterialLevelSweepPanel) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() end end function UIMaterialLevelMainPanel:OnCellInit(scrollRect, index, cellTable, data) local materialData = DataSheetManager.ResourcesChapterBase:GetDataByID(data) local activityData = DataSheetManager.ActivityData:GetDataByID(data) local namePath = string.format(Image_Path,activityData.BackgroundImage) UIUtils.SetImageByAssetBundle(cellTable.img_MaterialLevel,namePath) UTL.Item.ItemIconWithoutBg(cellTable.img_Rewards,materialData.RewardItem) UIUtils.SetLabelText(cellTable.lab_NameResources,Const_IDS[activityData.Activity]) if data == LuaConst.ActivityType.ResourcesChapterChild4 then UIUtils.SetGray(cellTable.img_BgMaterialLevel,true) UIUtils.SetGray(cellTable.img_MaterialLevel,true) UIUtils.SetActive(cellTable.group_CommingSoon, true) UIUtils.SetActive(cellTable.img_Locked, false) UIUtils.SetActive(cellTable.btn_AddCount, false) UIUtils.SetActive(cellTable.group_Rewards, false) UIUtils.SetActive(cellTable.group_New, false) cellTable.lab_NameRewards.text = nil return end UIUtils.SetLabelText(cellTable.lab_NameRewards,Const_IDS[materialData.RewardText]) UIUtils.SetActive(cellTable.btn_AddCount, true) UIUtils.SetActive(cellTable.group_Rewards, true) UIUtils.SetActive(cellTable.group_CommingSoon, false) local isOpen = MDL.Unlock.IsComplete(materialData.UnlockCondition,materialData.UnlockConditionParam) UIUtils.SetGray(cellTable.img_BgMaterialLevel,not isOpen) UIUtils.SetGray(cellTable.img_MaterialLevel,not isOpen) ---UIUtils.SetGray(cellTable.img_BgNameMaterialLevel,not isOpen) UIUtils.SetActive(cellTable.img_Locked, not isOpen) UIUtils.SetActive(cellTable.add_Count_bg, isOpen) -- 解锁条件和解锁数量拆分了2个txt, 未解锁状况下隐藏解锁数量的背景黑点 if isOpen then local count,totalCount = MDL.MaterialLevel.GetCount(data) if count == 0 then count = UTL.Color.FormatRedColor(count) else count = UTL.Color.FormatGreenColor(count) end UIUtils.SetLabel(cellTable.txt_Times, string.FormatByIdsId(Const_IDS.IDS_ResourcesChapter_RewardTimes, count, totalCount)) else UIUtils.SetLabel(cellTable.txt_Lock, string.FormatByIdsId(Const_IDS.IDS_ResourcesChapter_UnlockReminder_1, materialData.UnlockConditionParam)) end UIUtils.SetActive(cellTable.group_New, MDL.MaterialLevel.IsNewOpen(data) and isOpen) -- 已完成、可购买标记显隐 local activityData = DataSheetManager.ActivityData:GetDataByID(materialData.ID) local materialInfo = MDL.MaterialLevel.GetDataBychapterId(materialData.ID) local curBuyCount = #activityData.PayNum if materialInfo then curBuyCount = #activityData.PayNum - materialInfo.purchaseNums end UIUtils.SetGray(cellTable.img_AddCount, not (curBuyCount > 0)) UIUtils.SetActive(cellTable.group_AddCount, isOpen) end function UIMaterialLevelMainPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if data == LuaConst.ActivityType.ResourcesChapterChild4 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_NotOpen) return end local materialData = DataSheetManager.ResourcesChapterBase:GetDataByID(data) local isOpen = MDL.Unlock.IsComplete(materialData.UnlockCondition,materialData.UnlockConditionParam) if not isOpen then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_ResourcesChapter_UnlockReminder_2) else -- 购买按钮 if cellTable.btn_AddCount == target then CTL.MaterialLevel.OpenTimeUpView(data) else UIManager.OpenAndPush(Const_UI_Lua.UIEnum.UIMaterialLevel, {id = data}, nil, Const_UI_Lua.UIEnum.UIMaterialLevelMainPanel) end end end function UIMaterialLevelMainPanel:RefreshCell() self.scroll_MaterialLevel:ReloadAll(self.resourcesChapterList) end return UIMaterialLevelMainPanel