Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/PIRATE-BOOTIES-UI-WIP' into PIRA…
Browse files Browse the repository at this point in the history
…TE-BOOTIES
  • Loading branch information
whatston3 committed Jul 16, 2024
2 parents d185bd8 + 22399e1 commit 0a679c0
Show file tree
Hide file tree
Showing 16 changed files with 449 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Content.Client._NF.Pirate.UI;
using Content.Shared._NF.Pirate.Components;
using JetBrains.Annotations;

namespace Content.Client._NF.Pirate.BUI;

[UsedImplicitly]
public sealed class PirateBountyConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private PirateBountyMenu? _menu;

public PirateBountyConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

_menu = new();

_menu.OnClose += Close;

_menu.OnLabelButtonPressed += id =>
{
SendMessage(new PirateBountyPrintLabelMessage(id));
};

_menu.OnSkipButtonPressed += id =>
{
SendMessage(new PirateBountySkipMessage(id));
};

_menu.OpenCentered();
}

protected override void UpdateState(BoundUserInterfaceState message)
{
base.UpdateState(message);

if (message is not PirateBountyConsoleState state)
return;

_menu?.UpdateEntries(state.Bounties, state.UntilNextSkip);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (!disposing)
return;

_menu?.Dispose();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Content.Client._NF.Pirate.UI;
using Content.Shared._NF.Pirate.BUI;
using Content.Shared._NF.Pirate.Events;
using Robust.Client.GameObjects;

namespace Content.Client._NF.Pirate.BUI;

public sealed class PiratePalletConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private PiratePalletMenu? _menu;

public PiratePalletConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

_menu = new PiratePalletMenu();
_menu.SellRequested += OnSell;
_menu.OnClose += Close;

_menu.OpenCentered();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_menu?.Dispose();
}
}

private void OnSell()
{
SendMessage(new PiratePalletSellMessage());
}

// TODO: remove this, nothing to update
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not PiratePalletConsoleInterfaceState palletState)
return;
}
}
14 changes: 14 additions & 0 deletions Content.Client/_NF/Pirate/Systems/PirateSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Content.Shared._NF.Pirate;
using Robust.Client.GameObjects;

namespace Content.Client._NF.Pirate.Systems;

public sealed partial class PirateSystem : SharedPirateSystem
{
[Dependency] private readonly AnimationPlayerSystem _player = default!;

public override void Initialize()
{
base.Initialize();
}
}
37 changes: 37 additions & 0 deletions Content.Client/_NF/Pirate/UI/PirateBountyEntry.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Margin="10 10 10 0"
HorizontalExpand="True"
Visible="True">
<PanelContainer StyleClasses="AngleRect" HorizontalExpand="True">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True">
<BoxContainer Orientation="Horizontal">
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<RichTextLabel Name="RewardLabel"/>
<RichTextLabel Name="ManifestLabel"/>
</BoxContainer>
<Control MinWidth="10"/>
<BoxContainer Orientation="Vertical" MinWidth="120">
<BoxContainer Orientation="Horizontal" MinWidth="120">
<Button Name="PrintButton"
Text="{Loc 'bounty-console-label-button-text'}"
HorizontalExpand="False"
HorizontalAlignment="Right"
StyleClasses="OpenRight"/>
<Button Name="SkipButton"
Text="{Loc 'bounty-console-skip-button-text'}"
HorizontalExpand="False"
HorizontalAlignment="Right"
StyleClasses="OpenLeft"/>
</BoxContainer>
<RichTextLabel Name="IdLabel" HorizontalAlignment="Right" Margin="0 0 5 0"/>
</BoxContainer>
</BoxContainer>
<customControls:HSeparator Margin="5 10 5 10"/>
<BoxContainer>
<RichTextLabel Name="DescriptionLabel"/>
</BoxContainer>
</BoxContainer>
</PanelContainer>
</BoxContainer>
70 changes: 70 additions & 0 deletions Content.Client/_NF/Pirate/UI/PirateBountyEntry.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Content.Client.Message;
using Content.Shared._NF.Pirate;
using Content.Shared._NF.Pirate.Prototypes;
using Content.Shared.Random;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Serilog;

namespace Content.Client._NF.Pirate.UI;

