Lock icon for latejoin GUI (#11187)
* Margin + code cleanup + lock icon * Fix padding * Margins, caching
This commit is contained in:
@@ -5,10 +5,10 @@ using Content.Client.Players.PlayTimeTracking;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -21,9 +21,15 @@ namespace Content.Client.LateJoin
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
|
||||
[Dependency] private readonly PlayTimeTrackingManager _playTimeTracking = default!;
|
||||
|
||||
public event Action<(EntityUid, string)> SelectedId;
|
||||
|
||||
private readonly ClientGameTicker _gameTicker;
|
||||
private readonly SpriteSystem _sprites;
|
||||
private readonly CrewManifestSystem _crewManifest;
|
||||
|
||||
private readonly Dictionary<EntityUid, Dictionary<string, JobButton>> _jobButtons = new();
|
||||
private readonly Dictionary<EntityUid, Dictionary<string, BoxContainer>> _jobCategories = new();
|
||||
private readonly List<ScrollContainer> _jobLists = new();
|
||||
@@ -34,15 +40,16 @@ namespace Content.Client.LateJoin
|
||||
{
|
||||
MinSize = SetSize = (360, 560);
|
||||
IoCManager.InjectDependencies(this);
|
||||
_sprites = _entitySystem.GetEntitySystem<SpriteSystem>();
|
||||
_crewManifest = _entitySystem.GetEntitySystem<CrewManifestSystem>();
|
||||
_gameTicker = _entitySystem.GetEntitySystem<ClientGameTicker>();
|
||||
|
||||
var gameTicker = EntitySystem.Get<ClientGameTicker>();
|
||||
Title = Loc.GetString("late-join-gui-title");
|
||||
|
||||
_base = new BoxContainer()
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical,
|
||||
VerticalExpand = true,
|
||||
Margin = new Thickness(0),
|
||||
};
|
||||
|
||||
Contents.AddChild(_base);
|
||||
@@ -57,7 +64,7 @@ namespace Content.Client.LateJoin
|
||||
Close();
|
||||
};
|
||||
|
||||
gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated;
|
||||
_gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated;
|
||||
}
|
||||
|
||||
private void RebuildUI()
|
||||
@@ -67,17 +74,15 @@ namespace Content.Client.LateJoin
|
||||
_jobButtons.Clear();
|
||||
_jobCategories.Clear();
|
||||
|
||||
var gameTicker = EntitySystem.Get<ClientGameTicker>();
|
||||
var tracker = IoCManager.Resolve<PlayTimeTrackingManager>();
|
||||
|
||||
if (!gameTicker.DisallowedLateJoin && gameTicker.StationNames.Count == 0)
|
||||
if (!_gameTicker.DisallowedLateJoin && _gameTicker.StationNames.Count == 0)
|
||||
Logger.Warning("No stations exist, nothing to display in late-join GUI");
|
||||
|
||||
foreach (var (id, name) in gameTicker.StationNames)
|
||||
foreach (var (id, name) in _gameTicker.StationNames)
|
||||
{
|
||||
var jobList = new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical
|
||||
Orientation = LayoutOrientation.Vertical,
|
||||
Margin = new Thickness(0, 0, 5f, 0),
|
||||
};
|
||||
|
||||
var collapseButton = new ContainerButton()
|
||||
@@ -98,7 +103,8 @@ namespace Content.Client.LateJoin
|
||||
|
||||
_base.AddChild(new StripeBack()
|
||||
{
|
||||
Children = {
|
||||
Children =
|
||||
{
|
||||
new PanelContainer()
|
||||
{
|
||||
Children =
|
||||
@@ -115,16 +121,13 @@ namespace Content.Client.LateJoin
|
||||
}
|
||||
});
|
||||
|
||||
if (_configManager.GetCVar<bool>(CCVars.CrewManifestWithoutEntity))
|
||||
if (_configManager.GetCVar(CCVars.CrewManifestWithoutEntity))
|
||||
{
|
||||
var crewManifestButton = new Button()
|
||||
{
|
||||
Text = Loc.GetString("crew-manifest-button-label")
|
||||
};
|
||||
crewManifestButton.OnPressed += args =>
|
||||
{
|
||||
EntitySystem.Get<CrewManifestSystem>().RequestCrewManifest(id);
|
||||
};
|
||||
crewManifestButton.OnPressed += _ => _crewManifest.RequestCrewManifest(id);
|
||||
|
||||
_base.AddChild(crewManifestButton);
|
||||
}
|
||||
@@ -159,7 +162,7 @@ namespace Content.Client.LateJoin
|
||||
var departmentName = Loc.GetString($"department-{department.ID}");
|
||||
_jobCategories[id] = new Dictionary<string, BoxContainer>();
|
||||
_jobButtons[id] = new Dictionary<string, JobButton>();
|
||||
var stationAvailable = gameTicker.JobsAvailable[id];
|
||||
var stationAvailable = _gameTicker.JobsAvailable[id];
|
||||
|
||||
var category = new BoxContainer
|
||||
{
|
||||
@@ -199,7 +202,9 @@ namespace Content.Client.LateJoin
|
||||
|
||||
foreach (var jobId in department.Roles)
|
||||
{
|
||||
if (!stationAvailable.ContainsKey(jobId)) continue;
|
||||
if (!stationAvailable.ContainsKey(jobId))
|
||||
continue;
|
||||
|
||||
jobsAvailable.Add(_prototypeManager.Index<JobPrototype>(jobId));
|
||||
}
|
||||
|
||||
@@ -223,28 +228,24 @@ namespace Content.Client.LateJoin
|
||||
};
|
||||
|
||||
var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), prototype.Icon);
|
||||
icon.Texture = specifier.Frame0();
|
||||
icon.Texture = _sprites.Frame0(specifier);
|
||||
jobSelector.AddChild(icon);
|
||||
|
||||
var jobLabel = new Label
|
||||
{
|
||||
Margin = new Thickness(5f, 0, 0, 0),
|
||||
Text = value != null ?
|
||||
Loc.GetString("late-join-gui-job-slot-capped", ("jobName", prototype.LocalizedName), ("amount", value)) :
|
||||
Loc.GetString("late-join-gui-job-slot-uncapped", ("jobName", prototype.LocalizedName))
|
||||
Loc.GetString("late-join-gui-job-slot-uncapped", ("jobName", prototype.LocalizedName)),
|
||||
};
|
||||
|
||||
jobSelector.AddChild(jobLabel);
|
||||
jobButton.AddChild(jobSelector);
|
||||
category.AddChild(jobButton);
|
||||
|
||||
jobButton.OnPressed += _ =>
|
||||
{
|
||||
SelectedId?.Invoke((id, jobButton.JobId));
|
||||
};
|
||||
jobButton.OnPressed += _ => SelectedId.Invoke((id, jobButton.JobId));
|
||||
|
||||
string? reason = null;
|
||||
|
||||
if (!tracker.IsAllowed(prototype, out reason))
|
||||
if (!_playTimeTracking.IsAllowed(prototype, out var reason))
|
||||
{
|
||||
jobButton.Disabled = true;
|
||||
|
||||
@@ -252,6 +253,15 @@ namespace Content.Client.LateJoin
|
||||
{
|
||||
jobButton.ToolTip = reason;
|
||||
}
|
||||
|
||||
jobSelector.AddChild(new TextureRect
|
||||
{
|
||||
TextureScale = (0.4f, 0.4f),
|
||||
Stretch = TextureRect.StretchMode.KeepCentered,
|
||||
Texture = _sprites.Frame0(new SpriteSpecifier.Texture(new ResourcePath("/Textures/Interface/Nano/lock.svg.192dpi.png"))),
|
||||
HorizontalExpand = true,
|
||||
HorizontalAlignment = HAlignment.Right,
|
||||
});
|
||||
}
|
||||
else if (value == 0)
|
||||
{
|
||||
@@ -275,7 +285,7 @@ namespace Content.Client.LateJoin
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
EntitySystem.Get<ClientGameTicker>().LobbyJobsAvailableUpdated -= JobsAvailableUpdated;
|
||||
_gameTicker.LobbyJobsAvailableUpdated -= JobsAvailableUpdated;
|
||||
_jobButtons.Clear();
|
||||
_jobCategories.Clear();
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ late-join-gui-title = Late Join
|
||||
late-join-gui-jobs-amount-in-department-tooltip = Jobs in the {$departmentName} department
|
||||
late-join-gui-department-jobs-label = {$departmentName} jobs
|
||||
late-join-gui-job-slot-capped = {$jobName} ({$amount} open)
|
||||
late-join-gui-job-slot-uncapped = {$jobName} (No limit)
|
||||
late-join-gui-job-slot-uncapped = {$jobName} (∞ open)
|
||||
|
||||
Reference in New Issue
Block a user