#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;
@@ -45,7 +45,7 @@ namespace Content.Client.Actions.Assignments
_numHotbars = numHotbars;
_numSlots = numSlots;
_assignments = new Dictionary<ActionAssignment, List<(byte Hotbar, byte Slot)>>();
_slots = new ActionAssignment?[numHotbars,numSlots];
_slots = new ActionAssignment?[numHotbars, numSlots];
}
/// <summary>
@@ -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);
}