--[[ 宠物繁殖邀请回拨 ]]-- local UIPetInvite = UIViewClass() local function PetListSort(a, b) return a.Info.petPedigree > b.Info.petPedigree end function UIPetInvite:OnOpened(context) UIUtils.SetLabelText(self.UIPetPopUpSmall.txt_Title, Const_IDS.IDS_PetReproduce8) local petId = context.petId local petConfig = DataSheetManager.PetData:GetDataByID_Stage(petId, MDL.Pet.PetState.Basic) self.petName = UIUtils.GetLocalizedTxt(Const_IDS[petConfig.PetName]) self.playerAcid = context.playerAcid self.playerName = context.playerName local list = MDL.Pet.GetOrderedList() table.sort(list, PetListSort) for _, data in ipairs(list) do if data.Info.petGeneration == 1 and data.Config.ID == petId then if not self.petUniqId then self.petUniqId = data.Info.petUniqId end self.loop_Pet:AddData(data, 0) end end end function UIPetInvite:OnButtonClicked(comp) if comp == self.btn_2 then self:CloseView() elseif comp == self.btn_1 then MDL.Pet.OpenPetBreedViewReq(true, self.petUniqId, true, self.playerAcid, self.playerName) self:CloseView() elseif comp == self.UIPetPopUpSmall.btn_Close then self:CloseView() end end function UIPetInvite:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Pet then local collection = cellTable.pet_Arr[1] CTL.Pet.SetPetIconComp(collection.img_Pet, collection.img_Qua, nil, data.Info.petType, data.Config.Stage ) UIUtils.SetLabel(collection.txt_Level, string.FormatByIdsId(Const_IDS.IDS_RankOptimization_StarName, data.Info.petPedigree)) if self.petUniqId == data.Info.petUniqId then self.CurSelectedImg = collection.img_Select UIUtils.SetActive(self.CurSelectGemImg, true) UIUtils.SetLabel(self.lab_Pelease, string.FormatByIdsId(Const_IDS.IDS_PetBorn_InviteBorn2, data.Info.petPedigree, self.petName)) else UIUtils.SetActive(collection.img_Select, false) end end end function UIPetInvite:OnCellClicked(scrollRect, index, cellTable, target, data) if self.petUniqId == data.Info.petUniqId then return end self.petUniqId = data.Info.petUniqId local collection = cellTable.pet_Arr[1] UIUtils.SetActive(self.CurSelectedImg, false) self.CurSelectedImg = collection.img_Select UIUtils.SetActive(self.CurSelectedImg, true) UIUtils.SetLabel(self.lab_Pelease, string.FormatByIdsId(Const_IDS.IDS_PetBorn_InviteBorn2, data.Info.petPedigree, self.petName)) end return UIPetInvite