local UITreasureBreakSuccess = UIViewClass() function UITreasureBreakSuccess:OnOpened(context) local treasureId = context.treasureId local activeInfo = MDL.Treasure.GetTreasureInfo(treasureId) local starLevel = activeInfo.TreasureInfo.starLevel local data = DataSheetManager.TreasureStar:GetDataByTreasureID_Star(treasureId, starLevel - 1) UIUtils.SetLabelText(self.UITemplatePopUpZero.txt_Title, Const_IDS.IDS_MagicWeapon_SmallStar) self.txt_OldStar.text = string.FormatByIdsId(Const_IDS.IDS_HeroStarLevel, starLevel - 1) self.txt_NewStar.text = string.FormatByIdsId(Const_IDS.IDS_HeroStarLevel, starLevel) UIUtils.SetActive(self.group_OnlySkill.gameObject, false) UIUtils.SetActive(self.group_Attr.gameObject, false) UIUtils.SetActive(self.group_SkillWithAttr.gameObject, false) UIUtils.SetActive(self.img_FetterBg, false) if data.StarType == LuaConst.UIBreakStarType.Skill then self:SetSkillInfo(data.TreasureSkill, self.group_OnlySkill.img_Skill, self.group_OnlySkill.txt_Skill) UIUtils.SetLabel(self.group_OnlySkill.txt_Skill, UTL.String.FormatCombineTextByID(data.StarText)) UIUtils.SetActive(self.group_OnlySkill.txt_Skill, true) UIUtils.SetActive(self.group_OnlySkill.gameObject, true) else local oldData for i = starLevel - 2, 0, -1 do local tempData = DataSheetManager.TreasureStar:GetDataByTreasureID_Star(treasureId, i) if tempData.StarType == LuaConst.UIBreakStarType.Attrs or tempData.StarType == LuaConst.UIBreakStarType.Both then oldData = tempData break end end if data.StarType == LuaConst.UIBreakStarType.Attrs then self:SetAttrInfo(data.AttrSpecial, oldData) UIUtils.SetActive(self.group_Attr.gameObject, true) elseif data.StarType == LuaConst.UIBreakStarType.Both then self:SetSkillInfo(data.TreasureSkill, self.group_SkillWithAttr.img_SkillIcon, self.group_SkillWithAttr.txt_SkillDesc) local relationState = CTL.Treasure.GetTreasureHeroRelationState(treasureId, activeInfo.EquipHeroId) if CTL.Treasure.IsBreakRelationUp(treasureId) and relationState == CTL.Treasure.RelationState.ActiveRelation then UIUtils.SetLabel(self.txt_SkillRelationDes, CTL.Treasure.GetRelationSkillDesc(treasureId, MDL.Treasure.GetTreasureInfo(treasureId).TreasureInfo.starLevel)) UIUtils.SetActive(self.img_FetterBg, true) end UIUtils.SetLabel(self.group_SkillWithAttr.txt_SkillDesc, UTL.String.FormatCombineTextByID(data.StarText)) self:SetAttrInfo(data.AttrSpecial, oldData) UIUtils.SetActive(self.group_Attr.gameObject, true) UIUtils.SetActive(self.group_SkillWithAttr.gameObject, true) end end CTL.Sound.PlayGameSound("UI_breakthrough_03") end function UITreasureBreakSuccess:OnClosed() CTL.FormationResonance.OpenSubResonanceLevelUp() end function UITreasureBreakSuccess:SetSkillInfo(treasureSkillId, icon, text) local skillData = DataSheetManager.TreasureSkillData:GetDataByTreasureSkill(treasureSkillId) UIUtils.SetImageByAssetBundle(icon, skillData.TreasureSkillIcon) end function UITreasureBreakSuccess:SetAttrInfo(attrSpecialId, oldData) for i = 1, #self.group_AttrInfo do UIUtils.SetActive(self.group_AttrInfo[i].gameObject, false) end local attrData = DataSheetManager.TreasureStarAttrSpecial:GetDataByAttrRepeatID(attrSpecialId).Attr_Table local oldAttrData if oldData ~= nil then oldAttrData = DataSheetManager.TreasureStarAttrSpecial:GetDataByAttrRepeatID(oldData.AttrSpecial).Attr_Table end for i = 1, #attrData do local divLine = self.group_AttrInfo[(i - 1) * 2] if divLine then UIUtils.SetActive(divLine.gameObject, true) end local cell = self.group_AttrInfo[i] local attr = attrData[i] local oldAttr = oldAttrData ~= nil and oldAttrData[i].AttrNum or 0 if attr then UTL.Attr.SetAttrItemByCompName(cell, attr.AttrType, attr.AttrNum, true, true, oldAttr) UIUtils.SetActive(cell.gameObject, true) end end end function UITreasureBreakSuccess:OnButtonClicked(comp) if comp == self.UITemplatePopUpZero.Bottom then self:CloseView() end end return UITreasureBreakSuccess