local Title_Controller = {} local private = {} private.map_ItemIDToTitle = {} function Title_Controller.OnStartup() for _, v in DataSheetManager.Title:GetEnumerator() do private.map_ItemIDToTitle[v.ItemID] = v end end function Title_Controller.OpenTipsByItemID(itemID, bagTipsInfo, isChildTips, isOffset) local config = private.map_ItemIDToTitle[itemID] if config then local context = { titleConfig = config, bagTipsInfo = bagTipsInfo, isChildTips = isChildTips, isOffset = isOffset} UIManager.OpenView(Const_UI_Lua.UIEnum.UITitleTips, context) end end --离线获得/失效的称号,上线飘字提示 function Title_Controller.ShowOfflineMsg(msg) for _, v in ipairs(msg.obtainTitles) do local config = MDL.Title.GetConfigByGeneralTitleID(v) if config then Title_Controller.ShowTitleMsg(Const_IDS.IDS_Title_Activation, config) end end for _, v in ipairs(msg.invalidTitles) do local config = MDL.Title.GetConfigByGeneralTitleID(v) if config then Title_Controller.ShowTitleMsg(Const_IDS.IDS_Title_Invalid, config) end end end function Title_Controller.ShowTitleMsg(ids, config) local name = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[config.Name]), config.Color) local content = string.FormatByIdsId(ids, name) if BattleDataGetter.IsOnlineTownLevel() then CTL.Tips.AddTipsMsg(content) else CTL.HomeMain.AddTownHomeDelayFuncNoUI(CTL.Tips.AddTipsMsg, content) end end function Title_Controller.SetTitleShow(comp, config) if config.TitleFrame == 0 then UIUtils.SetActive(comp.img_TitleFrame, false) UIUtils.SetActive(comp.img_TitleIcon, true) local posY = config.InterfaceHigh == 0 and -18 or config.InterfaceHigh comp.img_TitleIcon.transform:SetAnchoredPosition(0, posY) local scale = config.InterfaceScale == 0 and 1 or config.InterfaceScale comp.img_TitleIcon.transform:SetLocalScale(scale, scale, scale) UIUtils.SetLocalizationImage(comp.img_TitleIcon, config.Icon) comp.img_TitleIcon:SetNativeSize() else UIUtils.SetActive(comp.img_TitleFrame, true) UIUtils.SetActive(comp.img_TitleIcon, false) UIUtils.SetLabelText(comp.lab_TitleName, Const_IDS[config.Name]) UTL.Color.SetTitleFrame(config.TitleFrame, comp.lab_TitleName, comp.img_TitleFrame) end end function Title_Controller.GetEntityTitleParam(titleID) local config = MDL.Title.GetConfigByGeneralTitleID(titleID) if config.TitleFrame == 0 then --纯图片 return {titleIcon = config.Icon, sceneHigh = config.SceneHigh} end --程序字 + 边框 local frameConfig = DataSheetManager.TitleFrame:GetDataByID(config.TitleFrame) if frameConfig then return Const_IDS[config.Name], frameConfig.Frame, frameConfig.Size, frameConfig.LowColorNum, frameConfig.UpColorNum end end function Title_Controller.GetTitleDataByItemId(itemID) return private.map_ItemIDToTitle[itemID] end return Title_Controller