* Xenoarch feedback print out reports, weight node traversal, dialog for destroy menu, slight effect tweaks * make the popup not bad * the popup, jimbo...
185 lines
6.2 KiB
C#
185 lines
6.2 KiB
C#
using Content.Client.Stylesheets;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.Xenoarchaeology.Equipment;
|
|
using Content.Shared.Xenoarchaeology.XenoArtifacts;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
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 IPrototypeManager _proto = default!;
|
|
|
|
public AnalysisDestroyWindow? AnalysisDestroyWindow;
|
|
|
|
public event Action<BaseButton.ButtonEventArgs>? OnServerSelectionButtonPressed;
|
|
public event Action<BaseButton.ButtonEventArgs>? OnScanButtonPressed;
|
|
public event Action<BaseButton.ButtonEventArgs>? OnPrintButtonPressed;
|
|
public event Action<BaseButton.ButtonEventArgs>? OnDestroyButtonPressed;
|
|
|
|
public AnalysisConsoleMenu()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
ServerSelectionButton.OnPressed += a => OnServerSelectionButtonPressed?.Invoke(a);
|
|
ScanButton.OnPressed += a => OnScanButtonPressed?.Invoke(a);
|
|
PrintButton.OnPressed += a => OnPrintButtonPressed?.Invoke(a);
|
|
DestroyButton.OnPressed += _ => OnDestroyButton();
|
|
}
|
|
|
|
private void OnDestroyButton()
|
|
{
|
|
// check if window is already open
|
|
if (AnalysisDestroyWindow is { IsOpen: true })
|
|
{
|
|
AnalysisDestroyWindow.MoveToFront();
|
|
return;
|
|
}
|
|
|
|
// open a new one
|
|
AnalysisDestroyWindow = new ();
|
|
AnalysisDestroyWindow.OpenCentered();
|
|
|
|
AnalysisDestroyWindow.OnYesButton += a =>
|
|
{
|
|
OnDestroyButtonPressed?.Invoke(a);
|
|
};
|
|
}
|
|
|
|
public void SetButtonsDisabled(AnalysisConsoleScanUpdateState state)
|
|
{
|
|
ScanButton.Disabled = !state.CanScan;
|
|
PrintButton.Disabled = !state.CanPrint;
|
|
|
|
var disabled = !state.ServerConnected || !state.CanScan;
|
|
|
|
DestroyButton.Disabled = disabled;
|
|
|
|
if (disabled)
|
|
{
|
|
DestroyButton.RemoveStyleClass(StyleBase.ButtonCaution);
|
|
}
|
|
else
|
|
{
|
|
DestroyButton.AddStyleClass(StyleBase.ButtonCaution);
|
|
}
|
|
}
|
|
|
|
public void UpdateArtifactIcon(EntityUid? uid)
|
|
{
|
|
if (uid == null)
|
|
{
|
|
ArtifactDisplay.Visible = false;
|
|
return;
|
|
}
|
|
ArtifactDisplay.Visible = true;
|
|
|
|
if (!_ent.TryGetComponent<SpriteComponent>(uid, out var sprite))
|
|
return;
|
|
|
|
ArtifactDisplay.Sprite = sprite;
|
|
}
|
|
|
|
public void UpdateInformationDisplay(AnalysisConsoleScanUpdateState state)
|
|
{
|
|
var message = new FormattedMessage();
|
|
|
|
if (state.Scanning)
|
|
{
|
|
message.AddMarkup(Loc.GetString("analysis-console-info-scanner"));
|
|
Information.SetMessage(message);
|
|
UpdateArtifactIcon(null); //set it to blank
|
|
return;
|
|
}
|
|
|
|
//do this here
|
|
UpdateArtifactIcon(state.Artifact);
|
|
|
|
if (state.Artifact == null)//no scan present
|
|
{
|
|
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"));
|
|
}
|
|
|
|
if (state.Id != null) //node id
|
|
message.AddMarkup(Loc.GetString("analysis-console-info-id", ("id", state.Id))+"\n");
|
|
if (state.Depth != null) //node depth
|
|
message.AddMarkup(Loc.GetString("analysis-console-info-depth", ("depth", state.Depth))+"\n");
|
|
|
|
if (state.Triggered != null) //whether it has been triggered
|
|
{
|
|
var activated = state.Triggered.Value
|
|
? "analysis-console-info-triggered-true"
|
|
: "analysis-console-info-triggered-false";
|
|
message.AddMarkup(Loc.GetString(activated)+"\n");
|
|
}
|
|
|
|
message.AddMarkup("\n");
|
|
var needSecondNewline = false;
|
|
|
|
if (state.TriggerProto != null && //possible triggers
|
|
_proto.TryIndex<ArtifactTriggerPrototype>(state.TriggerProto, out var trigger) &&
|
|
trigger.TriggerHint != null)
|
|
{
|
|
message.AddMarkup(Loc.GetString("analysis-console-info-trigger",
|
|
("trigger", Loc.GetString(trigger.TriggerHint))) + "\n");
|
|
needSecondNewline = true;
|
|
}
|
|
|
|
if (state.EffectProto != null && //possible effects
|
|
_proto.TryIndex<ArtifactEffectPrototype>(state.EffectProto, out var effect) &&
|
|
effect.EffectHint != null)
|
|
{
|
|
message.AddMarkup(Loc.GetString("analysis-console-info-effect",
|
|
("effect", Loc.GetString(effect.EffectHint))) + "\n");
|
|
needSecondNewline = true;
|
|
}
|
|
|
|
if (needSecondNewline)
|
|
message.AddMarkup("\n");
|
|
|
|
if (state.Edges != null) //number of edges
|
|
message.AddMarkup(Loc.GetString("analysis-console-info-edges", ("edges", state.Edges))+"\n");
|
|
if (state.Completion != null) //completion percentage
|
|
{
|
|
message.AddMarkup(Loc.GetString("analysis-console-info-completion",
|
|
("percentage", Math.Round(state.Completion.Value * 100)))+"\n");
|
|
}
|
|
|
|
Information.SetMessage(message);
|
|
}
|
|
|
|
public void UpdateProgressBar(AnalysisConsoleScanUpdateState state)
|
|
{
|
|
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);
|
|
}
|
|
|
|
public override void Close()
|
|
{
|
|
base.Close();
|
|
|
|
AnalysisDestroyWindow?.Close();
|
|
}
|
|
}
|
|
|