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.CCVar;
|
||||||
using Content.Shared.Roles;
|
using Content.Shared.Roles;
|
||||||
using Robust.Client.Console;
|
using Robust.Client.Console;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.Utility;
|
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -21,9 +21,15 @@ namespace Content.Client.LateJoin
|
|||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _configManager = 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;
|
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, JobButton>> _jobButtons = new();
|
||||||
private readonly Dictionary<EntityUid, Dictionary<string, BoxContainer>> _jobCategories = new();
|
private readonly Dictionary<EntityUid, Dictionary<string, BoxContainer>> _jobCategories = new();
|
||||||
private readonly List<ScrollContainer> _jobLists = new();
|
private readonly List<ScrollContainer> _jobLists = new();
|
||||||
@@ -34,15 +40,16 @@ namespace Content.Client.LateJoin
|
|||||||
{
|
{
|
||||||
MinSize = SetSize = (360, 560);
|
MinSize = SetSize = (360, 560);
|
||||||
IoCManager.InjectDependencies(this);
|
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");
|
Title = Loc.GetString("late-join-gui-title");
|
||||||
|
|
||||||
_base = new BoxContainer()
|
_base = new BoxContainer()
|
||||||
{
|
{
|
||||||
Orientation = LayoutOrientation.Vertical,
|
Orientation = LayoutOrientation.Vertical,
|
||||||
VerticalExpand = true,
|
VerticalExpand = true,
|
||||||
Margin = new Thickness(0),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Contents.AddChild(_base);
|
Contents.AddChild(_base);
|
||||||
@@ -57,7 +64,7 @@ namespace Content.Client.LateJoin
|
|||||||
Close();
|
Close();
|
||||||
};
|
};
|
||||||
|
|
||||||
gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated;
|
_gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RebuildUI()
|
private void RebuildUI()
|
||||||
@@ -67,17 +74,15 @@ namespace Content.Client.LateJoin
|
|||||||
_jobButtons.Clear();
|
_jobButtons.Clear();
|
||||||
_jobCategories.Clear();
|
_jobCategories.Clear();
|
||||||
|
|
||||||
var gameTicker = EntitySystem.Get<ClientGameTicker>();
|
if (!_gameTicker.DisallowedLateJoin && _gameTicker.StationNames.Count == 0)
|
||||||
var tracker = IoCManager.Resolve<PlayTimeTrackingManager>();
|
|
||||||
|
|
||||||
if (!gameTicker.DisallowedLateJoin && gameTicker.StationNames.Count == 0)
|
|
||||||
Logger.Warning("No stations exist, nothing to display in late-join GUI");
|
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
|
var jobList = new BoxContainer
|
||||||
{
|
{
|
||||||
Orientation = LayoutOrientation.Vertical
|
Orientation = LayoutOrientation.Vertical,
|
||||||
|
Margin = new Thickness(0, 0, 5f, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
var collapseButton = new ContainerButton()
|
var collapseButton = new ContainerButton()
|
||||||
@@ -98,7 +103,8 @@ namespace Content.Client.LateJoin
|
|||||||
|
|
||||||
_base.AddChild(new StripeBack()
|
_base.AddChild(new StripeBack()
|
||||||
{
|
{
|
||||||
Children = {
|
Children =
|
||||||
|
{
|
||||||
new PanelContainer()
|
new PanelContainer()
|
||||||
{
|
{
|
||||||
Children =
|
Children =
|
||||||
@@ -115,16 +121,13 @@ namespace Content.Client.LateJoin
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_configManager.GetCVar<bool>(CCVars.CrewManifestWithoutEntity))
|
if (_configManager.GetCVar(CCVars.CrewManifestWithoutEntity))
|
||||||
{
|
{
|
||||||
var crewManifestButton = new Button()
|
var crewManifestButton = new Button()
|
||||||
{
|
{
|
||||||
Text = Loc.GetString("crew-manifest-button-label")
|
Text = Loc.GetString("crew-manifest-button-label")
|
||||||
};
|
};
|
||||||
crewManifestButton.OnPressed += args =>
|
crewManifestButton.OnPressed += _ => _crewManifest.RequestCrewManifest(id);
|
||||||
{
|
|
||||||
EntitySystem.Get<CrewManifestSystem>().RequestCrewManifest(id);
|
|
||||||
};
|
|
||||||
|
|
||||||
_base.AddChild(crewManifestButton);
|
_base.AddChild(crewManifestButton);
|
||||||
}
|
}
|
||||||
@@ -159,7 +162,7 @@ namespace Content.Client.LateJoin
|
|||||||
var departmentName = Loc.GetString($"department-{department.ID}");
|
var departmentName = Loc.GetString($"department-{department.ID}");
|
||||||
_jobCategories[id] = new Dictionary<string, BoxContainer>();
|
_jobCategories[id] = new Dictionary<string, BoxContainer>();
|
||||||
_jobButtons[id] = new Dictionary<string, JobButton>();
|
_jobButtons[id] = new Dictionary<string, JobButton>();
|
||||||
var stationAvailable = gameTicker.JobsAvailable[id];
|
var stationAvailable = _gameTicker.JobsAvailable[id];
|
||||||
|
|
||||||
var category = new BoxContainer
|
var category = new BoxContainer
|
||||||
{
|
{
|
||||||
@@ -199,7 +202,9 @@ namespace Content.Client.LateJoin
|
|||||||
|
|
||||||
foreach (var jobId in department.Roles)
|
foreach (var jobId in department.Roles)
|
||||||
{
|
{
|
||||||
if (!stationAvailable.ContainsKey(jobId)) continue;
|
if (!stationAvailable.ContainsKey(jobId))
|
||||||
|
continue;
|
||||||
|
|
||||||
jobsAvailable.Add(_prototypeManager.Index<JobPrototype>(jobId));
|
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);
|
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);
|
jobSelector.AddChild(icon);
|
||||||
|
|
||||||
var jobLabel = new Label
|
var jobLabel = new Label
|
||||||
{
|
{
|
||||||
|
Margin = new Thickness(5f, 0, 0, 0),
|
||||||
Text = value != null ?
|
Text = value != null ?
|
||||||
Loc.GetString("late-join-gui-job-slot-capped", ("jobName", prototype.LocalizedName), ("amount", value)) :
|
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);
|
jobSelector.AddChild(jobLabel);
|
||||||
jobButton.AddChild(jobSelector);
|
jobButton.AddChild(jobSelector);
|
||||||
category.AddChild(jobButton);
|
category.AddChild(jobButton);
|
||||||
|
|
||||||
jobButton.OnPressed += _ =>
|
jobButton.OnPressed += _ => SelectedId.Invoke((id, jobButton.JobId));
|
||||||
{
|
|
||||||
SelectedId?.Invoke((id, jobButton.JobId));
|
|
||||||
};
|
|
||||||
|
|
||||||
string? reason = null;
|
if (!_playTimeTracking.IsAllowed(prototype, out var reason))
|
||||||
|
|
||||||
if (!tracker.IsAllowed(prototype, out reason))
|
|
||||||
{
|
{
|
||||||
jobButton.Disabled = true;
|
jobButton.Disabled = true;
|
||||||
|
|
||||||
@@ -252,6 +253,15 @@ namespace Content.Client.LateJoin
|
|||||||
{
|
{
|
||||||
jobButton.ToolTip = reason;
|
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)
|
else if (value == 0)
|
||||||
{
|
{
|
||||||
@@ -275,7 +285,7 @@ namespace Content.Client.LateJoin
|
|||||||
|
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
EntitySystem.Get<ClientGameTicker>().LobbyJobsAvailableUpdated -= JobsAvailableUpdated;
|
_gameTicker.LobbyJobsAvailableUpdated -= JobsAvailableUpdated;
|
||||||
_jobButtons.Clear();
|
_jobButtons.Clear();
|
||||||
_jobCategories.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-jobs-amount-in-department-tooltip = Jobs in the {$departmentName} department
|
||||||
late-join-gui-department-jobs-label = {$departmentName} jobs
|
late-join-gui-department-jobs-label = {$departmentName} jobs
|
||||||
late-join-gui-job-slot-capped = {$jobName} ({$amount} open)
|
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