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();
|
_jobCategories.Clear();
|
||||||
var firstCategory = true;
|
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}");
|
var departmentName = Loc.GetString($"department-{department.ID}");
|
||||||
|
|
||||||
@@ -567,8 +572,11 @@ namespace Content.Client.Preferences.UI
|
|||||||
_jobList.AddChild(category);
|
_jobList.AddChild(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jobs = department.Roles.Select(o => _prototypeManager.Index<JobPrototype>(o)).Where(o => o.SetPreference).ToList();
|
var jobs = department.Roles.Select(jobId => _prototypeManager.Index<JobPrototype>(jobId))
|
||||||
jobs.Sort((x, y) => -string.Compare(x.LocalizedName, y.LocalizedName, StringComparison.CurrentCultureIgnoreCase));
|
.Where(job => job.SetPreference)
|
||||||
|
.OrderByDescending(job => job.Weight)
|
||||||
|
.ThenBy(job => job.LocalizedName)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
foreach (var job in jobs)
|
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)
|
private void OnFlavorTextChange(string content)
|
||||||
|
|||||||
@@ -30,4 +30,10 @@ public sealed partial class DepartmentPrototype : IPrototype
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool Primary = true;
|
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
|
id: Civilian
|
||||||
description: department-Civilian-description
|
description: department-Civilian-description
|
||||||
color: "#9FED58"
|
color: "#9FED58"
|
||||||
|
weight: -10
|
||||||
roles:
|
roles:
|
||||||
- Bartender
|
- Bartender
|
||||||
- Borg
|
- Borg
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
- ResearchDirector
|
- ResearchDirector
|
||||||
- Quartermaster
|
- Quartermaster
|
||||||
primary: false
|
primary: false
|
||||||
|
weight: 100
|
||||||
|
|
||||||
- type: department
|
- type: department
|
||||||
id: Engineering
|
id: Engineering
|
||||||
@@ -71,6 +73,7 @@
|
|||||||
id: Security
|
id: Security
|
||||||
description: department-Security-description
|
description: department-Security-description
|
||||||
color: "#DE3A3A"
|
color: "#DE3A3A"
|
||||||
|
weight: 20
|
||||||
roles:
|
roles:
|
||||||
- HeadOfSecurity
|
- HeadOfSecurity
|
||||||
- SecurityCadet
|
- SecurityCadet
|
||||||
@@ -91,6 +94,7 @@
|
|||||||
id: Specific
|
id: Specific
|
||||||
description: department-Specific-description
|
description: department-Specific-description
|
||||||
color: "#9FED58"
|
color: "#9FED58"
|
||||||
|
weight: 10
|
||||||
roles:
|
roles:
|
||||||
- Boxer
|
- Boxer
|
||||||
- Reporter
|
- Reporter
|
||||||
|
|||||||
Reference in New Issue
Block a user