From 24042d5773cef8960b2a71bc863d30a7f6fc65a5 Mon Sep 17 00:00:00 2001 From: lodicolo Date: Sat, 26 Aug 2023 11:34:59 -0400 Subject: [PATCH] feat: toggle fullscreen key (#1873) * feat: toggle fullscreen key * fix: alt modifier, swap ToggleGui back to F11 and ToggleFullscreen to Alt+Enter --- Intersect.Client/Core/Controls/ControlEnum.cs | 2 ++ Intersect.Client/Core/Controls/Controls.cs | 1 + Intersect.Client/Core/Input.cs | 10 ++++++++++ Intersect.Client/Localization/Strings.cs | 1 + Intersect.Client/MonoGame/Input/MonoInput.cs | 9 ++++----- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Intersect.Client/Core/Controls/ControlEnum.cs b/Intersect.Client/Core/Controls/ControlEnum.cs index 11fbdc3a50..950c5c69de 100644 --- a/Intersect.Client/Core/Controls/ControlEnum.cs +++ b/Intersect.Client/Core/Controls/ControlEnum.cs @@ -78,6 +78,8 @@ public enum Control HoldToZoomOut, + ToggleFullscreen, + } } diff --git a/Intersect.Client/Core/Controls/Controls.cs b/Intersect.Client/Core/Controls/Controls.cs index 274cf70268..cfad73245d 100644 --- a/Intersect.Client/Core/Controls/Controls.cs +++ b/Intersect.Client/Core/Controls/Controls.cs @@ -98,6 +98,7 @@ public void ResetDefaults() CreateControlMap(Control.ToggleZoomOut, ControlValue.Default, ControlValue.Default); CreateControlMap(Control.HoldToZoomIn, ControlValue.Default, ControlValue.Default); CreateControlMap(Control.HoldToZoomOut, ControlValue.Default, ControlValue.Default); + CreateControlMap(Control.ToggleFullscreen, new ControlValue(Keys.Alt, Keys.Enter), ControlValue.Default); } private static void MigrateControlBindings(Control control) diff --git a/Intersect.Client/Core/Input.cs b/Intersect.Client/Core/Input.cs index d9417906a4..b76a798b2f 100644 --- a/Intersect.Client/Core/Input.cs +++ b/Intersect.Client/Core/Input.cs @@ -2,6 +2,7 @@ using Intersect.Admin.Actions; using Intersect.Client.Core.Controls; using Intersect.Client.Framework.GenericClasses; +using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Input; using Intersect.Client.General; using Intersect.Client.Interface; @@ -176,6 +177,15 @@ public static void OnKeyPressed(Keys modifier, Keys key) break; } + case Control.ToggleFullscreen: + { + Globals.Database.FullScreen = !Globals.Database.FullScreen; + Globals.Database.SavePreferences(); + Graphics.Renderer.OverrideResolution = Resolution.Empty; + Graphics.Renderer.Init(); + break; + } + case Control.OpenDebugger: MutableInterface.ToggleDebug(); break; diff --git a/Intersect.Client/Localization/Strings.cs b/Intersect.Client/Localization/Strings.cs index 7906de7a10..905bb3c067 100644 --- a/Intersect.Client/Localization/Strings.cs +++ b/Intersect.Client/Localization/Strings.cs @@ -724,6 +724,7 @@ public partial struct Controls {"holdtozoomin", "Hold to Zoom In:"}, {"togglezoomout", "Toggle Zoom Out:"}, {"holdtozoomout", "Hold to Zoom Out:"}, + {"togglefullscreen", "Toggle Fullscreen:"}, }; public static LocalizedString listening = @"Listening"; diff --git a/Intersect.Client/MonoGame/Input/MonoInput.cs b/Intersect.Client/MonoGame/Input/MonoInput.cs index 8804bd6752..e20c7b3d90 100644 --- a/Intersect.Client/MonoGame/Input/MonoInput.cs +++ b/Intersect.Client/MonoGame/Input/MonoInput.cs @@ -284,11 +284,10 @@ public Keys GetPressedModifier(KeyboardState state) modifier = Keys.Shift; } - // TODO: Make Alt function? For some reason MonoGame / XNA seems to just not capture the alt key properly. GWEN manages to capture it but the game does not? - //if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.) || state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt)) - //{ - // modifier = Keys.Alt; - //} + if (state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt) || state.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt)) + { + modifier = Keys.Alt; + } return modifier; }