local UIEffectIllustratedPopUp = UIViewClass() local GRAY_COLOR = "93969c" function UIEffectIllustratedPopUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_Illustration_LightEffect_RefreshPopUp, self.RefreshPanel) self.data = context self:RefreshPanel() end function UIEffectIllustratedPopUp:OnClosed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIEffectIllustratedPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Interactive then local id = self.data.ID local effectType = self.data.EffectType local isCanUnlocnOrUpdate = MDL.EffectLibrary.CanUnlockOrUpdate(id, effectType) if not isCanUnlocnOrUpdate then local level = MDL.EffectLibrary.GetEffectLevel(id, effectType) local txt = UIUtils.GetLocalizedTxt(Const_IDS[self.data.EffectName]) if level < 1 then -- TODO 替换IDS CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_LightEffectPictorial_Activate_NoCondition"], txt)) else CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_LightEffectPictorial_LevelUp_NoCondition"], txt)) end return end MDL.EffectLibrary.RequestUpdateLevel(id, effectType) end end function UIEffectIllustratedPopUp:RefreshPanel() local data = self.data UIUtils.SetActive(self.group_HeroCard.gameObject, false) UIUtils.SetActive(self.group_WeaponCard.gameObject, false) -- 考虑到特效套装是需要显示两个Effect if data.EffectType == MDL.EffectLibrary.PictorialType.SingleEffect then UIUtils.SetActive(self.group_TreasureHorseCard.gameObject, true) UIUtils.SetActive(self.group_LightEffectSuitCard.gameObject, false) UIUtils.SetActive(self.group_TreasureHorseCard.Treasure, false) UIUtils.SetActive(self.group_TreasureHorseCard.Horse, false) elseif data.EffectType == MDL.EffectLibrary.PictorialType.Suit then UIUtils.SetActive(self.group_TreasureHorseCard.gameObject, false) UIUtils.SetActive(self.group_LightEffectSuitCard.gameObject, true) end local isCanUnlockOrUpdate = MDL.EffectLibrary.CanUnlockOrUpdate(data.ID, data.EffectType) local level = MDL.EffectLibrary.GetEffectLevel(data.ID, data.EffectType) local curCfg,nextCfg if data.EffectType == MDL.EffectLibrary.PictorialType.SingleEffect then self:SetEffectCardImage(self.group_TreasureHorseCard, data, level) curCfg = level > 0 and DataSheetManager.LightEffectPictorialType:GetDataByLightEffectPictorialTypeID_PictorialLevel(data.PictorialType, level) or nil local _, nextdata = DataSheetManager.LightEffectPictorialType:TryGetDataByLightEffectPictorialTypeID_PictorialLevel(data.PictorialType, level + 1 > 0 and level + 1 or 1) nextCfg = nextdata elseif data.EffectType == MDL.EffectLibrary.PictorialType.Suit then self:SetEffectCardImage(self.lightEffectPictorial_01, data.EffectInfos[1], level) self:SetEffectCardImage(self.lightEffectPictorial_02, data.EffectInfos[2], level) curCfg = level > 0 and DataSheetManager.LightEffectSuitPictorialType:GetDataByLightEffectSuitPictorialTypeID_PictorialLevel(data.PictorialType, level) local _, nextdata = DataSheetManager.LightEffectSuitPictorialType:TryGetDataByLightEffectSuitPictorialTypeID_PictorialLevel(data.PictorialType, level + 1 > 0 and level + 1 or 1) nextCfg = nextdata end local nameTxt = UIUtils.GetLocalizedTxt(Const_IDS[data.EffectName]) 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_Hero_ActivateCondition_Tip"], nameTxt)) end if data.EffectType == MDL.EffectLibrary.PictorialType.SingleEffect then UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_LightEffectPictorial_Num2"], nextCfg.StarLevel)) elseif data.EffectType == MDL.EffectLibrary.PictorialType.Suit then UIUtils.SetLabel(self.txt_Condition, string.FormatByIdsId(Const_IDS["IDS_LightEffectPictorial_Level2"], nextCfg.StarLevel[1])) end end -- TODO 替换为Effect对应的IDS UIUtils.SetLabelText(self.txt_HeroScoreTitle, Const_IDS.IDS_LightEffectPictorial_Level3) 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) 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 function UIEffectIllustratedPopUp:SetEffectCardImage(effectPictorialCard, data, level) local effectNameTxt = UIUtils.GetLocalizedTxt(Const_IDS[data.LightEffectName]) if data.Activation > 0 then UTL.Item.ItemIconWithoutBg(effectPictorialCard.lightEffectPictorial, data.Activation) elseif #data.ActivationSkin > 0 then UTL.Item.ItemIconWithoutBg(effectPictorialCard.lightEffectPictorial, data.ID) end UTL.Color.SetQualityImageByType(effectPictorialCard.img_Quality, data.lightEffectQuality, UTL.Color.QualityType.Pictorial) UIUtils.SetActive(effectPictorialCard.lightEffectPictorial, true) UIUtils.SetLabel(effectPictorialCard.txt_Name, level < 1 and UTL.Color.FormatTextByColor(GRAY_COLOR, effectNameTxt) or UTL.Color.FormatQualityText(effectNameTxt, data.lightEffectQuality)) UIUtils.SetGray(effectPictorialCard.img_Quality, level < 1) UIUtils.SetGray(effectPictorialCard.lightEffectPictorial, level < 1) UIUtils.SetActive(effectPictorialCard.img_Gray, level < 1) UIUtils.SetActive(effectPictorialCard.group_Lv, false) end return UIEffectIllustratedPopUp