mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-01 09:37:03 +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>
116 lines
3.0 KiB
C#
116 lines
3.0 KiB
C#
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Profiling;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.IoC;
|
|
|
|
namespace Robust.Client.UserInterface;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class DevWindowTabPerf : Control
|
|
{
|
|
[Dependency] private ProfViewManager _profViewMgr = default!;
|
|
|
|
private ProfViewManager.Snapshot? _currentSnapshot;
|
|
|
|
public DevWindowTabPerf()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
SnapButton.OnPressed += SnapButtonOnOnPressed;
|
|
ButtonDeleteSnap.OnPressed += ButtonDeleteSnapOnOnPressed;
|
|
GraphView.FrameSelected += SelectFrame;
|
|
}
|
|
|
|
private void SelectFrame(long obj)
|
|
{
|
|
if (_currentSnapshot == null)
|
|
return;
|
|
|
|
GraphView.HighlightFrame = obj;
|
|
Tree.Frame = obj;
|
|
Tree.RebuildTree();
|
|
}
|
|
|
|
protected override void EnteredTree()
|
|
{
|
|
_profViewMgr.SnapshotsUpdated += ProfViewMgrOnSnapshotsUpdated;
|
|
|
|
UpdateSnapshotList();
|
|
}
|
|
|
|
protected override void ExitedTree()
|
|
{
|
|
_profViewMgr.SnapshotsUpdated -= ProfViewMgrOnSnapshotsUpdated;
|
|
}
|
|
|
|
private void ProfViewMgrOnSnapshotsUpdated()
|
|
{
|
|
UpdateSnapshotList();
|
|
}
|
|
|
|
private void SnapButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
_profViewMgr.Snap();
|
|
SnapshotSelected(_profViewMgr.Snapshots[^1]);
|
|
}
|
|
|
|
private void ButtonDeleteSnapOnOnPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
if (_currentSnapshot == null)
|
|
return;
|
|
|
|
_profViewMgr.DeleteSnapshot(_currentSnapshot);
|
|
_currentSnapshot = null;
|
|
UpdateRightPanel();
|
|
}
|
|
|
|
private void UpdateSnapshotList()
|
|
{
|
|
SnapList.RemoveAllChildren();
|
|
|
|
for (var i = _profViewMgr.Snapshots.Count - 1; i >= 0; i--)
|
|
{
|
|
var snap = _profViewMgr.Snapshots[i];
|
|
|
|
var button = new Button
|
|
{
|
|
Text = $"{snap.Identifier}: {snap.StartFrame} - {snap.EndFrame}",
|
|
ToggleMode = true
|
|
};
|
|
|
|
if (snap == _currentSnapshot)
|
|
button.Pressed = true;
|
|
|
|
button.OnPressed += _ => SnapshotSelected(snap);
|
|
|
|
SnapList.AddChild(button);
|
|
}
|
|
}
|
|
|
|
private void SnapshotSelected(ProfViewManager.Snapshot snapshot)
|
|
{
|
|
_currentSnapshot = snapshot;
|
|
UpdateSnapshotList();
|
|
UpdateRightPanel();
|
|
SelectFrame(_currentSnapshot.EndFrame);
|
|
Tree.RebuildTree();
|
|
}
|
|
|
|
private void UpdateRightPanel()
|
|
{
|
|
RightPanel.Visible = _currentSnapshot != null;
|
|
RightPanelPlaceholder.Visible = _currentSnapshot == null;
|
|
|
|
if (_currentSnapshot == null)
|
|
return;
|
|
|
|
LabelTopText.Text =
|
|
$"Snapshot: {_currentSnapshot.StartFrame} - {_currentSnapshot.EndFrame} Frame count: {_currentSnapshot.FrameCount}";
|
|
|
|
GraphView.LoadSnapshot(_currentSnapshot);
|
|
Tree.LoadSnapshot(_currentSnapshot);
|
|
}
|
|
}
|