Cargo bounty console improvements (with changes) (#6306)
* simple fix for "Approved by: Self" on all cargo invoices * port of ruddygreat's bounty console improvements to DeltaV * modified tooltips and fixed a few importing errors * StatusLabel in BountyEntry.xaml.cs * final stupid tweak * removed unrelated bugfix PR that snuck into this branch somehow * Cargo bounty fix requests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: cargomouse <dboozlebeep@gmail.com> Co-authored-by: Jessica Harvey <itsjessagain23@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
19ebd10ad1
commit
dbe955ca17
|
|
@ -2,6 +2,7 @@ using Content.Client.Cargo.UI;
|
|||
using Content.Shared.Cargo.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.UserInterface;
|
||||
using Content.Shared._DV.Cargo.Components; // DeltaV: Bounty claim messages
|
||||
|
||||
namespace Content.Client.Cargo.BUI;
|
||||
|
||||
|
|
@ -30,6 +31,18 @@ public sealed class CargoBountyConsoleBoundUserInterface : BoundUserInterface
|
|||
{
|
||||
SendMessage(new BountySkipMessage(id));
|
||||
};
|
||||
|
||||
// DeltaV: bounty claim stuff begins
|
||||
_menu.OnClaimButtonPressed += id =>
|
||||
{
|
||||
SendMessage(new BountyClaimedMessage(id));
|
||||
};
|
||||
|
||||
_menu.OnStatusOptionSelected += (id, status) =>
|
||||
{
|
||||
SendMessage(new BountySetStatusMessage(id, status));
|
||||
};
|
||||
// DeltaV: bounty claim stuff ends
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState message)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
|
||||
<RichTextLabel Name="RewardLabel"/>
|
||||
<RichTextLabel Name="ManifestLabel"/>
|
||||
<RichTextLabel Name="ClaimedBylabel"/> <!-- DeltaV bounty claim -->
|
||||
<RichTextLabel Name="StatusLabel"/> <!-- DeltaV bounty claim -->
|
||||
</BoxContainer>
|
||||
<Control MinWidth="10"/>
|
||||
<BoxContainer Orientation="Vertical" MinWidth="120">
|
||||
|
|
@ -17,14 +19,22 @@
|
|||
<Button Name="PrintButton"
|
||||
Text="{Loc 'bounty-console-label-button-text'}"
|
||||
HorizontalExpand="False"
|
||||
HorizontalAlignment="Right"
|
||||
StyleClasses="OpenRight"/>
|
||||
StyleClasses="OpenBoth"/>
|
||||
<Button Name="SkipButton"
|
||||
Text="{Loc 'bounty-console-skip-button-text'}"
|
||||
HorizontalExpand="False"
|
||||
HorizontalAlignment="Right"
|
||||
HorizontalExpand="True"
|
||||
StyleClasses="OpenLeft"/>
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal" MinWidth="120"> <!-- Begin DeltaV bounty claim content -->
|
||||
<Button Name="ClaimButton"
|
||||
Text= "{Loc 'bounty-console-claim-button-text'}"
|
||||
HorizontalExpand="False"
|
||||
StyleClasses="OpenRight"/>
|
||||
<OptionButton Name="BountyStatusSelector"
|
||||
Access="Public"
|
||||
StyleClasses="OpenBoth"
|
||||
HorizontalExpand="True"/>
|
||||
</BoxContainer> <!-- End DeltaV content-->
|
||||
<RichTextLabel Name="IdLabel" HorizontalAlignment="Right" Margin="0 0 5 0"/>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ public sealed partial class BountyEntry : BoxContainer
|
|||
|
||||
public Action? OnLabelButtonPressed;
|
||||
public Action? OnSkipButtonPressed;
|
||||
public Action? OnClaimButtonPressed; // DeltaV
|
||||
public Action? OnStatusOptionSelected; // DeltaV
|
||||
|
||||
public TimeSpan EndTime;
|
||||
public TimeSpan UntilNextSkip;
|
||||
|
|
@ -45,6 +47,20 @@ public sealed partial class BountyEntry : BoxContainer
|
|||
|
||||
PrintButton.OnPressed += _ => OnLabelButtonPressed?.Invoke();
|
||||
SkipButton.OnPressed += _ => OnSkipButtonPressed?.Invoke();
|
||||
|
||||
// Begin DeltaV bounty claiming
|
||||
ClaimButton.OnPressed += _ => OnClaimButtonPressed?.Invoke();
|
||||
BountyStatusSelector.AddItem(Loc.GetString($"bounty-console-status-{nameof(CargoBountyStatus.Undelivered)}"), 0);
|
||||
BountyStatusSelector.AddItem(Loc.GetString($"bounty-console-status-{nameof(CargoBountyStatus.Waiting)}"), 1);
|
||||
BountyStatusSelector.AddItem(Loc.GetString($"bounty-console-status-{nameof(CargoBountyStatus.OnShuttle)}"), 2);
|
||||
|
||||
BountyStatusSelector.Select((int) bounty.Status);
|
||||
BountyStatusSelector.ToolTip = Loc.GetString($"bounty-console-status-tooltip-{bounty.Status.ToString()}");
|
||||
|
||||
var claimedByText = string.IsNullOrEmpty(bounty.ClaimedBy) ? Loc.GetString("bounty-console-claimed-by-none") : bounty.ClaimedBy;
|
||||
ClaimedBylabel.SetMarkup(Loc.GetString("bounty-console-claimed-by", ("claimant", claimedByText)));
|
||||
StatusLabel.SetMarkup(Loc.GetString($"bounty-console-formatted-status-{bounty.Status.ToString()}"));
|
||||
// End DeltaV bounty claiming
|
||||
}
|
||||
|
||||
private void UpdateSkipButton(float deltaSeconds)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||
<!--DeltaV - SetSize was 550, now 750 to accomodate bounty claim UI -->
|
||||
<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 'bounty-console-menu-title'}"
|
||||
SetSize="550 420"
|
||||
SetSize="750 420"
|
||||
MinSize="400 350">
|
||||
<BoxContainer Orientation="Vertical"
|
||||
VerticalExpand="True"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ public sealed partial class CargoBountyMenu : FancyWindow
|
|||
{
|
||||
public Action<string>? OnLabelButtonPressed;
|
||||
public Action<string>? OnSkipButtonPressed;
|
||||
public Action<string>? OnClaimButtonPressed; // DeltaV
|
||||
public Action<string, int>? OnStatusOptionSelected; // DeltaV
|
||||
|
||||
public CargoBountyMenu()
|
||||
{
|
||||
|
|
@ -31,6 +33,8 @@ public sealed partial class CargoBountyMenu : FancyWindow
|
|||
var entry = new BountyEntry(b, untilNextSkip);
|
||||
entry.OnLabelButtonPressed += () => OnLabelButtonPressed?.Invoke(b.Id);
|
||||
entry.OnSkipButtonPressed += () => OnSkipButtonPressed?.Invoke(b.Id);
|
||||
entry.OnClaimButtonPressed += () => OnClaimButtonPressed?.Invoke(b.Id); // DeltaV
|
||||
entry.BountyStatusSelector.OnItemSelected += args => OnStatusOptionSelected?.Invoke(b.Id, args.Id); // DeltaV
|
||||
|
||||
BountyEntriesContainer.AddChild(entry);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Access.Systems; // DeltaV
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.NameIdentifier;
|
||||
using Content.Shared.Access.Components;
|
||||
|
|
@ -20,6 +21,7 @@ using Robust.Shared.Prototypes;
|
|||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared._DV.Cargo.Components; // DeltaV: Bounty claim messages
|
||||
|
||||
namespace Content.Server.Cargo.Systems;
|
||||
|
||||
|
|
@ -28,6 +30,7 @@ public sealed partial class CargoSystem
|
|||
[Dependency] private readonly ContainerSystem _container = default!;
|
||||
[Dependency] private readonly NameIdentifierSystem _nameIdentifier = default!;
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelistSys = default!;
|
||||
[Dependency] private readonly IdCardSystem _idCard = default!; // DeltaV
|
||||
|
||||
private static readonly ProtoId<NameIdentifierGroupPrototype> BountyNameIdentifierGroup = "Bounty";
|
||||
|
||||
|
|
@ -40,6 +43,8 @@ public sealed partial class CargoSystem
|
|||
SubscribeLocalEvent<CargoBountyConsoleComponent, BoundUIOpenedEvent>(OnBountyConsoleOpened);
|
||||
SubscribeLocalEvent<CargoBountyConsoleComponent, BountyPrintLabelMessage>(OnPrintLabelMessage);
|
||||
SubscribeLocalEvent<CargoBountyConsoleComponent, BountySkipMessage>(OnSkipBountyMessage);
|
||||
SubscribeLocalEvent<CargoBountyConsoleComponent, BountyClaimedMessage>(OnBountyClaimedMessage); // DeltaV
|
||||
SubscribeLocalEvent<CargoBountyConsoleComponent, BountySetStatusMessage>(OnSetBountyStatusMessage); // DeltaV
|
||||
SubscribeLocalEvent<CargoBountyLabelComponent, PriceCalculationEvent>(OnGetBountyPrice);
|
||||
SubscribeLocalEvent<EntitySoldEvent>(OnSold);
|
||||
SubscribeLocalEvent<StationCargoBountyDatabaseComponent, MapInitEvent>(OnMapInit);
|
||||
|
|
@ -111,6 +116,72 @@ public sealed partial class CargoSystem
|
|||
_audio.PlayPvs(component.SkipSound, uid);
|
||||
}
|
||||
|
||||
// Begin DeltaV bounty claim system
|
||||
private void OnSetBountyStatusMessage(Entity<CargoBountyConsoleComponent> ent, ref BountySetStatusMessage args)
|
||||
{
|
||||
if (_station.GetOwningStation(ent.Owner) is not { } station || !TryComp<StationCargoBountyDatabaseComponent>(station, out var bountyDbComp))
|
||||
return;
|
||||
|
||||
for (var i = 0; i < bountyDbComp.Bounties.Count; i++)
|
||||
{
|
||||
var bounty = bountyDbComp.Bounties[i];
|
||||
|
||||
if (bounty.Id != args.BountyId)
|
||||
continue;
|
||||
|
||||
var newData = new CargoBountyData
|
||||
{
|
||||
Id = bounty.Id,
|
||||
Bounty = bounty.Bounty,
|
||||
ClaimedBy = bounty.ClaimedBy,
|
||||
Status = (CargoBountyStatus)args.Status,
|
||||
};
|
||||
|
||||
bountyDbComp.Bounties[i] = newData;
|
||||
}
|
||||
|
||||
var untilNextSkip = bountyDbComp.NextSkipTime - Timing.CurTime;
|
||||
_uiSystem.SetUiState(ent.Owner, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(bountyDbComp.Bounties, bountyDbComp.History, untilNextSkip));
|
||||
}
|
||||
|
||||
private void OnBountyClaimedMessage(Entity<CargoBountyConsoleComponent> ent, ref BountyClaimedMessage args)
|
||||
{
|
||||
if (_station.GetOwningStation(ent.Owner) is not { } station || !TryComp<StationCargoBountyDatabaseComponent>(station, out var bountyDbComp))
|
||||
return;
|
||||
|
||||
for (var i = 0; i < bountyDbComp.Bounties.Count; i++)
|
||||
{
|
||||
var bounty = bountyDbComp.Bounties[i];
|
||||
|
||||
if (bounty.Id != args.BountyId)
|
||||
continue;
|
||||
|
||||
string name;
|
||||
if (_idCard.TryFindIdCard(args.Actor, out var idCard) && idCard.Comp.FullName != null)
|
||||
{
|
||||
name = idCard.Comp.FullName;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = Loc.GetString("bounty-console-claimed-by-unknown");
|
||||
}
|
||||
|
||||
var newData = new CargoBountyData
|
||||
{
|
||||
Id = bounty.Id,
|
||||
Bounty = bounty.Bounty,
|
||||
ClaimedBy = name.Equals(bounty.ClaimedBy) ? string.Empty : name,
|
||||
Status = bounty.Status,
|
||||
};
|
||||
|
||||
bountyDbComp.Bounties[i] = newData;
|
||||
}
|
||||
|
||||
var untilNextSkip = bountyDbComp.NextSkipTime - Timing.CurTime;
|
||||
_uiSystem.SetUiState(ent.Owner, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(bountyDbComp.Bounties, bountyDbComp.History, untilNextSkip));
|
||||
}
|
||||
// End DeltaV bounty claim system
|
||||
|
||||
public void SetupBountyLabel(EntityUid uid, EntityUid stationId, CargoBountyData bounty, PaperComponent? paper = null, CargoBountyLabelComponent? label = null)
|
||||
{
|
||||
if (!Resolve(uid, ref paper, ref label) || !_protoMan.Resolve<CargoBountyPrototype>(bounty.Bounty, out var prototype))
|
||||
|
|
|
|||
|
|
@ -28,4 +28,18 @@ public readonly partial record struct CargoBountyData
|
|||
Bounty = bounty.ID;
|
||||
Id = $"{bounty.IdPrefix}{uniqueIdentifier:D3}";
|
||||
}
|
||||
}
|
||||
// Begin DeltaV bounty claiming
|
||||
[DataField]
|
||||
public string ClaimedBy { get; init; } = string.Empty;
|
||||
|
||||
[DataField]
|
||||
public CargoBountyStatus Status { get; init; } = CargoBountyStatus.Undelivered;
|
||||
}
|
||||
|
||||
public enum CargoBountyStatus
|
||||
{
|
||||
Undelivered,
|
||||
Waiting,
|
||||
OnShuttle,
|
||||
} // End DeltaV bounty claiming
|
||||
|
||||
|
|
|
|||
|
|
@ -94,3 +94,4 @@ public sealed class BountySkipMessage : BoundUserInterfaceMessage
|
|||
BountyId = bountyId;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared._DV.Cargo.Components;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class BountyClaimedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly string BountyId;
|
||||
|
||||
public BountyClaimedMessage(string bountyId)
|
||||
{
|
||||
BountyId = bountyId;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class BountySetStatusMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly string BountyId;
|
||||
public readonly int Status;
|
||||
|
||||
public BountySetStatusMessage(string bountyId, int status)
|
||||
{
|
||||
BountyId = bountyId;
|
||||
Status = status;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,25 @@ bounty-console-manifest-reward = Reward: ${$reward}
|
|||
bounty-console-description-label = [color=gray]{$description}[/color]
|
||||
bounty-console-id-label = ID#{$id}
|
||||
|
||||
## Begin DeltaV
|
||||
bounty-console-claim-button-text = Claim
|
||||
bounty-console-claimed-by-none = None
|
||||
bounty-console-claimed-by-unknown = Unknown
|
||||
bounty-console-claimed-by = Claimed by: {$claimant}
|
||||
|
||||
bounty-console-status-Undelivered = Undelivered
|
||||
bounty-console-status-Waiting = Processing
|
||||
bounty-console-status-OnShuttle = On Shuttle
|
||||
|
||||
bounty-console-status-formatted-Undelivered = [color=orange]Undelivered[/color]
|
||||
bounty-console-status-formatted-Waiting = Processing
|
||||
bounty-console-status-formatted-OnShuttle = [color=limegreen]On Shuttle[/color]
|
||||
|
||||
bounty-console-status-tooltip-Undelivered = This bounty has not yet been sent out for fulfilment
|
||||
bounty-console-status-tooltip-Waiting = This bounty has been sent out, and is waiting to be fulfilled
|
||||
bounty-console-status-tooltip-OnShuttle = This bounty is completed, ready to be delivered to the trade station
|
||||
## End DeltaV
|
||||
|
||||
bounty-console-flavor-left = Bounties sourced from local unscrupulous dealers.
|
||||
bounty-console-flavor-right = v1.4
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue