local UIEffectIllustratedBase = UIViewClass() local ProgressStr = "%d/%d" local PrefabScoreTipPath = "Common/UICommonInfoTipsNew" local IconPath = ConstAssetPathConfig.IconPath function UIEffectIllustratedBase:OnOpened(context) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_Decorate_Set"]) UIUtils.SetActive(self.loop_HeroCard, false) UIUtils.SetActive(self.loop_TreasureHorse, false) UIUtils.SetActive(self.loop_WeaponCard, false) UIUtils.SetActive(self.loop_Stratagem, false) UIUtils.SetActive(self.group_Toggles, false) UIUtils.SetActive(self.group_EffectToggles, true) self:RegistSystemEvent(EventID.UI_Illustration_LightEffect_RefreshBase, self.RefreshPanel) self.selectedEffectTab = MDL.EffectLibrary.EffectTabEnum.Init self.attrCount = 0 self.group_EffectToggles:SelectIndex(MDL.EffectLibrary.EffectTabEnum.Encircle) self:RefreshPanel(true) end function UIEffectIllustratedBase:RefreshPanel(isRebuild) self:RefreshAttr() local effectDataList if self.selectedEffectTab == MDL.EffectLibrary.EffectTabEnum.Suit then UIUtils.SetActive(self.loop_EffectTheme, false) UIUtils.SetActive(self.loop_lightEffectPictorial, false) UIUtils.SetActive(self.loop_lightEffectPictorialSuit, true) self.LoopScroll = self.loop_lightEffectPictorialSuit effectDataList = MDL.LightEffect.GetLightEffectSuitInfoList() elseif self.selectedEffectTab == MDL.EffectLibrary.EffectTabEnum.Decoration then UIUtils.SetActive(self.loop_lightEffectPictorial, false) UIUtils.SetActive(self.loop_lightEffectPictorialSuit, false) UIUtils.SetActive(self.loop_EffectTheme, true) self.LoopScroll = self.loop_EffectTheme effectDataList = CTL.Decoration.GetDecorationBookList() else UIUtils.SetActive(self.loop_EffectTheme, false) UIUtils.SetActive(self.loop_lightEffectPictorial, true) UIUtils.SetActive(self.loop_lightEffectPictorialSuit, false) self.LoopScroll = self.loop_lightEffectPictorial local effectList = MDL.LightEffect.GetLightEffectSortedList() effectDataList = self.selectedEffectTab == MDL.EffectLibrary.EffectTabEnum.Encircle and effectList[MDL.LightEffect.LightEffectType.Encircle] or effectList[MDL.LightEffect.LightEffectType.Foot] end if self.LoopScroll.Count == 0 or isRebuild then self.count = 0 self.LoopScroll:ClearCells() for i, v in ipairs(effectDataList) do self.LoopScroll:AddData(v, 0) self.count = self.count + 1 end else self.LoopScroll:RefreshCells(false) end local level, score = MDL.EffectLibrary.GetLibraryLevelAndScore() local pictorialCfg = DataSheetManager.LightEffectPictorialScore:GetDataByLevelID(level + 1) if not pictorialCfg then pictorialCfg = DataSheetManager.LightEffectPictorialScore:GetDataByLevelID(level) end if level == DataSheetManager.LightEffectPictorialScore:GetDataCount() then UIUtils.SetLabel(self.txt_Num, score) else UIUtils.SetLabel(self.txt_Num, string.format(ProgressStr, score, pictorialCfg.NeedScore)) end UIUtils.SetLabel(self.lab_Score, string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_LightEffectPictorial_Level1"]), level)) self.slider_Score.value = score / pictorialCfg.NeedScore self:RefreshActiveNum() self:RefreshRedPoint() end function UIEffectIllustratedBase:RefreshActiveNum() local activeNum if self.selectedEffectTab == MDL.EffectLibrary.EffectTabEnum.Decoration then activeNum = MDL.Decoration.GetActiveDecorationSuitCount() UIUtils.SetLabelText(self.txt_HeroUnlockTitle, Const_IDS["IDS_LightEffectPictorial_Num3"]) else activeNum = MDL.LightEffect.GetPictorialUnlockCount(self.selectedEffectTab) UIUtils.SetLabelText(self.txt_HeroUnlockTitle, Const_IDS["IDS_LightEffectPictorial_Num1"]) end UIUtils.SetLabel(self.txt_HeroUnlockValue, string.format(ProgressStr, activeNum, self.count)) end function UIEffectIllustratedBase:RefreshAttr() if self.group_Attributes.gameObject.activeSelf then if self.loop_Pandect.Count == 0 then self.attrCount = 1 self.loop_Pandect:ClearCells() self.loop_Pandect:AddData(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Handbook_Hero_AttrPreview"]), 0) --属性 for k, _ in pairs(MDL.EffectLibrary.GetAttrs()) do self.attrCount = self.attrCount + 1 self.loop_Pandect:AddData(k, 1) end self.loop_Pandect:AddData(UIUtils.GetLocalizedTxt(Const_IDS["IDS_LightEffectPictorial_Level4"]), 0) for k, _ in pairs(MDL.EffectLibrary.GetAttrs(true)) do self.loop_Pandect:AddData(k, 1) end else self.loop_Pandect:RefreshCells(false) end end end function UIEffectIllustratedBase:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIEffectIllustratedBase:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.EffectPictorial }) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UIEffectIllustratedLevelTip, nil, PrefabScoreTipPath) elseif comp == self.btn_Pandect then UIUtils.SetActive(self.group_Attributes, true) self:RefreshAttr() elseif comp == self.btn_OneKey then MDL.HeroLibrary.OneKeyPictorialLevelUpReq(LuaConst.PictorialType.LightEffect) elseif comp == self.btn_CloseAttr then UIUtils.SetActive(self.group_Attributes, false) end end function UIEffectIllustratedBase:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_lightEffectPictorial then local itemCfg = DataSheetManager.ItemData:GetDataByID(data.ID) local itemNameAndDesc = UTL.Item.GetItemDataSpliceByType(data.ID) local canUpdateOrUnlock = MDL.EffectLibrary.CanUnlockOrUpdate(data.ID, MDL.EffectLibrary.PictorialType.SingleEffect) local pictorialLevel = MDL.EffectLibrary.GetEffectLevel(data.ID, MDL.EffectLibrary.PictorialType.SingleEffect) local isUnlock = pictorialLevel > 0 --设置光效名字颜色 local coloredName = UTL.Color.FormatQualityText(itemNameAndDesc.Name, itemCfg.Color) UIUtils.SetLabel(cellTable.txt_Name, coloredName) UTL.Color.SetQualityImageByType(cellTable.bg_Quality, itemCfg.Color, UTL.Color.QualityType.Square) -- 设置光效立绘 if data.Activation > 0 then UTL.Item.ItemIconWithoutBg(cellTable.img_item, data.Activation) elseif #data.ActivationSkin > 0 then UTL.Item.ItemIconWithoutBg(cellTable.img_item, data.ID) end UIUtils.SetActive(cellTable.group_Light, canUpdateOrUnlock) UIUtils.SetActive(cellTable.img_Locked, not isUnlock) UIUtils.SetActive(cellTable.img_Lv, isUnlock) UIUtils.SetGray(cellTable.img_item, not isUnlock) UIUtils.SetGray(cellTable.bg_Quality, not isUnlock) UIUtils.SetGray(cellTable.txt_Name, not isUnlock) UIUtils.SetLabel(cellTable.txt_LvNum, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelNum"], pictorialLevel)) if canUpdateOrUnlock then cellTable.effect_Light:PlayUIEffect() UIUtils.SetLabelText(cellTable.txt_Tip, pictorialLevel < 1 and Const_IDS["IDS_Handbook_Hero_AbleToActivate"] or Const_IDS["IDS_Handbook_Hero_AbleToLevelUp"]) end elseif scrollRect == self.loop_lightEffectPictorialSuit then UIUtils.SetLabelText(cellTable.txt_SuitName, Const_IDS[data.LightEffectSetName]) local pictorialLevel = MDL.EffectLibrary.GetEffectLevel(data.ID, MDL.EffectLibrary.PictorialType.Suit) local isUnlock = pictorialLevel > 0 local canUpdateOrUnlock = MDL.EffectLibrary.CanUnlockOrUpdate(data.ID, MDL.EffectLibrary.PictorialType.Suit) local leftEffectId = data.LightEffectList[1]-- 设置套装第一个光效信息 local leftItemCfg = DataSheetManager.ItemData:GetDataByID(leftEffectId) local leftItemNameAndDesc = UTL.Item.GetItemDataSpliceByType(leftEffectId) local leftEffectPictorialLevel = MDL.EffectLibrary.GetEffectLevel(leftEffectId, MDL.EffectLibrary.PictorialType.SingleEffect) local leftColoredName = UTL.Color.FormatQualityText(leftItemNameAndDesc.Name, leftItemCfg.Color) UIUtils.SetLabel(cellTable.txt_LeftName, leftColoredName) UTL.Color.SetQualityImageByType(cellTable.bg_LeftQuality, leftItemCfg.Color, UTL.Color.QualityType.Square) local leftEffectInfo = DataSheetManager.LightEffect:GetDataByID(leftEffectId) if leftEffectInfo.Activation > 0 then UTL.Item.ItemIconWithoutBg(cellTable.img_LeftItem, leftEffectInfo.Activation) elseif #leftEffectInfo.ActivationSkin > 0 then UTL.Item.ItemIconWithoutBg(cellTable.img_LeftItem, leftEffectId) end local rightEffectId = data.LightEffectList[2] local rightItemCfg = DataSheetManager.ItemData:GetDataByID(rightEffectId) local rightItemNameAndDesc = UTL.Item.GetItemDataSpliceByType(rightEffectId) local rightEffectPictorialLevel = MDL.EffectLibrary.GetEffectLevel(rightEffectId, MDL.EffectLibrary.PictorialType.SingleEffect) local rightColoredName = UTL.Color.FormatQualityText(rightItemNameAndDesc.Name, rightItemCfg.Color) UIUtils.SetLabel(cellTable.txt_RightName, rightColoredName) UTL.Color.SetQualityImageByType(cellTable.bg_RightQuality, rightItemCfg.Color, UTL.Color.QualityType.Square) local rightEffectInfo = DataSheetManager.LightEffect:GetDataByID(rightEffectId) if rightEffectInfo.Activation > 0 then UTL.Item.ItemIconWithoutBg(cellTable.img_RightItem, rightEffectInfo.Activation) elseif #rightEffectInfo.ActivationSkin > 0 then UTL.Item.ItemIconWithoutBg(cellTable.img_RightItem, rightEffectId) end -- 置灰 UIUtils.SetActive(cellTable.group_Light, canUpdateOrUnlock) UIUtils.SetActive(cellTable.img_LvTotal, isUnlock) UIUtils.SetActive(cellTable.img_LeftLv, false) UIUtils.SetActive(cellTable.img_RightLv, false) UIUtils.SetActive(cellTable.img_LeftLocked, not isUnlock) UIUtils.SetActive(cellTable.img_RightLocked, not isUnlock) UIUtils.SetComponentGray(cellTable.group_ItemAnime, not isUnlock) UIUtils.SetGray(cellTable.txt_LeftName, not isUnlock) UIUtils.SetGray(cellTable.txt_RightName, not isUnlock) UIUtils.SetLabel(cellTable.txt_LvTotalNum, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelNum"], pictorialLevel)) UIUtils.SetLabel(cellTable.txt_LeftLvNum, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelNum"], leftEffectPictorialLevel)) UIUtils.SetLabel(cellTable.txt_RightLvNum, string.FormatByIdsId(Const_IDS["IDS_Handbook_Hero_LevelNum"], rightEffectPictorialLevel)) if canUpdateOrUnlock then cellTable.effect_Light:PlayUIEffect() UIUtils.SetLabelText(cellTable.txt_Tip, pictorialLevel < 1 and Const_IDS["IDS_Handbook_Hero_AbleToActivate"] or Const_IDS["IDS_Handbook_Hero_AbleToLevelUp"]) end elseif scrollRect == self.loop_Pandect then if type(data) == "number" then local attrData = DataSheetManager.AttrData:GetDataByID(data) local attrValue = MDL.EffectLibrary.GetAttrValue(data, self.attrCount - 1 < index) UIUtils.SetLabelText(cellTable.txt_Attr, Const_IDS[attrData.Name]) UTL.Item.SetAtlasSprite(cellTable.img_AttrIcon, "UI_Common", attrData.Icon) UIUtils.SetLabel(cellTable.txt_NumBefore, attrValue) else UIUtils.SetLabel(cellTable.txt_Title, data) end elseif scrollRect == self.loop_EffectTheme then self:RefreshDecorationThemeCell(cellTable, data) end end function UIEffectIllustratedBase:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_EffectTheme then UIManager.OpenView(Const_UI_Lua.UIEnum.UIThemeIllustratedPopUp, data) elseif scrollRect == self.LoopScroll then local effctData = self:SetPopUpData(data) UIManager.OpenView(Const_UI_Lua.UIEnum.UIEffectIllustratedPopUp, effctData, Const_UI_Lua.UIEnum.UIHeroIllustratedPopUp) end end -- 因为传入的既有可能是LightEffect的Data也有可能是套装的data,需要在这里统一处理一下来传给PopUp页面 function UIEffectIllustratedBase:SetPopUpData(data) local effectData = {} local itemCfg effectData.ID = data.ID effectData.PictorialType = data.PictorialType if self.selectedEffectTab == MDL.EffectLibrary.EffectTabEnum.Suit then effectData.EffectType = MDL.EffectLibrary.PictorialType.Suit effectData.EffectName = data.LightEffectSetName effectData.EffectInfos= {} local curEffectInfo = DataSheetManager.LightEffect:GetDataByID(data.LightEffectList[1]) local leftEffectInfo = {} leftEffectInfo = self:SetEffectInfo(leftEffectInfo, curEffectInfo) table.insert(effectData.EffectInfos, leftEffectInfo) curEffectInfo = DataSheetManager.LightEffect:GetDataByID(data.LightEffectList[2]) local rightEffectInfo = {} rightEffectInfo = self:SetEffectInfo(rightEffectInfo, curEffectInfo) table.insert(effectData.EffectInfos, rightEffectInfo) elseif self.selectedEffectTab == MDL.EffectLibrary.EffectTabEnum.Encircle or self.selectedEffectTab == MDL.EffectLibrary.EffectTabEnum.FootPrint then effectData.EffectType = MDL.EffectLibrary.PictorialType.SingleEffect effectData.EffectName = data.LightEffectName effectData = self:SetEffectInfo(effectData, data) end return effectData end function UIEffectIllustratedBase:SetEffectInfo(lightEffectData, effectInfo) lightEffectData.ID = effectInfo.ID local itemCfg = DataSheetManager.ItemData:GetDataByID(effectInfo.ID) lightEffectData.lightEffectQuality = itemCfg.Color lightEffectData.Activation = effectInfo.Activation lightEffectData.ActivationSkin = effectInfo.ActivationSkin lightEffectData.LightEffectName = effectInfo.LightEffectName return lightEffectData end function UIEffectIllustratedBase:OnValueChanged(comp, state) if comp == self.group_EffectToggles then if self.selectedEffectTab ~= state then self.selectedEffectTab = state self:RefreshPanel(true) end end end function UIEffectIllustratedBase:RefreshRedPoint() local isUpgrade = false for i = 0, 2 do local value = MDL.EffectLibrary.IsShowRPByTab(i) self.group_EffectToggles:SetRedPoint(i, value) if isUpgrade == false then isUpgrade = value end end local red3 = CTL.Decoration.HasDecorationThemeCanActive() self.group_EffectToggles:SetRedPoint(3, red3) isUpgrade = isUpgrade or red3 UIUtils.SetActive(self.btn_OneKey, isUpgrade) end function UIEffectIllustratedBase:RefreshDecorationThemeCell(cellTable, data) local itemCount = #data.ItemID --加载所有的装饰cell for i, decorateId in ipairs(data.ItemID) do local isActive = MDL.Decoration.IsDecorationActive(decorateId) local cfg = DataSheetManager.Decorate:GetDataByID(decorateId) local iconSize = CTL.Decoration.GetDecorationBookIconSize(cfg.Type) local nameStr = CTL.Decoration.GetDecorationBookIDS(cfg.Type) local data = {index = i , isActive = isActive, itemImage = cfg.Image, itemName = nameStr, iconSize = iconSize} self:AddCellThemeItem(cellTable, data) end --头像 if data.HeadPortraitID > 0 then itemCount = itemCount + 1 local isActive = MDL.Character.IsPortraitActivedInBagByID(data.HeadPortraitID) local cfg = DataSheetManager.HeadPortrait:GetDataByID(data.HeadPortraitID) local iconSize = CTL.Decoration.GetDecorationBookIconSize(CTL.Decoration.DecorateBookType.Head) local nameStr = CTL.Decoration.GetDecorationBookIDS(CTL.Decoration.DecorateBookType.Head) local data = {index = itemCount , isActive = isActive, itemImage = string.format(IconPath, cfg.HeadResource), itemName = nameStr, iconSize = iconSize, isHead = true} self:AddCellThemeItem(cellTable, data) end --头像框 if data.HeadBoxID > 0 then itemCount = itemCount + 1 local isActive = MDL.Character.IsFrameActivedInBagByID(data.HeadBoxID) local cfg = DataSheetManager.HeadBox:GetDataByID(data.HeadBoxID) local iconSize = CTL.Decoration.GetDecorationBookIconSize(CTL.Decoration.DecorateBookType.HeadFrame) local nameStr = CTL.Decoration.GetDecorationBookIDS(CTL.Decoration.DecorateBookType.HeadFrame) local data = {index = itemCount , isActive = isActive, itemImage = string.format(IconPath, cfg.HeadResource), itemName = nameStr, iconSize = iconSize} self:AddCellThemeItem(cellTable, data) end --称号 if data.TitleID > 0 then itemCount = itemCount + 1 local isActive = MDL.Title.HasTitleByGeneralTitleID(data.TitleID) local titleData = DataSheetManager.Title:GetDataByID(data.TitleID) local iconSize = CTL.Decoration.GetDecorationBookIconSize(CTL.Decoration.DecorateBookType.Title) local nameStr = CTL.Decoration.GetDecorationBookIDS(CTL.Decoration.DecorateBookType.Title) local data = {index = itemCount , isActive = isActive, itemImage = titleData.Icon, itemName = nameStr, iconSize = iconSize, isTitle = true} self:AddCellThemeItem(cellTable, data) end for i = itemCount + 1, #cellTable.Content do local obj = cellTable.Content[i] UIUtils.SetActive(obj.gameObject, false) end --激活状态 local isBookActivated = MDL.Decoration.IsSuitBookActive(data.ID) local isBookCanActivate = CTL.Decoration.IsDecorationThemeCanActive(data) cellTable.click_event:SetRedPoint(isBookCanActivate) --可激活特效 UIUtils.SetActive(cellTable.group_Light, isBookCanActivate) --置灰 local isGray = not (isBookActivated or isBookCanActivate) UIUtils.SetGray(cellTable.bg_Theme, isGray) UIUtils.SetGray(cellTable.img_TextBg, isGray) UIUtils.SetGray(cellTable.txt_Name, isGray) UIUtils.SetLabelText(cellTable.txt_Name, Const_IDS[data.Name]) end function UIEffectIllustratedBase:AddCellThemeItem(cellTable, data) local obj = cellTable.Content[data.index] if obj == nil then obj = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.cell_ThemeItem.gameObject) end UIUtils.SetActive(obj.gameObject, true) UIUtils.SetGray(obj.txt_Name, not data.isActive) UIUtils.SetGray(obj.bg_Item, not data.isActive) UIUtils.SetGray(obj.bg_Item_lock, not data.isActive) UIUtils.SetActive(obj.bg_Item_lock, not data.isActive) UIUtils.SetLabel(obj.txt_Name, data.itemName) if data.isHead then obj.state_item:SetState(1) UIUtils.SetGray(obj.img_PlayerHead, not data.isActive) UIUtils.SetGray(obj.img_headBg, not data.isActive) UIUtils.SetImageByAssetBundle(obj.img_PlayerHead, data.itemImage) obj.img_PlayerHead.transform:SetSizeDelta(data.iconSize[1], data.iconSize[2]) else obj.state_item:SetState(0) UIUtils.SetGray(obj.img_item, not data.isActive) if data.isTitle then UIUtils.SetLocalizationImage(obj.img_item, data.itemImage) else UIUtils.SetImageByAssetBundle(obj.img_item, data.itemImage) end obj.img_item.transform:SetSizeDelta(data.iconSize[1], data.iconSize[2]) end end function UIEffectIllustratedBase:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end return UIEffectIllustratedBase