CatStation/Content.Client/Fullscreen/FullscreenHook.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

43 lines
1.5 KiB
C#

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.Player;
namespace Content.Client.Fullscreen;
public sealed partial class FullscreenHook
{
[Dependency] private IInputManager _inputManager = default!;
[Dependency] private IConfigurationManager _cfg = default!;
[Dependency] private 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}");
}
}
}