local UIStratagemMainPanel = UIViewClass() function UIStratagemMainPanel:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Stratagem_FunctionName) self:RefreshLoopScroll() self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Stratagem, self.RefreshLoopScroll) self:RegistSystemEvent(EventID.UI_Stratagem_Active, self.RefreshLoopScroll) self:SetPushStyle(LuaConst.PushStyleEnum.HIDE) end function UIStratagemMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIStratagemMainPanel:RefreshLoopScroll() local list = MDL.Stratagem.GetSortList() self.loop_StratagemPanel:ReloadAll(list) end function UIStratagemMainPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.Stratagem }) elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Change then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIStratagemEquip) end end function UIStratagemMainPanel:InitSlotTag(slot, cellTable) if slot and slot > 0 then UIUtils.SetActive(cellTable.img_BattleBg, true) if slot == 1 then UTL.Item.SetLocalizationImage(cellTable.loc_Battle, cellTable.img_BattleTitle, "tlrk_msz_zz.png") UIUtils.SetLabelText(cellTable.txt_BattleTitle, Const_IDS.IDS_Stratagem_MainSlot) cellTable.state_BattleBg:SetState(0) else UTL.Item.SetLocalizationImage(cellTable.loc_Battle, cellTable.img_BattleTitle, "tlrk_msz_fz.png") UIUtils.SetLabelText(cellTable.txt_BattleTitle, Const_IDS.IDS_Stratagem_SupportSlot) cellTable.state_BattleBg:SetState(1) end end end function UIStratagemMainPanel:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetImageByAssetBundle(cellTable.img_StratagemIcon, data.PicturePath) local stratagemInfo = MDL.Stratagem.GetStratagemInfo(data.ID) local itemId = data.Item_Table[1].ItemID local num = data.Item_Table[1].ItemNum local haveCount = MDL.Bag.GetItemCount(itemId) if stratagemInfo then UIUtils.SetActive(cellTable.img_Mask, false) UIUtils.SetActive(cellTable.img_Activated, false) UIUtils.SetGray(cellTable.img_StratagemIcon, false) local maxCount = DataSheetManager.StratagemLearn:GetDataLengthByID_LevelID_PointId(data.ID, stratagemInfo.Learn.CurrLvID) local leveId = MDL.Stratagem.GetLearnNextId(data.ID) if leveId then UIUtils.SetLabelText(cellTable.txt_Level, Const_IDS["IDS_Type_EquipShow_" .. leveId]) else UIUtils.SetLabelText(cellTable.txt_Level, Const_IDS["IDS_Type_EquipShow_" .. stratagemInfo.Learn.CurrLvID]) end UIUtils.SetActive(cellTable.img_LevelBg, true) cellTable.txt_ShardNum.text = haveCount local slot = MDL.Stratagem.GetSlotId(data.ID) if slot and slot > 0 then UIUtils.SetActive(cellTable.img_BattleBg, true) self:InitSlotTag(slot, cellTable) else UIUtils.SetActive(cellTable.img_BattleBg, false) end cellTable.cell:SetRedPoint(MDL.Stratagem.IsCanLearnLv(data)) if data.StratagemColorEffect > 0 then UTL.Color.PlayQualityEffect(cellTable.effect_StratagemDarkGold, data.StratagemColorEffect, UTL.Color.EffectType.Main) end else UIUtils.SetActive(cellTable.img_LevelBg, false) UIUtils.SetGray(cellTable.img_StratagemIcon, true) UIUtils.SetActive(cellTable.img_BattleBg, false) if MDL.Stratagem.IsCanActive(data) then UIUtils.SetLabelText(cellTable.txt_Activated, Const_IDS.IDS_Handbook_Hero_AbleToActivate) UIUtils.SetActive(cellTable.img_Activated, true) cellTable.txt_ShardNum.text = UTL.Color.FormatQualityText(haveCount, 1) .. "/" .. num UIUtils.SetActive(cellTable.img_Mask, false) else UIUtils.SetActive(cellTable.img_Activated, false) UIUtils.SetActive(cellTable.img_Mask, true) cellTable.txt_ShardNum.text = UTL.Color.FormatRedColor(haveCount) .. "/" .. num end cellTable.cell:SetRedPoint(false) end UTL.Color.SetQualityImageByType(cellTable.img_QualityBg, data.StratagemQuality, UTL.Color.QualityType.StratagemFrame) cellTable.txt_StratagemName.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[data.StratagemName]), data.StratagemQuality) end function UIStratagemMainPanel:OnCellClicked(scrollRect, index, cellTable, target, data) CTL.Stratagem.OpenInfoView(data) end return UIStratagemMainPanel