Пример #1
0
        /// <summary>
        /// Provides default button behavior for all platforms.
        /// </summary>
        protected bool DefaultButtonBehavior(Key key, KeyStatus state)
        {
            if (Engine.Configuration.DebugMode)
            {
                Engine.Log.Trace($"Key {key} is {state}.", MessageSource.Input);

                bool ctrl = IsKeyHeld(Key.LeftControl) || IsKeyHeld(Key.RightControl);
                if (key >= Key.F1 && key <= Key.F10 && state == KeyStatus.Down && ctrl && Window != null)
                {
                    Vector2 chosenSize = _windowSizes[key - Key.F1];
                    Window.Size = chosenSize;
                    Engine.Log.Info($"Set window size to {chosenSize}", MessageSource.Platform);
                    return(false);
                }

                switch (key)
                {
                case Key.F11 when state == KeyStatus.Down && ctrl && Window != null:
                    Window.Size = (Engine.Configuration.RenderSize * 1.999f) - Vector2.One;
                    break;

                case Key.Pause when state == KeyStatus.Down:
                    PerfProfiler.ProfileNextFrame();
                    break;
                }
            }

            bool alt = IsKeyHeld(Key.LeftAlt) || IsKeyHeld(Key.RightAlt);

            if (key == Key.Enter && state == KeyStatus.Down && alt && Window != null)
            {
                Window.DisplayMode = Window.DisplayMode == DisplayMode.Fullscreen ? DisplayMode.Windowed : DisplayMode.Fullscreen;
            }

            return(true);
        }