--[[ 宠物更换确认弹窗 ]]-- local UIPetChangeConfirm = UIViewClass() function UIPetChangeConfirm:OnOpened(context) local oldData = MDL.Pet.GetActiveInfo(context.oldPetUniqId) local oldPetInfo, oldPetCfg = oldData.Info, oldData.Config local newData = MDL.Pet.GetActiveInfo(context.newPetUniqId) local newPetInfo, newPetCfg = newData.Info, newData.Config self:SetPetInfo(self.group_OldHeroHead, oldPetInfo, oldPetCfg) self:SetPetInfo(self.group_NewHeroHead, newPetInfo, newPetCfg) local oldPetName = string.isNilOrEmpty(oldPetInfo.petName) == false and oldPetInfo.petName or UIUtils.GetLocalizedTxt(Const_IDS[oldPetCfg.PetName]) UIUtils.SetLabel(self.txt_Desc, string.FormatByIdsId(Const_IDS.IDS_Pet_ChangeTips, oldPetName)) UIUtils.SetLabelText(self.UICommonPopShowView.TextBtn1, Const_IDS.IDS_BUTTON_CHANGE) UIUtils.SetLabelText(self.UICommonPopShowView.lab_Title, Const_IDS.IDS_Formation_ChangePet_FucName) UIUtils.SetLabelText(self.UICommonPopShowView.TextBtn2, Const_IDS.IDS_BUTTON_CANCEL) end function UIPetChangeConfirm:SetPetInfo(col, petInfo, petCfg) UTL.Color.SetQualityImageByType(col.bg_HeroHead, petCfg.PetQualityFrame, UTL.Color.QualityType.Square) UIUtils.SetImageByAssetBundle(col.img_HeroHead, petCfg.PetIcon) if petInfo.bigBreak == 0 then UIUtils.SetActive(col.bg_Break, false) else UIUtils.SetActive(col.bg_Break, true) UIUtils.SetLabel(col.lab_Break, "+" .. petInfo.bigBreak) end end function UIPetChangeConfirm:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopShowView.btn_2) end function UIPetChangeConfirm:OnButtonClicked(comp) if comp == self.UICommonPopShowView.btn_1 then MDL.Pet.PetSlotLineUpReq(self.context.changeSlotIndex, self.context.newPetUniqId) self:CloseView() elseif comp == self.UICommonPopShowView.btn_2 then self:CloseView() end end return UIPetChangeConfirm