--[[ 宠物养成信息界面 (普通:洗宠) (神宠:激活 + 进阶) param = {petTypeID = 1, petUniqueID = "uniqueID"} 预览只传petTypeID 常规传petUniqueID ]]-- local UIPetDetailBase = UIViewClass() function UIPetDetailBase:OnCreated() self.cells = { [1] = self.cell_Skill01, [2] = self.cell_Skill02, [3] = self.cell_Skill03, [4] = self.cell_Skill04, [5] = self.cell_Skill05, [6] = self.cell_Skill06, } end function UIPetDetailBase:OnOpened(context) self.skillShowArr = {} self:RegistSystemEvent(EventID.UI_Pet_UpdateBasePanel, self.UpdateBasePanel) CTL.Bag.RegisteEventByItemType(LuaConst.ItemType.Pet, self.UpdateActiveMat, self, LuaConst.ItemMaterialsType.JingHunStone) self:UpdateBasePanel(context) end function UIPetDetailBase:OnClosed() CTL.Bag.UnRegisteEventByItemType(LuaConst.ItemType.Pet, self.UpdateActiveMat, self, LuaConst.ItemMaterialsType.JingHunStone) end function UIPetDetailBase:UpdateBasePanel(context) self:InitParam(context) self:RefreshPanel() end function UIPetDetailBase:InitParam(contextParam) if string.isNilOrEmpty(contextParam.petUniqueID) then self.isPreview = true self.petConfig = DataSheetManager.PetData:GetDataByID_Stage(contextParam.petTypeID, MDL.Pet.PetState.Basic) else self.isPreview = false local info = MDL.Pet.GetActiveInfo(contextParam.petUniqueID) self.petInfo = info.Info self.petConfig = info.Config end end function UIPetDetailBase:RefreshPanel() UIUtils.SetActive(self.group_Final, false) if self.isPreview then self.state_Btn:SetState(0) CTL.Pet.SetPetAptitudePreviewInfo(self.Attr_arr, self.petConfig.Talent_Table) if MDL.Pet.CanActiveGodPet(self.petConfig.ID) then self.btn_Active:SetRedPoint(true) else self.btn_Active:SetRedPoint(false) end else CTL.Pet.SetPetAptitude(self.Attr_arr, self.petInfo, self.petConfig) if self.petConfig.Quality == MDL.Pet.PetQuality.God then self.state_Btn:SetState(1) if CTL.Pet.CanGodPetBreak(self.petInfo) then self.btn_Advanced:SetRedPoint(true) else self.btn_Advanced:SetRedPoint(false) end local godPetStarCfg = DataSheetManager.GodPetStar:GetDataByPetID_PetStar(self.petInfo.petType, self.petInfo.bigBreak) if godPetStarCfg.GodPetStarTalentID <= 0 then UIUtils.SetActive(self.group_Final, true) UIUtils.SetActive(self.btn_Advanced, false) end else self.state_Btn:SetState(2) end end self:RefreshSkill() self:UpdateActiveMat() end function UIPetDetailBase:RefreshSkill() table.clearArray(self.skillShowArr) if self.isPreview then for i, v in ipairs(self.petConfig.TalentSkill) do table.insert(self.skillShowArr, v) end for i, v in ipairs(self.petConfig.ChildTalentSkill) do table.insert(self.skillShowArr, v) end else for i, v in ipairs(self.petInfo.congenitalSkill) do table.insert(self.skillShowArr, v) end end if #self.skillShowArr > 3 then UIUtils.SetActive(self.group_Godskills, true) else UIUtils.SetActive(self.group_Godskills, false) end CTL.Pet.SetTalentSkillGroup(self.cells, self.skillShowArr) end function UIPetDetailBase:OnButtonClicked(comp) if comp == self.btn_Active then MDL.Pet.GodPetActivateReq(self.petConfig.ID) elseif comp == self.btn_Advanced then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGodPetBreak, { petUniqueID = self.petInfo.petUniqId }) elseif comp == self.btn_Succinct then if self.petInfo.petGeneration == 1 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Pet_OnlyChildCan"]) return end UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIPetSuccinct, { petUniqueID = self.petInfo.petUniqId }) else for i, v in ipairs(self.cells) do if comp == v.btn_Skill then CTL.Pet.ShowSkillTips(self.skillShowArr[i]) return end if comp == v.img_Locked then CTL.Pet.ShowSkillUnlockTips(i) return end end for i, v in ipairs(self.Attr_arr) do if comp == v.btn_Attr then CTL.Pet.ShowTalentDesc(self.petConfig, self.petInfo, i, comp) return end end end end function UIPetDetailBase:UpdateActiveMat() if self.isPreview then local count = MDL.Bag.GetItemCount(self.petConfig.PieceItem) or 0 local showCount if count >= self.petConfig.PieceItemNum then showCount = UTL.Color.FormatGreenColor(count) .. "/" .. self.petConfig.PieceItemNum else showCount = UTL.Color.FormatRedColor(count) .. "/" .. self.petConfig.PieceItemNum end UIUtils.SetLabel(self.txt_ActiveNum, showCount) else self.txt_ActiveNum.text = nil end end return UIPetDetailBase