This commit is contained in:
Nemanja
2023-01-17 00:05:20 -05:00
committed by GitHub
parent 06f19dafc9
commit 9cd0c11870
85 changed files with 3109 additions and 54 deletions

View File

@@ -0,0 +1,59 @@
using Content.Shared.Anomaly;
using Content.Shared.Anomaly.Components;
using Robust.Client.GameObjects;
using Robust.Shared.Timing;
namespace Content.Client.Anomaly;
public sealed class AnomalySystem : SharedAnomalySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AnomalyComponent, AppearanceChangeEvent>(OnAppearanceChanged);
}
private void OnAppearanceChanged(EntityUid uid, AnomalyComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite is not { } sprite)
return;
if (!Appearance.TryGetData(uid, AnomalyVisuals.IsPulsing, out bool pulsing, args.Component))
pulsing = false;
if (Appearance.TryGetData(uid, AnomalyVisuals.IsPulsing, out bool super, args.Component) && super)
pulsing = super;
if (HasComp<AnomalySupercriticalComponent>(uid))
pulsing = true;
if (!sprite.LayerMapTryGet(AnomalyVisualLayers.Base, out var layer) ||
!sprite.LayerMapTryGet(AnomalyVisualLayers.Animated, out var animatedLayer))
return;
sprite.LayerSetVisible(layer, !pulsing);
sprite.LayerSetVisible(animatedLayer, pulsing);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
foreach (var (super, sprite) in EntityQuery<AnomalySupercriticalComponent, SpriteComponent>())
{
var completion = 1f - (float) ((super.EndTime - _timing.CurTime) / super.SupercriticalDuration);
var scale = completion * (super.MaxScaleAmount - 1f) + 1f;
sprite.Scale = new Vector2(scale, scale);
var transparency = (byte) (65 * (1f - completion) + 190);
if (transparency < sprite.Color.AByte)
{
sprite.Color = sprite.Color.WithAlpha(transparency);
}
}
}
}

View File

@@ -0,0 +1,8 @@
using Content.Shared.Anomaly.Effects;
namespace Content.Client.Anomaly.Effects;
public sealed class GravityAnomalySystem : SharedGravityAnomalySystem
{
// this is not the system you are looking for
}

View File

@@ -0,0 +1,54 @@
using Content.Shared.Anomaly;
using Content.Shared.Gravity;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client. Anomaly.Ui;
[UsedImplicitly]
public sealed class AnomalyGeneratorBoundUserInterface : BoundUserInterface
{
private AnomalyGeneratorWindow? _window;
public AnomalyGeneratorBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base (owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new (Owner.Owner);
_window.OpenCentered();
_window.OnClose += Close;
_window.OnGenerateButtonPressed += () =>
{
SendMessage(new AnomalyGeneratorGenerateButtonPressedEvent());
};
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not AnomalyGeneratorUserInterfaceState msg)
return;
_window?.UpdateState(msg);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
_window?.Dispose();
}
public void SetPowerSwitch(bool on)
{
SendMessage(new SharedGravityGeneratorComponent.SwitchGeneratorMessage(on));
}
}

View File

@@ -0,0 +1,48 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'anomaly-generator-ui-title'}"
MinSize="270 180"
SetSize="360 180">
<BoxContainer Margin="10 0 10 0"
Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer Orientation="Horizontal">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True"
Margin="0 0 0 0"
VerticalAlignment="Center">
<Label Text="{Loc 'anomaly-generator-fuel-display'}" StyleClasses="StatusFieldTitle" />
<ProgressBar Name="FuelBar"
HorizontalExpand="True"
MaxValue="1"
MinValue="0"
SetHeight="25"
Margin="10 0 10 0"
VerticalAlignment="Center">
<Label Name="FuelText"
Margin="4 0"
Text="0 %" />
</ProgressBar>
</BoxContainer>
<RichTextLabel Name="CooldownLabel" StyleClasses="StatusFieldTitle" />
<RichTextLabel Name="ReadyLabel" StyleClasses="StatusFieldTitle" />
</BoxContainer>
<PanelContainer Margin="12 0 0 0"
StyleClasses="Inset"
VerticalAlignment="Center">
<SpriteView Name="EntityView"
SetSize="96 96"
OverrideDirection="South" />
</PanelContainer>
</BoxContainer>
<BoxContainer VerticalExpand="True"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Button Name="GenerateButton"
Text="{Loc 'anomaly-generator-generate'}"></Button>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>

