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:
Kot
2024-01-21 02:03:10 +04:00
committed by GitHub
parent 0312196887
commit 4f307a49be
3 changed files with 26 additions and 3 deletions

View File

@@ -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)