Enemy viewer revamp, loading screen improvement
This commit is contained in:
@@ -28,9 +28,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
[Node] public Label UseItemPrompt { get; set; }
|
||||
[Node] public Label ItemEffectLabel { get; set; }
|
||||
|
||||
[Node] public Label BackArrow { get; set; } = default!;
|
||||
[Node] public Label ForwardArrow { get; set; } = default!;
|
||||
|
||||
[Node] public ItemSlot ItemSlot1 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot2 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot3 { get; set; }
|
||||
@@ -41,6 +38,16 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
[Node] public ItemSlot ItemSlot8 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot9 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot10 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot11 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot12 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot13 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot14 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot15 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot16 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot17 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot18 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot19 { get; set; }
|
||||
[Node] public ItemSlot ItemSlot20 { get; set; }
|
||||
|
||||
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
|
||||
[Dependency] private IGame _game => this.DependOn<IGame>();
|
||||
@@ -48,13 +55,10 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
|
||||
private List<IItemSlot> ItemSlots;
|
||||
|
||||
private InventoryPageNumber _currentPageNumber = InventoryPageNumber.FirstPage;
|
||||
|
||||
private string ITEM_SLOT_SCENE = "res://src/ui/inventory_menu/ItemSlot.tscn";
|
||||
|
||||
private const int _itemsPerPage = 10;
|
||||
|
||||
private IItemSlot _currentlySelectedItem = null;
|
||||
private bool _enableMenuSound = false;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
@@ -63,7 +67,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
ItemSlots = [ItemSlot1, ItemSlot2, ItemSlot3, ItemSlot4, ItemSlot5, ItemSlot6, ItemSlot7, ItemSlot8, ItemSlot9, ItemSlot10];
|
||||
ItemSlots = [ItemSlot1, ItemSlot2, ItemSlot3, ItemSlot4, ItemSlot5, ItemSlot6, ItemSlot7, ItemSlot8, ItemSlot9, ItemSlot10, ItemSlot11, ItemSlot12, ItemSlot13, ItemSlot14, ItemSlot15, ItemSlot16, ItemSlot17, ItemSlot18, ItemSlot19, ItemSlot20];
|
||||
_currentlySelectedItem = ItemSlot1;
|
||||
foreach (var item in ItemSlots)
|
||||
{
|
||||
@@ -83,9 +87,19 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
ThrowButton.Pressed += ThrowButtonPressed;
|
||||
DropButton.Pressed += DropButtonPressed;
|
||||
|
||||
UseButton.FocusEntered += ActionButtonFocusChanged;
|
||||
ThrowButton.FocusEntered += ActionButtonFocusChanged;
|
||||
DropButton.FocusEntered += ActionButtonFocusChanged;
|
||||
|
||||
VisibilityChanged += InventoryMenu_VisibilityChanged;
|
||||
}
|
||||
|
||||
private void ActionButtonFocusChanged()
|
||||
{
|
||||
if (!_enableMenuSound)
|
||||
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if (!Visible)
|
||||
@@ -94,18 +108,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
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);
|
||||
@@ -124,22 +126,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
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;
|
||||
ItemSlot1.GrabFocus();
|
||||
}
|
||||
else if (_currentPageNumber == InventoryPageNumber.SecondPage && Input.IsActionJustPressed(GameInputs.MoveLeft))
|
||||
{
|
||||
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
||||
_currentPageNumber = InventoryPageNumber.FirstPage;
|
||||
Inventory_InventoryChanged();
|
||||
_currentlySelectedItem = ItemSlot1;
|
||||
ItemSlot1.GrabFocus();
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed(GameInputs.InventorySort))
|
||||
{
|
||||
@@ -163,6 +149,11 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
{
|
||||
SfxDatabase.Instance.Play(SoundEffect.OpenInventory);
|
||||
_currentlySelectedItem.GrabFocus();
|
||||
_enableMenuSound = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_enableMenuSound = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +170,9 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
if (itemSlot.Item.Value == null)
|
||||
return;
|
||||
|
||||
if (_enableMenuSound)
|
||||
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
|
||||
|
||||
ItemDescriptionTitle.Text = $"{itemSlot.Item.Value.ItemName}";
|
||||
ItemEffectLabel.Text = $"{itemSlot.Item.Value.Description}";
|
||||
_currentlySelectedItem = itemSlot;
|
||||
@@ -197,28 +191,13 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
slot.SetItemStyle();
|
||||
}
|
||||
|
||||
if (_currentPageNumber == InventoryPageNumber.SecondPage && _player.Inventory.Items.Count <= 10)
|
||||
{
|
||||
_currentPageNumber = InventoryPageNumber.FirstPage;
|
||||
var elementToSelect = _player.Inventory.Items.IndexOf(_player.Inventory.Items.Last());
|
||||
_currentlySelectedItem = ItemSlots.ElementAt(elementToSelect);
|
||||
_currentlySelectedItem.GrabFocus();
|
||||
}
|
||||
|
||||
var itemsToDisplay = new List<InventoryItem>();
|
||||
if (_currentPageNumber == InventoryPageNumber.FirstPage)
|
||||
itemsToDisplay = [.. _player.Inventory.Items.Take(_itemsPerPage)];
|
||||
else
|
||||
itemsToDisplay = [.. _player.Inventory.Items.TakeLast(_player.Inventory.Items.Count - _itemsPerPage)];
|
||||
|
||||
var itemsToDisplay = _player.Inventory.Items;
|
||||
for (var i = 0; i < itemsToDisplay.Count; i++)
|
||||
{
|
||||
ItemSlots[i].Item.OnNext(itemsToDisplay[i]);
|
||||
ItemSlots[i].Visible = true;
|
||||
}
|
||||
|
||||
SetPageIndicators();
|
||||
|
||||
if (!_player.Inventory.Items.Contains(_currentlySelectedItem.Item.Value))
|
||||
{
|
||||
_currentlySelectedItem.Item.OnNext(null);
|
||||
@@ -228,20 +207,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPageIndicators()
|
||||
{
|
||||
if (_player.Inventory.Items.Count > 10 && _currentPageNumber == InventoryPageNumber.FirstPage)
|
||||
{
|
||||
ForwardArrow.Text = "►";
|
||||
BackArrow.Text = "";
|
||||
}
|
||||
else if (_player.Inventory.Items.Count > 10 && _currentPageNumber == InventoryPageNumber.SecondPage)
|
||||
{
|
||||
ForwardArrow.Text = "";
|
||||
BackArrow.Text = "◄";
|
||||
}
|
||||
}
|
||||
|
||||
private void Attack_Sync(int obj) => ATKValue.Text = $"{_player.AttackComponent.CurrentAttack.Value}/{_player.AttackComponent.MaximumAttack.Value}";
|
||||
private void Defense_Sync(int obj) => DEFValue.Text = $"{_player.DefenseComponent.CurrentDefense.Value}/{_player.DefenseComponent.MaximumDefense.Value}";
|
||||
|
||||
@@ -308,7 +273,8 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
UseButton.Text = "Use";
|
||||
}
|
||||
|
||||
UseButton.CallDeferred(MethodName.GrabFocus);
|
||||
UseButton.GrabFocus();
|
||||
_enableMenuSound = false;
|
||||
}
|
||||
|
||||
private void HideUserActionPrompt()
|
||||
@@ -321,6 +287,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
ThrowButton.ReleaseFocus();
|
||||
DropButton.ReleaseFocus();
|
||||
_currentlySelectedItem.GrabFocus();
|
||||
_enableMenuSound = true;
|
||||
}
|
||||
|
||||
private async Task EquipOrUnequipItem(EquipableItem equipable)
|
||||
|
||||
Reference in New Issue
Block a user