mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-01 17:47:24 +02:00
* [Dependency] source generator No more reflection, no more codegen at runtime Also various changes to Roslyn helpers to make this easier to write. Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback. No fallback is available for [field: Dependency] properties, due to a Roslyn bug. Code Fixes exist. We love Roslyn * Apply dependencies generator changes to all code * Release notes * Preprocessor got hands * Handle nullable dependencies These are bad but gotta deal with it. * Apply suggestions from code review Co-authored-by: Moony <moony@hellomouse.net> * Fine, let's not use collection expressions --------- Co-authored-by: Moony <moony@hellomouse.net>
68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using System.Linq;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.IoC;
|
|
|
|
namespace Robust.Client.Console.Commands
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed partial class LsMonitorCommand : LocalizedCommands
|
|
{
|
|
[Dependency] private IClyde _clyde = default!;
|
|
|
|
public override string Command => "lsmonitor";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
foreach (var monitor in _clyde.EnumerateMonitors())
|
|
{
|
|
shell.WriteLine(
|
|
$"[{monitor.Id}] {monitor.Name}: {monitor.Size.X}x{monitor.Size.Y}@{monitor.RefreshRate}Hz");
|
|
}
|
|
}
|
|
}
|
|
|
|
[UsedImplicitly]
|
|
public sealed partial class MonitorInfoCommand : LocalizedCommands
|
|
{
|
|
[Dependency] private IClyde _clyde = default!;
|
|
|
|
public override string Command => "monitorinfo";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length < 1)
|
|
{
|
|
shell.WriteError("Expected one argument.");
|
|
return;
|
|
}
|
|
|
|
var monitor = _clyde.EnumerateMonitors().Single(c => c.Id == int.Parse(args[0]));
|
|
|
|
shell.WriteLine($"{monitor.Id}: {monitor.Name}");
|
|
shell.WriteLine($"Video modes:");
|
|
|
|
foreach (var mode in monitor.VideoModes)
|
|
{
|
|
shell.WriteLine($" {mode.Width}x{mode.Height} {mode.RefreshRate} Hz {mode.RedBits}/{mode.GreenBits}/{mode.BlueBits}");
|
|
}
|
|
}
|
|
}
|
|
|
|
[UsedImplicitly]
|
|
public sealed partial class SetMonitorCommand : LocalizedCommands
|
|
{
|
|
[Dependency] private IClyde _clyde = default!;
|
|
|
|
public override string Command => "setmonitor";
|
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
var id = int.Parse(args[0]);
|
|
var monitor = _clyde.EnumerateMonitors().Single(m => m.Id == id);
|
|
_clyde.SetWindowMonitor(monitor);
|
|
}
|
|
}
|
|
}
|