Added a toggle fullscreen button (default F11) (#20272)

* Added a toggle fullscreen button (default F11)

* Removed un-needed comments

* Review Requested Changes

* Fixed Acidental Spacing Change

* bwoink, removed extraneous code

* nothing, litterally
This commit is contained in:
Miro Kavaliou
2023-09-28 19:55:10 -04:00
committed by GitHub
parent 3477349dfe
commit c06586f942
11 changed files with 82 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ using Content.Client.Changelog;
using Content.Client.Chat.Managers; using Content.Client.Chat.Managers;
using Content.Client.Eui; using Content.Client.Eui;
using Content.Client.Flash; using Content.Client.Flash;
using Content.Client.Fullscreen;
using Content.Client.GhostKick; using Content.Client.GhostKick;
using Content.Client.Guidebook; using Content.Client.Guidebook;
using Content.Client.Info; using Content.Client.Info;
@@ -49,6 +50,7 @@ namespace Content.Client.Entry
[Dependency] private readonly IConfigurationManager _configManager = default!; [Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly IStylesheetManager _stylesheetManager = default!; [Dependency] private readonly IStylesheetManager _stylesheetManager = default!;
[Dependency] private readonly IScreenshotHook _screenshotHook = default!; [Dependency] private readonly IScreenshotHook _screenshotHook = default!;
[Dependency] private readonly FullscreenHook _fullscreenHook = default!;
[Dependency] private readonly ChangelogManager _changelogManager = default!; [Dependency] private readonly ChangelogManager _changelogManager = default!;
[Dependency] private readonly RulesManager _rulesManager = default!; [Dependency] private readonly RulesManager _rulesManager = default!;
[Dependency] private readonly ViewportManager _viewportManager = default!; [Dependency] private readonly ViewportManager _viewportManager = default!;
@@ -123,6 +125,7 @@ namespace Content.Client.Entry
_componentFactory.GenerateNetIds(); _componentFactory.GenerateNetIds();
_adminManager.Initialize(); _adminManager.Initialize();
_screenshotHook.Initialize(); _screenshotHook.Initialize();
_fullscreenHook.Initialize();
_changelogManager.Initialize(); _changelogManager.Initialize();
_rulesManager.Initialize(); _rulesManager.Initialize();
_viewportManager.Initialize(); _viewportManager.Initialize();

View File

@@ -0,0 +1,43 @@
using Content.Shared.Input;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Players;
namespace Content.Client.Fullscreen;
public sealed class FullscreenHook
{
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly ILogManager _logManager = default!;
private ISawmill _sawmill = default!;
public void Initialize()
{
_inputManager.SetInputCommand(ContentKeyFunctions.ToggleFullscreen, InputCmdHandler.FromDelegate(ToggleFullscreen));
_sawmill = _logManager.GetSawmill("fullscreen");
}
private void ToggleFullscreen(ICommonSession? session)
{
var currentWindowMode = _cfg.GetCVar(CVars.DisplayWindowMode);
switch (currentWindowMode)
{
case (int) WindowMode.Windowed:
_cfg.SetCVar(CVars.DisplayWindowMode, (int) WindowMode.Fullscreen);
_sawmill.Info("Switched to Fullscreen mode");
break;
case (int) WindowMode.Fullscreen:
_cfg.SetCVar(CVars.DisplayWindowMode, (int) WindowMode.Windowed);
_sawmill.Info("Switched to Windowed mode");
break;
default:
throw new InvalidOperationException($"Unexpected WindowMode value: {currentWindowMode}");
}
}
}

View File

@@ -29,6 +29,7 @@ namespace Content.Client.Input
common.AddFunction(ContentKeyFunctions.OpenAHelp); common.AddFunction(ContentKeyFunctions.OpenAHelp);
common.AddFunction(ContentKeyFunctions.TakeScreenshot); common.AddFunction(ContentKeyFunctions.TakeScreenshot);
common.AddFunction(ContentKeyFunctions.TakeScreenshotNoUI); common.AddFunction(ContentKeyFunctions.TakeScreenshotNoUI);
common.AddFunction(ContentKeyFunctions.ToggleFullscreen);
common.AddFunction(ContentKeyFunctions.Point); common.AddFunction(ContentKeyFunctions.Point);
common.AddFunction(ContentKeyFunctions.ZoomOut); common.AddFunction(ContentKeyFunctions.ZoomOut);
common.AddFunction(ContentKeyFunctions.ZoomIn); common.AddFunction(ContentKeyFunctions.ZoomIn);

View File

@@ -11,6 +11,7 @@ using Content.Client.Parallax.Managers;
using Content.Client.Players.PlayTimeTracking; using Content.Client.Players.PlayTimeTracking;
using Content.Client.Preferences; using Content.Client.Preferences;
using Content.Client.Screenshot; using Content.Client.Screenshot;
using Content.Client.Fullscreen;
using Content.Client.Stylesheets; using Content.Client.Stylesheets;
using Content.Client.Viewport; using Content.Client.Viewport;
using Content.Client.Voting; using Content.Client.Voting;
@@ -21,6 +22,7 @@ using Content.Client.Guidebook;
using Content.Client.Replay; using Content.Client.Replay;
using Content.Shared.Administration.Managers; using Content.Shared.Administration.Managers;
namespace Content.Client.IoC namespace Content.Client.IoC
{ {
internal static class ClientContentIoC internal static class ClientContentIoC
@@ -32,6 +34,7 @@ namespace Content.Client.IoC
IoCManager.Register<IClientPreferencesManager, ClientPreferencesManager>(); IoCManager.Register<IClientPreferencesManager, ClientPreferencesManager>();
IoCManager.Register<IStylesheetManager, StylesheetManager>(); IoCManager.Register<IStylesheetManager, StylesheetManager>();
IoCManager.Register<IScreenshotHook, ScreenshotHook>(); IoCManager.Register<IScreenshotHook, ScreenshotHook>();
IoCManager.Register<FullscreenHook, FullscreenHook>();
IoCManager.Register<IClickMapManager, ClickMapManager>(); IoCManager.Register<IClickMapManager, ClickMapManager>();
IoCManager.Register<IClientAdminManager, ClientAdminManager>(); IoCManager.Register<IClientAdminManager, ClientAdminManager>();
IoCManager.Register<ISharedAdminManager, ClientAdminManager>(); IoCManager.Register<ISharedAdminManager, ClientAdminManager>();

View File

@@ -3,9 +3,9 @@
Title="{Loc 'ui-options-title'}" Title="{Loc 'ui-options-title'}"
MinSize="800 450"> MinSize="800 450">
<TabContainer Name="Tabs" Access="Public"> <TabContainer Name="Tabs" Access="Public">
<tabs:GraphicsTab /> <tabs:GraphicsTab Name="GraphicsTab" />
<tabs:KeyRebindTab /> <tabs:KeyRebindTab Name="KeyRebindTab" />
<tabs:AudioTab /> <tabs:AudioTab Name="AudioTab" />
<tabs:NetworkTab/> <tabs:NetworkTab Name="NetworkTab" />
</TabContainer> </TabContainer>
</DefaultWindow> </DefaultWindow>

View File

@@ -1,6 +1,9 @@
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
using Robust.Shared.IoC;
using Content.Client.Options.UI.Tabs;
namespace Content.Client.Options.UI namespace Content.Client.Options.UI
{ {
@@ -16,6 +19,13 @@ namespace Content.Client.Options.UI
Tabs.SetTabTitle(1, Loc.GetString("ui-options-tab-controls")); Tabs.SetTabTitle(1, Loc.GetString("ui-options-tab-controls"));
Tabs.SetTabTitle(2, Loc.GetString("ui-options-tab-audio")); Tabs.SetTabTitle(2, Loc.GetString("ui-options-tab-audio"));
Tabs.SetTabTitle(3, Loc.GetString("ui-options-tab-network")); Tabs.SetTabTitle(3, Loc.GetString("ui-options-tab-network"));
UpdateTabs();
}
public void UpdateTabs()
{
GraphicsTab.UpdateProperties();
} }
} }
} }

