local UIStratagemIllustratedPopUp = UIViewClass() local GRAY_COLOR = "93969c" function UIStratagemIllustratedPopUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_Illustration_Stratagem_RefreshPopUp, self.RefreshPanel) self.data = context self:RefreshPanel() end function UIStratagemIllustratedPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIStratagemIllustratedPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Interactive then local id = self.data.ID local isCanUnlockOrUpdate = MDL.StratagemLibrary.CanUnlockOrUpdate(id) if not isCanUnlockOrUpdate then local level = MDL.Stratagem.GetPictorialLevel(id) local txt = UIUtils.GetLocalizedTxt(Const_IDS[self.data.StratagemName]) if level < 1 then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_Handbook_Stratagem_Activate_NoCondition"], txt)) else CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_Handbook_Stratagem_LevelUp_NoCondition"], txt)) end return end MDL.StratagemLibrary.RequestUpdateLevel(id) end end function UIStratagemIllustratedPopUp:RefreshPanel(isPlayEft) local setLabel = UIUtils.SetLabel UIUtils.SetActive(self.group_HeroCard.gameObject, false) UIUtils.SetActive(self.group_WeaponCard.gameObject, false) UIUtils.SetActive(self.group_TreasureHorseCard.gameObject, true) -- 复用马的弹窗,其实是一样的 UIUtils.SetActive(self.group_LightEffectSuitCard.gameObject, false) local data = self.data UTL.Color.SetQualityImageByType(self.group_TreasureHorseCard.img_Quality, data.StratagemQuality, UTL.Color.QualityType.Pictorial) UIUtils.SetActive(self.group_TreasureHorseCard.Treasure, false) UIUtils.SetActive(self.group_TreasureHorseCard.lightEffectPictorial, false) UIUtils.SetActive(self.group_TreasureHorseCard.Horse, true) UIUtils.SetImageByAssetBundle(self.group_TreasureHorseCard.Horse, data.PicturePath) if isPlayEft then self.group_TreasureHorseCard.effect_Light:PlayUIEffect() end local isCanUnlockOrUpdate = MDL.StratagemLibrary.CanUnlockOrUpdate(data.ID) local level = MDL.Stratagem.GetPictorialLevel(data.ID) local curCfg = level>0 and DataSheetManager.StratagemPictorialType:GetDataByStratagemPictorialTypeID_PictorialLevel(data.PictorialID, level) or nil local __, nextCfg = DataSheetManager.StratagemPictorialType:TryGetDataByStratagemPictorialTypeID_PictorialLevel(data.PictorialID, level + 1) local nameTxt = UIUtils.GetLocalizedTxt(Const_IDS[data.StratagemName]) if not nextCfg then UIUtils.SetLabelText(self.txt_Condition, Const_IDS["IDS_Handbook_Hero_LevelUp_Max"]) self.UIStateCondition:SetState(2) else self.UIStateCondition:SetState(isCanUnlockOrUpdate and 0 or 1) if level < 1 then UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_Handbook_Stratagem_ActivateCondition_Tip"], nameTxt)) else UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_Handbook_Stratagem_LevelUp_Tip"], nextCfg.StarLevel)) end end UIUtils.SetLabelText(self.txt_HeroScoreTitle, Const_IDS.IDS_Handbook_Stratagem_StratagemScore) UIUtils.SetLabel(self.group_TreasureHorseCard.txt_Name, level < 1 and UTL.Color.FormatTextByColor(GRAY_COLOR, nameTxt) or UTL.Color.FormatQualityText(nameTxt, data.StratagemQuality)) UIUtils.SetLabelText(self.txt_ConditionTitle, level < 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_TreasureHorseCard.img_Quality, level < 1) UIUtils.SetGray(self.group_TreasureHorseCard.Horse, level < 1) UIUtils.SetActive(self.group_TreasureHorseCard.img_Gray, level < 1) UIUtils.SetActive(self.group_TreasureHorseCard.group_Lv, level > 0) UIUtils.SetLabel(self.group_TreasureHorseCard.txt_LibraryLv, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelNum"], level)) --属性数量是动态变化的,所以先隐藏所有 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 isCanUnlockOrUpdate, true) UIUtils.SetActive(self.btn_Interactive, nextCfg ~= nil) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, level < 1 and Const_IDS["IDS_Handbook_Hero_Activate_Title"] or Const_IDS["IDS_Handbook_Hero_LevelUp_Title"]) UIUtils.SetLabelText(self.txt_Btn, level < 1 and Const_IDS["IDS_Handbook_Hero_Activate_Button"] or Const_IDS["IDS_Handbook_Hero_LevelUp_Button"]) end return UIStratagemIllustratedPopUp