local Decoration_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') --UIChangePlayerAvatarPopUp 界面的TabType Decoration_Controller.TabType = { HeadPortrait = 0, HeadPortraitBox = 1, Competition = 2, ClickEffect = 3, ChatBubble = 4, NameDye = 5, } local DecorationType = MDL.Decoration.DecorationType local TabTypeMapDecorationType = { [Decoration_Controller.TabType.Competition] = DecorationType.Competition, [Decoration_Controller.TabType.ClickEffect] = DecorationType.ClickEffect, [Decoration_Controller.TabType.ChatBubble] = DecorationType.ChatBubble, [Decoration_Controller.TabType.NameDye] = DecorationType.NameDye, } --定义图鉴主题中的头像、头像框、称号的类型枚举5~7。 --装饰系统中的类型枚举当前是1~4 Decoration_Controller.DecorateBookType = { Head = 5, HeadFrame = 6, Title = 7, } --图鉴主题中,不同类型Icon大小 local DecorateBookIconSize = { {160,160}, --竞技装饰 {160,160}, --点击特效 {158,101}, --聊天气泡 {160,160}, --名染 {114,114}, --头像 {130,130}, --头像框 {166,28}, --称号 } local DecorationBookIDS = { Const_IDS.IDS_Decorate_Competition, Const_IDS.IDS_Decorate_ClickEffect, Const_IDS.IDS_Decorate_ChatBubble, Const_IDS.IDS_Decorate_NameDye, Const_IDS.IDS_Decorate_HeadPortrait, Const_IDS.IDS_Decorate_HeadBox, Const_IDS.IDS_Team_Title, } --图鉴装饰主题排序规则:ID从大到小 local function SortRule(a, b) return a.ID > b.ID end function Decoration_Controller.OnStartup() EventSystem.Regist(EventID.UI_PlayerHeadPortraitAndBox_Refresh, Decoration_Controller.CaculateDecorationThemeCanActive) --激活头像头像框,刷新主题装扮套装图鉴红点 EventSystem.Regist(EventID.UI_UpdateTitleInfo, Decoration_Controller.CaculateDecorationThemeCanActive) --激活称号,刷新主题装扮套装图鉴红点 private.decorateSuitCfg = {} --装饰图鉴配置表数据 private.hasDecorationThemeCanActive = false --装饰图鉴配置表数据 for i, data in DataSheetManager.DecorateSuit:GetEnumerator() do table.insert(private.decorateSuitCfg, data) end table.sort(private.decorateSuitCfg, SortRule) end function Decoration_Controller.GetDecorationListByTabType(tabType) return MDL.Decoration.GetDecorationList(TabTypeMapDecorationType[tabType]) end function Decoration_Controller.GetCurWearingDecorationIdByTabType(tabType) return MDL.Decoration.GetWearingDecorationId(TabTypeMapDecorationType[tabType]) end function Decoration_Controller.GetDecorationTypeByTabType(tabType) return TabTypeMapDecorationType[tabType] end function Decoration_Controller.CaculateDecorationThemeCanActive() local preRp = private.hasDecorationThemeCanActive private.hasDecorationThemeCanActive = false for _, cfg in ipairs(private.decorateSuitCfg) do if Decoration_Controller.IsDecorationThemeCanActive(cfg) then private.hasDecorationThemeCanActive = true break end end if preRp ~= private.hasDecorationThemeCanActive then EventSystem.Dispatch(EventID.UI_Decoration_Book_RedPoint_Refresh, true) end end --是否装饰主题图鉴可激活 function Decoration_Controller.IsDecorationThemeCanActive(cfg) --已激活 if MDL.Decoration.IsSuitBookActive(cfg.ID) then return false end --装饰 for i, decorateId in ipairs(cfg.ItemID) do local isActive = MDL.Decoration.IsDecorationActive(decorateId) if isActive == false then return false end end --头像 if cfg.HeadPortraitID > 0 then local isActive = MDL.Character.IsPortraitActivedInBagByID(cfg.HeadPortraitID) if isActive == false then return false end end --头像框 if cfg.HeadBoxID > 0 then local isActive = MDL.Character.IsFrameActivedInBagByID(cfg.HeadBoxID) if isActive == false then return false end end --称号 if cfg.TitleID > 0 then local isActive = MDL.Title.HasTitleByGeneralTitleID(cfg.TitleID) if isActive == false then return false end end return true end function Decoration_Controller.HasDecorationThemeCanActive() return private.hasDecorationThemeCanActive end function Decoration_Controller.GetDecorationBookList() return private.decorateSuitCfg end function Decoration_Controller.GetDecorationBookIconSize(type) return DecorateBookIconSize[type] end function Decoration_Controller.GetDecorationBookIDS(type) return UIUtils.GetLocalizedTxt(DecorationBookIDS[type]) end return Decoration_Controller