[GenerateTypedNameReferences]
public sealed partial class PirateBountyEntry : BoxContainer
{
[Dependency] private readonly IPrototypeManager _prototype = default!;

public Action? OnLabelButtonPressed;
public Action? OnSkipButtonPressed;

public TimeSpan EndTime;
public TimeSpan UntilNextSkip;

public PirateBountyEntry(PirateBountyData bounty, TimeSpan untilNextSkip)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

UntilNextSkip = untilNextSkip;

if (!_prototype.TryIndex<PirateBountyPrototype>(bounty.Bounty, out var bountyPrototype))
return;

var items = new List<string>();
foreach (var entry in bountyPrototype.Entries)
{
items.Add(Loc.GetString("pirate-bounty-console-manifest-entry",
("amount", entry.Amount),
("item", Loc.GetString(entry.Name))));
}
ManifestLabel.SetMarkup(Loc.GetString("pirate-bounty-console-manifest-label", ("item", string.Join(", ", items))));
RewardLabel.SetMarkup(Loc.GetString("pirate-bounty-console-reward-label", ("reward", bountyPrototype.Reward)));
DescriptionLabel.SetMarkup(Loc.GetString("pirate-bounty-console-description-label", ("description", Loc.GetString(bountyPrototype.Description))));
IdLabel.SetMarkup(Loc.GetString("pirate-bounty-console-id-label", ("id", bounty.Id)));

PrintButton.OnPressed += _ => OnLabelButtonPressed?.Invoke();
SkipButton.OnPressed += _ => OnSkipButtonPressed?.Invoke();
}

private void UpdateSkipButton(float deltaSeconds)
{
UntilNextSkip -= TimeSpan.FromSeconds(deltaSeconds);
if (UntilNextSkip > TimeSpan.Zero)
{
SkipButton.Label.Text = UntilNextSkip.ToString("mm\\:ss");
SkipButton.Disabled = true;
return;
}

SkipButton.Label.Text = Loc.GetString("pirate-bounty-console-skip-button-text");
SkipButton.Disabled = false;
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
UpdateSkipButton(args.DeltaSeconds);
}
}
37 changes: 37 additions & 0 deletions Content.Client/_NF/Pirate/UI/PirateBountyMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'pirate-bounty-console-menu-title'}"
SetSize="550 420"
MinSize="400 350">
<BoxContainer Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True">
<PanelContainer VerticalExpand="True" HorizontalExpand="True" Margin="10">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<ScrollContainer HScrollEnabled="False"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer Name="PirateBountyEntriesContainer"
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True">
</BoxContainer>
</ScrollContainer>
</PanelContainer>
<!-- Footer -->
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
<Label Text="{Loc 'pirate-bounty-console-flavor-left'}" StyleClasses="WindowFooterText" />
<Label Text="{Loc 'pirate-bounty-console-flavor-right'}" StyleClasses="WindowFooterText"
HorizontalAlignment="Right" HorizontalExpand="True" Margin="0 0 5 0" />
<!-- TODO: Probably remove this vv -->
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered"
VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
36 changes: 36 additions & 0 deletions Content.Client/_NF/Pirate/UI/PirateBountyMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Content.Client.UserInterface.Controls;
using Content.Shared._NF.Pirate;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._NF.Pirate.UI;

[GenerateTypedNameReferences]
public sealed partial class PirateBountyMenu : FancyWindow
{
public Action<string>? OnLabelButtonPressed;
public Action<string>? OnSkipButtonPressed;

public PirateBountyMenu()
{
RobustXamlLoader.Load(this);
}

public void UpdateEntries(List<PirateBountyData> bounties, TimeSpan untilNextSkip)
{
PirateBountyEntriesContainer.Children.Clear();
foreach (var b in bounties)
{
var entry = new PirateBountyEntry(b, untilNextSkip);
entry.OnLabelButtonPressed += () => OnLabelButtonPressed?.Invoke(b.Id);
entry.OnSkipButtonPressed += () => OnSkipButtonPressed?.Invoke(b.Id);

PirateBountyEntriesContainer.AddChild(entry);
}
PirateBountyEntriesContainer.AddChild(new Control
{
MinHeight = 10
});
}
}
11 changes: 11 additions & 0 deletions Content.Client/_NF/Pirate/UI/PiratePalletMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
SetSize="300 150"
MinSize="300 150"
Title="{Loc 'pirate-pallet-console-menu-title'}">
<BoxContainer Orientation="Vertical" Margin="5">
<Button Name="SellButton"
Text="{Loc 'pirate-pallet-sell-button'}"/>
<TextureButton VerticalExpand="True" />
</BoxContainer>
</controls:FancyWindow>
24 changes: 24 additions & 0 deletions Content.Client/_NF/Pirate/UI/PiratePalletMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Client.UserInterface.Controls;
using Content.Shared._NF.Pirate;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._NF.Pirate.UI;

[GenerateTypedNameReferences]
public sealed partial class PiratePalletMenu : FancyWindow
{
public Action? SellRequested;

public PiratePalletMenu()
{
RobustXamlLoader.Load(this);
SellButton.OnPressed += OnSellPressed;
}

private void OnSellPressed(BaseButton.ButtonEventArgs obj)
{
SellRequested?.Invoke();
}
}
Loading

0 comments on commit 0a679c0

Please sign in to comment.