Removed old Loc.GetString() use instances (#4155)

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Galactic Chimp
2021-06-21 02:13:54 +02:00
committed by GitHub
parent 4a46fbe6dd
commit 392b820796
523 changed files with 3082 additions and 1551 deletions

View File

@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Actions;
using Content.Shared.Actions.Components;
using Robust.Shared.GameObjects;
using System.Collections.Generic;
using System.Linq;
namespace Content.Client.Actions.Assignments
{
@@ -70,8 +70,6 @@ namespace Content.Client.Actions.Assignments
}
}
foreach (var (item, itemStates) in itemActionStates)
{
foreach (var itemActionState in itemStates)
@@ -94,10 +92,13 @@ namespace Content.Client.Actions.Assignments
// which once had an associated item but have been revoked (based on our newly provided action states)
// so we can dissociate them from the item. If the provided action states do not
// have a state for this action type + item, we can assume that the action has been revoked for that item.
var assignmentsWithoutItem = new List<KeyValuePair<ActionAssignment,List<(byte Hotbar, byte Slot)>>>();
var assignmentsWithoutItem = new List<KeyValuePair<ActionAssignment, List<(byte Hotbar, byte Slot)>>>();
foreach (var assignmentEntry in _assignments)
{
if (!assignmentEntry.Key.TryGetItemActionWithItem(out var actionType, out var item)) continue;
if (!assignmentEntry.Key.TryGetItemActionWithItem(out var actionType, out var item))
{
continue;
}
// we have this assignment currently tied to an item,
// check if it no longer has an associated item in our dict of states
@@ -110,8 +111,10 @@ namespace Content.Client.Actions.Assignments
continue;
}
}
assignmentsWithoutItem.Add(assignmentEntry);
}
// reassign without the item for each assignment we found that no longer has an associated item
foreach (var (assignment, slots) in assignmentsWithoutItem)
{
@@ -158,7 +161,7 @@ namespace Content.Client.Actions.Assignments
}
else
{
var newList = new List<(byte Hotbar, byte Slot)> {(hotbar, slot)};
var newList = new List<(byte Hotbar, byte Slot)> { (hotbar, slot) };
_assignments[actionType] = newList;
}
}
@@ -179,7 +182,12 @@ namespace Content.Client.Actions.Assignments
// remove this particular assignment from our data structures
// (keeping in mind something can be assigned multiple slots)
var currentAction = _slots[hotbar, slot];
if (!currentAction.HasValue) return;
if (!currentAction.HasValue)
{
return;
}
if (preventAutoPopulate)
{
var assignment = currentAction.Value;
@@ -199,6 +207,7 @@ namespace Content.Client.Actions.Assignments
actionTypes.Add(itemActionType);
}
}
var assignmentList = _assignments[currentAction.Value];
assignmentList = assignmentList.Where(a => a.Hotbar != hotbar || a.Slot != slot).ToList();
if (!assignmentList.Any())
@@ -209,6 +218,7 @@ namespace Content.Client.Actions.Assignments
{
_assignments[currentAction.Value] = assignmentList;
}
_slots[hotbar, slot] = null;
}
@@ -223,7 +233,11 @@ namespace Content.Client.Actions.Assignments
/// if this assignment has been prevented from auto population.</param>
public void AutoPopulate(ActionAssignment toAssign, byte currentHotbar, bool force = true)
{
if (ShouldPreventAutoPopulate(toAssign, force)) return;
if (ShouldPreventAutoPopulate(toAssign, force))
{
return;
}
// if the assignment to make is an item action with an associated item,
// then first look for currently assigned item actions without an item, to replace with this
// assignment
@@ -240,7 +254,7 @@ namespace Content.Client.Actions.Assignments
{
var cost = possibility.Slot + _numSlots * (currentHotbar >= possibility.Hotbar
? currentHotbar - possibility.Hotbar
: (_numHotbars - currentHotbar) + possibility.Hotbar);
: _numHotbars - currentHotbar + possibility.Hotbar);
if (cost < minCost)
{
hotbar = possibility.Hotbar;
@@ -273,8 +287,10 @@ namespace Content.Client.Actions.Assignments
AssignSlot(hotbar, slot, toAssign);
return;
}
continue;
}
// slot's empty, assign
AssignSlot(hotbar, slot, toAssign);
return;
@@ -285,7 +301,10 @@ namespace Content.Client.Actions.Assignments
private bool ShouldPreventAutoPopulate(ActionAssignment assignment, bool force)
{
if (force) return false;
if (force)
{
return false;
}
if (assignment.TryGetAction(out var actionType))
{

View File

@@ -44,7 +44,6 @@ namespace Content.Client.Actions
[ViewVariables]
private bool CurrentlyControlled => _playerManager.LocalPlayer != null && _playerManager.LocalPlayer.ControlledEntity == Owner;
protected override void Shutdown()
{
base.Shutdown();

View File

@@ -68,7 +68,7 @@ namespace Content.Client.Actions.UI
_actionManager = IoCManager.Resolve<ActionManager>();
_gameHud = IoCManager.Resolve<IGameHud>();
Title = Loc.GetString("Actions");
Title = Loc.GetString("ui-actionmenu-title");
MinSize = (300, 300);
Contents.AddChild(new VBoxContainer
@@ -83,17 +83,17 @@ namespace Content.Client.Actions.UI
{
StyleClasses = { StyleNano.StyleClassActionSearchBox },
HorizontalExpand = true,
PlaceHolder = Loc.GetString("Search")
PlaceHolder = Loc.GetString("ui-actionmenu-search-bar-placeholder-text")
}),
(_filterButton = new MultiselectOptionButton<string>()
{
Label = Loc.GetString("Filter")
Label = Loc.GetString("ui-actionmenu-filter-buttonr")
})
}
},
(_clearButton = new Button
{
Text = Loc.GetString("Clear"),
Text = Loc.GetString("ui-actionmenu-clear-button"),
}),
(_filterLabel = new Label()),
new ScrollContainer
@@ -353,7 +353,8 @@ namespace Content.Client.Actions.UI
else
{
_filterLabel.Visible = true;
_filterLabel.Text = Loc.GetString("Filters: {0}", string.Join(", ", _filterButton.SelectedLabels));
_filterLabel.Text = Loc.GetString("ui-actionmenu-filter-label",
("selectedLabels", string.Join(", ", _filterButton.SelectedLabels)));
}
}
@@ -430,7 +431,7 @@ namespace Content.Client.Actions.UI
/// </summary>
private static string Standardize(string rawText, bool splitOnCaseChange = false)
{
rawText ??= "";
rawText ??= string.Empty;
// treat non-alphanumeric characters as whitespace
rawText = NonAlphanumeric.Replace(rawText, " ");

View File

@@ -131,7 +131,7 @@ namespace Content.Client.Actions.UI
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
Scale = (0.5f, 0.5f),
ToolTip = Loc.GetString("ui-actionmenu-function-lock-action-slots"),
ToolTip = Loc.GetString("ui-actionsui-function-lock-action-slots"),
TooltipDelay = CustomTooltipDelay
};
settingsContainer.AddChild(_lockButton);
@@ -143,7 +143,7 @@ namespace Content.Client.Actions.UI
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
Scale = (0.5f, 0.5f),
ToolTip = Loc.GetString("ui-actionmenu-function-open-abilities-menu"),
ToolTip = Loc.GetString("ui-actionsui-function-open-abilities-menu"),
TooltipDelay = CustomTooltipDelay
};
settingsContainer.AddChild(_settingsButton);