Hud refactor (#7202)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Jezithyr <jmaster9999@gmail.com> Co-authored-by: Jezithyr <Jezithyr@gmail.com> Co-authored-by: Visne <39844191+Visne@users.noreply.github.com> Co-authored-by: wrexbe <wrexbe@protonmail.com> Co-authored-by: wrexbe <81056464+wrexbe@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,676 @@
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Content.Client.Actions;
|
||||
using Content.Client.DragDrop;
|
||||
using Content.Client.Gameplay;
|
||||
using Content.Client.Hands;
|
||||
using Content.Client.Outline;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Client.UserInterface.Systems.Actions.Controls;
|
||||
using Content.Client.UserInterface.Systems.Actions.Widgets;
|
||||
using Content.Client.UserInterface.Systems.Actions.Windows;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controllers;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Client.Actions.ActionsSystem;
|
||||
using static Content.Client.UserInterface.Systems.Actions.Windows.ActionsWindow;
|
||||
using static Robust.Client.UserInterface.Control;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
using static Robust.Client.UserInterface.Controls.LineEdit;
|
||||
using static Robust.Client.UserInterface.Controls.MultiselectOptionButton<
|
||||
Content.Client.UserInterface.Systems.Actions.Windows.ActionsWindow.Filters>;
|
||||
using static Robust.Client.UserInterface.Controls.TextureRect;
|
||||
using static Robust.Shared.Input.Binding.PointerInputCmdHandler;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Actions;
|
||||
|
||||
public sealed class ActionUIController : UIController, IOnStateChanged<GameplayState>, IOnSystemChanged<ActionsSystem>
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
[Dependency] private readonly IOverlayManager _overlays = default!;
|
||||
|
||||
[UISystemDependency] private readonly ActionsSystem _actionsSystem = default!;
|
||||
[UISystemDependency] private readonly InteractionOutlineSystem _interactionOutline = default!;
|
||||
[UISystemDependency] private readonly TargetOutlineSystem _targetOutline = default!;
|
||||
|
||||
private const int DefaultPageIndex = 0;
|
||||
private ActionButtonContainer? _container;
|
||||
private readonly List<ActionPage> _pages = new();
|
||||
private int _currentPageIndex = DefaultPageIndex;
|
||||
private readonly DragDropHelper<ActionButton> _menuDragHelper;
|
||||
private readonly TextureRect _dragShadow;
|
||||
private ActionsWindow? _window;
|
||||
|
||||
private ActionsBar? _actionsBar;
|
||||
private MenuButton? _actionButton;
|
||||
private ActionPage CurrentPage => _pages[_currentPageIndex];
|
||||
|
||||
public bool IsDragging => _menuDragHelper.IsDragging;
|
||||
|
||||
/// <summary>
|
||||
/// Action slot we are currently selecting a target for.
|
||||
/// </summary>
|
||||
public ActionButton? SelectingTargetFor { get; private set; }
|
||||
|
||||
public ActionUIController()
|
||||
{
|
||||
_menuDragHelper = new DragDropHelper<ActionButton>(OnMenuBeginDrag, OnMenuContinueDrag, OnMenuEndDrag);
|
||||
_dragShadow = new TextureRect
|
||||
{
|
||||
MinSize = (64, 64),
|
||||
Stretch = StretchMode.Scale,
|
||||
Visible = false,
|
||||
SetSize = (64, 64),
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
|
||||
var pageCount = ContentKeyFunctions.GetLoadoutBoundKeys().Length;
|
||||
var buttonCount = ContentKeyFunctions.GetHotbarBoundKeys().Length;
|
||||
for (var i = 0; i < pageCount; i++)
|
||||
{
|
||||
var page = new ActionPage(buttonCount);
|
||||
_pages.Add(page);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnStateEntered(GameplayState state)
|
||||
{
|
||||
DebugTools.Assert(_window == null);
|
||||
_window = UIManager.CreateWindow<ActionsWindow>();
|
||||
_actionButton = UIManager.GetActiveUIWidget<MenuBar.Widgets.GameTopMenuBar>().ActionButton;
|
||||
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
|
||||
_window.OnClose += () => { _actionButton.Pressed = false; };
|
||||
_window.OnOpen += () => { _actionButton.Pressed = true; };
|
||||
_window.ClearButton.OnPressed += OnClearPressed;
|
||||
_window.SearchBar.OnTextChanged += OnSearchChanged;
|
||||
_window.FilterButton.OnItemSelected += OnFilterSelected;
|
||||
UpdateFilterLabel();
|
||||
SearchAndDisplay();
|
||||
|
||||
_actionsBar = UIManager.GetActiveUIWidget<ActionsBar>();
|
||||
_actionsBar.PageButtons.LeftArrow.OnPressed += OnLeftArrowPressed;
|
||||
_actionsBar.PageButtons.RightArrow.OnPressed += OnRightArrowPressed;
|
||||
_actionButton.OnPressed += ActionButtonPressed;
|
||||
_dragShadow.Orphan();
|
||||
UIManager.PopupRoot.AddChild(_dragShadow);
|
||||
|
||||
var builder = CommandBinds.Builder;
|
||||
var hotbarKeys = ContentKeyFunctions.GetHotbarBoundKeys();
|
||||
for (var i = 0; i < hotbarKeys.Length; i++)
|
||||
{
|
||||
var boundId = i; // This is needed, because the lambda captures it.
|
||||
var boundKey = hotbarKeys[i];
|
||||
builder = builder.Bind(boundKey, new PointerInputCmdHandler((in PointerInputCmdArgs args) =>
|
||||
{
|
||||
if (args.State != BoundKeyState.Up)
|
||||
return false;
|
||||
|
||||
TriggerAction(boundId);
|
||||
return true;
|
||||
}, false));
|
||||
}
|
||||
|
||||
var loadoutKeys = ContentKeyFunctions.GetLoadoutBoundKeys();
|
||||
for (var i = 0; i < loadoutKeys.Length; i++)
|
||||
{
|
||||
var boundId = i; // This is needed, because the lambda captures it.
|
||||
var boundKey = loadoutKeys[i];
|
||||
builder = builder.Bind(boundKey,
|
||||
InputCmdHandler.FromDelegate(_ => ChangePage(boundId)));
|
||||
}
|
||||
|
||||
builder
|
||||
.Bind(ContentKeyFunctions.OpenActionsMenu,
|
||||
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
|
||||
.Register<ActionUIController>();
|
||||
}
|
||||
|
||||
public void OnStateExited(GameplayState state)
|
||||
{
|
||||
if (_window != null)
|
||||
{
|
||||
_window.Dispose();
|
||||
_window = null;
|
||||
}
|
||||
|
||||
if (_actionsBar != null)
|
||||
{
|
||||
_actionsBar.PageButtons.LeftArrow.OnPressed -= OnLeftArrowPressed;
|
||||
_actionsBar.PageButtons.RightArrow.OnPressed -= OnRightArrowPressed;
|
||||
}
|
||||
|
||||
if (_actionButton != null)
|
||||
{
|
||||
_actionButton.OnPressed -= ActionButtonPressed;
|
||||
_actionButton.Pressed = false;
|
||||
}
|
||||
|
||||
CommandBinds.Unregister<ActionUIController>();
|
||||
}
|
||||
|
||||
private void TriggerAction(int index)
|
||||
{
|
||||
if (CurrentPage[index] is not { } type)
|
||||
return;
|
||||
|
||||
_actionsSystem.TriggerAction(type);
|
||||
}
|
||||
|
||||
private void ChangePage(int index)
|
||||
{
|
||||
var lastPage = _pages.Count - 1;
|
||||
if (index < 0)
|
||||
{
|
||||
index = lastPage;
|
||||
}
|
||||
else if (index > lastPage)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
_currentPageIndex = index;
|
||||
var page = _pages[_currentPageIndex];
|
||||
_container?.SetActionData(page);
|
||||
|
||||
_actionsBar!.PageButtons.Label.Text = $"{_currentPageIndex + 1}";
|
||||
}
|
||||
|
||||
private void OnLeftArrowPressed(ButtonEventArgs args)
|
||||
{
|
||||
ChangePage(_currentPageIndex - 1);
|
||||
}
|
||||
|
||||
private void OnRightArrowPressed(ButtonEventArgs args)
|
||||
{
|
||||
ChangePage(_currentPageIndex + 1);
|
||||
}
|
||||
|
||||
private void ActionButtonPressed(ButtonEventArgs args)
|
||||
{
|
||||
ToggleWindow();
|
||||
}
|
||||
|
||||
private void ToggleWindow()
|
||||
{
|
||||
if (_window == null)
|
||||
return;
|
||||
|
||||
if (_window.IsOpen)
|
||||
{
|
||||
_window.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
_window.Open();
|
||||
}
|
||||
|
||||
private void UpdateFilterLabel()
|
||||
{
|
||||
if (_window == null)
|
||||
return;
|
||||
|
||||
if (_window.FilterButton.SelectedKeys.Count == 0)
|
||||
{
|
||||
_window.FilterLabel.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_window.FilterLabel.Visible = true;
|
||||
_window.FilterLabel.Text = Loc.GetString("ui-actionmenu-filter-label",
|
||||
("selectedLabels", string.Join(", ", _window.FilterButton.SelectedLabels)));
|
||||
}
|
||||
}
|
||||
|
||||
private bool MatchesFilter(ActionType action, Filters filter)
|
||||
{
|
||||
return filter switch
|
||||
{
|
||||
Filters.Enabled => action.Enabled,
|
||||
Filters.Item => action.Provider != null && action.Provider != _actionsSystem.PlayerActions?.Owner,
|
||||
Filters.Innate => action.Provider == null || action.Provider == _actionsSystem.PlayerActions?.Owner,
|
||||
Filters.Instant => action is InstantAction,
|
||||
Filters.Targeted => action is TargetedAction,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(filter), filter, null)
|
||||
};
|
||||
}
|
||||
|
||||
private void ClearList()
|
||||
{
|
||||
_window?.ResultsGrid.RemoveAllChildren();
|
||||
}
|
||||
|
||||
private void PopulateActions(IEnumerable<ActionType> actions)
|
||||
{
|
||||
if (_window == null)
|
||||
return;
|
||||
|
||||
ClearList();
|
||||
|
||||
foreach (var action in actions)
|
||||
{
|
||||
var button = new ActionButton {Locked = true};
|
||||
|
||||
button.UpdateData(_entities, action);
|
||||
button.ActionPressed += OnWindowActionPressed;
|
||||
button.ActionUnpressed += OnWindowActionUnPressed;
|
||||
button.ActionFocusExited += OnWindowActionFocusExisted;
|
||||
|
||||
_window.ResultsGrid.AddChild(button);
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchAndDisplay()
|
||||
{
|
||||
if (_window == null)
|
||||
return;
|
||||
|
||||
var search = _window.SearchBar.Text;
|
||||
var filters = _window.FilterButton.SelectedKeys;
|
||||
|
||||
IEnumerable<ActionType>? actions = _actionsSystem.PlayerActions?.Actions;
|
||||
actions ??= Array.Empty<ActionType>();
|
||||
|
||||
if (filters.Count == 0 && string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
PopulateActions(actions);
|
||||
return;
|
||||
}
|
||||
|
||||
actions = actions.Where(action =>
|
||||
{
|
||||
if (filters.Count > 0 && filters.Any(filter => !MatchesFilter(action, filter)))
|
||||
return false;
|
||||
|
||||
if (action.Keywords.Any(keyword => search.Contains(keyword, StringComparison.OrdinalIgnoreCase)))
|
||||
return true;
|
||||
|
||||
if (action.DisplayName.Contains((string) search, StringComparison.OrdinalIgnoreCase))
|
||||
return true;
|
||||
|
||||
if (action.Provider == null || action.Provider == _actionsSystem.PlayerActions?.Owner)
|
||||
return false;
|
||||
|
||||
var name = _entities.GetComponent<MetaDataComponent>(action.Provider.Value).EntityName;
|
||||
return name.Contains((string) search, StringComparison.OrdinalIgnoreCase);
|
||||
});
|
||||
|
||||
PopulateActions(actions);
|
||||
}
|
||||
|
||||
private void SetAction(ActionButton button, ActionType? type)
|
||||
{
|
||||
int position;
|
||||
|
||||
if (type == null)
|
||||
{
|
||||
button.ClearData();
|
||||
if (_container?.TryGetButtonIndex(button, out position) ?? false)
|
||||
{
|
||||
CurrentPage[position] = type;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (button.TryReplaceWith(_entities, type) &&
|
||||
_container != null &&
|
||||
_container.TryGetButtonIndex(button, out position))
|
||||
{
|
||||
CurrentPage[position] = type;
|
||||
}
|
||||
}
|
||||
|
||||
private void DragAction()
|
||||
{
|
||||
if (UIManager.CurrentlyHovered is ActionButton button)
|
||||
{
|
||||
if (!_menuDragHelper.IsDragging || _menuDragHelper.Dragged?.Action is not { } type)
|
||||
{
|
||||
_menuDragHelper.EndDrag();
|
||||
return;
|
||||
}
|
||||
|
||||
SetAction(button, type);
|
||||
}
|
||||
|
||||
if (_menuDragHelper.Dragged is {Parent: ActionButtonContainer} old)
|
||||
{
|
||||
SetAction(old, null);
|
||||
}
|
||||
|
||||
_menuDragHelper.EndDrag();
|
||||
}
|
||||
|
||||
private void OnClearPressed(ButtonEventArgs args)
|
||||
{
|
||||
if (_window == null)
|
||||
return;
|
||||
|
||||
_window.SearchBar.Clear();
|
||||
_window.FilterButton.DeselectAll();
|
||||
UpdateFilterLabel();
|
||||
SearchAndDisplay();
|
||||
}
|
||||
|
||||
private void OnSearchChanged(LineEditEventArgs args)
|
||||
{
|
||||
SearchAndDisplay();
|
||||
}
|
||||
|
||||
private void OnFilterSelected(ItemPressedEventArgs args)
|
||||
{
|
||||
UpdateFilterLabel();
|
||||
SearchAndDisplay();
|
||||
}
|
||||
|
||||
private void OnWindowActionPressed(GUIBoundKeyEventArgs args, ActionButton action)
|
||||
{
|
||||
if (args.Function != EngineKeyFunctions.UIClick && args.Function != EngineKeyFunctions.Use)
|
||||
return;
|
||||
|
||||
_menuDragHelper.MouseDown(action);
|
||||
args.Handle();
|
||||
}
|
||||
|
||||
private void OnWindowActionUnPressed(GUIBoundKeyEventArgs args, ActionButton dragged)
|
||||
{
|
||||
if (args.Function != EngineKeyFunctions.UIClick && args.Function != EngineKeyFunctions.Use)
|
||||
return;
|
||||
|
||||
DragAction();
|
||||
args.Handle();
|
||||
}
|
||||
|
||||
private void OnWindowActionFocusExisted(ActionButton button)
|
||||
{
|
||||
_menuDragHelper.EndDrag();
|
||||
}
|
||||
|
||||
private void OnActionPressed(GUIBoundKeyEventArgs args, ActionButton button)
|
||||
{
|
||||
if (args.Function == EngineKeyFunctions.UIClick)
|
||||
{
|
||||
_menuDragHelper.MouseDown(button);
|
||||
args.Handle();
|
||||
}
|
||||
else if (args.Function == EngineKeyFunctions.UIRightClick)
|
||||
{
|
||||
SetAction(button, null);
|
||||
args.Handle();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnActionUnpressed(GUIBoundKeyEventArgs args, ActionButton button)
|
||||
{
|
||||
if (args.Function != EngineKeyFunctions.UIClick)
|
||||
return;
|
||||
|
||||
if (UIManager.CurrentlyHovered == button)
|
||||
{
|
||||
if (button.Action is not InstantAction)
|
||||
{
|
||||
// for target actions, we go into "select target" mode, we don't
|
||||
// message the server until we actually pick our target.
|
||||
|
||||
// if we're clicking the same thing we're already targeting for, then we simply cancel
|
||||
// targeting
|
||||
ToggleTargeting(button);
|
||||
return;
|
||||
}
|
||||
|
||||
_actionsSystem.TriggerAction(button.Action);
|
||||
_menuDragHelper.EndDrag();
|
||||
}
|
||||
else
|
||||
{
|
||||
DragAction();
|
||||
}
|
||||
|
||||
args.Handle();
|
||||
}
|
||||
|
||||
private bool OnMenuBeginDrag()
|
||||
{
|
||||
_dragShadow.Texture = _menuDragHelper.Dragged?.IconTexture;
|
||||
LayoutContainer.SetPosition(_dragShadow, UIManager.MousePositionScaled.Position - (32, 32));
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool OnMenuContinueDrag(float frameTime)
|
||||
{
|
||||
LayoutContainer.SetPosition(_dragShadow, UIManager.MousePositionScaled.Position - (32, 32));
|
||||
_dragShadow.Visible = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnMenuEndDrag()
|
||||
{
|
||||
_dragShadow.Visible = false;
|
||||
}
|
||||
|
||||
public void RegisterActionContainer(ActionButtonContainer container)
|
||||
{
|
||||
if (_container != null)
|
||||
{
|
||||
Logger.Warning("Action container already defined for UI controller");
|
||||
return;
|
||||
}
|
||||
|
||||
_container = container;
|
||||
_container.ActionPressed += OnActionPressed;
|
||||
_container.ActionUnpressed += OnActionUnpressed;
|
||||
}
|
||||
|
||||
public void ClearActions()
|
||||
{
|
||||
_container?.ClearActionData();
|
||||
}
|
||||
|
||||
private void AssignSlots(List<SlotAssignment> assignments)
|
||||
{
|
||||
foreach (ref var assignment in CollectionsMarshal.AsSpan(assignments))
|
||||
{
|
||||
_pages[assignment.Hotbar][assignment.Slot] = assignment.Action;
|
||||
}
|
||||
|
||||
_container?.SetActionData(_pages[_currentPageIndex]);
|
||||
}
|
||||
|
||||
public void RemoveActionContainer()
|
||||
{
|
||||
_container = null;
|
||||
}
|
||||
|
||||
public void OnSystemLoaded(ActionsSystem system)
|
||||
{
|
||||
_actionsSystem.OnLinkActions += OnComponentLinked;
|
||||
_actionsSystem.OnUnlinkActions += OnComponentUnlinked;
|
||||
_actionsSystem.ClearAssignments += ClearActions;
|
||||
_actionsSystem.AssignSlot += AssignSlots;
|
||||
}
|
||||
|
||||
public void OnSystemUnloaded(ActionsSystem system)
|
||||
{
|
||||
_actionsSystem.OnLinkActions -= OnComponentLinked;
|
||||
_actionsSystem.OnUnlinkActions -= OnComponentUnlinked;
|
||||
_actionsSystem.ClearAssignments -= ClearActions;
|
||||
_actionsSystem.AssignSlot -= AssignSlots;
|
||||
}
|
||||
|
||||
public override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
_menuDragHelper.Update(args.DeltaSeconds);
|
||||
}
|
||||
|
||||
private void OnComponentLinked(ActionsComponent component)
|
||||
{
|
||||
LoadDefaultActions(component);
|
||||
_container?.SetActionData(_pages[DefaultPageIndex]);
|
||||
}
|
||||
|
||||
private void OnComponentUnlinked()
|
||||
{
|
||||
_container?.ClearActionData();
|
||||
//TODO: Clear button data
|
||||
}
|
||||
|
||||
private void LoadDefaultActions(ActionsComponent component)
|
||||
{
|
||||
var actions = component.Actions.Where(actionType => actionType.AutoPopulate).ToList();
|
||||
|
||||
var offset = 0;
|
||||
var totalPages = _pages.Count;
|
||||
var pagesLeft = totalPages;
|
||||
var currentPage = DefaultPageIndex;
|
||||
while (pagesLeft > 0)
|
||||
{
|
||||
var page = _pages[currentPage];
|
||||
var pageSize = page.Size;
|
||||
|
||||
for (var slot = 0; slot < pageSize; slot++)
|
||||
{
|
||||
var actionIndex = slot + offset;
|
||||
if (actionIndex < actions.Count)
|
||||
{
|
||||
page[slot] = actions[slot + offset];
|
||||
}
|
||||
else
|
||||
{
|
||||
page[slot] = null;
|
||||
}
|
||||
}
|
||||
|
||||
offset += pageSize;
|
||||
currentPage++;
|
||||
if (currentPage == totalPages)
|
||||
{
|
||||
currentPage = 0;
|
||||
}
|
||||
|
||||
pagesLeft--;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If currently targeting with this slot, stops targeting.
|
||||
/// If currently targeting with no slot or a different slot, switches to
|
||||
/// targeting with the specified slot.
|
||||
/// </summary>
|
||||
/// <param name="slot"></param>
|
||||
public void ToggleTargeting(ActionButton slot)
|
||||
{
|
||||
if (SelectingTargetFor == slot)
|
||||
{
|
||||
StopTargeting();
|
||||
return;
|
||||
}
|
||||
|
||||
StartTargeting(slot);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts us in targeting mode, where we need to pick either a target point or entity
|
||||
/// </summary>
|
||||
private void StartTargeting(ActionButton actionSlot)
|
||||
{
|
||||
if (actionSlot.Action == null)
|
||||
return;
|
||||
|
||||
// If we were targeting something else we should stop
|
||||
StopTargeting();
|
||||
|
||||
SelectingTargetFor = actionSlot;
|
||||
|
||||
if (actionSlot.Action is not TargetedAction action)
|
||||
return;
|
||||
|
||||
// override "held-item" overlay
|
||||
if (action.TargetingIndicator && _overlays.TryGetOverlay<ShowHandItemOverlay>(out var handOverlay))
|
||||
{
|
||||
if (action.ItemIconStyle == ItemActionIconStyle.BigItem && action.Provider != null)
|
||||
{
|
||||
handOverlay.EntityOverride = action.Provider;
|
||||
}
|
||||
else if (action.Toggled && action.IconOn != null)
|
||||
handOverlay.IconOverride = action.IconOn.Frame0();
|
||||
else if (action.Icon != null)
|
||||
handOverlay.IconOverride = action.Icon.Frame0();
|
||||
}
|
||||
|
||||
// TODO: allow world-targets to check valid positions. E.g., maybe:
|
||||
// - Draw a red/green ghost entity
|
||||
// - Add a yes/no checkmark where the HandItemOverlay usually is
|
||||
|
||||
// Highlight valid entity targets
|
||||
if (action is not EntityTargetAction entityAction)
|
||||
return;
|
||||
|
||||
Func<EntityUid, bool>? predicate = null;
|
||||
|
||||
if (!entityAction.CanTargetSelf)
|
||||
predicate = e => e != entityAction.AttachedEntity;
|
||||
|
||||
var range = entityAction.CheckCanAccess ? action.Range : -1;
|
||||
|
||||
_interactionOutline.SetEnabled(false);
|
||||
_targetOutline.Enable(range, entityAction.CheckCanAccess, predicate, entityAction.Whitelist, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switch out of targeting mode if currently selecting target for an action
|
||||
/// </summary>
|
||||
public void StopTargeting()
|
||||
{
|
||||
if (SelectingTargetFor == null)
|
||||
return;
|
||||
|
||||
SelectingTargetFor = null;
|
||||
_targetOutline.Disable();
|
||||
_interactionOutline.SetEnabled(true);
|
||||
|
||||
if (!_overlays.TryGetOverlay<ShowHandItemOverlay>(out var handOverlay) || handOverlay == null)
|
||||
return;
|
||||
|
||||
handOverlay.IconOverride = null;
|
||||
handOverlay.EntityOverride = null;
|
||||
}
|
||||
|
||||
|
||||
//TODO: Serialize this shit
|
||||
private sealed class ActionPage
|
||||
{
|
||||
private readonly ActionType?[] _data;
|
||||
|
||||
public ActionPage(int size)
|
||||
{
|
||||
_data = new ActionType?[size];
|
||||
}
|
||||
|
||||
public ActionType? this[int index]
|
||||
{
|
||||
get => _data[index];
|
||||
set => _data[index] = value;
|
||||
}
|
||||
|
||||
public static implicit operator ActionType?[](ActionPage p)
|
||||
{
|
||||
return p._data.ToArray();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Array.Fill(_data, null);
|
||||
}
|
||||
|
||||
public int Size => _data.Length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
using Content.Client.Actions.UI;
|
||||
using Content.Client.Cooldown;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Actions.Controls;
|
||||
|
||||
public sealed class ActionButton : Control
|
||||
{
|
||||
private ActionUIController Controller => UserInterfaceManager.GetUIController<ActionUIController>();
|
||||
private bool _beingHovered;
|
||||
private bool _depressed;
|
||||
private bool _toggled;
|
||||
|
||||
public BoundKeyFunction? KeyBind
|
||||
{
|
||||
set
|
||||
{
|
||||
_keybind = value;
|
||||
if (_keybind != null)
|
||||
{
|
||||
Label.Text = BoundKeyHelper.ShortKeyName(_keybind.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BoundKeyFunction? _keybind;
|
||||
|
||||
public readonly TextureRect Button;
|
||||
public readonly PanelContainer HighlightRect;
|
||||
public readonly TextureRect Icon;
|
||||
public readonly Label Label;
|
||||
public readonly SpriteView Sprite;
|
||||
public readonly CooldownGraphic Cooldown;
|
||||
|
||||
public Texture? IconTexture
|
||||
{
|
||||
get => Icon.Texture;
|
||||
private set => Icon.Texture = value;
|
||||
}
|
||||
|
||||
public ActionType? Action { get; private set; }
|
||||
public bool Locked { get; set; }
|
||||
|
||||
public event Action<GUIBoundKeyEventArgs, ActionButton>? ActionPressed;
|
||||
public event Action<GUIBoundKeyEventArgs, ActionButton>? ActionUnpressed;
|
||||
public event Action<ActionButton>? ActionFocusExited;
|
||||
|
||||
public ActionButton()
|
||||
{
|
||||
MouseFilter = MouseFilterMode.Pass;
|
||||
Button = new TextureRect
|
||||
{
|
||||
Name = "Button",
|
||||
TextureScale = new Vector2(2, 2)
|
||||
};
|
||||
HighlightRect = new PanelContainer
|
||||
{
|
||||
StyleClasses = {StyleNano.StyleClassHandSlotHighlight},
|
||||
MinSize = (32, 32),
|
||||
Visible = false
|
||||
};
|
||||
Icon = new TextureRect
|
||||
{
|
||||
Name = "Icon",
|
||||
TextureScale = new Vector2(2, 2),
|
||||
MaxSize = (64, 64),
|
||||
Stretch = TextureRect.StretchMode.Scale
|
||||
};
|
||||
Label = new Label
|
||||
{
|
||||
Name = "Label",
|
||||
HorizontalAlignment = HAlignment.Left,
|
||||
VerticalAlignment = VAlignment.Top,
|
||||
Margin = new Thickness(5, 0, 0, 0)
|
||||
};
|
||||
Sprite = new SpriteView
|
||||
{
|
||||
Name = "Sprite",
|
||||
OverrideDirection = Direction.South
|
||||
};
|
||||
Cooldown = new CooldownGraphic {Visible = false};
|
||||
|
||||
AddChild(Button);
|
||||
AddChild(HighlightRect);
|
||||
AddChild(Icon);
|
||||
AddChild(Label);
|
||||
AddChild(Sprite);
|
||||
AddChild(Cooldown);
|
||||
|
||||
Button.Modulate = new Color(255, 255, 255, 150);
|
||||
Icon.Modulate = new Color(255, 255, 255, 150);
|
||||
|
||||
OnThemeUpdated();
|
||||
OnThemeUpdated();
|
||||
|
||||
OnKeyBindDown += args =>
|
||||
{
|
||||
Depress(args, true);
|
||||
OnPressed(args);
|
||||
};
|
||||
OnKeyBindUp += args =>
|
||||
{
|
||||
Depress(args, false);
|
||||
OnUnpressed(args);
|
||||
};
|
||||
|
||||
TooltipDelay = 0.5f;
|
||||
TooltipSupplier = SupplyTooltip;
|
||||
}
|
||||
|
||||
protected override void OnThemeUpdated()
|
||||
{
|
||||
Button.Texture = Theme.ResolveTexture("SlotBackground");
|
||||
Label.FontColorOverride = Theme.ResolveColorOrSpecified("whiteText");
|
||||
}
|
||||
|
||||
private void OnPressed(GUIBoundKeyEventArgs args)
|
||||
{
|
||||
ActionPressed?.Invoke(args, this);
|
||||
}
|
||||
|
||||
private void OnUnpressed(GUIBoundKeyEventArgs args)
|
||||
{
|
||||
ActionUnpressed?.Invoke(args, this);
|
||||
}
|
||||
|
||||
private Control? SupplyTooltip(Control sender)
|
||||
{
|
||||
if (Action == null)
|
||||
return null;
|
||||
|
||||
var name = FormattedMessage.FromMarkupPermissive(Loc.GetString(Action.DisplayName));
|
||||
var decr = FormattedMessage.FromMarkupPermissive(Loc.GetString(Action.Description));
|
||||
|
||||
return new ActionAlertTooltip(name, decr);
|
||||
}
|
||||
|
||||
protected override void ControlFocusExited()
|
||||
{
|
||||
ActionFocusExited?.Invoke(this);
|
||||
}
|
||||
|
||||
public bool TryReplaceWith(IEntityManager entityManager, ActionType action)
|
||||
{
|
||||
if (Locked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
UpdateData(entityManager, action);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateData(IEntityManager entityManager, ActionType action)
|
||||
{
|
||||
Action = action;
|
||||
|
||||
if (action.Icon != null)
|
||||
{
|
||||
IconTexture = GetIcon();
|
||||
Sprite.Sprite = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (action.Provider == null ||
|
||||
!entityManager.TryGetComponent(action.Provider.Value, out SpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IconTexture = null;
|
||||
Sprite.Sprite = sprite;
|
||||
}
|
||||
|
||||
public void ClearData()
|
||||
{
|
||||
Action = null;
|
||||
IconTexture = null;
|
||||
Sprite.Sprite = null;
|
||||
Cooldown.Visible = false;
|
||||
Cooldown.Progress = 1;
|
||||
}
|
||||
|
||||
private Texture? GetIcon()
|
||||
{
|
||||
if (Action == null)
|
||||
return null;
|
||||
|
||||
return _toggled ? (Action.IconOn ?? Action.Icon)?.Frame0() : Action.Icon?.Frame0();
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
|
||||
if (Action?.Cooldown != null)
|
||||
{
|
||||
Cooldown.FromTime(Action.Cooldown.Value.Start, Action.Cooldown.Value.End);
|
||||
}
|
||||
|
||||
if (Action != null && _toggled != Action.Toggled)
|
||||
{
|
||||
_toggled = Action.Toggled;
|
||||
IconTexture = GetIcon();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void MouseEntered()
|
||||
{
|
||||
base.MouseEntered();
|
||||
|
||||
_beingHovered = true;
|
||||
DrawModeChanged();
|
||||
}
|
||||
|
||||
protected override void MouseExited()
|
||||
{
|
||||
base.MouseExited();
|
||||
|
||||
_beingHovered = false;
|
||||
DrawModeChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Press this button down. If it was depressed and now set to not depressed, will
|
||||
/// trigger the action.
|
||||
/// </summary>
|
||||
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})
|
||||
return;
|
||||
|
||||
if (_depressed && !depress)
|
||||
{
|
||||
// fire the action
|
||||
OnUnpressed(args);
|
||||
}
|
||||
|
||||
_depressed = depress;
|
||||
DrawModeChanged();
|
||||
}
|
||||
|
||||
public void DrawModeChanged()
|
||||
{
|
||||
HighlightRect.Visible = _beingHovered;
|
||||
|
||||
// always show the normal empty button style if no action in this slot
|
||||
if (Action == null)
|
||||
{
|
||||
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))
|
||||
{
|
||||
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassHover);
|
||||
}
|
||||
|
||||
// it's only depress-able if it's usable, so if we're depressed
|
||||
// show the depressed style
|
||||
if (_depressed)
|
||||
{
|
||||
HighlightRect.Visible = false;
|
||||
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassPressed);
|
||||
return;
|
||||
}
|
||||
|
||||
// if it's toggled on, always show the toggled on style (currently same as depressed style)
|
||||
if (Action.Toggled || Controller.SelectingTargetFor == this)
|
||||
{
|
||||
// when there's a toggle sprite, we're showing that sprite instead of highlighting this slot
|
||||
SetOnlyStylePseudoClass(Action.IconOn != null
|
||||
? ContainerButton.StylePseudoClassNormal
|
||||
: ContainerButton.StylePseudoClassPressed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Action.Enabled)
|
||||
{
|
||||
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassDisabled);
|
||||
return;
|
||||
}
|
||||
|
||||
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassNormal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Actions.Controls;
|
||||
|
||||
[Virtual]
|
||||
public class ActionButtonContainer : GridContainer
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public event Action<GUIBoundKeyEventArgs, ActionButton>? ActionPressed;
|
||||
public event Action<GUIBoundKeyEventArgs, ActionButton>? ActionUnpressed;
|
||||
public event Action<ActionButton>? ActionFocusExited;
|
||||
|
||||
public ActionButtonContainer()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
UserInterfaceManager.GetUIController<ActionUIController>().RegisterActionContainer(this);
|
||||
}
|
||||
|
||||
public ActionButton this[int index]
|
||||
{
|
||||
get => (ActionButton) GetChild(index);
|
||||
set
|
||||
{
|
||||
AddChild(value);
|
||||
value.SetPositionInParent(index);
|
||||
value.ActionPressed += ActionPressed;
|
||||
value.ActionUnpressed += ActionUnpressed;
|
||||
value.ActionFocusExited += ActionFocusExited;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActionData(params ActionType?[] actionTypes)
|
||||
{
|
||||
ClearActionData();
|
||||
|
||||
for (var i = 0; i < actionTypes.Length; i++)
|
||||
{
|
||||
var action = actionTypes[i];
|
||||
if (action == null)
|
||||
continue;
|
||||
|
||||
((ActionButton) GetChild(i)).UpdateData(_entityManager, action);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearActionData()
|
||||
{
|
||||
foreach (var button in Children)
|
||||
{
|
||||
((ActionButton) button).ClearData();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ChildAdded(Control newChild)
|
||||
{
|
||||
base.ChildAdded(newChild);
|
||||
|
||||
if (newChild is not ActionButton button)
|
||||
return;
|
||||
|
||||
button.ActionPressed += ActionPressed;
|
||||
button.ActionUnpressed += ActionUnpressed;
|
||||
button.ActionFocusExited += ActionFocusExited;
|
||||
}
|
||||
|
||||
public bool TryGetButtonIndex(ActionButton button, out int position)
|
||||
{
|
||||
if (button.Parent != this)
|
||||
{
|
||||
position = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
position = button.GetPositionInParent();
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<ActionButton> GetButtons()
|
||||
{
|
||||
foreach (var control in Children)
|
||||
{
|
||||
if (control is ActionButton button)
|
||||
yield return button;
|
||||
}
|
||||
}
|
||||
|
||||
~ActionButtonContainer()
|
||||
{
|
||||
UserInterfaceManager.GetUIController<ActionUIController>().RemoveActionContainer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<controls:ActionPageButtons
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Systems.Actions.Controls">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Control HorizontalExpand="True" SizeFlagsStretchRatio="1"/>
|
||||
<TextureButton TexturePath="/Textures/Interface/Nano/left_arrow.svg.192dpi.png"
|
||||
SizeFlagsStretchRatio="1"
|
||||
Scale="0.5 0.5"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Name="LeftArrow"
|
||||
Access="Public"/>
|
||||
<Control HorizontalExpand="True" SizeFlagsStretchRatio="2"/>
|
||||
<Label Text="1" SizeFlagsStretchRatio="1" Name="Label" Access="Public" />
|
||||
<Control HorizontalExpand="True" SizeFlagsStretchRatio="2"/>
|
||||
<TextureButton TexturePath="/Textures/Interface/Nano/right_arrow.svg.192dpi.png"
|
||||
SizeFlagsStretchRatio="1"
|
||||
Scale="0.5 0.5"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Name="RightArrow"
|
||||
Access="Public"/>
|
||||
<Control HorizontalExpand="True" SizeFlagsStretchRatio="1"/>
|
||||
</BoxContainer>
|
||||
</controls:ActionPageButtons>
|
||||
@@ -0,0 +1,14 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Actions.Controls;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class ActionPageButtons : Control
|
||||
{
|
||||
public ActionPageButtons()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<controls:ActionTooltip
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Systems.Actions.Controls"
|
||||
StyleClasses="StyleClassTooltipPanel">
|
||||
<BoxContainer Orientation="Vertical" RectClipContent="True">
|
||||
<RichTextLabel MaxWidth="350" StyleClasses="StyleClassTooltipActionTitle"/>
|
||||
<RichTextLabel MaxWidth="350" StyleClasses="StyleClassTooltipActionDescription"/>
|
||||
</BoxContainer>
|
||||
</controls:ActionTooltip>
|
||||
@@ -0,0 +1,14 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Actions.Controls;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class ActionTooltip : PanelContainer
|
||||
{
|
||||
public ActionTooltip()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<widgets:ActionsBar
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:in="clr-namespace:Content.Shared.Input;assembly=Content.Shared"
|
||||
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Actions.Widgets"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Systems.Actions.Controls"
|
||||
VerticalExpand="False"
|
||||
Orientation="Horizontal"
|
||||
HorizontalExpand="False"
|
||||
>
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<controls:ActionButtonContainer
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Name="ActionsContainer"
|
||||
Access="Public"/>
|
||||
<controls:ActionPageButtons Name="PageButtons" Access="Public"/>
|
||||
</BoxContainer>
|
||||
</widgets:ActionsBar>
|
||||
@@ -0,0 +1,34 @@
|
||||
using Content.Client.UserInterface.Systems.Actions.Controls;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Input;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Actions.Widgets;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class ActionsBar : UIWidget
|
||||
{
|
||||
public ActionsBar()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
var keys = ContentKeyFunctions.GetHotbarBoundKeys();
|
||||
for (var index = 1; index < keys.Length; index++)
|
||||
{
|
||||
ActionsContainer.Children.Add(MakeButton(index));
|
||||
}
|
||||
ActionsContainer.Children.Add(MakeButton(0));
|
||||
|
||||
ActionButton MakeButton(int index)
|
||||
{
|
||||
var boundKey = keys[index];
|
||||
var button = new ActionButton();
|
||||
button.KeyBind = boundKey;
|
||||
button.Label.Text = index.ToString();
|
||||
return button;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<windows:ActionsWindow
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:windows="clr-namespace:Content.Client.UserInterface.Systems.Actions.Windows"
|
||||
Name="ActionsList"
|
||||
HorizontalExpand="True"
|
||||
Title="Actions"
|
||||
VerticalExpand="True"
|
||||
Resizable="True"
|
||||
MinHeight="300"
|
||||
MinWidth="300"
|
||||
>
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Name="SearchContainer" Orientation="Horizontal">
|
||||
<LineEdit Name="SearchBar" Access="Public" StyleClasses="actionSearchBox" HorizontalExpand="True"
|
||||
PlaceHolder="{Loc ui-actionmenu-search-bar-placeholder-text}"/>
|
||||
</BoxContainer>
|
||||
<Button Name="ClearButton" Access="Public" Text="{Loc ui-actionmenu-clear-button}"/>
|
||||
<Label Name="FilterLabel" Access="Public"/>
|
||||
<ScrollContainer VerticalExpand="True" HorizontalExpand="True">
|
||||
<GridContainer Name="ResultsGrid" Access="Public" MaxGridWidth="300"/>
|
||||
</ScrollContainer>
|
||||
</BoxContainer>
|
||||
</windows:ActionsWindow>
|
||||
@@ -0,0 +1,36 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.Actions.Windows;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class ActionsWindow : DefaultWindow
|
||||
{
|
||||
public MultiselectOptionButton<Filters> FilterButton { get; private set; }
|
||||
|
||||
public ActionsWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
SearchContainer.AddChild(FilterButton = new MultiselectOptionButton<Filters>
|
||||
{
|
||||
Label = Loc.GetString("ui-actionmenu-filter-button")
|
||||
});
|
||||
|
||||
foreach (var filter in Enum.GetValues<Filters>())
|
||||
{
|
||||
FilterButton.AddItem(filter.ToString(), filter);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Filters
|
||||
{
|
||||
Enabled,
|
||||
Item,
|
||||
Innate,
|
||||
Instant,
|
||||
Targeted
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user