local UIBaseOptional = require "View/Common/UIBaseOptional" local UIHorseOptional = UIViewClass(UIBaseOptional) local HorseSort = function(a, b) return a.HorseID < b.HorseID end function UIHorseOptional:Init() self:RegistSystemEvent(EventID.UI_HorseRear_ChooseHorse, self.CloseView) self.curID = MDL.HorseRear.GetRearHorseChooseId(self.activityId) self.isSuperGold = CTL.HorseRear.IsSuperGold(self.activityId) self.noteID = LuaConst.NoteID.OptionalHorse local cardPoolList, selectPoolInfo = CTL.HorseRear.GetActivitySameQualityHorse(self.activityId, self.curID) table.sort(cardPoolList, HorseSort) table.insert(cardPoolList, 1, selectPoolInfo) self.cardPoolList = cardPoolList self.group_Remind.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OptionalHorseAndTreasure_Hint2) self.lab_Title.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OptionalHorseAndTreasure_Title2) end function UIHorseOptional:OnButtonClicked(comp) if comp == self.btn_Confirm then if self.selectID == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_OptionalHorseAndTreasure_Title2) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIHorseOptionalPopup, {activityId = self.activityId, leftID = self.curID, rightID = self.selectID}, Const_UI_Lua.UIEnum.UIGoldHeroOptionalPupup) end else UIBaseOptional.OnButtonClicked(self, comp) end end function UIHorseOptional:RefreshCellInfo(cellTable, data) cellTable.state_Type:SetState(1) UIUtils.SetImageByAssetBundle(cellTable.img_Hero, data.HorsePicture) cellTable.img_Hero:SetNativeSize() local activeInfo = MDL.WarHorse.GetInfoByID(data.HorseID) if activeInfo then cellTable.group_Break:SetState(1) UIUtils.SetLabel(cellTable.txt_BreakLevel, string.FormatByIdsId(Const_IDS.IDS_HeroStarLevel, "+" .. activeInfo.HorseInfo.starLevel)) else cellTable.group_Break:SetState(0) end cellTable.txt_OtherName.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[data.HorseName]), data.HorseQuality) UIUtils.SetActive(cellTable.group_Now, self.curID == data.HorseID) end function UIHorseOptional:CellClicked(data, index) if self.curID == data.HorseID then CTL.Tips.AddTipsMsg(Const_IDS.IDS_OptionalHorseAndTreasure_Hint4) return else if self.selectID ~= data.HorseID then self.selectID = data.HorseID self:PlaySelectEffect(index) end end end return UIHorseOptional