Ejemplo n.º 1
0
        /// <summary>
        /// Standard pause menu: Locked and invisible cursor, uses existing time scale, unpaused game.
        /// </summary>
        public static MenuAttributes StandardInGame()
        {
            MenuAttributes attributes = new MenuAttributes();

            attributes.cursorLockMode = CursorLockMode.Locked;
            attributes.cursorVisible  = false;
            attributes.timeScale      = -1f;
            attributes.pauseGame      = false;
            return(attributes);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Standard non-pause menu: Confined and visible cursor, uses existing time scale, unpaused game.
        /// </summary>
        public static MenuAttributes StandardNonPauseMenu()
        {
            MenuAttributes attributes = new MenuAttributes();

            attributes.cursorLockMode = CursorLockMode.Confined;
            attributes.cursorVisible  = true;
            attributes.timeScale      = -1f;
            attributes.pauseGame      = false;
            return(attributes);
        }
Ejemplo n.º 3
0
        void CacheCurrentMenuAttributes()
        {
            MenuAttributes attributes = new MenuAttributes();

            attributes.cursorLockMode = Cursor.lockState;
            attributes.cursorVisible  = Cursor.visible;
            attributes.timeScale      = Time.timeScale;
            attributes.pauseGame      = _paused;
            _cachedMenuAttributes.Push(attributes);
        }
Ejemplo n.º 4
0
        void PopAndApplyMenuAttributes()
        {
            if (_cachedMenuAttributes.Count == 0)
            {
                Debug.LogWarning("Attempting to pop menu attributes but stack is empty!");
                return;
            }
            MenuAttributes attributes = _cachedMenuAttributes.Pop();

            ApplyMenuAttributes(attributes);
        }
Ejemplo n.º 5
0
        public MenuAttributes GetMenuAttributes()
        {
            MenuAttributes attributes = new MenuAttributes {
                cursorLockMode = CursorLockMode,
                cursorVisible  = CursorVisible,
                pauseGame      = PausesGame,
                timeScale      = TimeScale
            };

            return(attributes);
        }
Ejemplo n.º 6
0
 public MenuConfig(bool toggleable, bool startsOpen, bool menuPausesGame, string mainPanelKey, PaletteConfig paletteConfig, PanelConfig[] panelConfigs, List <System.Action <string, string> > panelChangeCallbacks = null, MenuAttributes?menuAttributesOverride = null)
 {
     Toggleable     = toggleable;
     StartsOpen     = startsOpen;
     MenuPausesGame = menuPausesGame;
     MainPanelKey   = mainPanelKey;
     PaletteConfig  = paletteConfig;
     PanelConfigs   = panelConfigs;
     MenuAttributes = menuAttributesOverride.HasValue ? menuAttributesOverride.Value
                         : (menuPausesGame ? MenuAttributes.StandardPauseMenu() : MenuAttributes.StandardNonPauseMenu());
     PanelChangeCallbacks = panelChangeCallbacks ?? new List <System.Action <string, string> >();
 }
Ejemplo n.º 7
0
 void ApplyMenuAttributes(MenuAttributes attributes)
 {
     if (!DisableCursorManagement)
     {
         Cursor.lockState = attributes.cursorLockMode;
         Cursor.visible   = attributes.cursorVisible;
     }
     if (!DisableTimeManagement && attributes.timeScale >= 0)
     {
         Time.timeScale = attributes.timeScale;
     }
     UpdatePaused(attributes.pauseGame);
 }