Fix issue where round could reset all job priorities to high (#24340)
* Update job priorities when job requirements are getting updated * Sort jobs by weight and then by the name * Sort departments too
This commit is contained in:
@@ -523,7 +523,12 @@ namespace Content.Client.Preferences.UI
|
||||
_jobCategories.Clear();
|
||||
var firstCategory = true;
|
||||
|
||||
foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
|
||||
var departments = _prototypeManager.EnumeratePrototypes<DepartmentPrototype>()
|
||||
.OrderByDescending(department => department.Weight)
|
||||
.ThenBy(department => Loc.GetString($"department-{department.ID}"))
|
||||
.ToList();
|
||||
|
||||
foreach (var department in departments)
|
||||
{
|
||||
var departmentName = Loc.GetString($"department-{department.ID}");
|
||||
|
||||
@@ -567,8 +572,11 @@ namespace Content.Client.Preferences.UI
|
||||
_jobList.AddChild(category);
|
||||
}
|
||||
|
||||
var jobs = department.Roles.Select(o => _prototypeManager.Index<JobPrototype>(o)).Where(o => o.SetPreference).ToList();
|
||||
jobs.Sort((x, y) => -string.Compare(x.LocalizedName, y.LocalizedName, StringComparison.CurrentCultureIgnoreCase));
|
||||
var jobs = department.Roles.Select(jobId => _prototypeManager.Index<JobPrototype>(jobId))
|
||||
.Where(job => job.SetPreference)
|
||||
.OrderByDescending(job => job.Weight)
|
||||
.ThenBy(job => job.LocalizedName)
|
||||
.ToList();
|
||||
|
||||
foreach (var job in jobs)
|
||||
{
|
||||
@@ -605,6 +613,11 @@ namespace Content.Client.Preferences.UI
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (Profile is not null)
|
||||
{
|
||||
UpdateJobPriorities();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFlavorTextChange(string content)
|
||||
|
||||
@@ -30,4 +30,10 @@ public sealed partial class DepartmentPrototype : IPrototype
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Primary = true;
|
||||
|
||||
/// <summary>
|
||||
/// Departments with a higher weight sorted before other departments in UI.
|
||||
/// </summary>
|
||||
[DataField("weight")]
|
||||
public int Weight { get; private set; } = 0;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
id: Civilian
|
||||
description: department-Civilian-description
|
||||
color: "#9FED58"
|
||||
weight: -10
|
||||
roles:
|
||||
- Bartender
|
||||
- Borg
|
||||
@@ -44,6 +45,7 @@
|
||||
- ResearchDirector
|
||||
- Quartermaster
|
||||
primary: false
|
||||
weight: 100
|
||||
|
||||
- type: department
|
||||
id: Engineering
|
||||
@@ -71,6 +73,7 @@
|
||||
id: Security
|
||||
description: department-Security-description
|
||||
color: "#DE3A3A"
|
||||
weight: 20
|
||||
roles:
|
||||
- HeadOfSecurity
|
||||
- SecurityCadet
|
||||
@@ -91,6 +94,7 @@
|
||||
id: Specific
|
||||
description: department-Specific-description
|
||||
color: "#9FED58"
|
||||
weight: 10
|
||||
roles:
|
||||
- Boxer
|
||||
- Reporter
|
||||
|
||||
Reference in New Issue
Block a user