Files
RobustToolbox/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugMonitors.cs
T
83c2a1be11 [Dependency] source generator part 2 (#6550)
* [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>
2026-05-08 12:38:33 +02:00

58 lines
2.3 KiB
C#

using System;
using Robust.Client.GameStates;
using Robust.Client.Profiling;
using Robust.Client.Timing;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Network;
namespace Robust.Client.UserInterface.CustomControls.DebugMonitorControls
{
internal sealed partial class DebugMonitors : BoxContainer, IDebugMonitors
{
[Dependency] private IClientGameTiming _timing = default!;
[Dependency] private IClientGameStateManager _state = default!;
[Dependency] private IConfigurationManager _cfg = default!;
[Dependency] private IClientNetManager _net = default!;
private readonly Control[] _monitors = new Control[Enum.GetNames<DebugMonitor>().Length];
public void Init()
{
Visible = false;
SeparationOverride = 2;
Orientation = LayoutOrientation.Vertical;
Add(DebugMonitor.Fps, new FpsCounter(_timing));
Add(DebugMonitor.Coords, new DebugCoordsPanel());
Add(DebugMonitor.Net, new DebugNetPanel(_net, _timing));
Add(DebugMonitor.Bandwidth, new DebugNetBandwidthPanel(_net, _timing));
Add(DebugMonitor.Time, new DebugTimePanel(_timing, _state));
Add(DebugMonitor.Frames, new FrameGraph(_timing, _cfg));
Add(DebugMonitor.Memory, new DebugMemoryPanel());
Add(DebugMonitor.Clyde, new DebugClydePanel { HorizontalAlignment = HAlignment.Left });
Add(DebugMonitor.System, new DebugSystemPanel { HorizontalAlignment = HAlignment.Left });
Add(DebugMonitor.Version, new DebugVersionPanel(_cfg) { HorizontalAlignment = HAlignment.Left });
Add(DebugMonitor.Input, new DebugInputPanel { HorizontalAlignment = HAlignment.Left });
Add(DebugMonitor.Prof, new LiveProfileViewControl());
void Add(DebugMonitor monitor, Control instance)
{
_monitors[(int)monitor] = instance;
AddChild(instance);
}
}
public void ToggleMonitor(DebugMonitor monitor)
{
_monitors[(int)monitor].Visible ^= true;
}
public void SetMonitor(DebugMonitor monitor, bool visible)
{
_monitors[(int)monitor].Visible = visible;
}
}
}