* Initial Pass, Rev, Thief * Zombie initial pass * Rebase, Traitor * Nukeops, More overloads * Revert RevolutionaryRuleComponent * Use TryRoundStartAttempt, Rewrite nukie spawning * Comments, Add task scheduler to GameRuleSystem * Zombie initial testing done * Sort methods, rework GameRuleTask * Add CCVar, Initial testing continues * Might as well get rid of the obsolete logging * Oops, i dont know how to log apparently * Suggested formatting fixes * Suggested changes * Fix merge issues * Minor optimisation * Allowed thief to choose other antags * Review changes * Spawn items on floor first, then inserting * minor tweaks * Shift as much as possible to ProtoId<> * Remove unneeded * Add exclusive antag attribute * Fix merge issues * Minor formatting fix * Convert to struct * Cleanup * Review cleanup (need to test a lot) * Some fixes, (mostly) tested * oop * Pass tests (for real) --------- Co-authored-by: Rainfall <rainfey0+git@gmail.com> Co-authored-by: AJCM <AJCM@tutanota.com>
121 lines
4.7 KiB
C#
121 lines
4.7 KiB
C#
using Content.Client.Stylesheets;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.NukeOps;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.NukeOps;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class WarDeclaratorWindow : FancyWindow
|
|
{
|
|
private readonly IGameTiming _gameTiming;
|
|
|
|
public event Action<string>? OnActivated;
|
|
|
|
private TimeSpan _endTime;
|
|
private TimeSpan _shuttleDisabledTime;
|
|
private WarConditionStatus _status;
|
|
|
|
public WarDeclaratorWindow(IGameTiming gameTiming, ILocalizationManager localizationManager)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
|
|
_gameTiming = gameTiming;
|
|
|
|
WarButton.OnPressed += (_) => OnActivated?.Invoke(Rope.Collapse(MessageEdit.TextRope));
|
|
|
|
MessageEdit.Placeholder = new Rope.Leaf(localizationManager.GetString("war-declarator-message-placeholder"));
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
UpdateTimer();
|
|
}
|
|
|
|
public void UpdateState(WarDeclaratorBoundUserInterfaceState state)
|
|
{
|
|
if (state.Status == null)
|
|
return;
|
|
|
|
WarButton.Disabled = state.Status == WarConditionStatus.WarReady;
|
|
|
|
_endTime = state.EndTime;
|
|
_shuttleDisabledTime = state.ShuttleDisabledTime;
|
|
_status = state.Status.Value;
|
|
|
|
UpdateStatus(state.Status.Value);
|
|
|
|
}
|
|
|
|
private void UpdateStatus(WarConditionStatus status)
|
|
{
|
|
switch (status)
|
|
{
|
|
case WarConditionStatus.WarReady:
|
|
WarButton.Disabled = true;
|
|
StatusLabel.Text = Loc.GetString("war-declarator-boost-declared");
|
|
UpdateTimer();
|
|
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateLow);
|
|
break;
|
|
case WarConditionStatus.YesWar:
|
|
WarButton.Text = Loc.GetString("war-declarator-ui-war-button");
|
|
StatusLabel.Text = Loc.GetString("war-declarator-boost-possible");
|
|
UpdateTimer();
|
|
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateGood);
|
|
break;
|
|
case WarConditionStatus.NoWarSmallCrew:
|
|
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
|
|
InfoLabel.Text = Loc.GetString("war-declarator-conditions-small-crew");
|
|
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
|
|
break;
|
|
case WarConditionStatus.NoWarShuttleDeparted:
|
|
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
|
|
InfoLabel.Text = Loc.GetString("war-declarator-conditions-left-outpost");
|
|
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
|
|
break;
|
|
case WarConditionStatus.NoWarTimeout:
|
|
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
|
|
InfoLabel.Text = Loc.GetString("war-declarator-conditions-time-out");
|
|
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
|
|
break;
|
|
case WarConditionStatus.NoWarUnknown:
|
|
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
|
|
InfoLabel.Text = Loc.GetString("war-declarator-conditions-unknown");
|
|
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
|
|
break;
|
|
default:
|
|
StatusLabel.Text = Loc.GetString("war-declarator-boost-impossible");
|
|
InfoLabel.Text = Loc.GetString("war-declarator-conditions-unknown");
|
|
StatusLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void UpdateTimer()
|
|
{
|
|
switch(_status)
|
|
{
|
|
case WarConditionStatus.YesWar:
|
|
var timeLeft = _endTime.Subtract(_gameTiming.CurTime);
|
|
if (timeLeft > TimeSpan.Zero)
|
|
InfoLabel.Text = Loc.GetString("war-declarator-boost-timer", ("time", timeLeft.ToString("mm\\:ss")));
|
|
else
|
|
UpdateStatus(WarConditionStatus.NoWarTimeout);
|
|
break;
|
|
|
|
case WarConditionStatus.WarReady:
|
|
var time = _shuttleDisabledTime.Subtract(_gameTiming.CurTime);
|
|
if (time > TimeSpan.Zero)
|
|
InfoLabel.Text = Loc.GetString("war-declarator-boost-timer", ("time", time.ToString("mm\\:ss")));
|
|
else
|
|
InfoLabel.Text = Loc.GetString("war-declarator-conditions-ready");
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
}
|
|
}
|