Beispiel #1
0
        ////////////////

        /// <summary>
        /// Adds a piece of menu content to a menu "context" (menu page) by name.
        /// </summary>
        /// <param name="context"></param>
        public static void AddMenuContext(MenuContext context)
        {
            var mymod = ModHelpersMod.Instance;
            MenuUIDefinition menuDef = context.MenuDefinitionOfContext;

            IDictionary <string, MenuContext> contexts = mymod.MenuContextMngr.GetContexts(menuDef);

            contexts[context.ContextName] = context;

            UIState ui = Main.MenuUI.CurrentState;
            string  currUiContextName = ui?.GetType().Name;

            if (Enum.GetName(typeof(MenuUIDefinition), menuDef) == currUiContextName)
            {
                context.ActivateIfInactive(ui);
                context.Show(ui);
            }
        }
        ////////////////

        /// <summary>
        /// Adds a piece of menu content to a menu "context" (menu page) by name.
        /// </summary>
        /// <param name="context"></param>
        public static void AddMenuContext(MenuContext context)
        {
            var menuCtxMngr = ModContent.GetInstance <MenuContextServiceManager>();

            if (menuCtxMngr == null)
            {
                return;
            }

            MenuUIDefinition menuDef = context.MenuDefinitionOfContext;

            IDictionary <string, MenuContext> contexts = menuCtxMngr.GetContexts(menuDef);

            contexts[context.ContextName] = context;

            UIState ui = Main.MenuUI.CurrentState;
            string  currUiContextName = ui?.GetType().Name;

            if (Enum.GetName(typeof(MenuUIDefinition), menuDef) == currUiContextName)
            {
                context.ActivateIfInactive(ui);
                context.Show(ui);
            }
        }