local UIBaseOptional = require "View/Common/UIBaseOptional" local UIMonopolyTreasureOptional = UIViewClass(UIBaseOptional) local TreasSort = function(a, b) return a.TreasureID < b.TreasureID end function UIMonopolyTreasureOptional:Init() self:RegistSystemEvent(EventID.UI_Monopoly_ChooseTreasure, self.CloseView) self.curID = MDL.Monopoly.GetTreasureChooseId(self.activityId) self.isSuperGold = CTL.Monopoly.IsSuperGold(self.activityId) self.noteID = LuaConst.NoteID.OptionalTreasure local cardPoolList, selectPoolInfo = CTL.Monopoly.GetActivitySameQualityTreasure(self.activityId, self.curID) table.sort(cardPoolList, TreasSort) table.insert(cardPoolList, 1, selectPoolInfo) self.cardPoolList = cardPoolList self.group_Remind.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OptionalHorseAndTreasure_Hint1) self.lab_Title.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OptionalHorseAndTreasure_Title1) end function UIMonopolyTreasureOptional:OnButtonClicked(comp) if comp == self.btn_Confirm then if self.selectID == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_OptionalHorseAndTreasure_Title1) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIMonopolyTreasureOptionalPopup, {activityId = self.activityId, leftID = self.curID, rightID = self.selectID}, Const_UI_Lua.UIEnum.UIGoldHeroOptionalPupup) end else UIBaseOptional.OnButtonClicked(self, comp) end end function UIMonopolyTreasureOptional:RefreshCellInfo(cellTable, data) cellTable.state_Type:SetState(1) UIUtils.SetImageByAssetBundle(cellTable.img_Hero, data.TreasurePicture) cellTable.img_Hero:SetNativeSize() local activeInfo = MDL.Treasure.GetTreasureInfo(data.TreasureID) if activeInfo then cellTable.group_Break:SetState(1) UIUtils.SetLabel(cellTable.txt_BreakLevel, string.FormatByIdsId(Const_IDS.IDS_HeroStarLevel, "+" .. activeInfo.TreasureInfo.starLevel)) else cellTable.group_Break:SetState(0) end cellTable.txt_OtherName.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[data.TreasureName]),data.TreasureQuality) UIUtils.SetActive(cellTable.group_Now, self.curID == data.TreasureID) end function UIMonopolyTreasureOptional:CellClicked(data, index) if self.curID == data.TreasureID then CTL.Tips.AddTipsMsg(Const_IDS.IDS_OptionalHorseAndTreasure_Hint3) return else if self.selectID ~= data.TreasureID then self.selectID = data.TreasureID self:PlaySelectEffect(index) end end end return UIMonopolyTreasureOptional