Make role timer tooltips pretty (#19605)
Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
This commit is contained in:
@@ -257,9 +257,11 @@ namespace Content.Client.LateJoin
|
||||
{
|
||||
jobButton.Disabled = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(reason))
|
||||
if (!reason.IsEmpty)
|
||||
{
|
||||
jobButton.ToolTip = reason;
|
||||
var tooltip = new Tooltip();
|
||||
tooltip.SetMessage(reason);
|
||||
jobButton.TooltipSupplier = _ => tooltip;
|
||||
}
|
||||
|
||||
jobSelector.AddChild(new TextureRect
|
||||
|
||||
@@ -10,6 +10,7 @@ using Robust.Client.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Players.PlayTimeTracking;
|
||||
|
||||
@@ -18,6 +19,7 @@ public sealed class JobRequirementsManager
|
||||
[Dependency] private readonly IBaseClient _client = default!;
|
||||
[Dependency] private readonly IClientNetManager _net = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
||||
|
||||
@@ -78,13 +80,13 @@ public sealed class JobRequirementsManager
|
||||
Updated?.Invoke();
|
||||
}
|
||||
|
||||
public bool IsAllowed(JobPrototype job, [NotNullWhen(false)] out string? reason)
|
||||
public bool IsAllowed(JobPrototype job, [NotNullWhen(false)] out FormattedMessage? reason)
|
||||
{
|
||||
reason = null;
|
||||
|
||||
if (_roleBans.Contains($"Job:{job.ID}"))
|
||||
{
|
||||
reason = Loc.GetString("role-ban");
|
||||
reason = FormattedMessage.FromUnformatted(Loc.GetString("role-ban"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,20 +103,15 @@ public sealed class JobRequirementsManager
|
||||
|
||||
var reasonBuilder = new StringBuilder();
|
||||
|
||||
var first = true;
|
||||
foreach (var requirement in job.Requirements)
|
||||
{
|
||||
if (JobRequirements.TryRequirementMet(requirement, _roles, out reason, _prototypes))
|
||||
if (JobRequirements.TryRequirementMet(requirement, _roles, out var jobReason, _entManager, _prototypes))
|
||||
continue;
|
||||
|
||||
if (!first)
|
||||
reasonBuilder.Append('\n');
|
||||
first = false;
|
||||
|
||||
reasonBuilder.AppendLine(reason);
|
||||
reasonBuilder.AppendLine(jobReason.ToMarkup());
|
||||
}
|
||||
|
||||
reason = reasonBuilder.Length == 0 ? null : reasonBuilder.ToString();
|
||||
reason = reasonBuilder.Length == 0 ? null : FormattedMessage.FromMarkup(reasonBuilder.ToString().Trim());
|
||||
return reason == null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Configuration;
|
||||
@@ -1272,9 +1273,11 @@ namespace Content.Client.Preferences.UI
|
||||
});
|
||||
}
|
||||
|
||||
public void LockRequirements(string requirements)
|
||||
public void LockRequirements(FormattedMessage requirements)
|
||||
{
|
||||
_lockStripe.ToolTip = requirements;
|
||||
var tooltip = new Tooltip();
|
||||
tooltip.SetMessage(requirements);
|
||||
_lockStripe.TooltipSupplier = _ => tooltip;
|
||||
_lockStripe.Visible = true;
|
||||
_optionButton.Visible = false;
|
||||
}
|
||||
|
||||
9
Content.Client/Roles/JobSystem.cs
Normal file
9
Content.Client/Roles/JobSystem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Roles.Jobs;
|
||||
|
||||
namespace Content.Client.Roles;
|
||||
|
||||
public sealed class JobSystem : SharedJobSystem
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user