local UIHeroFundChoosePanel = UIViewClass() local HeroHalfCardImagePath = ConstAssetPathConfig.HeroPicPath function UIHeroFundChoosePanel:OnCreated() self.selectId = 0 self.selectHeroName = nil end function UIHeroFundChoosePanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_HeroFund_RefreshPanel, self.RefreshHeroFundChoosePanel) self.type = context.type self:RefreshHeroFundChoosePanel() end function UIHeroFundChoosePanel:RefreshHeroFundChoosePanel() local type = self.type local typeName = CTL.HeroFund.GetTypeName(type) UIUtils.SetLabelText(self.text_Select, Const_IDS[string.format("IDS_%sFund_ChooseHero", typeName)]) UIUtils.SetLabelText(self.txt_Tip, Const_IDS[string.format("IDS_%sFund_Tips3", typeName)]) local titleName, localTitleIDS if type == LuaConst.ShowGoldenType.Hero then titleName = "xzmj_msz.png" localTitleIDS = "IDS_HeroFund_Title" elseif type == LuaConst.ShowGoldenType.Horse then titleName = "xzmj_msz_02.png" localTitleIDS = "IDS_HorseFund_Title" elseif type == LuaConst.ShowGoldenType.Treasure then titleName = "xzmj_msz_01.png" localTitleIDS = "IDS_TreasureFund_Title" end UTL.Item.SetLocalizationImage(self.loc_Title, self.img_Title, titleName) self.img_Title:SetNativeSize() UIUtils.SetLabelText(self.txt_Title, Const_IDS[localTitleIDS]) --界面状态设置 if not CTL.HeroFund.IsHasCanSelectQuality(type) then UIUtils.SetActive(self.txt_Empty, true) UIUtils.SetLabelText(self.txt_Empty, Const_IDS[string.format("IDS_%sFund_Null",typeName)]) else UIUtils.SetActive(self.txt_Empty, false) self.Loop_HeroFundChoose:ClearCells() local sortedList = CTL.HeroFund.GetSortedList(type) for _, v in ipairs(sortedList) do self.Loop_HeroFundChoose:AddData(v, 0) end self.Loop_HeroFundChoose:SelectIndex(0) end end function UIHeroFundChoosePanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.Loop_HeroFundChoose then local type = self.type if type == LuaConst.ShowGoldenType.Hero then UIUtils.SetImageByAssetBundle(cellTable.img_Hero, string.format(HeroHalfCardImagePath, data.HalfCardImage)) cellTable.colorState:SetState(MDL.HeroSelect.IsHasHero(data.ID) and 0 or 1) UIUtils.SetLabelText(cellTable.txt_HeroName, Const_IDS[data.NameIDS]) local heroBreak = MDL.HeroStar.GetHeroStarLevel(data.ID) if heroBreak == 0 then UIUtils.SetLabel(cellTable.txt_LevelName, nil) else UIUtils.SetLabel(cellTable.txt_LevelName, "+" .. heroBreak) end UIUtils.SetActive(cellTable.img_Country, true) UIUtils.SetLocalizationImage(cellTable.img_Country, "country_" .. data.Kingdom .. ".png") cellTable.img_Country:SetNativeSize() elseif type == LuaConst.ShowGoldenType.Horse then UIUtils.SetImageByAssetBundle(cellTable.img_Hero, data.HorsePicture) cellTable.colorState:SetState(MDL.WarHorse.IsHasHorse(data.HorseID) and 0 or 1) UIUtils.SetLabelText(cellTable.txt_HeroName, Const_IDS[data.HorseName]) local horseBreak = CTL.WarHorse.GetCurHorousBreak(data.HorseID) if horseBreak == 0 then UIUtils.SetLabel(cellTable.txt_LevelName, nil) else UIUtils.SetLabel(cellTable.txt_LevelName, "+" .. horseBreak) end UIUtils.SetActive(cellTable.img_Country, false) elseif type == LuaConst.ShowGoldenType.Treasure then UIUtils.SetImageByAssetBundle(cellTable.img_Hero, data.TreasurePicture) cellTable.img_Hero:SetNativeSize() cellTable.colorState:SetState(MDL.Treasure.IsHasTreasure(data.TreasureID) and 0 or 1) UIUtils.SetLabelText(cellTable.txt_HeroName, Const_IDS[data.TreasureName]) local treasureBreak = CTL.Treasure.GetTreasureStarLevel(data.TreasureID) if treasureBreak == 0 then UIUtils.SetLabel(cellTable.txt_LevelName, nil) else UIUtils.SetLabel(cellTable.txt_LevelName, "+" .. treasureBreak) end UIUtils.SetActive(cellTable.img_Country, false) end end end function UIHeroFundChoosePanel:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.Loop_HeroFundChoose then local type = self.type if type == LuaConst.ShowGoldenType.Hero then self.selectId = data.ID self.selectHeroName = UIUtils.GetLocalizedTxt(Const_IDS[data.NameIDS]) elseif type == LuaConst.ShowGoldenType.Horse then self.selectId = data.HorseID self.selectHeroName = UIUtils.GetLocalizedTxt(Const_IDS[data.HorseName]) elseif type == LuaConst.ShowGoldenType.Treasure then self.selectId = data.TreasureID self.selectHeroName = UIUtils.GetLocalizedTxt(Const_IDS[data.TreasureName]) end end end function UIHeroFundChoosePanel:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIHeroFundChoosePanel:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.btn_Select then local hasFunc = CTL.HeroFund.Get_Has_ReachMax_GetStarLevel_Func(self.type) if not hasFunc(self.selectId) then local typeName = CTL.HeroFund.GetTypeName(self.type) CTL.Tips.AddTipsMsg(Const_IDS[string.format("IDS_%sFund_Tips3", typeName)]) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFundChooseTips, { type = self.type, id = self.selectId }) end end end return UIHeroFundChoosePanel