Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream sync #1687

Merged
merged 12 commits into from
Dec 27, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected override void Dispose(bool disposing)

if (!disposing)
return;

_consoleMenu?.Dispose();
}
}
Expand Down
34 changes: 27 additions & 7 deletions Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand All @@ -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);
Expand All @@ -28,6 +35,23 @@ public AnalysisConsoleMenu()
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;
Expand All @@ -54,8 +78,8 @@ private void UpdateArtifactIcon(EntityUid? uid)
ArtifactDisplay.Visible = false;
return;
}
ArtifactDisplay.Visible = true;

ArtifactDisplay.Visible = true;
ArtifactDisplay.SetEntity(uid);
}

Expand Down Expand Up @@ -95,12 +119,8 @@ 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);
_startTime = state.StartTime;
_totalTime = state.TotalTime;
}
}

4 changes: 2 additions & 2 deletions Content.Server/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override void Initialize()
_config.OnValueChanged(CVars.GameHostName, OnServerNameChanged, true);
_config.OnValueChanged(CCVars.AdminAhelpOverrideClientName, OnOverrideChanged, true);
_sawmill = IoCManager.Resolve<ILogManager>().GetSawmill("AHELP");
_maxAdditionalChars = GenerateAHelpMessage("", "", true, _timing.CurTime.ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel).Length;
_maxAdditionalChars = GenerateAHelpMessage("", "", true, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel).Length;
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;

SubscribeLocalEvent<GameRunLevelChangedEvent>(OnGameRunLevelChanged);
Expand Down Expand Up @@ -471,7 +471,7 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
{
str = str[..(DescriptionMax - _maxAdditionalChars - unameLength)];
}
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, _timing.CurTime.ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, admins.Count == 0));
_messageQueues[msg.UserId].Enqueue(GenerateAHelpMessage(senderSession.Name, str, !personalChannel, _gameTicker.RoundDuration().ToString("hh\\:mm\\:ss"), _gameTicker.RunLevel, admins.Count == 0));
}

if (admins.Count != 0 || sendsWebhook)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public override void Update(float frameTime)
var query = EntityQueryEnumerator<ActiveArtifactAnalyzerComponent, ArtifactAnalyzerComponent>();
while (query.MoveNext(out var uid, out var active, out var scan))
{
if (scan.Console != null)
UpdateUserInterface(scan.Console.Value);

if (_timing.CurTime - active.StartTime < scan.AnalysisDuration * scan.AnalysisDurationMulitplier)
continue;

Expand Down Expand Up @@ -191,7 +188,7 @@ private void UpdateUserInterface(EntityUid uid, AnalysisConsoleComponent? compon

EntityUid? artifact = null;
FormattedMessage? msg = null;
var totalTime = TimeSpan.Zero;
TimeSpan? totalTime = null;
var canScan = false;
var canPrint = false;
var points = 0;
Expand All @@ -212,10 +209,9 @@ private void UpdateUserInterface(EntityUid uid, AnalysisConsoleComponent? compon
var serverConnected = TryComp<ResearchClientComponent>(uid, out var client) && client.ConnectedToServer;

var scanning = TryComp<ActiveArtifactAnalyzerComponent>(component.AnalyzerEntity, out var active);
var remaining = active != null ? _timing.CurTime - active.StartTime : TimeSpan.Zero;

var state = new AnalysisConsoleScanUpdateState(GetNetEntity(artifact), analyzerConnected, serverConnected,
canScan, canPrint, msg, scanning, remaining, totalTime, points);
canScan, canPrint, msg, scanning, active?.StartTime, totalTime, points);

var bui = _ui.GetUi(uid, ArtifactAnalzyerUiKey.Key);
_ui.SetUiState(bui, state);
Expand Down Expand Up @@ -256,6 +252,7 @@ private void OnScanButton(EntityUid uid, AnalysisConsoleComponent component, Ana

var activeArtifact = EnsureComp<ActiveScannedArtifactComponent>(ent.Value);
activeArtifact.Scanner = component.AnalyzerEntity.Value;
UpdateUserInterface(uid, component);
}

private void OnPrintButton(EntityUid uid, AnalysisConsoleComponent component, AnalysisConsolePrintButtonPressedMessage args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public sealed class AnalysisConsoleScanUpdateState : BoundUserInterfaceState

public bool Scanning;

public TimeSpan TimeRemaining;
public TimeSpan? StartTime;

public TimeSpan TotalTime;
public TimeSpan? TotalTime;

public int PointAmount;

public AnalysisConsoleScanUpdateState(NetEntity? artifact, bool analyzerConnected, bool serverConnected, bool canScan, bool canPrint,
FormattedMessage? scanReport, bool scanning, TimeSpan timeRemaining, TimeSpan totalTime, int pointAmount)
FormattedMessage? scanReport, bool scanning, TimeSpan? startTime, TimeSpan? totalTime, int pointAmount)
{
Artifact = artifact;
AnalyzerConnected = analyzerConnected;
Expand All @@ -64,7 +64,7 @@ public AnalysisConsoleScanUpdateState(NetEntity? artifact, bool analyzerConnecte
ScanReport = scanReport;

Scanning = scanning;
TimeRemaining = timeRemaining;
StartTime = startTime;
TotalTime = totalTime;

PointAmount = pointAmount;
Expand Down
1 change: 0 additions & 1 deletion Resources/ConfigPresets/WizardsDen/wizardsDen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ limit = 10.0
[admin]
see_own_notes = true
deadmin_on_join = true
override_adminname_in_client_ahelp = "The Grinch"
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ent-CrateNPCPenguin = Penguin crate
.desc = A crate containing two penguins.

ent-CrateNPCMothroach = Crate of mothroaches
.desc = A crate containing six mothroaches.
.desc = A crate containing four mothroaches.

ent-CrateNPCPig = Pig crate
.desc = A crate containing a single pig.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-ClothingNeckStoleChaplain = chaplain stole
.desc = An elegantly designed stole, with a vibrant gold plus on either end.
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
ent-PartGingerbread = часть тела пряничного человечка
.desc = { ent-BaseItem.desc }
.desc = { ent-BaseItem.desc }
ent-TorsoGingerbread = туловище пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-HeadGingerbread = голова пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-LeftArmGingerbread = левая рука пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-RightArmGingerbread = правая рука пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-LeftHandGingerbread = левая кисть пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-RightHandGingerbread = правая кисть пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-LeftLegGingerbread = левая нога пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-RightLegGingerbread = правая нога пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-LeftFootGingerbread = левая стопа пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
ent-RightFootGingerbread = правая стопа пряничного человечка
.desc = { ent-PartGingerbread.desc }
.desc = { ent-PartGingerbread.desc }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-ClothingNeckStoleChaplain = chaplain stole
.desc = An elegantly designed stole, with a vibrant gold plus on either end.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ent-BaseTerminatorObjective = { ent-BaseObjective }
.desc = { ent-BaseObjective.desc }
ent-TerminateObjective = { ent-BaseTerminatorObjective }
.desc = Следуйте своей программе и уничтожьте цель.
.desc = Следуйте своей программе и уничтожьте цель.
ent-ShutDownObjective = Отключиться
.desc = Выполнив задание, умрите, чтобы предотвратить кражу нашей технологии.
Loading
Loading