diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs index 5b9ae453..558ec0ec 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs @@ -171,7 +171,10 @@ public partial class InventoryMenu : Control, IInventoryMenu ItemSlots[i].SetItemToSlot(inventory[i]); 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) { @@ -216,9 +219,9 @@ public partial class InventoryMenu : Control, IInventoryMenu ActionPanel.Hide(); SetProcessInput(true); 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.ItemSlot.FocusItem(); } @@ -283,39 +286,6 @@ public partial class InventoryMenu : Control, IInventoryMenu 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) { return item switch