This commit is contained in:
2026-02-14 19:26:33 -08:00
parent bf6b0d50c3
commit a6ea1b1873
5 changed files with 37 additions and 14 deletions

View File

@@ -3,7 +3,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://c63uufq63qpuy" uid="uid://c63uufq63qpuy"
path.bptc="res://.godot/imported/Rondo.png-57553b850a093da6dba43a1e1947fcce.bptc.ctex" path.bptc="res://.godot/imported/RONDO.PNG-77b50e9afaf9eb46f5672e079a5f50bf.bptc.ctex"
metadata={ metadata={
"imported_formats": ["s3tc_bptc"], "imported_formats": ["s3tc_bptc"],
"vram_texture": true "vram_texture": true
@@ -11,8 +11,8 @@ metadata={
[deps] [deps]
source_file="res://src/items/weapons/textures/Rondo.png" source_file="res://src/items/weapons/textures/RONDO.PNG"
dest_files=["res://.godot/imported/Rondo.png-57553b850a093da6dba43a1e1947fcce.bptc.ctex"] dest_files=["res://.godot/imported/RONDO.PNG-77b50e9afaf9eb46f5672e079a5f50bf.bptc.ctex"]
[params] [params]

View File

@@ -2,6 +2,7 @@ using Chickensoft.AutoInject;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
using System; using System;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter;
[Meta(typeof(IAutoNode))] [Meta(typeof(IAutoNode))]
@@ -13,6 +14,8 @@ public partial class ActionPanel : Panel
[Dependency] private IPlayer _player => this.DependOn<IPlayer>(); [Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Dependency] private IGame _game => this.DependOn<IGame>();
[Node] public Button InteractButton { get; set; } [Node] public Button InteractButton { get; set; }
[Node] public Button ThrowButton { get; set; } [Node] public Button ThrowButton { get; set; }
@@ -21,6 +24,8 @@ public partial class ActionPanel : Panel
public event Action ActionPanelClosing; public event Action ActionPanelClosing;
public event Action ReturnToGameAction;
public void OnResolved() public void OnResolved()
{ {
InteractButton.Pressed += InteractButton_Pressed; InteractButton.Pressed += InteractButton_Pressed;
@@ -49,12 +54,16 @@ public partial class ActionPanel : Panel
private void ThrowButton_Pressed() private void ThrowButton_Pressed()
{ {
throw new System.NotImplementedException(); _game.ThrowItem(_currentlySelected);
_currentlySelected = null;
ActionPanelClosing?.Invoke();
} }
private void DropButton_Pressed() private void DropButton_Pressed()
{ {
throw new System.NotImplementedException(); _game.DropItem(_currentlySelected);
_currentlySelected = null;
ActionPanelClosing?.Invoke();
} }
private void SetOptions(IBaseInventoryItem item) private void SetOptions(IBaseInventoryItem item)
@@ -93,4 +102,9 @@ public partial class ActionPanel : Panel
SfxDatabase.Instance.Play(SoundEffect.Equip); SfxDatabase.Instance.Play(SoundEffect.Equip);
} }
} }
private void PerformAction(IBaseInventoryItem item)
{
_game.UseItem(item);
}
} }

View File

@@ -29,6 +29,8 @@ public partial class InventoryMenu : Control, IInventoryMenu
private List<IItemSlot> ItemSlots; private List<IItemSlot> ItemSlots;
private IItemSlot _currentlySelected;
public void OnResolved() public void OnResolved()
{ {
ItemSlots = [.. Inventory.GetChildren().OfType<IItemSlot>()]; ItemSlots = [.. Inventory.GetChildren().OfType<IItemSlot>()];
@@ -36,6 +38,15 @@ public partial class InventoryMenu : Control, IInventoryMenu
ItemSlots.ForEach(x => x.ItemSelected += ItemSelected); ItemSlots.ForEach(x => x.ItemSelected += ItemSelected);
VisibilityChanged += ResetInventoryState; VisibilityChanged += ResetInventoryState;
ActionPanel.ActionPanelClosing += ActionPanel_ActionPanelClosing; 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) private void ItemPressed(IItemSlot selectedItem)
@@ -46,6 +57,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
private void ItemSelected(IItemSlot selectedItem) private void ItemSelected(IItemSlot selectedItem)
{ {
_currentlySelected = selectedItem;
ItemName.Text = selectedItem.Item.Value.ItemName; ItemName.Text = selectedItem.Item.Value.ItemName;
ItemFlavor.Text = selectedItem.Item.Value.Description; ItemFlavor.Text = selectedItem.Item.Value.Description;
} }
@@ -58,8 +70,11 @@ public partial class InventoryMenu : Control, IInventoryMenu
for (var i = 0; i < inventory.Count; i++) for (var i = 0; i < inventory.Count; i++)
ItemSlots[i].SetItemToSlot(inventory[i]); ItemSlots[i].SetItemToSlot(inventory[i]);
if (_currentlySelected == null && inventory.Any())
_currentlySelected = ItemSlots.First();
if (inventory.Any()) if (inventory.Any())
ItemSlots.First().FocusItem(); _currentlySelected.FocusItem();
ActionPanel.Hide();
} }
private void ActionPanel_ActionPanelClosing() private void ActionPanel_ActionPanelClosing()
@@ -68,14 +83,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
ResetInventoryState(); ResetInventoryState();
} }
private void Slot_FocusEntered(IItemSlot slot)
{
var item = slot.Item.Value;
ItemName.Text = item.ItemName;
ItemFlavor.Text = item.Description;
}
private void InteractButton_Pressed() private void InteractButton_Pressed()
{ {
//if (_currentlySelected != null) //if (_currentlySelected != null)

View File

@@ -45,6 +45,7 @@ outline_color = Color(0, 0, 0, 1)
[node name="InventoryMenu" type="PanelContainer"] [node name="InventoryMenu" type="PanelContainer"]
process_mode = 2 process_mode = 2
visible = false
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0

View File

@@ -37,6 +37,7 @@ public partial class ItemSlot : Control, IItemSlot
{ {
Item.Changed += Item_Changed; Item.Changed += Item_Changed;
ItemName.Pressed += ItemSlot_Pressed; ItemName.Pressed += ItemSlot_Pressed;
ItemName.FocusEntered += FocusItem;
} }
public void SetItemToSlot(IBaseInventoryItem item) public void SetItemToSlot(IBaseInventoryItem item)