local UIWeaponIllustratedPopUp = UIViewClass() local GRAY_COLOR = "93969c" ---------------------------------------------- 系统函数 ---------------------------------------------------------- function UIWeaponIllustratedPopUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_Illustration_WeaponLibrary_RefreshPopUp, self.RefreshPanel) self.weaponData = context self:RefreshPanel() end function UIWeaponIllustratedPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIWeaponIllustratedPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Interactive then local isCanUpdate = MDL.WeaponLibrary.IsWeaponCanUpdate(self.weaponData.MagicWeaponID) if not isCanUpdate then local libraryLevel = MDL.WeaponLibrary.GetWeaponLevel(self.weaponData.MagicWeaponID) if libraryLevel == -1 then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_Handbook_MW_Activate_NoCondition"], UIUtils.GetLocalizedTxt(Const_IDS[self.weaponData.MagicWeaponName]))) else local maxBreak = MDL.DivineWeapon.GetBreakMax(self.weaponData.MagicWeaponID) if libraryLevel < maxBreak then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_Handbook_MW_LevelUp_NoCondition"], UIUtils.GetLocalizedTxt(Const_IDS[self.weaponData.MagicWeaponName]))) elseif libraryLevel == maxBreak then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_44366_InfoCode_HeroAwaken_WeaponNotAwaken"]) else CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_NotAwakenEnough2"], UIUtils.GetLocalizedTxt(Const_IDS[self.weaponData.MagicWeaponName]))) end end return end MDL.WeaponLibrary.RequestUpdateLevel(self.weaponData.MagicWeaponID) end end ------------------------------------------------------------------------------------------------------------------- function UIWeaponIllustratedPopUp:RefreshPanel(isPlayEft) UIUtils.SetActive(self.group_HeroCard.gameObject,false) UIUtils.SetActive(self.group_WeaponCard.gameObject,true) UIUtils.SetActive(self.group_TreasureHorseCard.gameObject,false) local isAwaken = MDL.HeroAwaken.GetIsWeaponAwaken(self.weaponData.MagicWeaponID) local quality = CTL.HeroAwaken.GetWeaponQuality(self.weaponData.MagicWeaponID, isAwaken) UTL.Color.SetQualityImageByType(self.group_WeaponCard.img_Quality, quality, UTL.Color.QualityType.Pictorial) if isAwaken then CTL.HeroAwaken.SetWeaponImage(self.group_WeaponCard.img_Hero, self.weaponData.MagicWeaponID) CTL.HeroAwaken.SetWeaponImage(self.group_WeaponCard.weapon, self.weaponData.MagicWeaponID) else UTL.Item.SetHeroHalfCardImageByHeroId(self.group_WeaponCard.img_Hero, self.weaponData.MagicWeaponID) local itemIcon = string.format(ConstAssetPathConfig.Path22, self.weaponData.MagicWeaponPicture) UIUtils.SetImageByAssetBundle(self.group_WeaponCard.weapon, itemIcon) end self.group_WeaponCard.weapon:SetNativeSize() if isPlayEft then self.group_WeaponCard.effect_Light:PlayUIEffect() end local isCanUpdate = MDL.WeaponLibrary.IsWeaponCanUpdate(self.weaponData.MagicWeaponID) local weaponLibraryLevel = MDL.WeaponLibrary.GetWeaponLevel(self.weaponData.MagicWeaponID) local curCfg if weaponLibraryLevel >= 0 then curCfg = DataSheetManager.MWPictorialType:GetDataByMWPictorialTypeID_PictorialLevel(self.weaponData.MWPictorialType, weaponLibraryLevel) end local __, nextCfg = DataSheetManager.MWPictorialType:TryGetDataByMWPictorialTypeID_PictorialLevel(self.weaponData.MWPictorialType, weaponLibraryLevel + 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 weaponLibraryLevel == -1 then UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_Handbook_MW_ActivateCondition_Tip"], UIUtils.GetLocalizedTxt(Const_IDS[self.weaponData.MagicWeaponName]))) else local max = MDL.DivineWeapon.GetBreakMax(self.weaponData.MagicWeaponID) if weaponLibraryLevel < max then UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_Handbook_MW_LevelUp_Tip"], nextCfg.StarLevel)) elseif weaponLibraryLevel == max then UIUtils.SetLabelText(self.txt_Condition, Const_IDS["IDS_ContrastID_45"]) else UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_WeaponAwakenTo"], nextCfg.StarLevel - 1 - max)) end end end UIUtils.SetLabelText(self.txt_HeroScoreTitle,Const_IDS.IDS_Handbook_MW_MWScore) local weaponName = UIUtils.GetLocalizedTxt(Const_IDS[self.weaponData.MagicWeaponName]) if MDL.HeroAwaken.GetIsWeaponAwaken(self.weaponData.MagicWeaponID) then weaponName = string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_Awaken"], weaponName) end UIUtils.SetLabel(self.group_WeaponCard.txt_Name, weaponLibraryLevel == -1 and UTL.Color.FormatTextByColor(GRAY_COLOR, weaponName) or UTL.Color.FormatQualityText(weaponName, quality)) UIUtils.SetLabelText(self.txt_ConditionTitle, weaponLibraryLevel == -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_WeaponCard.weapon,weaponLibraryLevel == -1) UIUtils.SetGray(self.group_WeaponCard.img_Quality, weaponLibraryLevel == -1) UIUtils.SetGray(self.group_WeaponCard.img_Hero, weaponLibraryLevel == -1) UIUtils.SetActive(self.group_WeaponCard.img_Gray, weaponLibraryLevel == -1) UIUtils.SetActive(self.group_WeaponCard.group_Lv, weaponLibraryLevel > -1) UIUtils.SetLabel(self.group_WeaponCard.txt_LibraryLv, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelNum"], weaponLibraryLevel)) --属性数量是动态变化的,所以先隐藏所有 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, weaponLibraryLevel == -1 and Const_IDS["IDS_Handbook_Hero_Activate_Title"] or Const_IDS["IDS_Handbook_Hero_LevelUp_Title"]) UIUtils.SetLabelText(self.txt_Btn, weaponLibraryLevel == -1 and Const_IDS["IDS_Handbook_Hero_Activate_Button"] or Const_IDS["IDS_Handbook_Hero_LevelUp_Button"]) end return UIWeaponIllustratedPopUp