_jobPriorities.Clear();
var firstCategory = true;
- var departments = _prototypeManager.EnumeratePrototypes<DepartmentPrototype>().ToArray();
- Array.Sort(departments, DepartmentUIComparer.Instance);
+ // Get all displayed departments
+ var departments = new List<DepartmentPrototype>();
+ foreach (var department in _prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
+ {
+ if (department.EditorHidden)
+ continue;
+
+ departments.Add(department);
+ }
+
+ departments.Sort(DepartmentUIComparer.Instance);
var items = new[]
{
JobList.AddChild(category);
}
- var jobs = department.Roles.Select(jobId => _prototypeManager.Index<JobPrototype>(jobId))
+ var jobs = department.Roles.Select(jobId => _prototypeManager.Index(jobId))
.Where(job => job.SetPreference)
.ToArray();
if (jobId == job.ID)
{
other.Select(selectedPrio);
+ continue;
}
- else if (selectedJobPrio == JobPriority.High && (JobPriority) other.Selected == JobPriority.High)
- {
- // Lower any other high priorities to medium.
- other.Select((int) JobPriority.Medium);
- Profile = Profile?.WithJobPriority(jobId, JobPriority.Medium);
- }
+
+ if (selectedJobPrio != JobPriority.High || (JobPriority) other.Selected != JobPriority.High)
+ continue;
+
+ // Lower any other high priorities to medium.
+ other.Select((int)JobPriority.Medium);
+ Profile = Profile?.WithJobPriority(jobId, JobPriority.Medium);
}
// TODO: Only reload on high change (either to or from).
SetDirty();
ReloadPreview();
};
+
+ if (Profile is null)
+ return;
+
+ UpdateJobPriorities();
}
private void OnFlavorTextChange(string content)
using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Shared.Roles;
[Prototype("department")]
public sealed partial class DepartmentPrototype : IPrototype
{
- [IdDataField] public string ID { get; } = default!;
+ [IdDataField]
+ public string ID { get; } = string.Empty;
/// <summary>
- /// A description string to display in the character menu as an explanation of the department's function.
+ /// A description string to display in the character menu as an explanation of the department's function.
/// </summary>
- [DataField("description", required: true)]
- public string Description = default!;
+ [DataField(required: true)]
+ public string Description = string.Empty;
/// <summary>
- /// A color representing this department to use for text.
+ /// A color representing this department to use for text.
/// </summary>
- [DataField("color", required: true)]
- public Color Color = default!;
+ [DataField(required: true)]
+ public Color Color;
- [ViewVariables(VVAccess.ReadWrite),
- DataField("roles", customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
- public List<string> Roles = new();
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public List<ProtoId<JobPrototype>> Roles = new();
/// <summary>
/// Whether this is a primary department or not.
/// <summary>
/// Departments with a higher weight sorted before other departments in UI.
/// </summary>
- [DataField("weight")]
- public int Weight { get; private set; } = 0;
+ [DataField]
+ public int Weight { get; private set; }
+
+ /// <summary>
+ /// Toggles the display of the department in the priority setting menu in the character editor.
+ /// </summary>
+ [DataField]
+ public bool EditorHidden;
}
/// <summary>
{
if (ReferenceEquals(x, y))
return 0;
+
if (ReferenceEquals(null, y))
return 1;
+
if (ReferenceEquals(null, x))
return -1;
var cmp = -x.Weight.CompareTo(y.Weight);
- if (cmp != 0)
- return cmp;
- return string.Compare(x.ID, y.ID, StringComparison.Ordinal);
+ return cmp != 0 ? cmp : string.Compare(x.ID, y.ID, StringComparison.Ordinal);
}
}