Skip to content

Commit

Permalink
feat: toggle fullscreen key (#1873)
Browse files Browse the repository at this point in the history
* feat: toggle fullscreen key

* fix: alt modifier, swap ToggleGui back to F11 and ToggleFullscreen to Alt+Enter
  • Loading branch information
lodicolo authored Aug 26, 2023
1 parent 2df9a08 commit 24042d5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Intersect.Client/Core/Controls/ControlEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public enum Control

HoldToZoomOut,

ToggleFullscreen,

}

}
1 change: 1 addition & 0 deletions Intersect.Client/Core/Controls/Controls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions Intersect.Client/Core/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Intersect.Client/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
9 changes: 4 additions & 5 deletions Intersect.Client/MonoGame/Input/MonoInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 24042d5

Please sign in to comment.