Actions examine (#39558)
This commit is contained in:
@@ -21,7 +21,7 @@ namespace Content.Client.Actions.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public (TimeSpan Start, TimeSpan End)? Cooldown { get; set; }
|
public (TimeSpan Start, TimeSpan End)? Cooldown { get; set; }
|
||||||
|
|
||||||
public ActionAlertTooltip(FormattedMessage name, FormattedMessage? desc, string? requires = null, FormattedMessage? charges = null)
|
public ActionAlertTooltip(FormattedMessage name, FormattedMessage? desc, string? requires = null)
|
||||||
{
|
{
|
||||||
_gameTiming = IoCManager.Resolve<IGameTiming>();
|
_gameTiming = IoCManager.Resolve<IGameTiming>();
|
||||||
|
|
||||||
@@ -52,17 +52,6 @@ namespace Content.Client.Actions.UI
|
|||||||
vbox.AddChild(description);
|
vbox.AddChild(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (charges != null && !string.IsNullOrWhiteSpace(charges.ToString()))
|
|
||||||
{
|
|
||||||
var chargesLabel = new RichTextLabel
|
|
||||||
{
|
|
||||||
MaxWidth = TooltipTextMaxWidth,
|
|
||||||
StyleClasses = { StyleNano.StyleClassTooltipActionCharges }
|
|
||||||
};
|
|
||||||
chargesLabel.SetMessage(charges);
|
|
||||||
vbox.AddChild(chargesLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
vbox.AddChild(_cooldownLabel = new RichTextLabel
|
vbox.AddChild(_cooldownLabel = new RichTextLabel
|
||||||
{
|
{
|
||||||
MaxWidth = TooltipTextMaxWidth,
|
MaxWidth = TooltipTextMaxWidth,
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ using Content.Client.Actions;
|
|||||||
using Content.Client.Actions.UI;
|
using Content.Client.Actions.UI;
|
||||||
using Content.Client.Cooldown;
|
using Content.Client.Cooldown;
|
||||||
using Content.Client.Stylesheets;
|
using Content.Client.Stylesheets;
|
||||||
using Content.Shared.Actions;
|
|
||||||
using Content.Shared.Actions.Components;
|
using Content.Shared.Actions.Components;
|
||||||
using Content.Shared.Charges.Components;
|
|
||||||
using Content.Shared.Charges.Systems;
|
using Content.Shared.Charges.Systems;
|
||||||
|
using Content.Shared.Examine;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
|
using Robust.Client.Player;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Shared.Input;
|
using Robust.Shared.Input;
|
||||||
@@ -23,9 +23,9 @@ namespace Content.Client.UserInterface.Systems.Actions.Controls;
|
|||||||
public sealed class ActionButton : Control, IEntityControl
|
public sealed class ActionButton : Control, IEntityControl
|
||||||
{
|
{
|
||||||
private IEntityManager _entities;
|
private IEntityManager _entities;
|
||||||
|
private IPlayerManager _player;
|
||||||
private SpriteSystem? _spriteSys;
|
private SpriteSystem? _spriteSys;
|
||||||
private ActionUIController? _controller;
|
private ActionUIController? _controller;
|
||||||
private SharedChargesSystem _sharedChargesSys;
|
|
||||||
private bool _beingHovered;
|
private bool _beingHovered;
|
||||||
private bool _depressed;
|
private bool _depressed;
|
||||||
private bool _toggled;
|
private bool _toggled;
|
||||||
@@ -67,8 +67,8 @@ public sealed class ActionButton : Control, IEntityControl
|
|||||||
// TODO why is this constructor so slooooow. The rest of the code is fine
|
// TODO why is this constructor so slooooow. The rest of the code is fine
|
||||||
|
|
||||||
_entities = entities;
|
_entities = entities;
|
||||||
|
_player = IoCManager.Resolve<IPlayerManager>();
|
||||||
_spriteSys = spriteSys;
|
_spriteSys = spriteSys;
|
||||||
_sharedChargesSys = _entities.System<SharedChargesSystem>();
|
|
||||||
_controller = controller;
|
_controller = controller;
|
||||||
|
|
||||||
MouseFilter = MouseFilterMode.Pass;
|
MouseFilter = MouseFilterMode.Pass;
|
||||||
@@ -197,23 +197,17 @@ public sealed class ActionButton : Control, IEntityControl
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var name = FormattedMessage.FromMarkupPermissive(Loc.GetString(metadata.EntityName));
|
var name = FormattedMessage.FromMarkupPermissive(Loc.GetString(metadata.EntityName));
|
||||||
var decr = FormattedMessage.FromMarkupPermissive(Loc.GetString(metadata.EntityDescription));
|
var desc = FormattedMessage.FromMarkupPermissive(Loc.GetString(metadata.EntityDescription));
|
||||||
FormattedMessage? chargesText = null;
|
|
||||||
|
|
||||||
// TODO: Don't touch this use an event make callers able to add their own shit for actions or I kill you.
|
if (_player.LocalEntity is null)
|
||||||
if (_entities.TryGetComponent(Action, out LimitedChargesComponent? actionCharges))
|
return null;
|
||||||
{
|
|
||||||
var charges = _sharedChargesSys.GetCurrentCharges((Action.Value, actionCharges, null));
|
|
||||||
chargesText = FormattedMessage.FromMarkupPermissive(Loc.GetString($"Charges: {charges.ToString()}/{actionCharges.MaxCharges}"));
|
|
||||||
|
|
||||||
if (_entities.TryGetComponent(Action, out AutoRechargeComponent? autoRecharge))
|
var ev = new ExaminedEvent(desc, Action.Value, _player.LocalEntity.Value, true, !desc.IsEmpty);
|
||||||
{
|
_entities.EventBus.RaiseLocalEvent(Action.Value.Owner, ev);
|
||||||
var chargeTimeRemaining = _sharedChargesSys.GetNextRechargeTime((Action.Value, actionCharges, autoRecharge));
|
|
||||||
chargesText.AddText(Loc.GetString($"{Environment.NewLine}Time Til Recharge: {chargeTimeRemaining}"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ActionAlertTooltip(name, decr, charges: chargesText);
|
var newDesc = ev.GetTotalMessage();
|
||||||
|
|
||||||
|
return new ActionAlertTooltip(name, newDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ControlFocusExited()
|
protected override void ControlFocusExited()
|
||||||
|
|||||||
Reference in New Issue
Block a user