local UIHeroIllustratedPopUp = UIViewClass() local GRAY_COLOR = "93969c" ---------------------------------------------- 系统函数 ---------------------------------------------------------- function UIHeroIllustratedPopUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_Illustration_HeroLibrary_RefreshPopUp, self.RefreshPanel) self.heroData = context self:RefreshPanel() end function UIHeroIllustratedPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIHeroIllustratedPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Interactive then local isCanUpdate = MDL.HeroLibrary.IsHeroCanUpdate(self.heroData.ID) if not isCanUpdate then local heroLibraryLevel = MDL.HeroLibrary.GetHeroLevel(self.heroData.ID) if heroLibraryLevel == -1 then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_Activate_NoCondition"], UIUtils.GetLocalizedTxt(Const_IDS[self.heroData.NameIDS]))) else local maxStar = MDL.HeroStar.GetHeroMaxStarLevel(self.heroData.ID) if heroLibraryLevel < maxStar then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelUp_NoCondition"], UIUtils.GetLocalizedTxt(Const_IDS[self.heroData.NameIDS]))) elseif heroLibraryLevel == maxStar then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_44365_InfoCode_HeroAwaken_HeroNotAwaken"]) else CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_NotAwakenEnough1"], UIUtils.GetLocalizedTxt(Const_IDS[self.heroData.NameIDS]))) end end return end MDL.HeroLibrary.RequestUpdateHeroLevel(self.heroData.ID) end end ------------------------------------------------------------------------------------------------------------------- function UIHeroIllustratedPopUp:RefreshPanel(isPlayEft) UIUtils.SetActive(self.group_HeroCard.gameObject,true) UIUtils.SetActive(self.group_WeaponCard.gameObject,false) UIUtils.SetActive(self.group_TreasureHorseCard.gameObject,false) UIUtils.SetActive(self.group_LightEffectSuitCard.gameObject, false) UTL.Color.SetQualityImageByType(self.group_HeroCard.img_Quality, CTL.HeroAwaken.GetHeroQuality(self.heroData.ID, MDL.HeroAwaken.GetIsHeroAwaken(self.heroData.ID)), UTL.Color.QualityType.Pictorial) if MDL.HeroAwaken.GetIsHeroAwaken(self.heroData.ID) then CTL.HeroAwaken.SetHeroHalfCardImageByHeroId(self.group_HeroCard.img_Hero, self.heroData.ID) else UTL.Item.SetHeroHalfCardImageByHeroId(self.group_HeroCard.img_Hero, self.heroData.ID) end if isPlayEft then self.group_HeroCard.effect_Refresh:PlayUIEffect() end local isCanUpdate = MDL.HeroLibrary.IsHeroCanUpdate(self.heroData.ID) local heroLibraryLevel = MDL.HeroLibrary.GetHeroLevel(self.heroData.ID) local curCfg if heroLibraryLevel >= 0 then curCfg = DataSheetManager.HeroPictorialType:GetDataByHeroPictorialTypeID_PictorialLevel(self.heroData.HeroPictorialType, heroLibraryLevel) end local __, nextCfg = DataSheetManager.HeroPictorialType:TryGetDataByHeroPictorialTypeID_PictorialLevel(self.heroData.HeroPictorialType, heroLibraryLevel + 1) if not nextCfg then UIUtils.SetLabelText(self.txt_Condition, Const_IDS["IDS_Handbook_Hero_LevelUp_Max"]) self.UIStateCondition:SetState(2) else self.UIStateCondition:SetState(isCanUpdate and 0 or 1) if heroLibraryLevel == -1 then UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_ActivateCondition_Tip"], UIUtils.GetLocalizedTxt(Const_IDS[self.heroData.NameIDS]))) else local heroMaxStar = MDL.HeroStar.GetHeroMaxStarLevel(self.heroData.ID) if heroLibraryLevel < heroMaxStar then UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelUp_Tip"], nextCfg.StarLevel)) elseif heroLibraryLevel == heroMaxStar then UIUtils.SetLabelText(self.txt_Condition, Const_IDS["IDS_ContrastID_44"]) else UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_HeroAwakenTo"], nextCfg.StarLevel - 1 - heroMaxStar)) end end end UIUtils.SetLabelText(self.txt_HeroScoreTitle,Const_IDS.IDS_Handbook_Hero_HeroScore) local heroName = UIUtils.GetLocalizedTxt(Const_IDS[self.heroData.NameIDS]) if MDL.HeroAwaken.GetIsHeroAwaken(self.heroData.ID) then heroName = string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_Awaken"], heroName) end UIUtils.SetLabel(self.group_HeroCard.txt_Name, heroLibraryLevel == -1 and UTL.Color.FormatTextByColor(GRAY_COLOR, heroName) or UTL.Color.FormatQualityText(heroName, CTL.HeroAwaken.GetHeroQuality(self.heroData.ID, MDL.HeroAwaken.GetIsHeroAwaken(self.heroData.ID)))) UIUtils.SetLabelText(self.txt_ConditionTitle, heroLibraryLevel == -1 and Const_IDS["IDS_Handbook_Hero_ActivateCondition"] or Const_IDS["IDS_GuildCultivation_LevelUpHint"]) UIUtils.SetLabel(self.txt_NumBefore, curCfg and curCfg.Score or 0) UIUtils.SetLabel(self.txt_NumAfter, nextCfg and nextCfg.Score or curCfg.Score) UIUtils.SetActive(self.img_NumberIcon, nextCfg ~= nil) UIUtils.SetActive(self.txt_NumAfter, nextCfg ~= nil) UIUtils.SetGray(self.group_HeroCard.img_Quality, heroLibraryLevel == -1) UIUtils.SetGray(self.group_HeroCard.img_Hero, heroLibraryLevel == -1) UIUtils.SetActive(self.group_HeroCard.img_Gray, heroLibraryLevel == -1) UIUtils.SetActive(self.group_HeroCard.group_Lv, heroLibraryLevel > -1) UIUtils.SetLabel(self.group_HeroCard.txt_LibraryLv, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelNum"], heroLibraryLevel)) --属性数量是动态变化的,所以先隐藏所有 for i=1,#self.group_Attr do UIUtils.SetActive(self.group_Attr[i].gameObject,false) end local showCfg = curCfg or nextCfg for i, v in ipairs (showCfg.Attr_Table) do UIUtils.SetActive(self.group_Attr[i].gameObject,true) local attrCfg = DataSheetManager.AttrData:GetDataByID(v.AttrType) local groupAttr = self.group_Attr[i] UIUtils.SetLabelText(groupAttr.txt_Attr, Const_IDS[attrCfg.Name]) UTL.Item.SetAtlasSprite(groupAttr.img_AttrIcon,"UI_Common", attrCfg.Icon) UIUtils.SetLabel(groupAttr.txt_NumBefore, curCfg and curCfg.Attr_Table[i].AttrNum or 0) UIUtils.SetLabel(groupAttr.txt_NumAfter, nextCfg and nextCfg.Attr_Table[i].AttrNum or curCfg.Attr_Table[i].AttrNum) UIUtils.SetActive(groupAttr.img_Icon, nextCfg ~= nil) UIUtils.SetActive(groupAttr.txt_NumAfter, nextCfg ~= nil) end self.btn_Interactive:SetGray(not isCanUpdate, true) UIUtils.SetActive(self.btn_Interactive, nextCfg ~= nil) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, heroLibraryLevel == -1 and Const_IDS["IDS_Handbook_Hero_Activate_Title"] or Const_IDS["IDS_Handbook_Hero_LevelUp_Title"]) UIUtils.SetLabelText(self.txt_Btn, heroLibraryLevel == -1 and Const_IDS["IDS_Handbook_Hero_Activate_Button"] or Const_IDS["IDS_Handbook_Hero_LevelUp_Button"]) end return UIHeroIllustratedPopUp