Files
tbd-station-14/Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs
Hannah Giovanna Dawson f059714a75 SS14-26480 Roll Traversal Distorter into regular Artifact Analyzers (#26545)
* SS14-26480 Roll Traversal Distorter into regular Artifact Analyzers

Bit of a grab-bag of cleanup of Xenoarchaeology prompted by #26480.

1. Traversal distortion biases are now "up" and "down" instead of "in" and "out".
2. Node generation has been tidied up to make it a little clearer how it works.
3. Traversal Distorters have been removed from the game along with their board.
4. Traversal distortion is now done by the artifact analyzers by default.
5. Some loc strings have been made clearer.
6. The Abnormal Artifact Manipulation tech has been made slightly cheaper.
7. The aformentioned tech is now localized as Artifact Recycling, given all it does is unlock the crusher.
8. The Xenoarchaeology guidebook entry has been given a bit of a rewrite, putting all information into
one page and making sure to cover the basics that otherwise would require someone typing "Liltenhead
artifact tutorial" into Youtube.

* Fix references to deleted guidebook entry

* Add fancy button to console because @EmoGarbage404 asked me to

* migration comprete

* Fixed a goober comment

* maint fails to resolve conflicts: more at 11

* Resolve PR comments

* Make UI nice

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
2024-04-21 12:09:26 -04:00

152 lines
4.9 KiB
C#

using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.Xenoarchaeology.Equipment;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Client.Xenoarchaeology.Ui;
[GenerateTypedNameReferences]
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;
public event Action? OnUpBiasButtonPressed;
public event Action? OnDownBiasButtonPressed;
// For rendering the progress bar, updated from BUI state
private TimeSpan? _startTime;
private TimeSpan? _totalTime;
private TimeSpan? _accumulatedRunTime;
private bool _paused;
public AnalysisConsoleMenu()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
ServerSelectionButton.OnPressed += _ => OnServerSelectionButtonPressed?.Invoke();
ScanButton.OnPressed += _ => OnScanButtonPressed?.Invoke();
PrintButton.OnPressed += _ => OnPrintButtonPressed?.Invoke();
ExtractButton.OnPressed += _ => OnExtractButtonPressed?.Invoke();
UpBiasButton.OnPressed += _ => OnUpBiasButtonPressed?.Invoke();
DownBiasButton.OnPressed += _ => OnDownBiasButtonPressed?.Invoke();
var buttonGroup = new ButtonGroup(false);
UpBiasButton.Group = buttonGroup;
DownBiasButton.Group = buttonGroup;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (_startTime is not { } start || _totalTime is not { } total || _accumulatedRunTime is not { } accumulated)
return;
var remaining = total - accumulated;
if (!_paused)
{
// If the analyzer is running, its remaining time is further discounted by the time it's been running for.
remaining += start - _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(AnalysisConsoleUpdateState state)
{
ScanButton.Disabled = !state.CanScan;
PrintButton.Disabled = !state.CanPrint;
var disabled = !state.ServerConnected || !state.CanScan || state.PointAmount <= 0;
ExtractButton.Disabled = disabled;
if (disabled)
{
ExtractButton.RemoveStyleClass("ButtonColorGreen");
}
else
{
ExtractButton.AddStyleClass("ButtonColorGreen");
}
}
private void UpdateArtifactIcon(EntityUid? uid)
{
if (uid == null)
{
ArtifactDisplay.Visible = false;
return;
}
ArtifactDisplay.Visible = true;
ArtifactDisplay.SetEntity(uid);
}
public void UpdateInformationDisplay(AnalysisConsoleUpdateState state)
{
var message = new FormattedMessage();
if (state.Scanning)
{
if (state.Paused)
{
message.AddMarkup(Loc.GetString("analysis-console-info-scanner-paused"));
}
else
{
message.AddMarkup(Loc.GetString("analysis-console-info-scanner"));
}
Information.SetMessage(message);
UpdateArtifactIcon(null); //set it to blank
return;
}
UpdateArtifactIcon(_ent.GetEntity(state.Artifact));
if (state.ScanReport == null)
{
if (!state.AnalyzerConnected) //no analyzer connected
message.AddMarkup(Loc.GetString("analysis-console-info-no-scanner"));
else if (!state.CanScan) //no artifact
message.AddMarkup(Loc.GetString("analysis-console-info-no-artifact"));
else if (state.Artifact == null) //ready to go
message.AddMarkup(Loc.GetString("analysis-console-info-ready"));
}
else
{
message.AddMessage(state.ScanReport);
}
Information.SetMessage(message);
}
public void UpdateProgressBar(AnalysisConsoleUpdateState state)
{
ProgressBar.Visible = state.Scanning;
ProgressLabel.Visible = state.Scanning;
_startTime = state.StartTime;
_totalTime = state.TotalTime;
_accumulatedRunTime = state.AccumulatedRunTime;
_paused = state.Paused;
}
}