diff --git a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml index eee8c5cc165..3b60aecb5f2 100644 --- a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml +++ b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml @@ -1,8 +1,8 @@ - + @@ -10,14 +10,14 @@ - - - - - + + + + + diff --git a/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs b/Content.Client/Cargo/UI/BountyHistoryEntry.xaml.cs index f3c9bbfafb1..54804be641c 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,26 +29,21 @@ 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"); - if (bounty.ActorName == null) + 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 ?? ""))); } } - protected override void FrameUpdate(FrameEventArgs args) - { - base.FrameUpdate(args); - } } diff --git a/Content.Client/Cargo/UI/CargoBountyMenu.xaml b/Content.Client/Cargo/UI/CargoBountyMenu.xaml index 0f093d5f8e7..526ba69129b 100644 --- a/Content.Client/Cargo/UI/CargoBountyMenu.xaml +++ b/Content.Client/Cargo/UI/CargoBountyMenu.xaml @@ -13,22 +13,24 @@ + HorizontalExpand="True" + VerticalExpand="True"> - + Orientation="Vertical" + VerticalExpand="True" + HorizontalExpand="True" /> + HorizontalExpand="True" + VerticalExpand="True"> + diff --git a/Content.Client/Cargo/UI/CargoBountyMenu.xaml.cs b/Content.Client/Cargo/UI/CargoBountyMenu.xaml.cs index 0717aacc5e6..26e5af1ba33 100644 --- a/Content.Client/Cargo/UI/CargoBountyMenu.xaml.cs +++ b/Content.Client/Cargo/UI/CargoBountyMenu.xaml.cs @@ -37,10 +37,19 @@ public void UpdateEntries(List bounties, List= 0; i--) + { + BountyHistoryContainer.AddChild(new BountyHistoryEntry(history[i])); + } } } } 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(); /// diff --git a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs index 236b018a9da..7f74fe269d4 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, 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,33 +437,44 @@ 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, + bool skipped, + 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, skipped, actor); } - public bool TryRemoveBounty(EntityUid uid, CargoBountyData data, StationCargoBountyDatabaseComponent? component = null, EntityUid? actor = null) + public bool TryRemoveBounty(Entity ent, + CargoBountyData data, + bool skipped, + 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; + string? actorName = null; 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, + 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 43da42d5587..9f9809434d5 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,34 +13,50 @@ 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. + /// 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, 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; - 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, + } } diff --git a/Resources/Locale/en-US/cargo/cargo-bounty-console.ftl b/Resources/Locale/en-US/cargo/cargo-bounty-console.ftl index 4d849c5bdab..d7a7025927f 100644 --- a/Resources/Locale/en-US/cargo/cargo-bounty-console.ftl +++ b/Resources/Locale/en-US/cargo/cargo-bounty-console.ftl @@ -21,7 +21,6 @@ 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-empty-label = No bounty history found +bounty-console-history-notice-completed-label = [color=limegreen]Completed[/color] +bounty-console-history-notice-skipped-label = [color=red]Skipped[/color] by {$id}