Files
RobustToolbox/Robust.Client/UserInterface/CustomControls/DebugMonitorControls/DebugInputPanel.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

57 lines
1.5 KiB
C#

using System.Text;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Robust.Client.UserInterface.CustomControls.DebugMonitorControls
{
internal sealed partial class DebugInputPanel : PanelContainer
{
[Dependency] private IInputManager _inputManager = default!;
private readonly Label _label;
private readonly StringBuilder _textBuilder = new();
private readonly char[] _textBuffer = new char[512];
public DebugInputPanel()
{
IoCManager.InjectDependencies(this);
PanelOverride = new StyleBoxFlat
{
BackgroundColor = new Color(67, 105, 255, 138),
};
PanelOverride.SetContentMarginOverride(StyleBox.Margin.All, 5);
AddChild(_label = new Label());
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!VisibleInTree)
{
return;
}
_textBuilder.Clear();
_textBuilder.Append($"Input context: {_inputManager.Contexts.ActiveContext.Name}");
foreach (var func in _inputManager.DownKeyFunctions)
{
_textBuilder.Append($"\n {func.FunctionName}");
}
_label.TextMemory = FormatHelpers.BuilderToMemory(_textBuilder, _textBuffer);
}
}
}