Merge remote-tracking branch 'upstream/stable' into ed-10-06-2025-upstream-sync
# Conflicts: # .github/CODEOWNERS # Content.IntegrationTests/Tests/Atmos/ConstantsTest.cs # Content.Server/Chat/Managers/ChatManager.cs # Content.Server/Connection/ConnectionManager.cs # Content.Shared/Actions/SharedActionsSystem.cs # Content.Shared/Lock/LockSystem.cs
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Content.Client.UserInterface.Controls;
|
||||
/// <summary>
|
||||
/// A button intended for use with a monotone color palette
|
||||
/// </summary>
|
||||
public sealed class MonotoneButton : ContainerButton
|
||||
public sealed class MonotoneButton : Button
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the color of the label text when the button is pressed.
|
||||
@@ -15,43 +15,9 @@ public sealed class MonotoneButton : ContainerButton
|
||||
[ViewVariables]
|
||||
public Color AltTextColor { set; get; } = new Color(0.2f, 0.2f, 0.2f);
|
||||
|
||||
/// <summary>
|
||||
/// The label that holds the button text.
|
||||
/// </summary>
|
||||
public Label Label { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The text displayed by the button.
|
||||
/// </summary>
|
||||
[PublicAPI, ViewVariables]
|
||||
public string? Text { get => Label.Text; set => Label.Text = value; }
|
||||
|
||||
/// <summary>
|
||||
/// How to align the text inside the button.
|
||||
/// </summary>
|
||||
[PublicAPI, ViewVariables]
|
||||
public AlignMode TextAlign { get => Label.Align; set => Label.Align = value; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, the button will allow shrinking and clip text
|
||||
/// to prevent the text from going outside the bounds of the button.
|
||||
/// If false, the minimum size will always fit the contained text.
|
||||
/// </summary>
|
||||
[PublicAPI, ViewVariables]
|
||||
public bool ClipText
|
||||
{
|
||||
get => Label.ClipText;
|
||||
set => Label.ClipText = value;
|
||||
}
|
||||
|
||||
public MonotoneButton()
|
||||
{
|
||||
Label = new Label
|
||||
{
|
||||
StyleClasses = { StyleClassButton }
|
||||
};
|
||||
|
||||
AddChild(Label);
|
||||
RemoveStyleClass("button");
|
||||
UpdateAppearance();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using Content.Client.UserInterface.Systems.Actions.Widgets;
|
||||
using Content.Client.UserInterface.Systems.Actions.Windows;
|
||||
using Content.Client.UserInterface.Systems.Gameplay;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.Components;
|
||||
using Content.Shared.Charges.Systems;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.GameObjects;
|
||||
@@ -162,142 +163,33 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
if (_playerManager.LocalEntity is not { } user)
|
||||
return false;
|
||||
|
||||
if (!EntityManager.TryGetComponent(user, out ActionsComponent? comp))
|
||||
if (!EntityManager.TryGetComponent<ActionsComponent>(user, out var comp))
|
||||
return false;
|
||||
|
||||
if (!_actionsSystem.TryGetActionData(actionId, out var baseAction) ||
|
||||
baseAction is not BaseTargetActionComponent action)
|
||||
if (_actionsSystem.GetAction(actionId) is not {} action ||
|
||||
!EntityManager.TryGetComponent<TargetActionComponent>(action, out var target))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is the action currently valid?
|
||||
if (!action.Enabled
|
||||
|| action.Cooldown.HasValue && action.Cooldown.Value.End > _timing.CurTime)
|
||||
if (!_actionsSystem.ValidAction(action))
|
||||
{
|
||||
// The user is targeting with this action, but it is not valid. Maybe mark this click as
|
||||
// handled and prevent further interactions.
|
||||
return !action.InteractOnMiss;
|
||||
return !target.InteractOnMiss;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
var ev = new ActionTargetAttemptEvent(args, (user, comp), action);
|
||||
EntityManager.EventBus.RaiseLocalEvent(action, ref ev);
|
||||
if (!ev.Handled)
|
||||
{
|
||||
case WorldTargetActionComponent mapTarget:
|
||||
return TryTargetWorld(args, actionId, mapTarget, user, comp) || !mapTarget.InteractOnMiss;
|
||||
|
||||
case EntityTargetActionComponent entTarget:
|
||||
return TryTargetEntity(args, actionId, entTarget, user, comp) || !entTarget.InteractOnMiss;
|
||||
|
||||
case EntityWorldTargetActionComponent entMapTarget:
|
||||
return TryTargetEntityWorld(args, actionId, entMapTarget, user, comp) || !entMapTarget.InteractOnMiss;
|
||||
|
||||
default:
|
||||
Logger.Error($"Unknown targeting action: {actionId.GetType()}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryTargetWorld(in PointerInputCmdArgs args, EntityUid actionId, WorldTargetActionComponent action, EntityUid user, ActionsComponent actionComp)
|
||||
{
|
||||
if (_actionsSystem == null)
|
||||
return false;
|
||||
|
||||
var coords = args.Coordinates;
|
||||
|
||||
if (!_actionsSystem.ValidateWorldTarget(user, coords, (actionId, action)))
|
||||
{
|
||||
// Invalid target.
|
||||
if (action.DeselectOnMiss)
|
||||
StopTargeting();
|
||||
|
||||
Log.Error($"Action {EntityManager.ToPrettyString(actionId)} did not handle ActionTargetAttemptEvent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (action.ClientExclusive)
|
||||
{
|
||||
if (action.Event != null)
|
||||
{
|
||||
action.Event.Target = coords;
|
||||
}
|
||||
|
||||
_actionsSystem.PerformAction(user, actionComp, actionId, action, action.Event, _timing.CurTime);
|
||||
}
|
||||
else
|
||||
EntityManager.RaisePredictiveEvent(new RequestPerformActionEvent(EntityManager.GetNetEntity(actionId), EntityManager.GetNetCoordinates(coords)));
|
||||
|
||||
if (!action.Repeat)
|
||||
StopTargeting();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryTargetEntity(in PointerInputCmdArgs args, EntityUid actionId, EntityTargetActionComponent action, EntityUid user, ActionsComponent actionComp)
|
||||
{
|
||||
if (_actionsSystem == null)
|
||||
return false;
|
||||
|
||||
var entity = args.EntityUid;
|
||||
|
||||
if (!_actionsSystem.ValidateEntityTarget(user, entity, (actionId, action)))
|
||||
{
|
||||
if (action.DeselectOnMiss)
|
||||
StopTargeting();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (action.ClientExclusive)
|
||||
{
|
||||
if (action.Event != null)
|
||||
{
|
||||
action.Event.Target = entity;
|
||||
}
|
||||
|
||||
_actionsSystem.PerformAction(user, actionComp, actionId, action, action.Event, _timing.CurTime);
|
||||
}
|
||||
else
|
||||
EntityManager.RaisePredictiveEvent(new RequestPerformActionEvent(EntityManager.GetNetEntity(actionId), EntityManager.GetNetEntity(args.EntityUid)));
|
||||
|
||||
if (!action.Repeat)
|
||||
StopTargeting();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryTargetEntityWorld(in PointerInputCmdArgs args,
|
||||
EntityUid actionId,
|
||||
EntityWorldTargetActionComponent action,
|
||||
EntityUid user,
|
||||
ActionsComponent actionComp)
|
||||
{
|
||||
if (_actionsSystem == null)
|
||||
return false;
|
||||
|
||||
var entity = args.EntityUid;
|
||||
var coords = args.Coordinates;
|
||||
|
||||
if (!_actionsSystem.ValidateEntityWorldTarget(user, entity, coords, (actionId, action)))
|
||||
{
|
||||
if (action.DeselectOnMiss)
|
||||
StopTargeting();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (action.ClientExclusive)
|
||||
{
|
||||
if (action.Event != null)
|
||||
{
|
||||
action.Event.Entity = entity;
|
||||
action.Event.Coords = coords;
|
||||
}
|
||||
|
||||
_actionsSystem.PerformAction(user, actionComp, actionId, action, action.Event, _timing.CurTime);
|
||||
}
|
||||
else
|
||||
EntityManager.RaisePredictiveEvent(new RequestPerformActionEvent(EntityManager.GetNetEntity(actionId), EntityManager.GetNetEntity(args.EntityUid), EntityManager.GetNetCoordinates(coords)));
|
||||
|
||||
if (!action.Repeat)
|
||||
// stop targeting when needed
|
||||
if (ev.FoundTarget ? !target.Repeat : target.DeselectOnMiss)
|
||||
StopTargeting();
|
||||
|
||||
return true;
|
||||
@@ -305,36 +197,26 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
|
||||
public void UnloadButton()
|
||||
{
|
||||
if (ActionButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActionButton.OnPressed -= ActionButtonPressed;
|
||||
if (ActionButton != null)
|
||||
ActionButton.OnPressed -= ActionButtonPressed;
|
||||
}
|
||||
|
||||
public void LoadButton()
|
||||
{
|
||||
if (ActionButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActionButton.OnPressed += ActionButtonPressed;
|
||||
if (ActionButton != null)
|
||||
ActionButton.OnPressed += ActionButtonPressed;
|
||||
}
|
||||
|
||||
private void OnWindowOpened()
|
||||
{
|
||||
if (ActionButton != null)
|
||||
ActionButton.SetClickPressed(true);
|
||||
ActionButton?.SetClickPressed(true);
|
||||
|
||||
SearchAndDisplay();
|
||||
}
|
||||
|
||||
private void OnWindowClosed()
|
||||
{
|
||||
if (ActionButton != null)
|
||||
ActionButton.SetClickPressed(false);
|
||||
ActionButton?.SetClickPressed(false);
|
||||
}
|
||||
|
||||
public void OnStateExited(GameplayState state)
|
||||
@@ -351,35 +233,33 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
|
||||
private void TriggerAction(int index)
|
||||
{
|
||||
if (_actionsSystem == null ||
|
||||
!_actions.TryGetValue(index, out var actionId) ||
|
||||
!_actionsSystem.TryGetActionData(actionId, out var baseAction))
|
||||
if (!_actions.TryGetValue(index, out var actionId) ||
|
||||
_actionsSystem?.GetAction(actionId) is not {} action)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (baseAction is BaseTargetActionComponent action)
|
||||
ToggleTargeting(actionId.Value, action);
|
||||
// TODO: probably should have a clientside event raised for flexibility
|
||||
if (EntityManager.TryGetComponent<TargetActionComponent>(action, out var target))
|
||||
ToggleTargeting((action, action, target));
|
||||
else
|
||||
_actionsSystem?.TriggerAction(actionId.Value, baseAction);
|
||||
_actionsSystem?.TriggerAction(action);
|
||||
}
|
||||
|
||||
private void OnActionAdded(EntityUid actionId)
|
||||
{
|
||||
if (_actionsSystem == null ||
|
||||
!_actionsSystem.TryGetActionData(actionId, out var action))
|
||||
{
|
||||
if (_actionsSystem?.GetAction(actionId) is not {} action)
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: event
|
||||
// if the action is toggled when we add it, start targeting
|
||||
if (action is BaseTargetActionComponent targetAction && action.Toggled)
|
||||
StartTargeting(actionId, targetAction);
|
||||
if (action.Comp.Toggled && EntityManager.TryGetComponent<TargetActionComponent>(actionId, out var target))
|
||||
StartTargeting((action, action, target));
|
||||
|
||||
if (_actions.Contains(actionId))
|
||||
if (_actions.Contains(action))
|
||||
return;
|
||||
|
||||
_actions.Add(actionId);
|
||||
_actions.Add(action);
|
||||
}
|
||||
|
||||
private void OnActionRemoved(EntityUid actionId)
|
||||
@@ -437,15 +317,16 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
}
|
||||
}
|
||||
|
||||
private bool MatchesFilter(BaseActionComponent action, Filters filter)
|
||||
private bool MatchesFilter(Entity<ActionComponent> ent, Filters filter)
|
||||
{
|
||||
var (uid, comp) = ent;
|
||||
return filter switch
|
||||
{
|
||||
Filters.Enabled => action.Enabled,
|
||||
Filters.Item => action.Container != null && action.Container != _playerManager.LocalEntity,
|
||||
Filters.Innate => action.Container == null || action.Container == _playerManager.LocalEntity,
|
||||
Filters.Instant => action is InstantActionComponent,
|
||||
Filters.Targeted => action is BaseTargetActionComponent,
|
||||
Filters.Enabled => comp.Enabled,
|
||||
Filters.Item => comp.Container != null && comp.Container != _playerManager.LocalEntity,
|
||||
Filters.Innate => comp.Container == null || comp.Container == _playerManager.LocalEntity,
|
||||
Filters.Instant => EntityManager.HasComponent<InstantActionComponent>(uid),
|
||||
Filters.Targeted => EntityManager.HasComponent<TargetActionComponent>(uid),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(filter), filter, null)
|
||||
};
|
||||
}
|
||||
@@ -456,7 +337,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
_window.ResultsGrid.RemoveAllChildren();
|
||||
}
|
||||
|
||||
private void PopulateActions(IEnumerable<(EntityUid Id, BaseActionComponent Comp)> actions)
|
||||
private void PopulateActions(IEnumerable<Entity<ActionComponent>> actions)
|
||||
{
|
||||
if (_window is not { Disposed: false, IsOpen: true })
|
||||
return;
|
||||
@@ -478,7 +359,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
{
|
||||
if (i < existing.Count)
|
||||
{
|
||||
existing[i++].UpdateData(action.Id, _actionsSystem);
|
||||
existing[i++].UpdateData(action, _actionsSystem);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -486,7 +367,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
button.ActionPressed += OnWindowActionPressed;
|
||||
button.ActionUnpressed += OnWindowActionUnPressed;
|
||||
button.ActionFocusExited += OnWindowActionFocusExisted;
|
||||
button.UpdateData(action.Id, _actionsSystem);
|
||||
button.UpdateData(action, _actionsSystem);
|
||||
_window.ResultsGrid.AddChild(button);
|
||||
}
|
||||
|
||||
@@ -525,13 +406,13 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
|
||||
actions = actions.Where(action =>
|
||||
{
|
||||
if (filters.Count > 0 && filters.Any(filter => !MatchesFilter(action.Comp, filter)))
|
||||
if (filters.Count > 0 && filters.Any(filter => !MatchesFilter(action, filter)))
|
||||
return false;
|
||||
|
||||
if (action.Comp.Keywords.Any(keyword => search.Contains(keyword, StringComparison.OrdinalIgnoreCase)))
|
||||
return true;
|
||||
|
||||
var name = EntityManager.GetComponent<MetaDataComponent>(action.Id).EntityName;
|
||||
var name = EntityManager.GetComponent<MetaDataComponent>(action).EntityName;
|
||||
if (name.Contains(search, StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
|
||||
@@ -581,7 +462,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
|
||||
private void DragAction()
|
||||
{
|
||||
if (_menuDragHelper.Dragged is not {ActionId: {} action} dragged)
|
||||
if (_menuDragHelper.Dragged is not {Action: {} action} dragged)
|
||||
{
|
||||
_menuDragHelper.EndDrag();
|
||||
return;
|
||||
@@ -591,7 +472,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
var currentlyHovered = UIManager.MouseGetControl(_input.MouseScreenPosition);
|
||||
if (currentlyHovered is ActionButton button)
|
||||
{
|
||||
swapAction = button.ActionId;
|
||||
swapAction = button.Action;
|
||||
SetAction(button, action, false);
|
||||
}
|
||||
|
||||
@@ -665,16 +546,13 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
private void HandleActionPressed(GUIBoundKeyEventArgs args, ActionButton button)
|
||||
{
|
||||
args.Handle();
|
||||
if (button.ActionId != null)
|
||||
if (button.Action != null)
|
||||
{
|
||||
_menuDragHelper.MouseDown(button);
|
||||
return;
|
||||
}
|
||||
|
||||
var ev = new FillActionSlotEvent();
|
||||
EntityManager.EventBus.RaiseEvent(EventSource.Local, ev);
|
||||
if (ev.Action != null)
|
||||
SetAction(button, ev.Action);
|
||||
// good job
|
||||
}
|
||||
|
||||
private void OnActionUnpressed(GUIBoundKeyEventArgs args, ActionButton button)
|
||||
@@ -700,12 +578,13 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
|
||||
_menuDragHelper.EndDrag();
|
||||
|
||||
if (!_actionsSystem.TryGetActionData(button.ActionId, out var baseAction))
|
||||
if (button.Action is not {} action)
|
||||
return;
|
||||
|
||||
if (baseAction is not BaseTargetActionComponent action)
|
||||
// TODO: make this an event
|
||||
if (!EntityManager.TryGetComponent<TargetActionComponent>(action, out var target))
|
||||
{
|
||||
_actionsSystem?.TriggerAction(button.ActionId.Value, baseAction);
|
||||
_actionsSystem?.TriggerAction(action);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -714,7 +593,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
|
||||
// if we're clicking the same thing we're already targeting for, then we simply cancel
|
||||
// targeting
|
||||
ToggleTargeting(button.ActionId.Value, action);
|
||||
ToggleTargeting((action, action.Comp, target));
|
||||
}
|
||||
|
||||
private bool OnMenuBeginDrag()
|
||||
@@ -722,16 +601,16 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
// TODO ACTIONS
|
||||
// The dragging icon shuld be based on the entity's icon style. I.e. if the action has a large icon texture,
|
||||
// and a small item/provider sprite, then the dragged icon should be the big texture, not the provider.
|
||||
if (_actionsSystem != null && _actionsSystem.TryGetActionData(_menuDragHelper.Dragged?.ActionId, out var action))
|
||||
if (_menuDragHelper.Dragged?.Action is {} action)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(action.EntityIcon, out SpriteComponent? sprite)
|
||||
if (EntityManager.TryGetComponent(action.Comp.EntityIcon, out SpriteComponent? sprite)
|
||||
&& sprite.Icon?.GetFrame(RsiDirection.South, 0) is {} frame)
|
||||
{
|
||||
_dragShadow.Texture = frame;
|
||||
}
|
||||
else if (action.Icon != null)
|
||||
else if (action.Comp.Icon is {} icon)
|
||||
{
|
||||
_dragShadow.Texture = _spriteSystem.Frame0(action.Icon);
|
||||
_dragShadow.Texture = _spriteSystem.Frame0(icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -898,33 +777,35 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
/// If currently targeting with no slot or a different slot, switches to
|
||||
/// targeting with the specified slot.
|
||||
/// </summary>
|
||||
private void ToggleTargeting(EntityUid actionId, BaseTargetActionComponent action)
|
||||
private void ToggleTargeting(Entity<ActionComponent, TargetActionComponent> ent)
|
||||
{
|
||||
if (SelectingTargetFor == actionId)
|
||||
if (SelectingTargetFor == ent)
|
||||
{
|
||||
StopTargeting();
|
||||
return;
|
||||
}
|
||||
|
||||
StartTargeting(actionId, action);
|
||||
StartTargeting(ent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts us in targeting mode, where we need to pick either a target point or entity
|
||||
/// </summary>
|
||||
private void StartTargeting(EntityUid actionId, BaseTargetActionComponent action)
|
||||
private void StartTargeting(Entity<ActionComponent, TargetActionComponent> ent)
|
||||
{
|
||||
var (uid, action, target) = ent;
|
||||
|
||||
// If we were targeting something else we should stop
|
||||
StopTargeting();
|
||||
|
||||
SelectingTargetFor = actionId;
|
||||
SelectingTargetFor = uid;
|
||||
// TODO inform the server
|
||||
action.Toggled = true;
|
||||
_actionsSystem?.SetToggled(uid, true);
|
||||
|
||||
// override "held-item" overlay
|
||||
var provider = action.Container;
|
||||
|
||||
if (action.TargetingIndicator && _overlays.TryGetOverlay<ShowHandItemOverlay>(out var handOverlay))
|
||||
if (target.TargetingIndicator && _overlays.TryGetOverlay<ShowHandItemOverlay>(out var handOverlay))
|
||||
{
|
||||
if (action.ItemIconStyle == ItemActionIconStyle.BigItem && action.Container != null)
|
||||
{
|
||||
@@ -940,7 +821,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
{
|
||||
foreach (var button in _container.GetButtons())
|
||||
{
|
||||
if (button.ActionId == actionId)
|
||||
if (button.Action?.Owner == uid)
|
||||
button.UpdateIcons();
|
||||
}
|
||||
}
|
||||
@@ -950,19 +831,19 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
// - Add a yes/no checkmark where the HandItemOverlay usually is
|
||||
|
||||
// Highlight valid entity targets
|
||||
if (action is not EntityTargetActionComponent entityAction)
|
||||
if (!EntityManager.TryGetComponent<EntityTargetActionComponent>(uid, out var entity))
|
||||
return;
|
||||
|
||||
Func<EntityUid, bool>? predicate = null;
|
||||
var attachedEnt = entityAction.AttachedEntity;
|
||||
var attachedEnt = action.AttachedEntity;
|
||||
|
||||
if (!entityAction.CanTargetSelf)
|
||||
if (!entity.CanTargetSelf)
|
||||
predicate = e => e != attachedEnt;
|
||||
|
||||
var range = entityAction.CheckCanAccess ? action.Range : -1;
|
||||
var range = target.CheckCanAccess ? target.Range : -1;
|
||||
|
||||
_interactionOutline?.SetEnabled(false);
|
||||
_targetOutline?.Enable(range, entityAction.CheckCanAccess, predicate, entityAction.Whitelist, entityAction.Blacklist, null);
|
||||
_targetOutline?.Enable(range, target.CheckCanAccess, predicate, entity.Whitelist, entity.Blacklist, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -974,11 +855,8 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
return;
|
||||
|
||||
var oldAction = SelectingTargetFor;
|
||||
if (_actionsSystem != null && _actionsSystem.TryGetActionData(oldAction, out var action))
|
||||
{
|
||||
// TODO inform the server
|
||||
action.Toggled = false;
|
||||
}
|
||||
// TODO inform the server
|
||||
_actionsSystem?.SetToggled(oldAction, false);
|
||||
|
||||
SelectingTargetFor = null;
|
||||
|
||||
@@ -989,7 +867,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
|
||||
{
|
||||
foreach (var button in _container.GetButtons())
|
||||
{
|
||||
if (button.ActionId == oldAction)
|
||||
if (button.Action?.Owner == oldAction)
|
||||
button.UpdateIcons();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Client.Actions.UI;
|
||||
using Content.Client.Cooldown;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.Components;
|
||||
using Content.Shared.Charges.Components;
|
||||
using Content.Shared.Charges.Systems;
|
||||
using Robust.Client.GameObjects;
|
||||
@@ -54,8 +55,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
private Texture? _buttonBackgroundTexture;
|
||||
|
||||
public EntityUid? ActionId { get; private set; }
|
||||
private BaseActionComponent? _action;
|
||||
public Entity<ActionComponent>? Action { get; private set; }
|
||||
public bool Locked { get; set; }
|
||||
|
||||
public event Action<GUIBoundKeyEventArgs, ActionButton>? ActionPressed;
|
||||
@@ -193,7 +193,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
private Control? SupplyTooltip(Control sender)
|
||||
{
|
||||
if (!_entities.TryGetComponent(ActionId, out MetaDataComponent? metadata))
|
||||
if (!_entities.TryGetComponent(Action, out MetaDataComponent? metadata))
|
||||
return null;
|
||||
|
||||
var name = FormattedMessage.FromMarkupPermissive(Loc.GetString(metadata.EntityName));
|
||||
@@ -201,14 +201,14 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
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 (_entities.TryGetComponent(ActionId, out LimitedChargesComponent? actionCharges))
|
||||
if (_entities.TryGetComponent(Action, out LimitedChargesComponent? actionCharges))
|
||||
{
|
||||
var charges = _sharedChargesSys.GetCurrentCharges((ActionId.Value, actionCharges, null));
|
||||
var charges = _sharedChargesSys.GetCurrentCharges((Action.Value, actionCharges, null));
|
||||
chargesText = FormattedMessage.FromMarkupPermissive(Loc.GetString($"Charges: {charges.ToString()}/{actionCharges.MaxCharges}"));
|
||||
|
||||
if (_entities.TryGetComponent(ActionId, out AutoRechargeComponent? autoRecharge))
|
||||
if (_entities.TryGetComponent(Action, out AutoRechargeComponent? autoRecharge))
|
||||
{
|
||||
var chargeTimeRemaining = _sharedChargesSys.GetNextRechargeTime((ActionId.Value, actionCharges, autoRecharge));
|
||||
var chargeTimeRemaining = _sharedChargesSys.GetNextRechargeTime((Action.Value, actionCharges, autoRecharge));
|
||||
chargesText.AddText(Loc.GetString($"{Environment.NewLine}Time Til Recharge: {chargeTimeRemaining}"));
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
private void UpdateItemIcon()
|
||||
{
|
||||
if (_action is not {EntityIcon: { } entity} ||
|
||||
if (Action?.Comp is not {EntityIcon: { } entity} ||
|
||||
!_entities.HasComponent<SpriteComponent>(entity))
|
||||
{
|
||||
_bigItemSpriteView.Visible = false;
|
||||
@@ -233,7 +233,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (_action.ItemIconStyle)
|
||||
switch (Action?.Comp.ItemIconStyle)
|
||||
{
|
||||
case ItemActionIconStyle.BigItem:
|
||||
_bigItemSpriteView.Visible = true;
|
||||
@@ -259,17 +259,17 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
private void SetActionIcon(Texture? texture)
|
||||
{
|
||||
if (_action == null || texture == null)
|
||||
if (Action?.Comp is not {} action || texture == null)
|
||||
{
|
||||
_bigActionIcon.Texture = null;
|
||||
_bigActionIcon.Visible = false;
|
||||
_smallActionIcon.Texture = null;
|
||||
_smallActionIcon.Visible = false;
|
||||
}
|
||||
else if (_action.EntityIcon != null && _action.ItemIconStyle == ItemActionIconStyle.BigItem)
|
||||
else if (action.EntityIcon != null && action.ItemIconStyle == ItemActionIconStyle.BigItem)
|
||||
{
|
||||
_smallActionIcon.Texture = texture;
|
||||
_smallActionIcon.Modulate = _action.IconColor;
|
||||
_smallActionIcon.Modulate = action.IconColor;
|
||||
_smallActionIcon.Visible = true;
|
||||
_bigActionIcon.Texture = null;
|
||||
_bigActionIcon.Visible = false;
|
||||
@@ -277,7 +277,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
else
|
||||
{
|
||||
_bigActionIcon.Texture = texture;
|
||||
_bigActionIcon.Modulate = _action.IconColor;
|
||||
_bigActionIcon.Modulate = action.IconColor;
|
||||
_bigActionIcon.Visible = true;
|
||||
_smallActionIcon.Texture = null;
|
||||
_smallActionIcon.Visible = false;
|
||||
@@ -289,7 +289,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
UpdateItemIcon();
|
||||
UpdateBackground();
|
||||
|
||||
if (_action == null)
|
||||
if (Action is not {} action)
|
||||
{
|
||||
SetActionIcon(null);
|
||||
return;
|
||||
@@ -297,29 +297,27 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
_controller ??= UserInterfaceManager.GetUIController<ActionUIController>();
|
||||
_spriteSys ??= _entities.System<SpriteSystem>();
|
||||
if ((_controller.SelectingTargetFor == ActionId || _action.Toggled))
|
||||
var icon = action.Comp.Icon;
|
||||
if (_controller.SelectingTargetFor == action || action.Comp.Toggled)
|
||||
{
|
||||
if (_action.IconOn != null)
|
||||
SetActionIcon(_spriteSys.Frame0(_action.IconOn));
|
||||
else if (_action.Icon != null)
|
||||
SetActionIcon(_spriteSys.Frame0(_action.Icon));
|
||||
else
|
||||
SetActionIcon(null);
|
||||
if (action.Comp.IconOn is {} iconOn)
|
||||
icon = iconOn;
|
||||
|
||||
if (_action.BackgroundOn != null)
|
||||
_buttonBackgroundTexture = _spriteSys.Frame0(_action.BackgroundOn);
|
||||
if (action.Comp.BackgroundOn is {} background)
|
||||
_buttonBackgroundTexture = _spriteSys.Frame0(background);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetActionIcon(_action.Icon != null ? _spriteSys.Frame0(_action.Icon) : null);
|
||||
_buttonBackgroundTexture = Theme.ResolveTexture("SlotBackground");
|
||||
}
|
||||
|
||||
SetActionIcon(icon != null ? _spriteSys.Frame0(icon) : null);
|
||||
}
|
||||
|
||||
public void UpdateBackground()
|
||||
{
|
||||
_controller ??= UserInterfaceManager.GetUIController<ActionUIController>();
|
||||
if (_action != null ||
|
||||
if (Action != null ||
|
||||
_controller.IsDragging && GetPositionInParent() == Parent?.ChildCount - 1)
|
||||
{
|
||||
Button.Texture = _buttonBackgroundTexture;
|
||||
@@ -333,9 +331,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
public bool TryReplaceWith(EntityUid actionId, ActionsSystem system)
|
||||
{
|
||||
if (Locked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateData(actionId, system);
|
||||
return true;
|
||||
@@ -343,16 +339,15 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
public void UpdateData(EntityUid? actionId, ActionsSystem system)
|
||||
{
|
||||
ActionId = actionId;
|
||||
system.TryGetActionData(actionId, out _action);
|
||||
Label.Visible = actionId != null;
|
||||
Action = system.GetAction(actionId);
|
||||
|
||||
Label.Visible = Action != null;
|
||||
UpdateIcons();
|
||||
}
|
||||
|
||||
public void ClearData()
|
||||
{
|
||||
ActionId = null;
|
||||
_action = null;
|
||||
Action = null;
|
||||
Cooldown.Visible = false;
|
||||
Cooldown.Progress = 1;
|
||||
Label.Visible = false;
|
||||
@@ -365,19 +360,15 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
|
||||
UpdateBackground();
|
||||
|
||||
Cooldown.Visible = _action != null && _action.Cooldown != null;
|
||||
if (_action == null)
|
||||
Cooldown.Visible = Action?.Comp.Cooldown != null;
|
||||
if (Action?.Comp is not {} action)
|
||||
return;
|
||||
|
||||
if (_action.Cooldown != null)
|
||||
{
|
||||
Cooldown.FromTime(_action.Cooldown.Value.Start, _action.Cooldown.Value.End);
|
||||
}
|
||||
if (action.Cooldown is {} cooldown)
|
||||
Cooldown.FromTime(cooldown.Start, cooldown.End);
|
||||
|
||||
if (ActionId != null && _toggled != _action.Toggled)
|
||||
{
|
||||
_toggled = _action.Toggled;
|
||||
}
|
||||
if (_toggled != action.Toggled)
|
||||
_toggled = action.Toggled;
|
||||
}
|
||||
|
||||
protected override void MouseEntered()
|
||||
@@ -404,7 +395,7 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
public void Depress(GUIBoundKeyEventArgs args, bool depress)
|
||||
{
|
||||
// action can still be toggled if it's allowed to stay selected
|
||||
if (_action is not {Enabled: true})
|
||||
if (Action?.Comp is not {Enabled: true})
|
||||
return;
|
||||
|
||||
_depressed = depress;
|
||||
@@ -414,17 +405,17 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
public void DrawModeChanged()
|
||||
{
|
||||
_controller ??= UserInterfaceManager.GetUIController<ActionUIController>();
|
||||
HighlightRect.Visible = _beingHovered && (_action != null || _controller.IsDragging);
|
||||
HighlightRect.Visible = _beingHovered && (Action != null || _controller.IsDragging);
|
||||
|
||||
// always show the normal empty button style if no action in this slot
|
||||
if (_action == null)
|
||||
if (Action?.Comp is not {} action)
|
||||
{
|
||||
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassNormal);
|
||||
return;
|
||||
}
|
||||
|
||||
// show a hover only if the action is usable or another action is being dragged on top of this
|
||||
if (_beingHovered && (_controller.IsDragging || _action!.Enabled))
|
||||
if (_beingHovered && (_controller.IsDragging || action.Enabled))
|
||||
{
|
||||
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassHover);
|
||||
}
|
||||
@@ -439,16 +430,16 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
}
|
||||
|
||||
// if it's toggled on, always show the toggled on style (currently same as depressed style)
|
||||
if (_action.Toggled || _controller.SelectingTargetFor == ActionId)
|
||||
if (action.Toggled || _controller.SelectingTargetFor == Action?.Owner)
|
||||
{
|
||||
// when there's a toggle sprite, we're showing that sprite instead of highlighting this slot
|
||||
SetOnlyStylePseudoClass(_action.IconOn != null
|
||||
SetOnlyStylePseudoClass(action.IconOn != null
|
||||
? ContainerButton.StylePseudoClassNormal
|
||||
: ContainerButton.StylePseudoClassPressed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_action.Enabled)
|
||||
if (!action.Enabled)
|
||||
{
|
||||
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassDisabled);
|
||||
return;
|
||||
@@ -457,5 +448,5 @@ public sealed class ActionButton : Control, IEntityControl
|
||||
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassNormal);
|
||||
}
|
||||
|
||||
EntityUid? IEntityControl.UiEntity => ActionId;
|
||||
EntityUid? IEntityControl.UiEntity => Action;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
|
||||
private bool _bwoinkSoundEnabled;
|
||||
private string? _aHelpSound;
|
||||
|
||||
protected override string SawmillName => "c.s.go.es.bwoink";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -129,7 +131,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
|
||||
|
||||
private void ReceivedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage message)
|
||||
{
|
||||
Logger.InfoS("c.s.go.es.bwoink", $"@{message.UserId}: {message.Text}");
|
||||
Log.Info($"@{message.UserId}: {message.Text}");
|
||||
var localPlayer = _playerManager.LocalSession;
|
||||
if (localPlayer == null)
|
||||
{
|
||||
|
||||
@@ -28,21 +28,16 @@ namespace Content.Client.UserInterface.Systems.Character;
|
||||
public sealed class CharacterUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CharacterInfoSystem>
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _ent = default!;
|
||||
[Dependency] private readonly ILogManager _logMan = default!;
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
[UISystemDependency] private readonly CharacterInfoSystem _characterInfo = default!;
|
||||
[UISystemDependency] private readonly SpriteSystem _sprite = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_sawmill = _logMan.GetSawmill("character");
|
||||
|
||||
SubscribeNetworkEvent<MindRoleTypeChangedEvent>(OnRoleTypeChanged);
|
||||
}
|
||||
|
||||
@@ -222,7 +217,7 @@ public sealed class CharacterUIController : UIController, IOnStateEntered<Gamepl
|
||||
return;
|
||||
|
||||
if (!_prototypeManager.TryIndex(mind.RoleType, out var proto))
|
||||
_sawmill.Error($"Player '{_player.LocalSession}' has invalid Role Type '{mind.RoleType}'. Displaying default instead");
|
||||
Log.Error($"Player '{_player.LocalSession}' has invalid Role Type '{mind.RoleType}'. Displaying default instead");
|
||||
|
||||
_window.RoleType.Text = Loc.GetString(proto?.Name ?? "role-type-crew-aligned-name");
|
||||
_window.RoleType.FontColorOverride = proto?.Color ?? Color.White;
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controllers;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Client.CharacterInfo;
|
||||
using static Content.Client.CharacterInfo.CharacterInfoSystem;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// A partial class of ChatUIController that handles the saving and loading of highlights for the chatbox.
|
||||
/// It also makes use of the CharacterInfoSystem to optionally generate highlights based on the character's info.
|
||||
/// </summary>
|
||||
public sealed partial class ChatUIController : IOnSystemChanged<CharacterInfoSystem>
|
||||
{
|
||||
[UISystemDependency] private readonly CharacterInfoSystem _characterInfo = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The list of words to be highlighted in the chatbox.
|
||||
/// </summary>
|
||||
private List<string> _highlights = new();
|
||||
|
||||
/// <summary>
|
||||
/// The string holding the hex color used to highlight words.
|
||||
/// </summary>
|
||||
private string? _highlightsColor;
|
||||
|
||||
private bool _autoFillHighlightsEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// The boolean that keeps track of the 'OnCharacterUpdated' event, whenever it's a player attaching or opening the character info panel.
|
||||
/// </summary>
|
||||
private bool _charInfoIsAttach = false;
|
||||
|
||||
public event Action<string>? HighlightsUpdated;
|
||||
|
||||
private void InitializeHighlights()
|
||||
{
|
||||
_config.OnValueChanged(CCVars.ChatAutoFillHighlights, (value) => { _autoFillHighlightsEnabled = value; }, true);
|
||||
|
||||
_config.OnValueChanged(CCVars.ChatHighlightsColor, (value) => { _highlightsColor = value; }, true);
|
||||
|
||||
// Load highlights if any were saved.
|
||||
string highlights = _config.GetCVar(CCVars.ChatHighlights);
|
||||
|
||||
if (!string.IsNullOrEmpty(highlights))
|
||||
{
|
||||
UpdateHighlights(highlights, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSystemLoaded(CharacterInfoSystem system)
|
||||
{
|
||||
system.OnCharacterUpdate += OnCharacterUpdated;
|
||||
}
|
||||
|
||||
public void OnSystemUnloaded(CharacterInfoSystem system)
|
||||
{
|
||||
system.OnCharacterUpdate -= OnCharacterUpdated;
|
||||
}
|
||||
|
||||
private void UpdateAutoFillHighlights()
|
||||
{
|
||||
if (!_autoFillHighlightsEnabled)
|
||||
return;
|
||||
|
||||
// If auto highlights are enabled generate a request for new character info
|
||||
// that will be used to determine the highlights.
|
||||
_charInfoIsAttach = true;
|
||||
_characterInfo.RequestCharacterInfo();
|
||||
}
|
||||
|
||||
public void UpdateHighlights(string newHighlights, bool firstLoad = false)
|
||||
{
|
||||
// Do nothing if the provided highlights are the same as the old ones and it is not the first time.
|
||||
if (!firstLoad && _config.GetCVar(CCVars.ChatHighlights).Equals(newHighlights, StringComparison.CurrentCultureIgnoreCase))
|
||||
return;
|
||||
|
||||
_config.SetCVar(CCVars.ChatHighlights, newHighlights);
|
||||
_config.SaveToFile();
|
||||
|
||||
_highlights.Clear();
|
||||
|
||||
// We first subdivide the highlights based on newlines to prevent replacing
|
||||
// a valid "\n" tag and adding it to the final regex.
|
||||
string[] splittedHighlights = newHighlights.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
|
||||
for (int i = 0; i < splittedHighlights.Length; i++)
|
||||
{
|
||||
// Replace every "\" character with a "\\" to prevent "\n", "\0", etc...
|
||||
string keyword = splittedHighlights[i].Replace(@"\", @"\\");
|
||||
|
||||
// Escape the keyword to prevent special characters like "(" and ")" to be considered valid regex.
|
||||
keyword = Regex.Escape(keyword);
|
||||
|
||||
// 1. Since the "["s in WrappedMessage are already sanitized, add 2 extra "\"s
|
||||
// to make sure it matches the literal "\" before the square bracket.
|
||||
keyword = keyword.Replace(@"\[", @"\\\[");
|
||||
|
||||
// If present, replace the double quotes at the edges with tags
|
||||
// that make sure the words to match are separated by spaces or punctuation.
|
||||
// NOTE: The reason why we don't use \b tags is that \b doesn't match reverse slash characters "\" so
|
||||
// a pre-sanitized (see 1.) string like "\[test]" wouldn't get picked up by the \b.
|
||||
if (keyword.Count(c => (c == '"')) > 0)
|
||||
{
|
||||
// Matches the last double quote character.
|
||||
keyword = Regex.Replace(keyword, "\"$", "(?!\\w)");
|
||||
// When matching for the first double quote character we also consider the possibility
|
||||
// of the double quote being preceded by a @ character.
|
||||
keyword = Regex.Replace(keyword, "^\"|(?<=^@)\"", "(?<!\\w)");
|
||||
}
|
||||
|
||||
// Make sure any name tagged as ours gets highlighted only when others say it.
|
||||
keyword = Regex.Replace(keyword, "^@", "(?<=(?<=/name.*)|(?<=,.*\"\".*))");
|
||||
|
||||
_highlights.Add(keyword);
|
||||
}
|
||||
|
||||
// Arrange the list of highlights in descending order so that when highlighting,
|
||||
// the full word (eg. "Security") gets picked before the abbreviation (eg. "Sec").
|
||||
_highlights.Sort((x, y) => y.Length.CompareTo(x.Length));
|
||||
}
|
||||
|
||||
private void OnCharacterUpdated(CharacterData data)
|
||||
{
|
||||
// If _charInfoIsAttach is false then the opening of the character panel was the one
|
||||
// to generate the event, dismiss it.
|
||||
if (!_charInfoIsAttach)
|
||||
return;
|
||||
|
||||
var (_, job, _, _, entityName) = data;
|
||||
|
||||
// Mark this entity's name as our character name for the "UpdateHighlights" function.
|
||||
string newHighlights = "@" + entityName;
|
||||
|
||||
// Subdivide the character's name based on spaces or hyphens so that every word gets highlighted.
|
||||
if (newHighlights.Count(c => (c == ' ' || c == '-')) == 1)
|
||||
newHighlights = newHighlights.Replace("-", "\n@").Replace(" ", "\n@");
|
||||
|
||||
// If the character has a name with more than one hyphen assume it is a lizard name and extract the first and
|
||||
// last name eg. "Eats-The-Food" -> "@Eats" "@Food"
|
||||
if (newHighlights.Count(c => c == '-') > 1)
|
||||
newHighlights = newHighlights.Split('-')[0] + "\n@" + newHighlights.Split('-')[^1];
|
||||
|
||||
// Convert the job title to kebab-case and use it as a key for the loc file.
|
||||
string jobKey = job.Replace(' ', '-').ToLower();
|
||||
|
||||
if (Loc.TryGetString($"highlights-{jobKey}", out var jobMatches))
|
||||
newHighlights += '\n' + jobMatches.Replace(", ", "\n");
|
||||
|
||||
UpdateHighlights(newHighlights);
|
||||
HighlightsUpdated?.Invoke(newHighlights);
|
||||
_charInfoIsAttach = false;
|
||||
}
|
||||
}
|
||||
@@ -41,9 +41,10 @@ using Robust.Shared.Replays;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Chat;
|
||||
|
||||
public sealed class ChatUIController : UIController
|
||||
public sealed partial class ChatUIController : UIController
|
||||
{
|
||||
[Dependency] private readonly IClientAdminManager _admin = default!;
|
||||
[Dependency] private readonly IChatManager _manager = default!;
|
||||
@@ -240,6 +241,7 @@ public sealed class ChatUIController : UIController
|
||||
|
||||
_config.OnValueChanged(CCVars.ChatWindowOpacity, OnChatWindowOpacityChanged);
|
||||
|
||||
InitializeHighlights();
|
||||
}
|
||||
|
||||
public void OnScreenLoad()
|
||||
@@ -426,6 +428,8 @@ public sealed class ChatUIController : UIController
|
||||
private void OnAttachedChanged(EntityUid uid)
|
||||
{
|
||||
UpdateChannelPermissions();
|
||||
|
||||
UpdateAutoFillHighlights();
|
||||
}
|
||||
|
||||
private void AddSpeechBubble(ChatMessage msg, SpeechBubble.SpeechType speechType)
|
||||
@@ -825,6 +829,12 @@ public sealed class ChatUIController : UIController
|
||||
msg.WrappedMessage = SharedChatSystem.InjectTagInsideTag(msg, "Name", "color", GetNameColor(SharedChatSystem.GetStringInsideTag(msg, "Name")));
|
||||
}
|
||||
|
||||
// Color any words chosen by the client.
|
||||
foreach (var highlight in _highlights)
|
||||
{
|
||||
msg.WrappedMessage = SharedChatSystem.InjectTagAroundString(msg, highlight, "color", _highlightsColor);
|
||||
}
|
||||
|
||||
// Color any codewords for minds that have roles that use them
|
||||
if (_player.LocalUser != null && _mindSystem != null && _roleCodewordSystem != null)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
<controls:ChannelFilterPopup
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Systems.Chat.Controls">
|
||||
<PanelContainer Name="FilterPopupPanel" StyleClasses="BorderedWindowPanel">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Control MinSize="4 0"/>
|
||||
<BoxContainer Name="FilterVBox" MinWidth="110" Margin="0 10" Orientation="Vertical" SeparationOverride="4"/>
|
||||
<BoxContainer Orientation="Horizontal" SeparationOverride="8" Margin="10 0">
|
||||
<BoxContainer Name="FilterVBox" MinWidth="105" Margin="0 10" Orientation="Vertical" SeparationOverride="4"/>
|
||||
<BoxContainer Name="HighlightsVBox" MinWidth="120" Margin="0 10" Orientation="Vertical" SeparationOverride="4">
|
||||
<Label Text="{Loc 'hud-chatbox-highlights'}"/>
|
||||
<PanelContainer>
|
||||
<!-- Begin custom background for TextEdit -->
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#323446"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<!-- End custom background -->
|
||||
<TextEdit Name="HighlightEdit" MinHeight="150" Margin="5 5"/>
|
||||
</PanelContainer>
|
||||
<Button Name="HighlightButton" Text="{Loc 'hud-chatbox-highlights-button'}" ToolTip="{Loc 'hud-chatbox-highlights-tooltip'}"/>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</controls:ChannelFilterPopup>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
@@ -29,10 +32,24 @@ public sealed partial class ChannelFilterPopup : Popup
|
||||
private readonly Dictionary<ChatChannel, ChannelFilterCheckbox> _filterStates = new();
|
||||
|
||||
public event Action<ChatChannel, bool>? OnChannelFilter;
|
||||
public event Action<string>? OnNewHighlights;
|
||||
|
||||
public ChannelFilterPopup()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
HighlightButton.OnPressed += HighlightsEntered;
|
||||
// Add a placeholder text to the highlights TextEdit.
|
||||
HighlightEdit.Placeholder = new Rope.Leaf(Loc.GetString("hud-chatbox-highlights-placeholder"));
|
||||
|
||||
// Load highlights if any were saved.
|
||||
var cfg = IoCManager.Resolve<IConfigurationManager>();
|
||||
string highlights = cfg.GetCVar(CCVars.ChatHighlights);
|
||||
|
||||
if (!string.IsNullOrEmpty(highlights))
|
||||
{
|
||||
UpdateHighlights(highlights);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsActive(ChatChannel channel)
|
||||
@@ -92,12 +109,22 @@ public sealed partial class ChannelFilterPopup : Popup
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateHighlights(string highlights)
|
||||
{
|
||||
HighlightEdit.TextRope = new Rope.Leaf(highlights);
|
||||
}
|
||||
|
||||
private void CheckboxPressed(ButtonEventArgs args)
|
||||
{
|
||||
var checkbox = (ChannelFilterCheckbox) args.Button;
|
||||
OnChannelFilter?.Invoke(checkbox.Channel, checkbox.Pressed);
|
||||
}
|
||||
|
||||
private void HighlightsEntered(ButtonEventArgs _args)
|
||||
{
|
||||
OnNewHighlights?.Invoke(Rope.Collapse(HighlightEdit.TextRope));
|
||||
}
|
||||
|
||||
public void UpdateUnread(ChatChannel channel, int? unread)
|
||||
{
|
||||
if (_filterStates.TryGetValue(channel, out var checkbox))
|
||||
|
||||
@@ -38,9 +38,10 @@ public partial class ChatBox : UIWidget
|
||||
ChatInput.Input.OnFocusExit += OnFocusExit;
|
||||
ChatInput.ChannelSelector.OnChannelSelect += OnChannelSelect;
|
||||
ChatInput.FilterButton.Popup.OnChannelFilter += OnChannelFilter;
|
||||
|
||||
ChatInput.FilterButton.Popup.OnNewHighlights += OnNewHighlights;
|
||||
_controller = UserInterfaceManager.GetUIController<ChatUIController>();
|
||||
_controller.MessageAdded += OnMessageAdded;
|
||||
_controller.HighlightsUpdated += OnHighlightsUpdated;
|
||||
_controller.RegisterChat(this);
|
||||
}
|
||||
|
||||
@@ -67,6 +68,11 @@ public partial class ChatBox : UIWidget
|
||||
AddLine(msg.WrappedMessage, color);
|
||||
}
|
||||
|
||||
private void OnHighlightsUpdated(string highlights)
|
||||
{
|
||||
ChatInput.FilterButton.Popup.UpdateHighlights(highlights);
|
||||
}
|
||||
|
||||
private void OnChannelSelect(ChatSelectChannel channel)
|
||||
{
|
||||
_controller.UpdateSelectedChannel(this);
|
||||
@@ -97,6 +103,11 @@ public partial class ChatBox : UIWidget
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNewHighlights(string highlighs)
|
||||
{
|
||||
_controller.UpdateHighlights(highlighs);
|
||||
}
|
||||
|
||||
public void AddLine(string message, Color color)
|
||||
{
|
||||
var formatted = new FormattedMessage(3);
|
||||
|
||||
@@ -227,7 +227,7 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(guideId, out var guide))
|
||||
{
|
||||
Logger.Error($"Encountered unknown guide prototype: {guideId}");
|
||||
Log.Error($"Encountered unknown guide prototype: {guideId}");
|
||||
continue;
|
||||
}
|
||||
guides.Add(guideId, guide);
|
||||
@@ -257,7 +257,7 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
|
||||
|
||||
if (!_prototypeManager.TryIndex(childId, out var child))
|
||||
{
|
||||
Logger.Error($"Encountered unknown guide prototype: {childId} as a child of {guide.Id}. If the child is not a prototype, it must be directly provided.");
|
||||
Log.Error($"Encountered unknown guide prototype: {childId} as a child of {guide.Id}. If the child is not a prototype, it must be directly provided.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,22 +15,21 @@ public sealed class InfoUIController : UIController, IOnStateExited<GameplayStat
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
[Dependency] private readonly INetManager _netManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly ILogManager _logMan = default!;
|
||||
|
||||
private RulesPopup? _rulesPopup;
|
||||
private RulesAndInfoWindow? _infoWindow;
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
[ValidatePrototypeId<GuideEntryPrototype>]
|
||||
private const string DefaultRuleset = "DefaultRuleset";
|
||||
|
||||
public ProtoId<GuideEntryPrototype> RulesEntryId = DefaultRuleset;
|
||||
|
||||
protected override string SawmillName => "rules";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_sawmill = _logMan.GetSawmill("rules");
|
||||
_netManager.RegisterNetMessage<RulesAcceptedMessage>();
|
||||
_netManager.RegisterNetMessage<SendRulesInformationMessage>(OnRulesInformationMessage);
|
||||
|
||||
@@ -94,7 +93,7 @@ public sealed class InfoUIController : UIController, IOnStateExited<GameplayStat
|
||||
if (!_prototype.TryIndex(RulesEntryId, out var guideEntryPrototype))
|
||||
{
|
||||
guideEntryPrototype = _prototype.Index<GuideEntryPrototype>(DefaultRuleset);
|
||||
_sawmill.Error($"Couldn't find the following prototype: {RulesEntryId}. Falling back to {DefaultRuleset}, please check that the server has the rules set up correctly");
|
||||
Log.Error($"Couldn't find the following prototype: {RulesEntryId}. Falling back to {DefaultRuleset}, please check that the server has the rules set up correctly");
|
||||
return guideEntryPrototype;
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
|
||||
{
|
||||
if (_inventoryHotbar == null)
|
||||
{
|
||||
Logger.Warning("Tried to toggle inventory bar when none are assigned");
|
||||
Log.Warning("Tried to toggle inventory bar when none are assigned");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,6 @@ public sealed class ViewportUIController : UIController
|
||||
|
||||
// Currently, this shouldn't happen. This likely happened because the main eye was set to null. When this
|
||||
// does happen it can create hard to troubleshoot bugs, so lets print some helpful warnings:
|
||||
Logger.Warning($"Main viewport's eye is in nullspace (main eye is null?). Attached entity: {_entMan.ToPrettyString(ent.Value)}. Entity has eye comp: {eye != null}");
|
||||
Log.Warning($"Main viewport's eye is in nullspace (main eye is null?). Attached entity: {_entMan.ToPrettyString(ent.Value)}. Entity has eye comp: {eye != null}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user