#3814 - dropping an item, which adds an action to the actions bar, wi… (#4123)

* #3814 - dropping an item, which adds an action to the actions bar, will no longer leave weird ui glitch in actions bar

* #3814 - small reformat + minor style tweaks

* #3814 - bit better working ActionMenu locking + added missing toolips for ActionMenu lock and OpenAbilities button

* #3814 - tooltip text typo fix

* #3814 - incorporated suggestions

* #3814 localization tweaks
This commit is contained in:
Galactic Chimp
2021-06-19 12:41:43 +02:00
committed by GitHub
parent 53671aeee7
commit cfc3f2e7fc
5 changed files with 42 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Actions;
using Content.Shared.Actions.Components;
@@ -55,7 +55,8 @@ namespace Content.Client.Actions.Assignments
/// which no longer have an associated state will be decoupled from their item.
/// </summary>
public void Reconcile(byte currentHotbar, IReadOnlyDictionary<ActionType, ActionState> actionStates,
IReadOnlyDictionary<EntityUid,Dictionary<ItemActionType, ActionState>> itemActionStates)
IReadOnlyDictionary<EntityUid, Dictionary<ItemActionType, ActionState>> itemActionStates,
bool actionMenuLocked)
{
// if we've been granted any actions which have no assignment to any hotbar, we must auto-populate them
// into the hotbar so the user knows about them.
@@ -116,9 +117,19 @@ namespace Content.Client.Actions.Assignments
{
foreach (var (hotbar, slot) in slots)
{
if (!assignment.TryGetItemActionWithItem(out var actionType, out _)) continue;
AssignSlot(hotbar, slot,
ActionAssignment.For(actionType));
if (!assignment.TryGetItemActionWithItem(out var actionType, out _))
{
continue;
}
if (actionMenuLocked)
{
AssignSlot(hotbar, slot, ActionAssignment.For(actionType));
}
else
{
ClearSlot(hotbar, slot, false);
}
}
}
@@ -190,7 +201,7 @@ namespace Content.Client.Actions.Assignments
}
var assignmentList = _assignments[currentAction.Value];
assignmentList = assignmentList.Where(a => a.Hotbar != hotbar || a.Slot != slot).ToList();
if (assignmentList.Count == 0)
if (!assignmentList.Any())
{
_assignments.Remove(currentAction.Value);
}

View File

@@ -102,7 +102,7 @@ namespace Content.Client.Actions
return;
}
Assignments.Reconcile(_ui.SelectedHotbar, ActionStates(), ItemActionStates());
Assignments.Reconcile(_ui.SelectedHotbar, ActionStates(), ItemActionStates(), _ui.Locked);
_ui.UpdateUI();
}

View File

@@ -15,6 +15,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Timing;
@@ -25,6 +26,7 @@ namespace Content.Client.Actions.UI
/// </summary>
public sealed class ActionsUI : Container
{
private const float CustomTooltipDelay = 0.4f;
private readonly ClientActionsComponent _actionsComponent;
private readonly ActionManager _actionManager;
private readonly IEntityManager _entityManager;
@@ -128,7 +130,9 @@ namespace Content.Client.Actions.UI
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
Scale = (0.5f, 0.5f)
Scale = (0.5f, 0.5f),
ToolTip = Loc.GetString("ui-actionmenu-function-lock-action-slots"),
TooltipDelay = CustomTooltipDelay
};
settingsContainer.AddChild(_lockButton);
settingsContainer.AddChild(new Control { HorizontalExpand = true, SizeFlagsStretchRatio = 2 });
@@ -138,7 +142,9 @@ namespace Content.Client.Actions.UI
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
Scale = (0.5f, 0.5f)
Scale = (0.5f, 0.5f),
ToolTip = Loc.GetString("ui-actionmenu-function-open-abilities-menu"),
TooltipDelay = CustomTooltipDelay
};
settingsContainer.AddChild(_settingsButton);
settingsContainer.AddChild(new Control { HorizontalExpand = true, SizeFlagsStretchRatio = 1 });

View File

@@ -0,0 +1,4 @@
# Action menu stuff (left panel, with hotbars etc)
ui-actionmenu-function-lock-action-slots = (Un)lock dragging and clearing action slots
ui-actionmenu-function-open-abilities-menu = Open action menu

View File

@@ -99,6 +99,17 @@ ui-options-function-open-admin-menu = Open admin menu
ui-options-function-take-screenshot = Take screenshot
ui-options-function-take-screenshot-no-ui = Take screenshot (without UI)
ui-options-function-editor-place-object = Place object
ui-options-function-editor-cancel-place = Cancel placement
ui-options-function-editor-grid-place = Place in grid
ui-options-function-editor-line-place = Place line
ui-options-function-editor-rotate-object = Rotate
ui-options-function-open-abilities-menu = Open action menu
ui-options-function-show-debug-console = Open Console
ui-options-function-show-debug-monitors = Show Debug Monitors
ui-options-function-hide-ui = Hide UI
ui-options-function-hotbar1 = Hotbar slot 1
ui-options-function-hotbar2 = Hotbar slot 2
ui-options-function-hotbar3 = Hotbar slot 3
@@ -118,13 +129,3 @@ ui-options-function-loadout6 = Hotbar Loadout 6
ui-options-function-loadout7 = Hotbar Loadout 7
ui-options-function-loadout8 = Hotbar Loadout 8
ui-options-function-loadout9 = Hotbar Loadout 9
ui-options-function-editor-place-object = Place object
ui-options-function-editor-cancel-place = Cancel placement
ui-options-function-editor-grid-place = Place in grid
ui-options-function-editor-line-place = Place line
ui-options-function-editor-rotate-object = Rotate
ui-options-function-show-debug-console = Open Console
ui-options-function-show-debug-monitors = Show Debug Monitors
ui-options-function-hide-ui = Hide UI