Fix issue where equipping a mystery item selected the wrong inventory item
This commit is contained in:
@@ -171,7 +171,10 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
ItemSlots[i].SetItemToSlot(inventory[i]);
|
ItemSlots[i].SetItemToSlot(inventory[i]);
|
||||||
|
|
||||||
if (_currentlySelected.ItemSlot != null && !inventory.Contains(_currentlySelected.ItemSlot.Item.Value))
|
if (_currentlySelected.ItemSlot != null && !inventory.Contains(_currentlySelected.ItemSlot.Item.Value))
|
||||||
_currentlySelected = (null, -1);
|
{
|
||||||
|
var newIndex = Mathf.Clamp(_currentlySelected.InventoryIndex, 0, _player.Inventory.Items.Count - 1);
|
||||||
|
_currentlySelected = (ItemSlots[newIndex], newIndex);
|
||||||
|
}
|
||||||
|
|
||||||
if (_currentlySelected.ItemSlot == null && inventory.Count > 0)
|
if (_currentlySelected.ItemSlot == null && inventory.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -216,9 +219,9 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
ActionPanel.Hide();
|
ActionPanel.Hide();
|
||||||
SetProcessInput(true);
|
SetProcessInput(true);
|
||||||
ActionPanel.SetProcessInput(false);
|
ActionPanel.SetProcessInput(false);
|
||||||
if (_player.Inventory.Items.Count != 0 && !_player.Inventory.Items.Contains(_currentlySelected.ItemSlot.Item.Value))
|
if (_player.Inventory.Items.Count > 0)
|
||||||
{
|
{
|
||||||
var newIndex = Mathf.Max(0, _currentlySelected.InventoryIndex - 1);
|
var newIndex = Mathf.Clamp(_currentlySelected.InventoryIndex, 0, ItemSlots.Count - 1);
|
||||||
_currentlySelected = (ItemSlots[newIndex], newIndex);
|
_currentlySelected = (ItemSlots[newIndex], newIndex);
|
||||||
_currentlySelected.ItemSlot.FocusItem();
|
_currentlySelected.ItemSlot.FocusItem();
|
||||||
}
|
}
|
||||||
@@ -283,39 +286,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetAugmentText(Weapon item)
|
|
||||||
{
|
|
||||||
if (item is IAugmentableItem augmentable && augmentable.Augment != null)
|
|
||||||
{
|
|
||||||
ItemAugmentTexture.Texture = augmentable.Augment.AugmentTexture;
|
|
||||||
return $"{augmentable.Augment.AugmentName}{System.Environment.NewLine}{augmentable.Augment.AugmentDescription}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetAugmentText(Armor item)
|
|
||||||
{
|
|
||||||
if (item is IAugmentableItem augmentable && augmentable.Augment != null)
|
|
||||||
{
|
|
||||||
ItemAugmentTexture.Texture = augmentable.Augment.AugmentTexture;
|
|
||||||
return $"{augmentable.Augment.AugmentName}{System.Environment.NewLine}{augmentable.Augment.AugmentDescription}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetAugmentText(Accessory item)
|
|
||||||
{
|
|
||||||
if (item is IAugmentableItem augmentable && augmentable.Augment != null)
|
|
||||||
{
|
|
||||||
ItemAugmentTexture.Texture = augmentable.Augment.AugmentTexture;
|
|
||||||
return $"{augmentable.Augment.AugmentName}{System.Environment.NewLine}{augmentable.Augment.AugmentDescription}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string SetItemTypeName(IBaseInventoryItem item)
|
private static string SetItemTypeName(IBaseInventoryItem item)
|
||||||
{
|
{
|
||||||
return item switch
|
return item switch
|
||||||
|
|||||||
Reference in New Issue
Block a user