|
|
|
|
@@ -83,7 +83,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|
|
|
|
ThrowButton.Pressed += ThrowButtonPressed;
|
|
|
|
|
DropButton.Pressed += DropButtonPressed;
|
|
|
|
|
|
|
|
|
|
VisibilityChanged += InventoryMenu2_VisibilityChanged;
|
|
|
|
|
VisibilityChanged += InventoryMenu_VisibilityChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void _Input(InputEvent @event)
|
|
|
|
|
@@ -91,23 +91,42 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|
|
|
|
if (!Visible)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if ((!Input.IsActionJustPressed(GameInputs.UiUp) && Input.IsActionPressed(GameInputs.UiUp)) || (!Input.IsActionJustPressed(GameInputs.UiDown) && Input.IsActionPressed(GameInputs.UiDown)))
|
|
|
|
|
AcceptEvent();
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionJustPressed(GameInputs.UiUp) && _currentlySelectedItem.GetIndex() != ItemSlots.First().GetIndex() && !(UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus()))
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
|
|
|
|
if (Input.IsActionJustPressed(GameInputs.UiDown) && _currentlySelectedItem.GetIndex() != ItemSlots.Last(x => x.Visible).GetIndex() && !(UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus()))
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionJustPressed(GameInputs.UiUp) && (DropButton.HasFocus() || ThrowButton.HasFocus()))
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
|
|
|
|
if (Input.IsActionJustPressed(GameInputs.UiDown) && (UseButton.HasFocus() || ThrowButton.HasFocus()))
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionJustPressed(GameInputs.Inventory) && !(UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus()))
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
|
|
|
|
|
AcceptEvent();
|
|
|
|
|
_gameRepo.CloseInventory();
|
|
|
|
|
}
|
|
|
|
|
if (Input.IsActionJustPressed(GameInputs.UiCancel) && (UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus()))
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
|
|
|
|
|
AcceptEvent();
|
|
|
|
|
HideUserActionPrompt();
|
|
|
|
|
}
|
|
|
|
|
else if (Input.IsActionJustPressed(GameInputs.UiCancel))
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
|
|
|
|
|
AcceptEvent();
|
|
|
|
|
_gameRepo.CloseInventory();
|
|
|
|
|
}
|
|
|
|
|
if (_currentPageNumber == InventoryPageNumber.FirstPage && _player.Inventory.Items.Count > 10 && Input.IsActionJustPressed(GameInputs.MoveRight))
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
|
|
|
|
_currentPageNumber = InventoryPageNumber.SecondPage;
|
|
|
|
|
Inventory_InventoryChanged();
|
|
|
|
|
_currentlySelectedItem = ItemSlot1;
|
|
|
|
|
@@ -115,6 +134,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|
|
|
|
}
|
|
|
|
|
else if (_currentPageNumber == InventoryPageNumber.SecondPage && Input.IsActionJustPressed(GameInputs.MoveLeft))
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
|
|
|
|
_currentPageNumber = InventoryPageNumber.FirstPage;
|
|
|
|
|
Inventory_InventoryChanged();
|
|
|
|
|
_currentlySelectedItem = ItemSlot1;
|
|
|
|
|
@@ -123,7 +143,11 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionJustPressed(GameInputs.InventorySort))
|
|
|
|
|
{
|
|
|
|
|
_player.Inventory.Sort(_player.EquipmentComponent.EquippedWeapon.Value, _player.EquipmentComponent.EquippedArmor.Value, _player.EquipmentComponent.EquippedAccessory.Value);
|
|
|
|
|
var isChanged = _player.Inventory.Sort(_player.EquipmentComponent.EquippedWeapon.Value, _player.EquipmentComponent.EquippedArmor.Value, _player.EquipmentComponent.EquippedAccessory.Value);
|
|
|
|
|
if (!isChanged)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.SortInventory);
|
|
|
|
|
Inventory_InventoryChanged();
|
|
|
|
|
foreach (var slot in ItemSlots)
|
|
|
|
|
slot.SetItemStyle();
|
|
|
|
|
@@ -133,9 +157,13 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InventoryMenu2_VisibilityChanged()
|
|
|
|
|
private void InventoryMenu_VisibilityChanged()
|
|
|
|
|
{
|
|
|
|
|
_currentlySelectedItem.GrabFocus();
|
|
|
|
|
if (Visible)
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.OpenInventory);
|
|
|
|
|
_currentlySelectedItem.GrabFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Item_ItemExitFocus(IItemSlot itemSlot)
|
|
|
|
|
@@ -156,6 +184,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|
|
|
|
_currentlySelectedItem = itemSlot;
|
|
|
|
|
itemSlot.IsSelected = true;
|
|
|
|
|
itemSlot.SetItemStyle();
|
|
|
|
|
AcceptEvent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Item_Pressed(InventoryItem item) => DisplayUserActionPrompt(item);
|
|
|
|
|
@@ -257,6 +286,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|
|
|
|
|
|
|
|
|
private void DisplayUserActionPrompt(InventoryItem item)
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.SelectUI);
|
|
|
|
|
ItemDescriptionTitle.Hide();
|
|
|
|
|
ItemEffectLabel.Hide();
|
|
|
|
|
UseItemPrompt.Show();
|
|
|
|
|
@@ -297,11 +327,13 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|
|
|
|
{
|
|
|
|
|
if (_player.EquipmentComponent.IsItemEquipped(equipable))
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.Unequip);
|
|
|
|
|
ItemEffectLabel.Text = $"{equipable.GetType().Name} unequipped.";
|
|
|
|
|
_player.Unequip(equipable);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SfxDatabase.Instance.Play(SoundEffect.Equip);
|
|
|
|
|
var itemSlot = _currentlySelectedItem;
|
|
|
|
|
ItemEffectLabel.Text = $"{equipable.GetType().Name} equipped.";
|
|
|
|
|
_player.Equip(equipable);
|
|
|
|
|
|