From cfc3f2e7fc54a1200868f6cc2980e14ac71befe7 Mon Sep 17 00:00:00 2001 From: Galactic Chimp <63882831+GalacticChimp@users.noreply.github.com> Date: Sat, 19 Jun 2021 12:41:43 +0200 Subject: [PATCH] =?UTF-8?q?#3814=20-=20dropping=20an=20item,=20which=20add?= =?UTF-8?q?s=20an=20action=20to=20the=20actions=20bar,=20wi=E2=80=A6=20(#4?= =?UTF-8?q?123)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * #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 --- .../Actions/Assignments/ActionAssignments.cs | 25 +++++++++++++------ .../Actions/ClientActionsComponent.cs | 2 +- Content.Client/Actions/UI/ActionsUI.cs | 10 ++++++-- Resources/Locale/en-US/ui/actionmenu.ftl | 4 +++ Resources/Locale/en-US/ui/options.ftl | 21 ++++++++-------- 5 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 Resources/Locale/en-US/ui/actionmenu.ftl diff --git a/Content.Client/Actions/Assignments/ActionAssignments.cs b/Content.Client/Actions/Assignments/ActionAssignments.cs index 4f9dd5143e..9c6f6d8af0 100644 --- a/Content.Client/Actions/Assignments/ActionAssignments.cs +++ b/Content.Client/Actions/Assignments/ActionAssignments.cs @@ -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>(); - _slots = new ActionAssignment?[numHotbars,numSlots]; + _slots = new ActionAssignment?[numHotbars, numSlots]; } /// @@ -55,7 +55,8 @@ namespace Content.Client.Actions.Assignments /// which no longer have an associated state will be decoupled from their item. /// public void Reconcile(byte currentHotbar, IReadOnlyDictionary actionStates, - IReadOnlyDictionary> itemActionStates) + IReadOnlyDictionary> 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); } diff --git a/Content.Client/Actions/ClientActionsComponent.cs b/Content.Client/Actions/ClientActionsComponent.cs index 159c76500d..a148d31b83 100644 --- a/Content.Client/Actions/ClientActionsComponent.cs +++ b/Content.Client/Actions/ClientActionsComponent.cs @@ -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(); } diff --git a/Content.Client/Actions/UI/ActionsUI.cs b/Content.Client/Actions/UI/ActionsUI.cs index 07f07a4e2d..46fa256524 100644 --- a/Content.Client/Actions/UI/ActionsUI.cs +++ b/Content.Client/Actions/UI/ActionsUI.cs @@ -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 /// 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 }); diff --git a/Resources/Locale/en-US/ui/actionmenu.ftl b/Resources/Locale/en-US/ui/actionmenu.ftl new file mode 100644 index 0000000000..924ed0710b --- /dev/null +++ b/Resources/Locale/en-US/ui/actionmenu.ftl @@ -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 \ No newline at end of file diff --git a/Resources/Locale/en-US/ui/options.ftl b/Resources/Locale/en-US/ui/options.ftl index 857677c593..7bf7c1924e 100644 --- a/Resources/Locale/en-US/ui/options.ftl +++ b/Resources/Locale/en-US/ui/options.ftl @@ -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