From 5e69de8914db0157cc13eb3b557f6428b9d27ffb Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Thu, 19 Dec 2024 14:37:54 +0100 Subject: [PATCH 01/12] Remove redundant access specifications --- .../Cargo/Components/StationCargoBountyDatabaseComponent.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Server/Cargo/Components/StationCargoBountyDatabaseComponent.cs b/Content.Server/Cargo/Components/StationCargoBountyDatabaseComponent.cs index f58b5450ba4..c650438b286 100644 --- a/Content.Server/Cargo/Components/StationCargoBountyDatabaseComponent.cs +++ b/Content.Server/Cargo/Components/StationCargoBountyDatabaseComponent.cs @@ -12,20 +12,20 @@ public sealed partial class StationCargoBountyDatabaseComponent : Component /// /// Maximum amount of bounties a station can have. /// - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField] public int MaxBounties = 6; /// /// A list of all the bounties currently active for a station. /// - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField] public List Bounties = new(); /// /// A list of all the bounties that have been completed or /// skipped for a station. /// - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField] public List History = new(); /// From 93a8429a51b206763de78f57b8aad17bf0fc8461 Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Thu, 19 Dec 2024 14:38:34 +0100 Subject: [PATCH 02/12] Remove un-needed override --- Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs index f3c9bbfafb1..77d7bea297c 100644 --- a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs +++ b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs @@ -47,8 +47,4 @@ public BountyHistoryEntry(CargoBountyHistoryData bounty) ("time", stationTime))); } } - protected override void FrameUpdate(FrameEventArgs args) - { - base.FrameUpdate(args); - } } From dd59d83cc8fe8d7eec033eb50e690b0db6144582 Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Thu, 19 Dec 2024 14:49:00 +0100 Subject: [PATCH 03/12] Fixup BountyHistoryEntry backing code --- Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs index 77d7bea297c..0e119ea2710 100644 --- a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs +++ b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs @@ -19,7 +19,7 @@ public BountyHistoryEntry(CargoBountyHistoryData bounty) RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); - if (!_prototype.TryIndex(bounty.Bounty, out var bountyPrototype)) + if (!_prototype.TryIndex(bounty.Bounty, out var bountyPrototype)) return; var items = new List(); @@ -29,11 +29,12 @@ public BountyHistoryEntry(CargoBountyHistoryData bounty) ("amount", entry.Amount), ("item", Loc.GetString(entry.Name)))); } + ManifestLabel.SetMarkup(Loc.GetString("bounty-console-manifest-label", ("item", string.Join(", ", items)))); RewardLabel.SetMarkup(Loc.GetString("bounty-console-reward-label", ("reward", bountyPrototype.Reward))); IdLabel.SetMarkup(Loc.GetString("bounty-console-id-label", ("id", bounty.Id))); - var stationTime = bounty.Timestamp.ToString("hh\\:mm\\:ss"); + var stationTime = bounty.Timestamp.ToString(@"hh\:mm\:ss"); if (bounty.ActorName == null) { StatusLabel.SetMarkup(Loc.GetString("bounty-console-history-completed-label")); From 4ae4ccb67ef062b0ceb90996654d9763d9a7fd78 Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Thu, 19 Dec 2024 14:50:07 +0100 Subject: [PATCH 04/12] Fix formatting in CargoBountyMenu --- Content.Client/Cargo/UI/CargoBountyMenu.xaml | 22 +++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Content.Client/Cargo/UI/CargoBountyMenu.xaml b/Content.Client/Cargo/UI/CargoBountyMenu.xaml index 0f093d5f8e7..8c9a652ba4f 100644 --- a/Content.Client/Cargo/UI/CargoBountyMenu.xaml +++ b/Content.Client/Cargo/UI/CargoBountyMenu.xaml @@ -13,22 +13,20 @@ + HorizontalExpand="True" + VerticalExpand="True"> - + Orientation="Vertical" + VerticalExpand="True" + HorizontalExpand="True" /> + HorizontalExpand="True" + VerticalExpand="True"> - + Orientation="Vertical" + VerticalExpand="True" + HorizontalExpand="True" /> From bbd7380e1ce21bf28cce60f070c07d886b361487 Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Thu, 19 Dec 2024 15:02:23 +0100 Subject: [PATCH 05/12] Reformat BountyHistoryData --- Content.Shared/Cargo/CargoBountyHistoryData.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Content.Shared/Cargo/CargoBountyHistoryData.cs b/Content.Shared/Cargo/CargoBountyHistoryData.cs index 43da42d5587..9954218ef55 100644 --- a/Content.Shared/Cargo/CargoBountyHistoryData.cs +++ b/Content.Shared/Cargo/CargoBountyHistoryData.cs @@ -1,6 +1,6 @@ -using Robust.Shared.Serialization; using Content.Shared.Cargo.Prototypes; using Robust.Shared.Prototypes; +using Robust.Shared.Serialization; namespace Content.Shared.Cargo; @@ -13,26 +13,25 @@ public readonly partial record struct CargoBountyHistoryData /// /// A unique id used to identify the bounty /// - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField] public string Id { get; init; } = string.Empty; /// /// Optional name of the actor that skipped the bounty. /// Only set when the bounty has been skipped. /// - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField] public string? ActorName { get; init; } = default; /// /// Time when this bounty was completed or skipped /// - [DataField, ViewVariables(VVAccess.ReadWrite)] + [DataField] public TimeSpan Timestamp { get; init; } = TimeSpan.MinValue; /// /// The prototype containing information about the bounty. /// - [ViewVariables(VVAccess.ReadWrite)] [DataField(required: true)] public ProtoId Bounty { get; init; } = string.Empty; From 6eee83178e7e176099376518ff37353490e13a0a Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Thu, 19 Dec 2024 17:06:49 +0100 Subject: [PATCH 06/12] Rework TryRemoveBounty to use new Entity type --- .../Cargo/Systems/CargoSystem.Bounty.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs index 236b018a9da..d50107be846 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs @@ -98,7 +98,7 @@ private void OnSkipBountyMessage(EntityUid uid, CargoBountyConsoleComponent comp return; } - if (!TryRemoveBounty(station, bounty.Value, null, args.Actor)) + if (!TryRemoveBounty(station, bounty.Value, args.Actor)) return; FillBountyDatabase(station); @@ -437,33 +437,33 @@ public bool TryAddBounty(EntityUid uid, CargoBountyPrototype bounty, StationCarg } [PublicAPI] - public bool TryRemoveBounty(EntityUid uid, string dataId, StationCargoBountyDatabaseComponent? component = null, EntityUid? actor = null) + public bool TryRemoveBounty(Entity ent, string dataId, EntityUid? actor = null) { - if (!TryGetBountyFromId(uid, dataId, out var data, component)) + if (!TryGetBountyFromId(ent.Owner, dataId, out var data, ent.Comp)) return false; - return TryRemoveBounty(uid, data.Value, component, actor); + return TryRemoveBounty(ent, data.Value, actor); } - public bool TryRemoveBounty(EntityUid uid, CargoBountyData data, StationCargoBountyDatabaseComponent? component = null, EntityUid? actor = null) + public bool TryRemoveBounty(Entity ent, CargoBountyData data, EntityUid? actor = null) { - if (!Resolve(uid, ref component)) + if (!Resolve(ent, ref ent.Comp)) return false; - for (var i = 0; i < component.Bounties.Count; i++) + for (var i = 0; i < ent.Comp.Bounties.Count; i++) { - if (component.Bounties[i].Id == data.Id) + if (ent.Comp.Bounties[i].Id == data.Id) { string? actorName = default; if (actor != null) { - var getIdentityEvent = new TryGetIdentityShortInfoEvent(uid, actor.Value); + var getIdentityEvent = new TryGetIdentityShortInfoEvent(ent.Owner, actor.Value); RaiseLocalEvent(getIdentityEvent); actorName = getIdentityEvent.Title; } - component.History.Add(new CargoBountyHistoryData(data, _gameTiming.CurTime, actorName)); - component.Bounties.RemoveAt(i); + ent.Comp.History.Add(new CargoBountyHistoryData(data, _gameTiming.CurTime, actorName)); + ent.Comp.Bounties.RemoveAt(i); return true; } } From d4a3ad571df3180d21a5e74845e7c5e90f280a0c Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Thu, 19 Dec 2024 17:16:34 +0100 Subject: [PATCH 07/12] Add Enum for showing bounty results --- .../Cargo/UI/BountyHistoryEntry.xaml.cs | 5 ++-- .../Cargo/Systems/CargoSystem.Bounty.cs | 23 ++++++++++++++----- .../Cargo/CargoBountyHistoryData.cs | 23 ++++++++++++++++--- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs index 0e119ea2710..fd569267b89 100644 --- a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs +++ b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs @@ -35,7 +35,8 @@ public BountyHistoryEntry(CargoBountyHistoryData bounty) IdLabel.SetMarkup(Loc.GetString("bounty-console-id-label", ("id", bounty.Id))); var stationTime = bounty.Timestamp.ToString(@"hh\:mm\:ss"); - if (bounty.ActorName == null) + + if (bounty.Result == CargoBountyHistoryData.BountyResult.Completed) { StatusLabel.SetMarkup(Loc.GetString("bounty-console-history-completed-label")); NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-completed-label", ("time", stationTime))); @@ -44,7 +45,7 @@ public BountyHistoryEntry(CargoBountyHistoryData bounty) { StatusLabel.SetMarkup(Loc.GetString("bounty-console-history-skipped-label")); NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-skipped-label", - ("id", bounty.ActorName), + ("id", bounty.ActorName ?? ""), ("time", stationTime))); } } diff --git a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs index d50107be846..2a287047047 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs @@ -98,7 +98,7 @@ private void OnSkipBountyMessage(EntityUid uid, CargoBountyConsoleComponent comp return; } - if (!TryRemoveBounty(station, bounty.Value, args.Actor)) + if (!TryRemoveBounty(station, bounty.Value, true, args.Actor)) return; FillBountyDatabase(station); @@ -182,7 +182,7 @@ private void OnSold(ref EntitySoldEvent args) continue; } - TryRemoveBounty(station, bounty.Value); + TryRemoveBounty(station, bounty.Value, false); FillBountyDatabase(station); _adminLogger.Add(LogType.Action, LogImpact.Low, $"Bounty \"{bounty.Value.Bounty}\" (id:{bounty.Value.Id}) was fulfilled"); } @@ -437,15 +437,21 @@ public bool TryAddBounty(EntityUid uid, CargoBountyPrototype bounty, StationCarg } [PublicAPI] - public bool TryRemoveBounty(Entity ent, string dataId, EntityUid? actor = null) + public bool TryRemoveBounty(Entity ent, + string dataId, + bool skipped, + EntityUid? actor = null) { if (!TryGetBountyFromId(ent.Owner, dataId, out var data, ent.Comp)) return false; - return TryRemoveBounty(ent, data.Value, actor); + return TryRemoveBounty(ent, data.Value, skipped, actor); } - public bool TryRemoveBounty(Entity ent, CargoBountyData data, EntityUid? actor = null) + public bool TryRemoveBounty(Entity ent, + CargoBountyData data, + bool skipped, + EntityUid? actor = null) { if (!Resolve(ent, ref ent.Comp)) return false; @@ -462,7 +468,12 @@ public bool TryRemoveBounty(Entity ent, Ca actorName = getIdentityEvent.Title; } - ent.Comp.History.Add(new CargoBountyHistoryData(data, _gameTiming.CurTime, actorName)); + ent.Comp.History.Add(new CargoBountyHistoryData(data, + skipped + ? CargoBountyHistoryData.BountyResult.Skipped + : CargoBountyHistoryData.BountyResult.Completed, + _gameTiming.CurTime, + actorName)); ent.Comp.Bounties.RemoveAt(i); return true; } diff --git a/Content.Shared/Cargo/CargoBountyHistoryData.cs b/Content.Shared/Cargo/CargoBountyHistoryData.cs index 9954218ef55..9f9809434d5 100644 --- a/Content.Shared/Cargo/CargoBountyHistoryData.cs +++ b/Content.Shared/Cargo/CargoBountyHistoryData.cs @@ -17,8 +17,13 @@ public readonly partial record struct CargoBountyHistoryData public string Id { get; init; } = string.Empty; /// - /// Optional name of the actor that skipped the bounty. - /// Only set when the bounty has been skipped. + /// Whether this bounty was completed or skipped. + /// + [DataField] + public BountyResult Result { get; init; } = BountyResult.Completed; + + /// + /// Optional name of the actor that completed/skipped the bounty. /// [DataField] public string? ActorName { get; init; } = default; @@ -35,11 +40,23 @@ public readonly partial record struct CargoBountyHistoryData [DataField(required: true)] public ProtoId Bounty { get; init; } = string.Empty; - public CargoBountyHistoryData(CargoBountyData bounty, TimeSpan timestamp, string? actorName) + public CargoBountyHistoryData(CargoBountyData bounty, BountyResult result, TimeSpan timestamp, string? actorName) { Bounty = bounty.Bounty; + Result = result; Id = bounty.Id; ActorName = actorName; Timestamp = timestamp; } + + /// + /// Covers how a bounty was actually finished. + /// Completed - Bounty was actually fulfilled and the goods sold + /// Skipped - Bounty was explicitly skipped by some actor + /// + public enum BountyResult + { + Completed = 0, + Skipped = 1, + } } From f86c80197dc40605c2d85ff9ca47820d14c8cd53 Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Thu, 19 Dec 2024 17:38:36 +0100 Subject: [PATCH 08/12] Rework look and feel of History tab --- Content.Client/Cargo/UI/BountyHistoryEntry.xaml | 15 ++++++++------- .../Cargo/UI/BountyHistoryEntry.xaml.cs | 9 +++------ .../Locale/en-US/cargo/cargo-bounty-console.ftl | 6 ++---- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml index eee8c5cc165..637da32ab5f 100644 --- a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml +++ b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml @@ -1,8 +1,8 @@ - + @@ -10,14 +10,15 @@ - - + + + diff --git a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs index fd569267b89..54804be641c 100644 --- a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs +++ b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs @@ -34,19 +34,16 @@ public BountyHistoryEntry(CargoBountyHistoryData bounty) RewardLabel.SetMarkup(Loc.GetString("bounty-console-reward-label", ("reward", bountyPrototype.Reward))); IdLabel.SetMarkup(Loc.GetString("bounty-console-id-label", ("id", bounty.Id))); - var stationTime = bounty.Timestamp.ToString(@"hh\:mm\:ss"); + TimestampLabel.SetMarkup(bounty.Timestamp.ToString(@"hh\:mm\:ss")); if (bounty.Result == CargoBountyHistoryData.BountyResult.Completed) { - StatusLabel.SetMarkup(Loc.GetString("bounty-console-history-completed-label")); - NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-completed-label", ("time", stationTime))); + NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-completed-label")); } else { - StatusLabel.SetMarkup(Loc.GetString("bounty-console-history-skipped-label")); NoticeLabel.SetMarkup(Loc.GetString("bounty-console-history-notice-skipped-label", - ("id", bounty.ActorName ?? ""), - ("time", stationTime))); + ("id", bounty.ActorName ?? ""))); } } } diff --git a/Resources/Locale/en-US/cargo/cargo-bounty-console.ftl b/Resources/Locale/en-US/cargo/cargo-bounty-console.ftl index 4d849c5bdab..edbd4147e1d 100644 --- a/Resources/Locale/en-US/cargo/cargo-bounty-console.ftl +++ b/Resources/Locale/en-US/cargo/cargo-bounty-console.ftl @@ -21,7 +21,5 @@ bounty-manifest-list-start = Item manifest: bounty-console-tab-available-label = Available bounty-console-tab-history-label = History -bounty-console-history-notice-completed-label = {$time} - Completed -bounty-console-history-notice-skipped-label = {$time} - Skipped by {$id} -bounty-console-history-completed-label = [color=limegreen]Completed[/color] -bounty-console-history-skipped-label = [color=red]Skipped[/color] +bounty-console-history-notice-completed-label = [color=limegreen]Completed[/color] +bounty-console-history-notice-skipped-label = [color=red]Skipped[/color] by {$id} From fdeaef969f915b6818c9b70fd082f197b8b26042 Mon Sep 17 00:00:00 2001 From: BarryNorfolk Date: Fri, 20 Dec 2024 09:54:52 +0100 Subject: [PATCH 09/12] Add visible text when no bounties have been completed yet --- Content.Client/Cargo/UI/CargoBountyMenu.xaml | 4 ++++ Content.Client/Cargo/UI/CargoBountyMenu.xaml.cs | 13 ++++++++++--- .../Locale/en-US/cargo/cargo-bounty-console.ftl | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Content.Client/Cargo/UI/CargoBountyMenu.xaml b/Content.Client/Cargo/UI/CargoBountyMenu.xaml index 8c9a652ba4f..526ba69129b 100644 --- a/Content.Client/Cargo/UI/CargoBountyMenu.xaml +++ b/Content.Client/Cargo/UI/CargoBountyMenu.xaml @@ -23,6 +23,10 @@ +