Big project cleanup with overhaul of file responsibilities (KISS) and code (DRY, YAGNI)

This commit is contained in:
2026-05-14 11:17:02 +02:00
parent bd6cdeb97b
commit 300c8f5a42
54 changed files with 2030 additions and 1745 deletions
+21 -12
View File
@@ -3,7 +3,8 @@ using Godot;
public partial class InventoryDisplay : PanelContainer
{
private PackedScene itemDisplayPrefab = ResourceLoader.LoadItemDisplay();
private readonly PackedScene itemDisplayPrefab = ResourceLoader.LoadItemDisplay();
[Export] VBoxContainer itemList;
[Export] RichTextLabel inventorySpace;
@@ -34,24 +35,32 @@ public partial class InventoryDisplay : PanelContainer
}
public void ReloadItems()
{
ClearItems();
foreach (Item item in GameData.inventory.items)
{
itemList.AddChild(CreateItemDisplay(item));
}
}
private void ClearItems()
{
foreach (Node node in itemList.GetChildren())
{
itemList.RemoveChild(node);
node.QueueFree();
}
}
ItemDisplay display;
foreach (Item item in GameData.inventory.items)
{
display = itemDisplayPrefab.Instantiate<ItemDisplay>();
display.item = item;
display.text.Text = item.data.GetReadableName();
display.amount.Text = $"{item.currentAmount}/{item.data.StackSize}";
display.texture.Texture = ResourceLoader.LoadPath(item.data.Texture);
itemList.AddChild(display);
}
private ItemDisplay CreateItemDisplay(Item item)
{
ItemDisplay display = itemDisplayPrefab.Instantiate<ItemDisplay>();
display.item = item;
display.text.Text = item.data.GetReadableName();
display.amount.Text = $"{item.currentAmount}/{item.data.StackSize}";
display.texture.Texture = ResourceLoader.LoadPath(item.data.Texture);
return display;
}
public void OnInventoryUpdate(object sender, EventArgs args)