local UIThemeIllustratedPopUp = UIViewClass() local GRAY_COLOR = "93969c" local IconPath = ConstAssetPathConfig.IconPath function UIThemeIllustratedPopUp:OnOpened(context) self:RegistSystemEvent(EventID.UI_Illustration_LightEffect_RefreshPopUp, self.RefreshPanel) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS["IDS_Decorate_Theme"]) self.suitId = context.ID self.suitCfg = DataSheetManager.DecorateSuit:GetDataByID(self.context.ID) self.decoratePictorialTypeCfg = DataSheetManager.DecoratePictorialType:GetDataByDecoratePictorialTypeID(self.suitCfg.PictorialType) self.isBookActivated = MDL.Decoration.IsSuitBookActive(self.suitId) self.isBookCanActivate = CTL.Decoration.IsDecorationThemeCanActive(self.suitCfg) self:RefreshPanel() self:RefreshTopInfo() end function UIThemeIllustratedPopUp:RefreshPanel() self.isBookActivated = MDL.Decoration.IsSuitBookActive(self.suitId) self.isBookCanActivate = CTL.Decoration.IsDecorationThemeCanActive(self.suitCfg) self:RefreshAttr() self:RefreshPoints() self.btn_Interactive:SetGray(not self.isBookCanActivate, true) if self.isBookActivated then self.State_ActiveCondition:SetState(2) elseif self.isBookCanActivate then self.State_ActiveCondition:SetState(1) else self.State_ActiveCondition:SetState(0) end end function UIThemeIllustratedPopUp:RefreshTopInfo() --置灰 local isGray = not (self.isBookActivated or self.isBookCanActivate) UIUtils.SetGray(self.bg_Theme, isGray) UIUtils.SetGray(self.img_TextBg, isGray) UIUtils.SetGray(self.txt_Name, isGray) UIUtils.SetLabelText(self.txt_Name, Const_IDS[self.suitCfg.Name]) for i, decorateId in ipairs(self.suitCfg.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 = {itemName = nameStr, itemImage = cfg.Image, isActive = isActive, iconSize = iconSize} self.loop_ThemeItem:AddData(data, 0) end if self.suitCfg.HeadPortraitID > 0 then local isActive = MDL.Character.IsPortraitActivedInBagByID(self.suitCfg.HeadPortraitID) local cfg = DataSheetManager.HeadPortrait:GetDataByID(self.suitCfg.HeadPortraitID) local iconSize = CTL.Decoration.GetDecorationBookIconSize(CTL.Decoration.DecorateBookType.Head) local nameStr = CTL.Decoration.GetDecorationBookIDS(CTL.Decoration.DecorateBookType.Head) local data = {itemName = nameStr, itemImage = string.format(IconPath, cfg.HeadResource), isActive = isActive, iconSize = iconSize, isHead = true} self.loop_ThemeItem:AddData(data, 0) end if self.suitCfg.HeadBoxID > 0 then local isActive = MDL.Character.IsFrameActivedInBagByID(self.suitCfg.HeadBoxID) local cfg = DataSheetManager.HeadBox:GetDataByID(self.suitCfg.HeadBoxID) local iconSize = CTL.Decoration.GetDecorationBookIconSize(CTL.Decoration.DecorateBookType.HeadFrame) local nameStr = CTL.Decoration.GetDecorationBookIDS(CTL.Decoration.DecorateBookType.HeadFrame) local data = {itemName = nameStr, itemImage = string.format(IconPath, cfg.HeadResource), isActive = isActive, iconSize = iconSize} self.loop_ThemeItem:AddData(data, 0) end if self.suitCfg.TitleID > 0 then local titleData = DataSheetManager.Title:GetDataByID(self.suitCfg.TitleID) local isActive = MDL.Title.HasTitleByGeneralTitleID(self.suitCfg.TitleID) local iconSize = CTL.Decoration.GetDecorationBookIconSize(CTL.Decoration.DecorateBookType.Title) local nameStr = CTL.Decoration.GetDecorationBookIDS(CTL.Decoration.DecorateBookType.Title) local data = {itemName = nameStr, itemImage = titleData.Icon, isActive = isActive, iconSize = iconSize, isTitle = true} self.loop_ThemeItem:AddData(data, 0) end end function UIThemeIllustratedPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_Interactive then if not self.isBookCanActivate then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Decorate_unactivatable) return end MDL.EffectLibrary.RequestUpdateLevel(self.suitId, MDL.EffectLibrary.PictorialType.Decoration) end end function UIThemeIllustratedPopUp:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetLabel(cellTable.txt_Name, data.itemName) UIUtils.SetGray(cellTable.txt_Name, not data.isActive) UIUtils.SetGray(cellTable.bg_Item, not data.isActive) UIUtils.SetGray(cellTable.bg_Item_lock, not data.isActive) UIUtils.SetActive(cellTable.bg_Item_lock, not data.isActive) if data.isHead then cellTable.state_item:SetState(1) UIUtils.SetGray(cellTable.img_PlayerHead, not data.isActive) UIUtils.SetGray(cellTable.img_headBg, not data.isActive) UIUtils.SetImageByAssetBundle(cellTable.img_PlayerHead, data.itemImage) cellTable.img_PlayerHead.transform:SetSizeDelta(data.iconSize[1], data.iconSize[2]) else cellTable.state_item:SetState(0) UIUtils.SetGray(cellTable.img_item, not data.isActive) if data.isTitle then UIUtils.SetLocalizationImage(cellTable.img_item, data.itemImage) else UIUtils.SetImageByAssetBundle(cellTable.img_item, data.itemImage) end cellTable.img_item.transform:SetSizeDelta(data.iconSize[1], data.iconSize[2]) end end function UIThemeIllustratedPopUp:RefreshAttr() for i = 1, #self.group_Attr do UIUtils.SetActive(self.group_Attr[i].gameObject, false) end for i, v in ipairs(self.decoratePictorialTypeCfg.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, 0) UIUtils.SetLabel(groupAttr.txt_NumAfter, self.decoratePictorialTypeCfg.Attr_Table[i].AttrNum) end end function UIThemeIllustratedPopUp:RefreshPoints() UIUtils.SetLabel(self.txt_NumBefore, 0) UIUtils.SetLabel(self.txt_NumAfter, self.decoratePictorialTypeCfg.Score) end return UIThemeIllustratedPopUp