Hotbar Improvements + Item Action Integration Test (#2749)

* my IDE keeps wanting to change this so....

* Add item actions integration test, fix bug where empty item action
dict was left in SharedActionsComponent state

* bigger hotbar arrows

* nice wide hotbar pagination hitboxes

* add ability to switch hotbar loadout
via keybinds

* always highlight on drag over
of actions hotbar

* dont rely on content entity for integration test
This commit is contained in:
chairbender
2020-12-22 06:41:56 -08:00
committed by GitHub
parent 7f7f22ef5d
commit 9a3dee2042
14 changed files with 386 additions and 48 deletions

View File

@@ -110,6 +110,7 @@ namespace Content.Client.UserInterface.Controls
private readonly SpriteView _bigItemSpriteView;
private readonly CooldownGraphic _cooldownGraphic;
private readonly ActionsUI _actionsUI;
private readonly ActionMenu _actionMenu;
private readonly ClientActionsComponent _actionsComponent;
private bool _toggledOn;
// whether button is currently pressed down by mouse or keybind down.
@@ -120,10 +121,11 @@ namespace Content.Client.UserInterface.Controls
/// Creates an action slot for the specified number
/// </summary>
/// <param name="slotIndex">slot index this corresponds to, 0-9 (0 labeled as 1, 8, labeled "9", 9 labeled as "0".</param>
public ActionSlot(ActionsUI actionsUI, ClientActionsComponent actionsComponent, byte slotIndex)
public ActionSlot(ActionsUI actionsUI, ActionMenu actionMenu, ClientActionsComponent actionsComponent, byte slotIndex)
{
_actionsComponent = actionsComponent;
_actionsUI = actionsUI;
_actionMenu = actionMenu;
_gameTiming = IoCManager.Resolve<IGameTiming>();
SlotIndex = slotIndex;
MouseFilter = MouseFilterMode.Stop;
@@ -259,7 +261,7 @@ namespace Content.Client.UserInterface.Controls
if (args.Function == EngineKeyFunctions.UIRightClick)
{
if (!_actionsUI.Locked && !_actionsUI.DragDropHelper.IsDragging)
if (!_actionsUI.Locked && !_actionsUI.DragDropHelper.IsDragging && !_actionMenu.IsDragging)
{
_actionsComponent.Assignments.ClearSlot(_actionsUI.SelectedHotbar, SlotIndex, true);
_actionsUI.StopTargeting();
@@ -582,6 +584,18 @@ namespace Content.Client.UserInterface.Controls
private void DrawModeChanged()
{
// show a hover only if the action is usable or another action is being dragged on top of this
if (_beingHovered)
{
if (_actionsUI.DragDropHelper.IsDragging || _actionMenu.IsDragging ||
(HasAssignment && ActionEnabled && !IsOnCooldown))
{
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassHover);
return;
}
}
// always show the normal empty button style if no action in this slot
if (!HasAssignment)
{
@@ -597,15 +611,6 @@ namespace Content.Client.UserInterface.Controls
return;
}
// show a hover only if the action is usable
if (_beingHovered)
{
if (ActionEnabled && !IsOnCooldown)
{
SetOnlyStylePseudoClass(ContainerButton.StylePseudoClassHover);
return;
}
}
// if it's toggled on, always show the toggled on style (currently same as depressed style)
if (ToggledOn)