Skip to content

Commit

Permalink
Salvage magnet revamp (space-wizards#23119)
Browse files Browse the repository at this point in the history
* Generic offering window

* More work

* weh

* Parity

* Progression meter

* magnet

* rona

* PG asteroid work

* code red

* Asteroid spawnings

* clams

* a

* Marker fixes

* More fixes

* Workings of biome asteroids

* A

* Fix this loading code

* a

* Fix masking

* weh

* Fixes

* Magnet claiming

* toe

* petogue

* magnet

* Bunch of fixes

* Fix default

* Fixes

* asteroids

* Fix offerings

* Localisation and a bunch of fixes

* a

* Fixes

* Preliminary draft

* Announcement fixes

* Fixes and bump spawn rate

* Fix asteroid spawns and UI

* More fixes

* Expeditions fix

* fix

* Gravity

* Fix announcement rounding

* a

* Offset tweak

* sus

* jankass

* Fix merge
  • Loading branch information
metalgearsloth authored Jan 4, 2024
1 parent 98f5f47 commit bf79acd
Show file tree
Hide file tree
Showing 66 changed files with 2,249 additions and 1,244 deletions.
1 change: 0 additions & 1 deletion Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public override void Init()
_prototypeManager.RegisterIgnore("npcFaction");
_prototypeManager.RegisterIgnore("lobbyBackground");
_prototypeManager.RegisterIgnore("advertisementsPack");
_prototypeManager.RegisterIgnore("salvageMap");
_prototypeManager.RegisterIgnore("gamePreset");
_prototypeManager.RegisterIgnore("noiseChannel");
_prototypeManager.RegisterIgnore("spaceBiome");
Expand Down
7 changes: 0 additions & 7 deletions Content.Client/Salvage/SalvageMagnetComponent.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@
Title="{Loc 'salvage-expedition-window-title'}"
MinSize="800 360">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal" Name="ProgressionBox" Visible="False">
<Label Name="ProgressionLabel"
Text="{Loc 'salvage-expedition-window-progression'}"
SetWidth="96"
Margin="5"/>
<ProgressBar Name="ProgressionBar"
HorizontalExpand="True"
MinValue="0"
MaxValue="1"
SetHeight="25"/>
<Label Name="ProgressionText" Text="00:00"
Margin="5"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Name="NextOfferLabel"
Text="{Loc 'salvage-expedition-window-next'}"
Margin="5"></Label>
SetWidth="96"
Margin="5"/>
<ProgressBar Name="NextOfferBar"
HorizontalExpand="True"
MinValue="0"
Expand Down
117 changes: 117 additions & 0 deletions Content.Client/Salvage/UI/OfferingWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using Content.Client.Computer;
using Content.Client.UserInterface.Controls;
using Content.Shared.Shuttles.BUIStates;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Timing;

namespace Content.Client.Salvage.UI;

/// <summary>
/// Generic window for offering multiple selections with a timer.
/// </summary>
[GenerateTypedNameReferences]
public sealed partial class OfferingWindow : FancyWindow,
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
{
[Dependency] private readonly IGameTiming _timing = default!;

public bool Claimed;
public TimeSpan NextOffer;
private TimeSpan? _progression;

/// <summary>
/// Time between NextOffers
/// </summary>
public TimeSpan Cooldown;

/// <summary>
/// Time between Progressions
/// </summary>
public TimeSpan ProgressionCooldown;

/// <summary>
/// Secondary timer used for tracking active progress.
/// </summary>
public TimeSpan? Progression
{
get => _progression;
set
{
if (_progression == value)
return;

_progression = value;

if (value == null)
{
ProgressionBox.Visible = false;
}
else
{
ProgressionBox.Visible = true;
}
}
}

public OfferingWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

ProgressionBar.ForegroundStyleBoxOverride = new StyleBoxFlat(Color.FromHex("#C74EBD"));
}

public void AddOption(OfferingWindowOption option)
{
Container.AddChild(option);
}

public void ClearOptions()
{
Container.DisposeAllChildren();
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

if (_progression != null)
{
var remaining = _progression.Value - _timing.CurTime;

if (remaining < TimeSpan.Zero)
{
ProgressionBar.Value = 1f;
ProgressionText.Text = "00:00";
}
else
{
ProgressionBar.Value = 1f - (float) (remaining / ProgressionCooldown);
ProgressionText.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
}
}

if (Claimed)
{
NextOfferBar.Value = 1f;
NextOfferText.Text = "00:00";
}
else
{
var remaining = NextOffer - _timing.CurTime;

if (remaining < TimeSpan.Zero)
{
NextOfferBar.Value = 1f;
NextOfferText.Text = "00:00";
}
else
{
NextOfferBar.Value = 1f - (float) (remaining / Cooldown);
NextOfferText.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
}
}
}
}
24 changes: 24 additions & 0 deletions Content.Client/Salvage/UI/OfferingWindowOption.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<PanelContainer xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
HorizontalExpand="True"
Name="BigPanel"
Margin="5 0">
<BoxContainer Orientation="Vertical"
Margin="5 5">
<!-- Title box -->
<controls:StripeBack>
<Label Name="TitleStripe"
HorizontalAlignment="Center"
Margin="0 5 0 5"/>
</controls:StripeBack>
<BoxContainer Orientation="Vertical" Name="ContentBox"/>
<!-- Buffer so all claim buttons are in the same position -->
<Control VerticalExpand="True"/>
<Button Name="ClaimButton"
HorizontalExpand="True"
VerticalAlignment="Bottom"
ToggleMode="True"
Disabled="True"
Text="{Loc 'offering-window-claim'}"/>
</BoxContainer>
</PanelContainer>
87 changes: 87 additions & 0 deletions Content.Client/Salvage/UI/OfferingWindowOption.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System.Linq;
using Content.Client.Computer;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.CCVar;
using Content.Shared.Parallax.Biomes;
using Content.Shared.Procedural;
using Content.Shared.Salvage;
using Content.Shared.Salvage.Expeditions;
using Content.Shared.Salvage.Expeditions.Modifiers;
using Content.Shared.Shuttles.BUIStates;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client.Salvage.UI;

/// <summary>
/// Generic window for offering multiple selections with a timer.
/// </summary>
[GenerateTypedNameReferences]
public sealed partial class OfferingWindowOption : PanelContainer
{
private bool _claimed;

public string? Title
{
get => TitleStripe.Text;
set => TitleStripe.Text = value;
}

public event Action<BaseButton.ButtonEventArgs>? ClaimPressed;

public OfferingWindowOption()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
BigPanel.PanelOverride = new StyleBoxFlat(new Color(30, 30, 34));

ClaimButton.OnPressed += args =>
{
ClaimPressed?.Invoke(args);
};
}

public void AddContent(Control control)
{
ContentBox.AddChild(control);
}

public bool Disabled
{
get => ClaimButton.Disabled;
set => ClaimButton.Disabled = value;
}

public bool Claimed
{
get => _claimed;
set
{
if (_claimed == value)
return;

_claimed = value;

if (_claimed)
{
ClaimButton.AddStyleClass(StyleBase.ButtonCaution);
ClaimButton.Text = Loc.GetString("offering-window-claimed");
}
else
{
ClaimButton.RemoveStyleClass(StyleBase.ButtonCaution);
ClaimButton.Text = Loc.GetString("offering-window-claim");
}
}
}
}
Loading

0 comments on commit bf79acd

Please sign in to comment.