diff --git a/Zennysoft.Game.Ma/src/items/weapons/textures/RONDO.PNG.import b/Zennysoft.Game.Ma/src/items/weapons/textures/RONDO.PNG.import index 0c842ad38..947fcd210 100644 --- a/Zennysoft.Game.Ma/src/items/weapons/textures/RONDO.PNG.import +++ b/Zennysoft.Game.Ma/src/items/weapons/textures/RONDO.PNG.import @@ -3,7 +3,7 @@ importer="texture" type="CompressedTexture2D" uid="uid://c63uufq63qpuy" -path.bptc="res://.godot/imported/Rondo.png-57553b850a093da6dba43a1e1947fcce.bptc.ctex" +path.bptc="res://.godot/imported/RONDO.PNG-77b50e9afaf9eb46f5672e079a5f50bf.bptc.ctex" metadata={ "imported_formats": ["s3tc_bptc"], "vram_texture": true @@ -11,8 +11,8 @@ metadata={ [deps] -source_file="res://src/items/weapons/textures/Rondo.png" -dest_files=["res://.godot/imported/Rondo.png-57553b850a093da6dba43a1e1947fcce.bptc.ctex"] +source_file="res://src/items/weapons/textures/RONDO.PNG" +dest_files=["res://.godot/imported/RONDO.PNG-77b50e9afaf9eb46f5672e079a5f50bf.bptc.ctex"] [params] diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.cs index 4d550af9b..ac1c70ca2 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/ActionPanel.cs @@ -2,6 +2,7 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; using System; +using Zennysoft.Game.Ma; using Zennysoft.Ma.Adapter; [Meta(typeof(IAutoNode))] @@ -13,6 +14,8 @@ public partial class ActionPanel : Panel [Dependency] private IPlayer _player => this.DependOn(); + [Dependency] private IGame _game => this.DependOn(); + [Node] public Button InteractButton { get; set; } [Node] public Button ThrowButton { get; set; } @@ -21,6 +24,8 @@ public partial class ActionPanel : Panel public event Action ActionPanelClosing; + public event Action ReturnToGameAction; + public void OnResolved() { InteractButton.Pressed += InteractButton_Pressed; @@ -49,12 +54,16 @@ public partial class ActionPanel : Panel private void ThrowButton_Pressed() { - throw new System.NotImplementedException(); + _game.ThrowItem(_currentlySelected); + _currentlySelected = null; + ActionPanelClosing?.Invoke(); } private void DropButton_Pressed() { - throw new System.NotImplementedException(); + _game.DropItem(_currentlySelected); + _currentlySelected = null; + ActionPanelClosing?.Invoke(); } private void SetOptions(IBaseInventoryItem item) @@ -93,4 +102,9 @@ public partial class ActionPanel : Panel SfxDatabase.Instance.Play(SoundEffect.Equip); } } + + private void PerformAction(IBaseInventoryItem item) + { + _game.UseItem(item); + } } diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs index 9a2c5889f..730262b11 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.cs @@ -29,6 +29,8 @@ public partial class InventoryMenu : Control, IInventoryMenu private List ItemSlots; + private IItemSlot _currentlySelected; + public void OnResolved() { ItemSlots = [.. Inventory.GetChildren().OfType()]; @@ -36,6 +38,15 @@ public partial class InventoryMenu : Control, IInventoryMenu ItemSlots.ForEach(x => x.ItemSelected += ItemSelected); VisibilityChanged += ResetInventoryState; ActionPanel.ActionPanelClosing += ActionPanel_ActionPanelClosing; + ActionPanel.ReturnToGameAction += ActionPanel_ReturnToGameAction; + ItemName.Text = string.Empty; + ItemFlavor.Text = string.Empty; + ItemStats.Text = string.Empty; + } + + private void ActionPanel_ReturnToGameAction() + { + _gameRepo.CloseInventory(); } private void ItemPressed(IItemSlot selectedItem) @@ -46,6 +57,7 @@ public partial class InventoryMenu : Control, IInventoryMenu private void ItemSelected(IItemSlot selectedItem) { + _currentlySelected = selectedItem; ItemName.Text = selectedItem.Item.Value.ItemName; ItemFlavor.Text = selectedItem.Item.Value.Description; } @@ -58,8 +70,11 @@ public partial class InventoryMenu : Control, IInventoryMenu for (var i = 0; i < inventory.Count; i++) ItemSlots[i].SetItemToSlot(inventory[i]); + if (_currentlySelected == null && inventory.Any()) + _currentlySelected = ItemSlots.First(); if (inventory.Any()) - ItemSlots.First().FocusItem(); + _currentlySelected.FocusItem(); + ActionPanel.Hide(); } private void ActionPanel_ActionPanelClosing() @@ -68,14 +83,6 @@ public partial class InventoryMenu : Control, IInventoryMenu ResetInventoryState(); } - private void Slot_FocusEntered(IItemSlot slot) - { - var item = slot.Item.Value; - ItemName.Text = item.ItemName; - ItemFlavor.Text = item.Description; - } - - private void InteractButton_Pressed() { //if (_currentlySelected != null) diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.tscn b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.tscn index f88053676..dc0ab0add 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.tscn +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/InventoryMenu.tscn @@ -45,6 +45,7 @@ outline_color = Color(0, 0, 0, 1) [node name="InventoryMenu" type="PanelContainer"] process_mode = 2 +visible = false anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs index 6b268f5ea..238d0766a 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs @@ -37,6 +37,7 @@ public partial class ItemSlot : Control, IItemSlot { Item.Changed += Item_Changed; ItemName.Pressed += ItemSlot_Pressed; + ItemName.FocusEntered += FocusItem; } public void SetItemToSlot(IBaseInventoryItem item)