Optimize artifact analyzer UI state sending (#22949)
* Remove n rename cruft old shit * Artifact analyzer UI updating optimization * Revert "Remove n rename cruft old shit" This reverts commit 8789338fb20f77d79c5b0e40719896efe0103fcc.
This commit is contained in:
@@ -61,6 +61,7 @@ public sealed class AnalysisConsoleBoundUserInterface : BoundUserInterface
|
||||
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
_consoleMenu?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Xenoarchaeology.Equipment;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Xenoarchaeology.Ui;
|
||||
@@ -12,11 +13,17 @@ namespace Content.Client.Xenoarchaeology.Ui;
|
||||
public sealed partial class AnalysisConsoleMenu : FancyWindow
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _ent = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
public event Action? OnServerSelectionButtonPressed;
|
||||
public event Action? OnScanButtonPressed;
|
||||
public event Action? OnPrintButtonPressed;
|
||||
public event Action? OnExtractButtonPressed;
|
||||
|
||||
// For rendering the progress bar, updated from BUI state
|
||||
private TimeSpan? _startTime;
|
||||
private TimeSpan? _totalTime;
|
||||
|
||||
public AnalysisConsoleMenu()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
@@ -28,6 +35,23 @@ public sealed partial class AnalysisConsoleMenu : FancyWindow
|
||||
ExtractButton.OnPressed += _ => OnExtractButtonPressed?.Invoke();
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
|
||||
if (_startTime is not { } start || _totalTime is not { } total)
|
||||
return;
|
||||
|
||||
var remaining = start + total - _timing.CurTime;
|
||||
var secsText = Math.Max((int) remaining.TotalSeconds, 0);
|
||||
|
||||
ProgressLabel.Text = Loc.GetString("analysis-console-progress-text",
|
||||
("seconds", secsText));
|
||||
|
||||
// 1.0 - div because we want it to tick up not down
|
||||
ProgressBar.Value = Math.Clamp(1.0f - (float) remaining.Divide(total), 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
public void SetButtonsDisabled(AnalysisConsoleScanUpdateState state)
|
||||
{
|
||||
ScanButton.Disabled = !state.CanScan;
|
||||
@@ -54,8 +78,8 @@ public sealed partial class AnalysisConsoleMenu : FancyWindow
|
||||
ArtifactDisplay.Visible = false;
|
||||
return;
|
||||
}
|
||||
ArtifactDisplay.Visible = true;
|
||||
|
||||
ArtifactDisplay.Visible = true;
|
||||
ArtifactDisplay.SetEntity(uid);
|
||||
}
|
||||
|
||||
@@ -95,12 +119,8 @@ public sealed partial class AnalysisConsoleMenu : FancyWindow
|
||||
ProgressBar.Visible = state.Scanning;
|
||||
ProgressLabel.Visible = state.Scanning;
|
||||
|
||||
if (!state.Scanning)
|
||||
return;
|
||||
|
||||
ProgressLabel.Text = Loc.GetString("analysis-console-progress-text",
|
||||
("seconds", (int) state.TotalTime.TotalSeconds - (int) state.TimeRemaining.TotalSeconds));
|
||||
ProgressBar.Value = (float) state.TimeRemaining.Divide(state.TotalTime);
|
||||
_startTime = state.StartTime;
|
||||
_totalTime = state.TotalTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user