Add job categories to the lobby screen (#2770)
* Rename department property to departments * WIP Categories * Add better spacing to categories * Fix first separator and sync selectors * You want some types with that * Apply changes to latejoin as well * Add category sorting to the late join gui as well * CONTROL STUCK
This commit is contained in:
@@ -43,8 +43,11 @@ namespace Content.Client.UserInterface
|
||||
private readonly Button _sexClassifiedButton;
|
||||
private readonly HairStylePicker _hairPicker;
|
||||
private readonly FacialHairStylePicker _facialHairPicker;
|
||||
|
||||
private readonly List<JobPrioritySelector> _jobPriorities;
|
||||
private readonly OptionButton _preferenceUnavailableButton;
|
||||
private readonly Dictionary<string, VBoxContainer> _jobCategories;
|
||||
|
||||
private readonly List<AntagPreferenceSelector> _antagPreferences;
|
||||
|
||||
private readonly IEntity _previewDummy;
|
||||
@@ -313,11 +316,52 @@ namespace Content.Client.UserInterface
|
||||
};
|
||||
|
||||
_jobPriorities = new List<JobPrioritySelector>();
|
||||
_jobCategories = new Dictionary<string, VBoxContainer>();
|
||||
|
||||
var firstCategory = true;
|
||||
|
||||
foreach (var job in prototypeManager.EnumeratePrototypes<JobPrototype>().OrderBy(j => j.Name))
|
||||
{
|
||||
foreach (var department in job.Departments)
|
||||
{
|
||||
if (!_jobCategories.TryGetValue(department, out var category))
|
||||
{
|
||||
category = new VBoxContainer
|
||||
{
|
||||
Name = department,
|
||||
ToolTip = Loc.GetString("Jobs in the {0} department", department)
|
||||
};
|
||||
|
||||
if (firstCategory)
|
||||
{
|
||||
firstCategory = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
category.AddChild(new Control
|
||||
{
|
||||
CustomMinimumSize = new Vector2(0, 23),
|
||||
});
|
||||
}
|
||||
|
||||
category.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#464966")},
|
||||
Children =
|
||||
{
|
||||
new Label
|
||||
{
|
||||
Text = Loc.GetString("{0} jobs", department)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_jobCategories[department] = category;
|
||||
jobList.AddChild(category);
|
||||
}
|
||||
|
||||
var selector = new JobPrioritySelector(job);
|
||||
jobList.AddChild(selector);
|
||||
category.AddChild(selector);
|
||||
_jobPriorities.Add(selector);
|
||||
|
||||
selector.PriorityChanged += priority =>
|
||||
@@ -325,12 +369,18 @@ namespace Content.Client.UserInterface
|
||||
Profile = Profile.WithJobPriority(job.ID, priority);
|
||||
IsDirty = true;
|
||||
|
||||
if (priority == JobPriority.High)
|
||||
{
|
||||
// Lower any other high priorities to medium.
|
||||
foreach (var jobSelector in _jobPriorities)
|
||||
{
|
||||
if (jobSelector != selector && jobSelector.Priority == JobPriority.High)
|
||||
// Sync other selectors with the same job in case of multiple department jobs
|
||||
if (jobSelector.Job == selector.Job)
|
||||
{
|
||||
jobSelector.Priority = priority;
|
||||
}
|
||||
|
||||
// Lower any other high priorities to medium.
|
||||
if (priority == JobPriority.High)
|
||||
{
|
||||
if (jobSelector.Job != selector.Job && jobSelector.Priority == JobPriority.High)
|
||||
{
|
||||
jobSelector.Priority = JobPriority.Medium;
|
||||
Profile = Profile.WithJobPriority(jobSelector.Job.ID, JobPriority.Medium);
|
||||
@@ -340,6 +390,7 @@ namespace Content.Client.UserInterface
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Linq;
|
||||
using Content.Client.Interfaces;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.Utility;
|
||||
@@ -27,6 +29,7 @@ namespace Content.Client.UserInterface
|
||||
public event Action<string> SelectedId;
|
||||
|
||||
private readonly Dictionary<string, JobButton> _jobButtons = new();
|
||||
private readonly Dictionary<string, VBoxContainer> _jobCategories = new();
|
||||
|
||||
public LateJoinGui()
|
||||
{
|
||||
@@ -49,10 +52,51 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Contents.AddChild(vBox);
|
||||
|
||||
var firstCategory = true;
|
||||
|
||||
foreach (var job in _prototypeManager.EnumeratePrototypes<JobPrototype>().OrderBy(j => j.Name))
|
||||
{
|
||||
foreach (var department in job.Departments)
|
||||
{
|
||||
if (!_jobCategories.TryGetValue(department, out var category))
|
||||
{
|
||||
category = new VBoxContainer
|
||||
{
|
||||
Name = department,
|
||||
ToolTip = Loc.GetString("Jobs in the {0} department", department)
|
||||
};
|
||||
|
||||
if (firstCategory)
|
||||
{
|
||||
firstCategory = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
category.AddChild(new Control
|
||||
{
|
||||
CustomMinimumSize = new Vector2(0, 23),
|
||||
});
|
||||
}
|
||||
|
||||
category.AddChild(new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#464966")},
|
||||
Children =
|
||||
{
|
||||
new Label
|
||||
{
|
||||
Text = Loc.GetString("{0} jobs", department)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_jobCategories[department] = category;
|
||||
jobList.AddChild(category);
|
||||
}
|
||||
|
||||
var jobButton = new JobButton
|
||||
{
|
||||
JobId = job.ID
|
||||
@@ -74,6 +118,7 @@ namespace Content.Client.UserInterface
|
||||
var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), job.Icon);
|
||||
icon.Texture = specifier.Frame0();
|
||||
}
|
||||
|
||||
jobSelector.AddChild(icon);
|
||||
|
||||
var jobLabel = new Label
|
||||
@@ -82,10 +127,10 @@ namespace Content.Client.UserInterface
|
||||
};
|
||||
|
||||
jobSelector.AddChild(jobLabel);
|
||||
|
||||
jobButton.AddChild(jobSelector);
|
||||
jobList.AddChild(jobButton);
|
||||
jobButton.OnPressed += args =>
|
||||
category.AddChild(jobButton);
|
||||
|
||||
jobButton.OnPressed += _ =>
|
||||
{
|
||||
SelectedId?.Invoke(jobButton.JobId);
|
||||
};
|
||||
@@ -97,6 +142,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
_jobButtons[job.ID] = jobButton;
|
||||
}
|
||||
}
|
||||
|
||||
SelectedId += jobId =>
|
||||
{
|
||||
@@ -108,11 +154,6 @@ namespace Content.Client.UserInterface
|
||||
_gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated;
|
||||
}
|
||||
|
||||
public string ReturnId()
|
||||
{
|
||||
return SelectedId.ToString();
|
||||
}
|
||||
|
||||
private void JobsAvailableUpdated(IReadOnlyList<string> jobs)
|
||||
{
|
||||
foreach (var (id, button) in _jobButtons)
|
||||
@@ -129,6 +170,7 @@ namespace Content.Client.UserInterface
|
||||
{
|
||||
_gameTicker.LobbyJobsAvailableUpdated -= JobsAvailableUpdated;
|
||||
_jobButtons.Clear();
|
||||
_jobCategories.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Content.Shared.Roles
|
||||
|
||||
public JobSpecial Special { get; private set; }
|
||||
|
||||
public IReadOnlyCollection<string> Department { get; private set; }
|
||||
public IReadOnlyCollection<string> Departments { get; private set; }
|
||||
public IReadOnlyCollection<string> Access { get; private set; }
|
||||
|
||||
public void LoadFrom(YamlMappingNode mapping)
|
||||
@@ -51,7 +51,7 @@ namespace Content.Shared.Roles
|
||||
ID = srz.ReadDataField<string>("id");
|
||||
Name = Loc.GetString(srz.ReadDataField<string>("name"));
|
||||
StartingGear = srz.ReadDataField<string>("startingGear");
|
||||
Department = srz.ReadDataField<List<string>>("department");
|
||||
Departments = srz.ReadDataField<List<string>>("departments");
|
||||
TotalPositions = srz.ReadDataField<int>("positions");
|
||||
|
||||
srz.DataField(this, p => p.SpawnPositions, "spawnPositions", TotalPositions);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
positions: 2
|
||||
spawnPositions: 1
|
||||
startingGear: CargoTechGear
|
||||
department:
|
||||
departments:
|
||||
- Cargo
|
||||
icon: "CargoTechnician"
|
||||
access:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
positions: 1
|
||||
spawnPositions: 1
|
||||
startingGear: QuartermasterGear
|
||||
department:
|
||||
departments:
|
||||
- Cargo
|
||||
icon: "QuarterMaster"
|
||||
access:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
name: "assistant"
|
||||
positions: -1 # Treated as infinite.
|
||||
startingGear: AssistantGear
|
||||
department:
|
||||
departments:
|
||||
- Civilian
|
||||
icon: "Assistant"
|
||||
access:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
name: "bartender"
|
||||
positions: 1
|
||||
startingGear: BartenderGear
|
||||
department:
|
||||
departments:
|
||||
- Civilian
|
||||
icon: "Bartender"
|
||||
access:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
positions: 2
|
||||
spawnPositions: 2
|
||||
startingGear: BotanistGear
|
||||
department:
|
||||
departments:
|
||||
- Civilian
|
||||
icon: "Botanist"
|
||||
access:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# name: "chaplain"
|
||||
# positions: 1
|
||||
# startingGear: ChaplainGear
|
||||
# department:
|
||||
# departments:
|
||||
# - Civilian
|
||||
# icon: "Chaplain"
|
||||
# access:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
name: "chef"
|
||||
positions: 1
|
||||
startingGear: ChefGear
|
||||
department:
|
||||
departments:
|
||||
- Civilian
|
||||
icon: "Chef"
|
||||
access:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
name: "clown"
|
||||
positions: 1
|
||||
startingGear: ClownGear
|
||||
department:
|
||||
departments:
|
||||
- Civilian
|
||||
icon: "Clown"
|
||||
access:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
name: "janitor"
|
||||
positions: 1
|
||||
startingGear: JanitorGear
|
||||
department:
|
||||
departments:
|
||||
- Civilian
|
||||
icon: "Janitor"
|
||||
access:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
name: "mime"
|
||||
positions: 1
|
||||
startingGear: MimeGear
|
||||
department:
|
||||
departments:
|
||||
- Civilian
|
||||
icon: "Mime"
|
||||
access:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
head: true
|
||||
positions: 1
|
||||
startingGear: CaptainGear
|
||||
department:
|
||||
departments:
|
||||
- Command
|
||||
icon: "Captain"
|
||||
access:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
head: true
|
||||
positions: 1
|
||||
startingGear: HoPGear
|
||||
department:
|
||||
departments:
|
||||
- Command
|
||||
- Civilian
|
||||
icon: "HeadOfPersonnel"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
head: true
|
||||
positions: 1
|
||||
startingGear: ChiefEngineerGear
|
||||
department:
|
||||
departments:
|
||||
- Command
|
||||
- Engineering
|
||||
icon: "ChiefEngineer"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
positions: 3
|
||||
spawnPositions: 2
|
||||
startingGear: StationEngineerGear
|
||||
department:
|
||||
departments:
|
||||
- Engineering
|
||||
icon: "StationEngineer"
|
||||
access:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
head: true
|
||||
positions: 1
|
||||
startingGear: CMOGear
|
||||
department:
|
||||
departments:
|
||||
- Command
|
||||
- Medical
|
||||
icon: "ChiefMedicalOfficer"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
positions: 3
|
||||
spawnPositions: 2
|
||||
startingGear: DoctorGear
|
||||
department:
|
||||
departments:
|
||||
- Medical
|
||||
icon: "MedicalDoctor"
|
||||
access:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
head: true
|
||||
positions: 1
|
||||
startingGear: ResearchDirectorGear
|
||||
department:
|
||||
departments:
|
||||
- Command
|
||||
- Science
|
||||
icon: "ResearchDirector"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
positions: 3
|
||||
spawnPositions: 2
|
||||
startingGear: ScientistGear
|
||||
department:
|
||||
departments:
|
||||
- Science
|
||||
icon: "Scientist"
|
||||
access:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
head: true
|
||||
positions: 1
|
||||
startingGear: HoSGear
|
||||
department:
|
||||
departments:
|
||||
- Command
|
||||
- Security
|
||||
icon: "HeadOfSecurity"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
positions: 3
|
||||
spawnPositions: 2
|
||||
startingGear: SecurityOfficerGear
|
||||
department:
|
||||
departments:
|
||||
- Security
|
||||
icon: "SecurityOfficer"
|
||||
access:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
positions: 1
|
||||
spawnPositions: 1
|
||||
startingGear: WardenGear
|
||||
department:
|
||||
departments:
|
||||
- Security
|
||||
icon: "Warden"
|
||||
access:
|
||||
|
||||
Reference in New Issue
Block a user