From f37c01f08dc0f5827a16bc6e780017b505579bb3 Mon Sep 17 00:00:00 2001 From: emmauss Date: Thu, 6 Feb 2020 13:44:23 +0000 Subject: [PATCH] add fullscreen, enable input on focus, disable aplha --- Ryujinx/Ui/GLRenderer.cs | 65 +++++++++++++++++++++++++++++++++++-- Ryujinx/Ui/MainWindow.cs | 19 +++++++++++ Ryujinx/Ui/MainWindow.glade | 4 +-- 3 files changed, 84 insertions(+), 4 deletions(-) diff --git a/Ryujinx/Ui/GLRenderer.cs b/Ryujinx/Ui/GLRenderer.cs index 25247b6c3e..2974de0481 100644 --- a/Ryujinx/Ui/GLRenderer.cs +++ b/Ryujinx/Ui/GLRenderer.cs @@ -34,6 +34,8 @@ namespace Ryujinx.Ui private bool _titleEvent; + private bool _toggleFullscreen; + private string _newTitle; private readonly long _ticksPerFrame; @@ -67,7 +69,11 @@ namespace Ryujinx.Ui _primaryController = new Input.NpadController(ConfigurationState.Instance.Hid.JoystickControls); - AddEvents((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask)); + AddEvents((int)(Gdk.EventMask.ButtonPressMask | + Gdk.EventMask.ButtonReleaseMask | + Gdk.EventMask.PointerMotionMask | + Gdk.EventMask.KeyPressMask | + Gdk.EventMask.KeyReleaseMask)); } private void Parent_FocusOutEvent(object o, Gtk.FocusOutEventArgs args) @@ -87,6 +93,45 @@ namespace Ryujinx.Ui this.Dispose(); } + public void HandleScreenState(KeyboardState keyboard) + { + bool toggleFullscreen = keyboard.IsKeyDown(OpenTK.Input.Key.F11) || + ((keyboard.IsKeyDown(OpenTK.Input.Key.AltLeft) || keyboard.IsKeyDown(OpenTK.Input.Key.AltRight)) + && keyboard.IsKeyDown(OpenTK.Input.Key.Enter)); + + if (toggleFullscreen == _toggleFullscreen) + { + return; + } + + _toggleFullscreen = toggleFullscreen; + + if (IsFocussed) + { + if (this.ParentWindow.State.HasFlag(Gdk.WindowState.Fullscreen) ) + { + if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape) || _toggleFullscreen) + { + this.ParentWindow.Unfullscreen(); + (this.Toplevel as MainWindow)?.ToggleExtraWidgets(true); + } + } + else + { + if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape)) + { + Exit(); + } + + if (_toggleFullscreen) + { + this.ParentWindow.Fullscreen(); + (this.Toplevel as MainWindow)?.ToggleExtraWidgets(false); + } + } + } + } + private void GLRenderer_Initialized(object sender, EventArgs e) { // Release the GL exclusivity that OpenTK gave us. @@ -211,9 +256,17 @@ namespace Ryujinx.Ui return; } +<<<<<<< HEAD using (ScopedGLContext scopedGLContext = new ScopedGLContext(WindowInfo, GraphicsContext)) { GL.ClearColor(Color4.Black); +======= + GraphicsContext.MakeCurrent(WindowInfo); + + GL.Disable(EnableCap.AlphaTest); + + SwapBuffers(); +>>>>>>> add fullscreen, enable input on focus, disable aplha _ticks += _chrono.ElapsedTicks; @@ -272,7 +325,10 @@ namespace Ryujinx.Ui this.ParentWindow.Title = _newTitle; }); } - UpdateFrame(); + if (IsFocussed) + { + UpdateFrame(); + } // Polling becomes expensive if it's not slept Thread.Sleep(1); @@ -299,6 +355,11 @@ namespace Ryujinx.Ui KeyboardState keyboard = OpenTK.Input.Keyboard.GetState(); + Gtk.Application.Invoke(delegate + { + HandleScreenState(keyboard); + }); + int leftJoystickDx = 0; int leftJoystickDy = 0; int rightJoystickDx = 0; diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs index 2af7a56b09..bec1c8b71d 100644 --- a/Ryujinx/Ui/MainWindow.cs +++ b/Ryujinx/Ui/MainWindow.cs @@ -49,6 +49,8 @@ namespace Ryujinx.Ui #pragma warning disable IDE0044 [GUI] Window _mainWin; + [GUI] MenuBar _menuBar; + [GUI] Box _footerBox; [GUI] CheckMenuItem _fullScreen; [GUI] MenuItem _stopEmulation; [GUI] CheckMenuItem _favToggle; @@ -444,6 +446,23 @@ namespace Ryujinx.Ui _screenExitStatus.Set(); } + public void ToggleExtraWidgets(bool show) + { + Gtk.Application.Invoke(delegate + { + if (show) + { + _menuBar.ShowAll(); + _footerBox.ShowAll(); + } + else + { + _menuBar.Hide(); + _footerBox.Hide(); + } + }); + } + private static void UpdateGameMetadata(string titleId) { if (_gameLoaded) diff --git a/Ryujinx/Ui/MainWindow.glade b/Ryujinx/Ui/MainWindow.glade index 5a65a3a92e..ec05004192 100644 --- a/Ryujinx/Ui/MainWindow.glade +++ b/Ryujinx/Ui/MainWindow.glade @@ -17,7 +17,7 @@ False vertical - + True False @@ -402,7 +402,7 @@ - + True False