Salvage magnet revamp (#23119)
* 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
This commit is contained in:
@@ -108,7 +108,6 @@ namespace Content.Client.Entry
|
||||
_prototypeManager.RegisterIgnore("npcFaction");
|
||||
_prototypeManager.RegisterIgnore("lobbyBackground");
|
||||
_prototypeManager.RegisterIgnore("advertisementsPack");
|
||||
_prototypeManager.RegisterIgnore("salvageMap");
|
||||
_prototypeManager.RegisterIgnore("gamePreset");
|
||||
_prototypeManager.RegisterIgnore("noiseChannel");
|
||||
_prototypeManager.RegisterIgnore("spaceBiome");
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
using Content.Shared.Salvage;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Client.Salvage;
|
||||
|
||||
[NetworkedComponent, RegisterComponent]
|
||||
public sealed partial class SalvageMagnetComponent : SharedSalvageMagnetComponent {}
|
||||
@@ -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"
|
||||
117
Content.Client/Salvage/UI/OfferingWindow.xaml.cs
Normal file
117
Content.Client/Salvage/UI/OfferingWindow.xaml.cs
Normal file
@@ -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
Content.Client/Salvage/UI/OfferingWindowOption.xaml
Normal file
24
Content.Client/Salvage/UI/OfferingWindowOption.xaml
Normal file
@@ -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
Content.Client/Salvage/UI/OfferingWindowOption.xaml.cs
Normal file
87
Content.Client/Salvage/UI/OfferingWindowOption.xaml.cs
Normal file
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,14 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Salvage.Expeditions;
|
||||
using Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.Salvage.UI;
|
||||
|
||||
@@ -8,23 +16,21 @@ namespace Content.Client.Salvage.UI;
|
||||
public sealed class SalvageExpeditionConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private SalvageExpeditionWindow? _window;
|
||||
private OfferingWindow? _window;
|
||||
|
||||
[Dependency] private readonly IConfigurationManager _cfgManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoManager = default!;
|
||||
|
||||
public SalvageExpeditionConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window = new SalvageExpeditionWindow();
|
||||
_window.ClaimMission += index =>
|
||||
{
|
||||
SendMessage(new ClaimSalvageMessage()
|
||||
{
|
||||
Index = index,
|
||||
});
|
||||
};
|
||||
_window = new OfferingWindow();
|
||||
_window.OnClose += Close;
|
||||
_window?.OpenCenteredLeft();
|
||||
}
|
||||
@@ -40,9 +46,133 @@ public sealed class SalvageExpeditionConsoleBoundUserInterface : BoundUserInterf
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (state is not SalvageExpeditionConsoleState current)
|
||||
if (state is not SalvageExpeditionConsoleState current || _window == null)
|
||||
return;
|
||||
|
||||
_window?.UpdateState(current);
|
||||
_window.Progression = null;
|
||||
_window.Cooldown = TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown));
|
||||
_window.NextOffer = current.NextOffer;
|
||||
_window.Claimed = current.Claimed;
|
||||
_window.ClearOptions();
|
||||
var salvage = _entManager.System<SalvageSystem>();
|
||||
|
||||
for (var i = 0; i < current.Missions.Count; i++)
|
||||
{
|
||||
var missionParams = current.Missions[i];
|
||||
|
||||
var offering = new OfferingWindowOption();
|
||||
offering.Title = Loc.GetString($"salvage-expedition-type");
|
||||
|
||||
var difficultyId = "Moderate";
|
||||
var difficultyProto = _protoManager.Index<SalvageDifficultyPrototype>(difficultyId);
|
||||
// TODO: Selectable difficulty soon.
|
||||
var mission = salvage.GetMission(difficultyProto, missionParams.Seed);
|
||||
|
||||
// Difficulty
|
||||
// Details
|
||||
offering.AddContent(new Label()
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-difficulty")
|
||||
});
|
||||
|
||||
var difficultyColor = difficultyProto.Color;
|
||||
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-difficulty-Moderate"),
|
||||
FontColorOverride = difficultyColor,
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-difficulty-players"),
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
});
|
||||
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = difficultyProto.RecommendedPlayers.ToString(),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Details
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-hostiles")
|
||||
});
|
||||
|
||||
var faction = mission.Faction;
|
||||
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = faction,
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Duration
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-duration")
|
||||
});
|
||||
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = mission.Duration.ToString(),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Biome
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-biome")
|
||||
});
|
||||
|
||||
var biome = mission.Biome;
|
||||
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = Loc.GetString(_protoManager.Index<SalvageBiomeModPrototype>(biome).ID),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Modifiers
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-modifiers")
|
||||
});
|
||||
|
||||
var mods = mission.Modifiers;
|
||||
|
||||
offering.AddContent(new Label
|
||||
{
|
||||
Text = string.Join("\n", mods.Select(o => "- " + o)).TrimEnd(),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
offering.ClaimPressed += args =>
|
||||
{
|
||||
SendMessage(new ClaimSalvageMessage()
|
||||
{
|
||||
Index = missionParams.Index,
|
||||
});
|
||||
};
|
||||
|
||||
offering.Claimed = current.ActiveMission == missionParams.Index;
|
||||
offering.Disabled = current.Claimed || current.Cooldown;
|
||||
|
||||
_window.AddOption(offering);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
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;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class SalvageExpeditionWindow : FancyWindow,
|
||||
IComputerWindow<EmergencyConsoleBoundUserInterfaceState>
|
||||
{
|
||||
private readonly IConfigurationManager _cfgManager;
|
||||
private readonly IGameTiming _timing;
|
||||
private readonly IPrototypeManager _prototype;
|
||||
private readonly SharedSalvageSystem _salvage;
|
||||
|
||||
public event Action<ushort>? ClaimMission;
|
||||
private bool _claimed;
|
||||
private bool _cooldown;
|
||||
private TimeSpan _nextOffer;
|
||||
|
||||
public SalvageExpeditionWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
_cfgManager = IoCManager.Resolve<IConfigurationManager>();
|
||||
_timing = IoCManager.Resolve<IGameTiming>();
|
||||
_prototype = IoCManager.Resolve<IPrototypeManager>();
|
||||
_salvage = IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SharedSalvageSystem>();
|
||||
}
|
||||
|
||||
public void UpdateState(SalvageExpeditionConsoleState state)
|
||||
{
|
||||
_claimed = state.Claimed;
|
||||
_cooldown = state.Cooldown;
|
||||
_nextOffer = state.NextOffer;
|
||||
Container.DisposeAllChildren();
|
||||
|
||||
for (var i = 0; i < state.Missions.Count; i++)
|
||||
{
|
||||
var missionParams = state.Missions[i];
|
||||
var difficultyId = "Moderate";
|
||||
var difficultyProto = _prototype.Index<SalvageDifficultyPrototype>(difficultyId);
|
||||
// TODO: Selectable difficulty soon.
|
||||
var mission = _salvage.GetMission(difficultyProto, missionParams.Seed);
|
||||
|
||||
// Mission title
|
||||
var missionStripe = new StripeBack()
|
||||
{
|
||||
Margin = new Thickness(0f, -5f, 0f, 0f)
|
||||
};
|
||||
|
||||
missionStripe.AddChild(new Label()
|
||||
{
|
||||
Text = Loc.GetString($"salvage-expedition-type"),
|
||||
HorizontalAlignment = HAlignment.Center,
|
||||
Margin = new Thickness(0f, 5f, 0f, 5f),
|
||||
});
|
||||
|
||||
var lBox = new BoxContainer()
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Vertical
|
||||
};
|
||||
|
||||
// Difficulty
|
||||
// Details
|
||||
lBox.AddChild(new Label()
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-difficulty")
|
||||
});
|
||||
|
||||
var difficultyColor = difficultyProto.Color;
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-difficulty-Moderate"),
|
||||
FontColorOverride = difficultyColor,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-difficulty-players"),
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
});
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = difficultyProto.RecommendedPlayers.ToString(),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Details
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-hostiles")
|
||||
});
|
||||
|
||||
var faction = mission.Faction;
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = faction,
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Duration
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-duration")
|
||||
});
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = mission.Duration.ToString(),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Biome
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-biome")
|
||||
});
|
||||
|
||||
var biome = mission.Biome;
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = Loc.GetString(_prototype.Index<SalvageBiomeModPrototype>(biome).ID),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Modifiers
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = Loc.GetString("salvage-expedition-window-modifiers")
|
||||
});
|
||||
|
||||
var mods = mission.Modifiers;
|
||||
|
||||
lBox.AddChild(new Label
|
||||
{
|
||||
Text = string.Join("\n", mods.Select(o => "- " + o)).TrimEnd(),
|
||||
FontColorOverride = StyleNano.NanoGold,
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
Margin = new Thickness(0f, 0f, 0f, 5f),
|
||||
});
|
||||
|
||||
// Claim
|
||||
var claimButton = new Button()
|
||||
{
|
||||
HorizontalExpand = true,
|
||||
VerticalAlignment = VAlignment.Bottom,
|
||||
Pressed = state.ActiveMission == missionParams.Index,
|
||||
ToggleMode = true,
|
||||
Disabled = state.Claimed || state.Cooldown,
|
||||
};
|
||||
|
||||
claimButton.Label.Margin = new Thickness(0f, 5f);
|
||||
|
||||
claimButton.OnPressed += args =>
|
||||
{
|
||||
ClaimMission?.Invoke(missionParams.Index);
|
||||
};
|
||||
|
||||
if (state.ActiveMission == missionParams.Index)
|
||||
{
|
||||
claimButton.Text = Loc.GetString("salvage-expedition-window-claimed");
|
||||
claimButton.AddStyleClass(StyleBase.ButtonCaution);
|
||||
}
|
||||
else
|
||||
{
|
||||
claimButton.Text = Loc.GetString("salvage-expedition-window-claim");
|
||||
}
|
||||
|
||||
var box = new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat(new Color(30, 30, 34)),
|
||||
HorizontalExpand = true,
|
||||
Margin = new Thickness(5f, 0f),
|
||||
Children =
|
||||
{
|
||||
new BoxContainer
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Vertical,
|
||||
Children =
|
||||
{
|
||||
missionStripe,
|
||||
lBox,
|
||||
new Control() {VerticalExpand = true},
|
||||
claimButton,
|
||||
},
|
||||
Margin = new Thickness(5f, 5f)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
LayoutContainer.SetAnchorPreset(box, LayoutContainer.LayoutPreset.Wide);
|
||||
|
||||
Container.AddChild(box);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
|
||||
if (_claimed)
|
||||
{
|
||||
NextOfferBar.Value = 0f;
|
||||
NextOfferText.Text = "00:00";
|
||||
return;
|
||||
}
|
||||
|
||||
var remaining = _nextOffer - _timing.CurTime;
|
||||
|
||||
if (remaining < TimeSpan.Zero)
|
||||
{
|
||||
NextOfferBar.Value = 1f;
|
||||
NextOfferText.Text = "00:00";
|
||||
}
|
||||
else
|
||||
{
|
||||
var cooldown = _cooldown
|
||||
? TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown))
|
||||
: TimeSpan.FromSeconds(_cfgManager.GetCVar(CCVars.SalvageExpeditionCooldown));
|
||||
|
||||
NextOfferBar.Value = 1f - (float) (remaining / cooldown);
|
||||
NextOfferText.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}";
|
||||
}
|
||||
}
|
||||
}
|
||||
110
Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs
Normal file
110
Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Salvage;
|
||||
using Content.Shared.Salvage.Magnet;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.Salvage.UI;
|
||||
|
||||
public sealed class SalvageMagnetBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
|
||||
private OfferingWindow? _window;
|
||||
|
||||
public SalvageMagnetBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
_window = new OfferingWindow();
|
||||
_window.OnClose += Close;
|
||||
_window.OpenCenteredLeft();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (state is not SalvageMagnetBoundUserInterfaceState current || _window == null)
|
||||
return;
|
||||
|
||||
_window.ClearOptions();
|
||||
|
||||
var salvageSystem = _entManager.System<SharedSalvageSystem>();
|
||||
_window.NextOffer = current.NextOffer;
|
||||
_window.Progression = current.EndTime ?? TimeSpan.Zero;
|
||||
_window.Claimed = current.EndTime != null;
|
||||
_window.Cooldown = current.Cooldown;
|
||||
_window.ProgressionCooldown = current.Duration;
|
||||
|
||||
for (var i = 0; i < current.Offers.Count; i++)
|
||||
{
|
||||
var seed = current.Offers[i];
|
||||
var offer = salvageSystem.GetSalvageOffering(seed);
|
||||
var option = new OfferingWindowOption();
|
||||
option.MinWidth = 210f;
|
||||
option.Disabled = current.EndTime != null;
|
||||
option.Claimed = current.ActiveSeed == seed;
|
||||
var claimIndex = i;
|
||||
|
||||
option.ClaimPressed += args =>
|
||||
{
|
||||
SendMessage(new MagnetClaimOfferEvent()
|
||||
{
|
||||
Index = claimIndex
|
||||
});
|
||||
};
|
||||
|
||||
switch (offer)
|
||||
{
|
||||
case AsteroidOffering asteroid:
|
||||
option.Title = Loc.GetString($"dungeon-config-proto-{asteroid.DungeonConfig.ID}");
|
||||
var layerKeys = asteroid.MarkerLayers.Keys.ToList();
|
||||
layerKeys.Sort();
|
||||
|
||||
foreach (var resource in layerKeys)
|
||||
{
|
||||
var count = asteroid.MarkerLayers[resource];
|
||||
|
||||
var container = new BoxContainer()
|
||||
{
|
||||
Orientation = BoxContainer.LayoutOrientation.Horizontal,
|
||||
HorizontalExpand = true,
|
||||
};
|
||||
|
||||
var resourceLabel = new Label()
|
||||
{
|
||||
Text = Loc.GetString("salvage-magnet-resources",
|
||||
("resource", resource)),
|
||||
HorizontalAlignment = Control.HAlignment.Left,
|
||||
};
|
||||
|
||||
var countLabel = new Label()
|
||||
{
|
||||
Text = Loc.GetString("salvage-magnet-resources-count", ("count", count)),
|
||||
HorizontalAlignment = Control.HAlignment.Right,
|
||||
HorizontalExpand = true,
|
||||
};
|
||||
|
||||
container.AddChild(resourceLabel);
|
||||
container.AddChild(countLabel);
|
||||
|
||||
option.AddContent(container);
|
||||
}
|
||||
|
||||
break;
|
||||
case SalvageOffering salvage:
|
||||
option.Title = Loc.GetString($"salvage-map-proto-{salvage.SalvageMap.ID}");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
_window.AddOption(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user