View File

@@ -0,0 +1,80 @@
using Content.Client.Message;
using Content.Shared.Anomaly;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using FancyWindow = Content.Client.UserInterface.Controls.FancyWindow;
namespace Content.Client.Anomaly.Ui;
[GenerateTypedNameReferences]
public sealed partial class AnomalyGeneratorWindow : FancyWindow
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
private TimeSpan _cooldownEnd = TimeSpan.Zero;
private bool _hasEnoughFuel;
public Action? OnGenerateButtonPressed;
public AnomalyGeneratorWindow(EntityUid gen)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
EntityView.Sprite = _entityManager.GetComponent<SpriteComponent>(gen);
GenerateButton.OnPressed += _ => OnGenerateButtonPressed?.Invoke();
}
public void UpdateState(AnomalyGeneratorUserInterfaceState state)
{
_cooldownEnd = state.CooldownEndTime;
_hasEnoughFuel = state.FuelCost <= state.FuelAmount;
var fuelCompletion = Math.Clamp((float) state.FuelAmount / state.FuelCost, 0f, 1f);
FuelBar.Value = fuelCompletion;
FuelText.Text = $"{fuelCompletion:P}";
UpdateTimer();
UpdateReady(); // yes this can trigger twice. no i don't care
}
public void UpdateTimer()
{
if (_timing.CurTime > _cooldownEnd)
{
CooldownLabel.SetMarkup(Loc.GetString("anomaly-generator-no-cooldown"));
}
else
{
var timeLeft = _cooldownEnd - _timing.CurTime;
var timeString = $"{timeLeft.Minutes:0}:{timeLeft.Seconds:00}";
CooldownLabel.SetMarkup(Loc.GetString("anomaly-generator-cooldown", ("time", timeString)));
UpdateReady();
}
}
public void UpdateReady()
{
var ready = _hasEnoughFuel && _timing.CurTime > _cooldownEnd;
var msg = ready
? Loc.GetString("anomaly-generator-yes-fire")
: Loc.GetString("anomaly-generator-no-fire");
ReadyLabel.SetMarkup(msg);
GenerateButton.Disabled = !ready;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
UpdateTimer();
}
}

View File

@@ -0,0 +1,48 @@
using Content.Shared.Anomaly;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.Anomaly.Ui;
[UsedImplicitly]
public sealed class AnomalyScannerBoundUserInterface : BoundUserInterface
{
private AnomalyScannerMenu? _menu;
public AnomalyScannerBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_menu = new AnomalyScannerMenu();
_menu.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not AnomalyScannerUserInterfaceState msg)
return;
if (_menu == null)
return;
_menu.LastMessage = msg.Message;
_menu.NextPulseTime = msg.NextPulseTime;
_menu.UpdateMenu();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_menu?.Dispose();
}
}

View File

@@ -0,0 +1,12 @@
<controls:FancyWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'anomaly-scanner-ui-title'}"
MinSize="350 260"
SetSize="350 260">
<BoxContainer Orientation="Vertical" VerticalExpand="True" Margin="10 0 10 10">
<RichTextLabel Name="TextDisplay"></RichTextLabel>
</BoxContainer>
</controls:FancyWindow>

View File

@@ -0,0 +1,47 @@
using Content.Client.Message;
using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Client.Anomaly.Ui;
[GenerateTypedNameReferences]
public sealed partial class AnomalyScannerMenu : FancyWindow
{
[Dependency] private readonly IGameTiming _timing = default!;
public FormattedMessage LastMessage = new();
public TimeSpan? NextPulseTime;
public AnomalyScannerMenu()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
}
public void UpdateMenu()
{
var msg = new FormattedMessage(LastMessage);
if (NextPulseTime != null)
{
msg.PushNewline();
msg.PushNewline();
var time = NextPulseTime.Value - _timing.CurTime;
var timestring = $"{time.Minutes:00}:{time.Seconds:00}";
msg.AddMarkup(Loc.GetString("anomaly-scanner-pulse-timer", ("time", timestring)));
}
TextDisplay.SetMarkup(msg.ToMarkup());
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (NextPulseTime != null)
UpdateMenu();
}
}