diff --git a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs index c9a64eb097..dc72cbc49e 100644 --- a/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs @@ -523,7 +523,12 @@ namespace Content.Client.Preferences.UI _jobCategories.Clear(); var firstCategory = true; - foreach (var department in _prototypeManager.EnumeratePrototypes()) + var departments = _prototypeManager.EnumeratePrototypes() + .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(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(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) diff --git a/Content.Shared/Roles/DepartmentPrototype.cs b/Content.Shared/Roles/DepartmentPrototype.cs index b3549d9584..f79b03f4a6 100644 --- a/Content.Shared/Roles/DepartmentPrototype.cs +++ b/Content.Shared/Roles/DepartmentPrototype.cs @@ -30,4 +30,10 @@ public sealed partial class DepartmentPrototype : IPrototype /// [DataField, ViewVariables(VVAccess.ReadWrite)] public bool Primary = true; + + /// + /// Departments with a higher weight sorted before other departments in UI. + /// + [DataField("weight")] + public int Weight { get; private set; } = 0; } diff --git a/Resources/Prototypes/Roles/Jobs/departments.yml b/Resources/Prototypes/Roles/Jobs/departments.yml index e1df397721..20b1847699 100644 --- a/Resources/Prototypes/Roles/Jobs/departments.yml +++ b/Resources/Prototypes/Roles/Jobs/departments.yml @@ -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