local UIReplayHeroPopUp = UIViewClass() local IconPath = ConstAssetPathConfig.IconPath2 local EventSystem = require('Event/EventSystem') --不同职业图标 local selectProfessionIcon = { [1] = "zr_icon_po02.png", [2] = "zr_icon_tan02.png", [3] = "zr_icon_zhi02.png", [4] = "zr_icon_she02.png", [5] = "zr_icon_fu02.png", [6] = "zr_icon_meng02.png", } --不同职业图标 local unSelectProfessionIcon = { [1] = "zr_msz_ci.png", [2] = "zr_msz_tan.png", [3] = "zr_msz_fa.png", [4] = "zr_msz_she.png", [5] = "zr_msz_fu.png", [6] = "zr_msz_zhan.png", } function UIReplayHeroPopUp:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUpTab.txt_Title, Const_IDS["IDS_FairPlayReplay_HeroChoose"]) self.heroId = context.heroId self.levelType = context.levelType self:InitHeroProfessionTab() end function UIReplayHeroPopUp:OnClosed() end function UIReplayHeroPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIReplayHeroPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUpTab.btn_Close then self:CloseView() end end function UIReplayHeroPopUp:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then if data.isAll then UIUtils.SetActive(cellTable.img_Icon,false) UIUtils.SetActive(cellTable.img_Icon02,false) else UIUtils.SetActive(cellTable.img_Icon,true) UIUtils.SetActive(cellTable.img_Icon02,true) --没选中的图标 UIUtils.SetImageByAssetBundle(cellTable.img_Icon, string.format(IconPath, unSelectProfessionIcon[data.ID])) --选中的图标 UIUtils.SetImageByAssetBundle(cellTable.img_Icon02, string.format(IconPath, selectProfessionIcon[data.ID])) end UIUtils.SetLabelText(cellTable.txt_Name_Nomal,Const_IDS[data.Name]) UIUtils.SetLabelText(cellTable.txt_Name_Selected,Const_IDS[data.Name]) UIUtils.SetActive(cellTable.img_Arrow,false) UIUtils.SetActive(cellTable.img_ArrowS,false) elseif scrollRect == self.loop_Relation then UIUtils.SetLabelText(cellTable.txt_Name,Const_IDS[data.NameIDS]) UIUtils.SetActive(cellTable.img_Selected,data.ID == self.heroId) UTL.Item.SetHeroIconByHeroId(cellTable.img_HeroHead, data.ID) end end function UIReplayHeroPopUp:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.UICommonPopUpTab.loop_Tab then local heroDataArray = self:GetHeroNumDataByTypeId(data.ID) self.loop_Relation:ReloadAll(heroDataArray) elseif scrollRect == self.loop_Relation then EventSystem.Dispatch(EventID.UI_Replay_SelectHero,false,data.ID) self:CloseView() end end local function SortHeroData(a,b) if a.HeroQuality > b.HeroQuality then return true end if a.HeroQuality < b.HeroQuality then return false end return a.ID < b.ID end function UIReplayHeroPopUp:GetHeroNumDataByTypeId(typeId) local data = {} for _,v in DataSheetManager.HeroNum:GetEnumerator() do --过滤掉不显示的金将及品质更高的将 local isCanShow = MDL.HideGolden.IsShowGoldenByID(LuaConst.ShowGoldenType.Hero, v.ID, self.levelType) if isCanShow and (v.TypeID == typeId or typeId == nil) then table.insert(data,v) end end table.sort(data,SortHeroData) return data end function UIReplayHeroPopUp:InitHeroProfessionTab() local allData = {isAll = true,Name = "IDS_FairPlayReplay_All"} self.UICommonPopUpTab.loop_Tab:AddData(allData, 0); for k,v in DataSheetManager.HeroProfession:GetEnumerator() do self.UICommonPopUpTab.loop_Tab:AddData(v, 0); end self.UICommonPopUpTab.loop_Tab:SelectIndex(0) end return UIReplayHeroPopUp