Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Station Records: Populate job list whenever possible #1954

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ public sealed partial class GeneralStationRecordConsoleWindow : DefaultWindow
private bool _isPopulating;

private StationRecordFilterType _currentFilterType;
[Dependency] private readonly IPrototypeManager _prototype = default!; // Frontier

public GeneralStationRecordConsoleWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this); // Frontier

_currentFilterType = StationRecordFilterType.Name;

Expand Down Expand Up @@ -178,10 +180,21 @@ private void PopulateJobsContainer(IReadOnlyDictionary<ProtoId<JobPrototype>, in
JobListing.RemoveAllChildren();
foreach (var (job, amount) in jobList)
{
// Skip overflow jobs.
if (amount < 0 || amount is null)
continue;

// Get proper job names when possible
string jobName;
if (_prototype.TryIndex(job, out var jobProto))
jobName = jobProto.LocalizedName;
else
jobName = job;

var jobEntry = new JobRow
{
Job = job,
JobName = { Text = job },
JobName = { Text = jobName },
JobAmount = { Text = amount.ToString() },
};
jobEntry.DecreaseJobSlot.OnPressed += (args) => { OnJobSubtract?.Invoke(args); };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Robust.Server.GameObjects;
using System.Linq;
using Content.Shared.Roles;
using Robust.Shared.Prototypes; // Frontier

namespace Content.Server.StationRecords.Systems;

Expand Down Expand Up @@ -82,20 +83,23 @@ private void UpdateUserInterface(Entity<GeneralStationRecordConsoleComponent> en
var (uid, console) = ent;
var owningStation = _station.GetOwningStation(uid);

IReadOnlyDictionary<ProtoId<JobPrototype>, int?>? jobList = null; // Frontier
if (owningStation != null) // Frontier
jobList = _stationJobsSystem.GetJobs(owningStation.Value); // Frontier: moved this up - populate whenever possible.

if (!TryComp<StationRecordsComponent>(owningStation, out var stationRecords))
{
_ui.SetUiState(uid, GeneralStationRecordConsoleKey.Key, new GeneralStationRecordConsoleState());
_ui.SetUiState(uid, GeneralStationRecordConsoleKey.Key, new GeneralStationRecordConsoleState(null, null, null, jobList, console.Filter, ent.Comp.CanDeleteEntries)); // Frontier: add as many args as we can
return;
}

var jobList = _stationJobsSystem.GetJobs(owningStation.Value);

var listing = _stationRecords.BuildListing((owningStation.Value, stationRecords), console.Filter);

switch (listing.Count)
{
case 0:
_ui.SetUiState(uid, GeneralStationRecordConsoleKey.Key, new GeneralStationRecordConsoleState());
var consoleState = new GeneralStationRecordConsoleState(null, null, null, jobList, console.Filter, ent.Comp.CanDeleteEntries); // Frontier: add as many args as we can
_ui.SetUiState(uid, GeneralStationRecordConsoleKey.Key, consoleState);
return;
default:
if (console.ActiveKey == null)
Expand All @@ -104,7 +108,10 @@ private void UpdateUserInterface(Entity<GeneralStationRecordConsoleComponent> en
}

if (console.ActiveKey is not { } id)
{
_ui.SetUiState(uid, GeneralStationRecordConsoleKey.Key, new GeneralStationRecordConsoleState(null, null, listing, jobList, console.Filter, ent.Comp.CanDeleteEntries)); // Frontier: add as many args as we can
return;
}

var key = new StationRecordKey(id, owningStation.Value);
_stationRecords.TryGetRecord<GeneralStationRecord>(key, out var record, stationRecords);
Expand Down
Loading