View File

@@ -229,6 +229,12 @@ namespace Content.Client.Options.UI.Tabs
private bool ConfigIsFullscreen => private bool ConfigIsFullscreen =>
_cfg.GetCVar(CVars.DisplayWindowMode) == (int) WindowMode.Fullscreen; _cfg.GetCVar(CVars.DisplayWindowMode) == (int) WindowMode.Fullscreen;
public void UpdateProperties()
{
FullscreenCheckBox.Pressed = ConfigIsFullscreen;
}
private float ConfigUIScale => _cfg.GetCVar(CVars.DisplayUIScale); private float ConfigUIScale => _cfg.GetCVar(CVars.DisplayUIScale);
private int GetConfigLightingQuality() private int GetConfigLightingQuality()

View File

@@ -159,6 +159,7 @@ namespace Content.Client.Options.UI.Tabs
AddHeader("ui-options-header-misc"); AddHeader("ui-options-header-misc");
AddButton(ContentKeyFunctions.TakeScreenshot); AddButton(ContentKeyFunctions.TakeScreenshot);
AddButton(ContentKeyFunctions.TakeScreenshotNoUI); AddButton(ContentKeyFunctions.TakeScreenshotNoUI);
AddButton(ContentKeyFunctions.ToggleFullscreen);
AddHeader("ui-options-header-hotbar"); AddHeader("ui-options-header-hotbar");
foreach (var boundKey in ContentKeyFunctions.GetHotbarBoundKeys()) foreach (var boundKey in ContentKeyFunctions.GetHotbarBoundKeys())

View File

@@ -47,6 +47,8 @@ public sealed class OptionsUIController : UIController
{ {
EnsureWindow(); EnsureWindow();
_optionsWindow.UpdateTabs();
_optionsWindow.OpenCentered(); _optionsWindow.OpenCentered();
_optionsWindow.MoveToFront(); _optionsWindow.MoveToFront();
} }

View File

@@ -44,6 +44,7 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction OpenAdminMenu = "OpenAdminMenu"; public static readonly BoundKeyFunction OpenAdminMenu = "OpenAdminMenu";
public static readonly BoundKeyFunction TakeScreenshot = "TakeScreenshot"; public static readonly BoundKeyFunction TakeScreenshot = "TakeScreenshot";
public static readonly BoundKeyFunction TakeScreenshotNoUI = "TakeScreenshotNoUI"; public static readonly BoundKeyFunction TakeScreenshotNoUI = "TakeScreenshotNoUI";
public static readonly BoundKeyFunction ToggleFullscreen = "ToggleFullscreen";
public static readonly BoundKeyFunction Point = "Point"; public static readonly BoundKeyFunction Point = "Point";
public static readonly BoundKeyFunction ZoomOut = "ZoomOut"; public static readonly BoundKeyFunction ZoomOut = "ZoomOut";
public static readonly BoundKeyFunction ZoomIn = "ZoomIn"; public static readonly BoundKeyFunction ZoomIn = "ZoomIn";

View File

@@ -89,6 +89,9 @@ binds:
- function: ShowEscapeMenu - function: ShowEscapeMenu
type: State type: State
key: F10 key: F10
- function: ToggleFullscreen
type: State
key: F11
- function: CycleChatChannelForward - function: CycleChatChannelForward
type: State type: State
key: Tab key: Tab