Redesign and reimplement inventory menu

Add jewels but no implementation yet (needed redesign of inventory menu to function correctly)
This commit is contained in:
2026-02-11 04:08:42 -08:00
parent 5451f0b31f
commit 8ce38c3c13
51 changed files with 1695 additions and 256 deletions

View File

@@ -2,13 +2,13 @@
[ext_resource type="Script" uid="uid://dlq2mkhl4pe7a" path="res://src/ui/in_game_ui/InGameUI.cs" id="1_sc13i"]
[ext_resource type="PackedScene" uid="uid://bwbofurcvf3yh" path="res://src/minimap/Minimap.tscn" id="2_6sfje"]
[ext_resource type="PackedScene" uid="uid://dlj8qdg1c5048" path="res://src/ui/inventory_menu/InventoryMenu.tscn" id="3_4vcdl"]
[ext_resource type="PackedScene" uid="uid://dxl8il8f13c2x" path="res://src/ui/player_ui/PlayerInfoUI.tscn" id="4_46s5l"]
[ext_resource type="PackedScene" uid="uid://bea2waybmgd6u" path="res://src/ui/teleport_prompt/UseTeleportPrompt.tscn" id="5_h1hgq"]
[ext_resource type="PackedScene" uid="uid://x0f1ol50nnp3" path="res://src/ui/in_game_ui/InventoryMessageUI.tscn" id="6_y26qy"]
[ext_resource type="Script" uid="uid://dj6oqler47dqf" path="res://src/utils/FpsCounter.cs" id="7_c6o8j"]
[ext_resource type="Script" uid="uid://3fpuxsgdl8xe" path="res://src/utils/FpsCounter.cs" id="7_c6o8j"]
[ext_resource type="PackedScene" uid="uid://8f3dk16nj0dn" path="res://src/menu/DebugMenu.tscn" id="7_llomk"]
[ext_resource type="Texture2D" uid="uid://bj4p4qxb1mj3q" path="res://src/ui/player_ui/Assets/panel rough draft.png" id="7_ur8ag"]
[ext_resource type="PackedScene" uid="uid://c3e6hbctay1us" path="res://src/ui/inventory_menu/InventoryMenu2.tscn" id="9_ur8ag"]
[sub_resource type="StyleBoxLine" id="StyleBoxLine_ur8ag"]
color = Color(0.792157, 0.698039, 0.643137, 1)
@@ -144,7 +144,6 @@ offset_right = 267.0
offset_bottom = 1004.0
size_flags_vertical = 3
[node name="InventoryMenu" parent="." instance=ExtResource("3_4vcdl")]
[node name="InventoryMenu" parent="." instance=ExtResource("9_ur8ag")]
unique_name_in_owner = true
process_mode = 3
layout_mode = 1

View File

@@ -9,11 +9,9 @@ public interface IItemSlot : IButton
{
public AutoProp<InventoryItem> Item { get; }
public bool IsSelected { get; set; }
public void SetItemEquipmentStatus(bool isEquipped);
public void SetItemStyle();
public event Action<IItemSlot> ItemPressed;
public event Action<InventoryItem> ItemPressed;
public event Action<IItemSlot> ItemEnterFocus;
public event Action<IItemSlot> ItemExitFocus;
public event Action<IItemSlot> ItemSelected;
}

View File

@@ -67,8 +67,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
foreach (var item in ItemSlots)
{
item.ItemPressed += Item_Pressed;
item.ItemEnterFocus += Item_FocusEntered;
item.ItemExitFocus += Item_ItemExitFocus;
}
_player.AttackComponent.CurrentAttack.Sync += Attack_Sync;
@@ -122,8 +120,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
SfxDatabase.Instance.Play(SoundEffect.SortInventory);
Inventory_InventoryChanged();
foreach (var slot in ItemSlots)
slot.SetItemStyle();
Item_ItemExitFocus(_currentlySelectedItem);
_currentlySelectedItem = ItemSlot1;
_currentlySelectedItem.GrabFocus();
@@ -151,8 +147,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
{
ItemDescriptionTitle.Text = string.Empty;
ItemEffectLabel.Text = string.Empty;
itemSlot.IsSelected = false;
itemSlot.SetItemStyle();
}
private void Item_FocusEntered(IItemSlot itemSlot)
@@ -166,19 +160,16 @@ public partial class InventoryMenu : Control, IInventoryMenu
ItemDescriptionTitle.Text = $"{itemSlot.Item.Value.ItemName}";
ItemEffectLabel.Text = $"{itemSlot.Item.Value.Description}";
_currentlySelectedItem = itemSlot;
itemSlot.IsSelected = true;
itemSlot.SetItemStyle();
AcceptEvent();
}
private void Item_Pressed(InventoryItem item) => DisplayUserActionPrompt(item);
private void Item_Pressed(IItemSlot item) => DisplayUserActionPrompt(item.Item.Value);
private async void Inventory_InventoryChanged()
{
foreach (var slot in ItemSlots)
{
slot.Visible = false;
slot.SetItemStyle();
}
var itemsToDisplay = _player.Inventory.Items;
@@ -213,6 +204,8 @@ public partial class InventoryMenu : Control, IInventoryMenu
await EquipOrUnequipItem(equipable);
else if (_currentlySelectedItem.Item.Value is Plastique plastique)
SetItem();
else if (_currentlySelectedItem.Item.Value is Jewel jewel)
AugmentEquipment(jewel);
else
await _game.UseItem(_currentlySelectedItem.Item.Value);
UseButton.Disabled = false;
@@ -250,6 +243,15 @@ public partial class InventoryMenu : Control, IInventoryMenu
_gameRepo.CloseInventory();
}
private void AugmentEquipment(Jewel jewel)
{
DisplayUserActionPrompt(jewel);
foreach (var item in ItemSlots)
{
item.Disabled = item.Item.Value is not Weapon && item.Item.Value is not Armor && item.Item.Value is not Accessory;
}
}
private void DisplayUserActionPrompt(InventoryItem item)
{
SfxDatabase.Instance.Play(SoundEffect.SelectUI);
@@ -264,6 +266,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
{
var isItemEquipped = _player.EquipmentComponent.IsItemEquipped(equipable);
UseButton.Text = isItemEquipped ? "Unequip" : "Equip";
UseButton.Disabled = equipable.Glued;
ThrowButton.Disabled = isItemEquipped;
ThrowButton.FocusMode = isItemEquipped ? FocusModeEnum.None : FocusModeEnum.All;
DropButton.Disabled = isItemEquipped;

View File

@@ -38,7 +38,6 @@ light_mode = 2
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_unikd"]
[node name="InventoryMenu" type="Control"]
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -290,120 +289,126 @@ offset_top = 23.0
offset_right = 1885.0
offset_bottom = 1015.0
[node name="ScrollContainer" type="ScrollContainer" parent="Panel"]
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="ScrollContainer" type="ScrollContainer" parent="Panel/MarginContainer"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_unikd")
follow_focus = true
draw_focus_border = true
[node name="ItemsPage" type="VBoxContainer" parent="Panel/ScrollContainer"]
[node name="ItemsPage" type="VBoxContainer" parent="Panel/MarginContainer/ScrollContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 2
alignment = 1
[node name="ItemSlot1" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot1" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
layout_mode = 2
[node name="ItemSlot2" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot2" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot3" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot3" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot4" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot4" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot5" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot5" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot6" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot6" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot7" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot7" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot8" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot8" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot9" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot9" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot10" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot10" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot11" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot11" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot12" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot12" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot13" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot13" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot14" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot14" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot15" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot15" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot16" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot16" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot17" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot17" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot18" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot18" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot19" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot19" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="ItemSlot20" parent="Panel/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
[node name="ItemSlot20" parent="Panel/MarginContainer/ScrollContainer/ItemsPage" instance=ExtResource("4_aiji3")]
unique_name_in_owner = true
visible = false
layout_mode = 2

View File

@@ -0,0 +1,264 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using System.Collections.Generic;
using System.Linq;
using Zennysoft.Game.Implementation;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
[Meta(typeof(IAutoNode))]
public partial class InventoryMenu2 : Control, IInventoryMenu
{
public override void _Notification(int what) => this.Notify(what);
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Dependency] private IGame _game => this.DependOn<IGame>();
[Dependency] private IGameRepo _gameRepo => this.DependOn<IGameRepo>();
[Node] public Label ItemName { get; set; }
[Node] public Label ItemFlavor { get; set; }
[Node] public Label ItemStats { get; set; }
[Node] public Button InteractButton { get; set; }
[Node] public Button ThrowButton { get; set; }
[Node] public Button DropButton { get; set; }
[Node] public Control ActionPanel { get; set; }
private List<IItemSlot> ItemSlots;
private List<Label> ItemCountLabels;
private IItemSlot _currentlySelected;
#region ItemSlots
[Node] public IItemSlot ItemSlot01 { get; set; }
[Node] public IItemSlot ItemSlot02 { get; set; }
[Node] public IItemSlot ItemSlot03 { get; set; }
[Node] public IItemSlot ItemSlot04 { get; set; }
[Node] public IItemSlot ItemSlot05 { get; set; }
[Node] public IItemSlot ItemSlot06 { get; set; }
[Node] public IItemSlot ItemSlot07 { get; set; }
[Node] public IItemSlot ItemSlot08 { get; set; }
[Node] public IItemSlot ItemSlot09 { get; set; }
[Node] public IItemSlot ItemSlot10 { get; set; }
[Node] public IItemSlot ItemSlot11 { get; set; }
[Node] public IItemSlot ItemSlot12 { get; set; }
[Node] public IItemSlot ItemSlot13 { get; set; }
[Node] public IItemSlot ItemSlot14 { get; set; }
[Node] public IItemSlot ItemSlot15 { get; set; }
[Node] public IItemSlot ItemSlot16 { get; set; }
[Node] public IItemSlot ItemSlot17 { get; set; }
[Node] public IItemSlot ItemSlot18 { get; set; }
[Node] public IItemSlot ItemSlot19 { get; set; }
[Node] public IItemSlot ItemSlot20 { get; set; }
[Node] public Label ItemCount01 { get; set; }
[Node] public Label ItemCount02 { get; set; }
[Node] public Label ItemCount03 { get; set; }
[Node] public Label ItemCount04 { get; set; }
[Node] public Label ItemCount05 { get; set; }
[Node] public Label ItemCount06 { get; set; }
[Node] public Label ItemCount07 { get; set; }
[Node] public Label ItemCount08 { get; set; }
[Node] public Label ItemCount09 { get; set; }
[Node] public Label ItemCount10 { get; set; }
[Node] public Label ItemCount11 { get; set; }
[Node] public Label ItemCount12 { get; set; }
[Node] public Label ItemCount13 { get; set; }
[Node] public Label ItemCount14 { get; set; }
[Node] public Label ItemCount15 { get; set; }
[Node] public Label ItemCount16 { get; set; }
[Node] public Label ItemCount17 { get; set; }
[Node] public Label ItemCount18 { get; set; }
[Node] public Label ItemCount19 { get; set; }
[Node] public Label ItemCount20 { get; set; }
#endregion
public void OnResolved()
{
ItemSlots = [ItemSlot01, ItemSlot02, ItemSlot03, ItemSlot04, ItemSlot05, ItemSlot06, ItemSlot07, ItemSlot08, ItemSlot09, ItemSlot10, ItemSlot11, ItemSlot12, ItemSlot13, ItemSlot14, ItemSlot15, ItemSlot16, ItemSlot17, ItemSlot18, ItemSlot19, ItemSlot20];
ItemCountLabels = [ItemCount01, ItemCount02, ItemCount03, ItemCount04, ItemCount05, ItemCount06, ItemCount07, ItemCount08, ItemCount09, ItemCount10, ItemCount11, ItemCount12, ItemCount13, ItemCount14, ItemCount15, ItemCount16, ItemCount17, ItemCount18, ItemCount19, ItemCount20];
foreach (var slot in ItemSlots)
{
slot.ItemSelected += Slot_FocusEntered;
slot.ItemPressed += Slot_ItemPressed;
}
VisibilityChanged += InventoryMenu_VisibilityChanged;
InteractButton.Pressed += InteractButton_Pressed;
ThrowButton.Pressed += ThrowButton_Pressed;
DropButton.Pressed += DropButton_Pressed;
_currentlySelected = ItemSlot01;
}
private void InteractButton_Pressed()
{
if (_currentlySelected != null)
{
var item = _currentlySelected.Item.Value;
if (item is EquipableItem equipable)
{
if (_player.EquipmentComponent.IsItemEquipped(equipable))
_player.Unequip(equipable);
else
{
_player.Equip(equipable);
}
foreach (var slot in ItemSlots)
slot.SetItemEquipmentStatus(_player.EquipmentComponent.IsItemEquipped(slot.Item.Value));
}
else if (item is Plastique plastique)
_game.SetItem(plastique);
else
_game.UseItem(_currentlySelected.Item.Value);
CloseActionMenu();
}
}
private void DropButton_Pressed()
{
var previousItemInList = Mathf.Max(0, ItemSlots.IndexOf(_currentlySelected) - 1);
_game.DropItem(_currentlySelected.Item.Value);
CloseActionMenu();
_gameRepo.CloseInventory();
if (!_player.Inventory.Items.Contains(_currentlySelected.Item.Value))
_currentlySelected = ItemSlots[previousItemInList];
}
private void ThrowButton_Pressed()
{
var previousItemInList = Mathf.Max(0, ItemSlots.IndexOf(_currentlySelected) - 1);
_game.ThrowItem(_currentlySelected.Item.Value);
CloseActionMenu();
_gameRepo.CloseInventory();
if (!_player.Inventory.Items.Contains(_currentlySelected.Item.Value))
_currentlySelected = ItemSlots[previousItemInList];
}
public override void _Input(InputEvent @event)
{
if (ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.Interact))
{
CloseActionMenu();
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
GetViewport().SetInputAsHandled();
}
if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.MoveUp))
{
if (ItemSlots.First(x => x.Visible) != _currentlySelected)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
}
if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.MoveDown))
{
if (ItemSlots.Last(x => x.Visible) != _currentlySelected)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
}
if (Input.IsActionJustPressed(GameInputs.MoveDown) && ActionPanel.Visible && InteractButton.HasFocus() && !ThrowButton.Disabled)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (Input.IsActionJustPressed(GameInputs.MoveDown) && ActionPanel.Visible && ThrowButton.HasFocus() && !DropButton.Disabled)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (Input.IsActionJustPressed(GameInputs.MoveUp) && ActionPanel.Visible && ThrowButton.HasFocus() && !InteractButton.Disabled)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (Input.IsActionJustPressed(GameInputs.MoveUp) && ActionPanel.Visible && DropButton.HasFocus() && !ThrowButton.Disabled)
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (!ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.InventorySort))
{
_player.Inventory.Sort(_player.EquipmentComponent.EquippedWeapon.Value, _player.EquipmentComponent.EquippedArmor.Value, _player.EquipmentComponent.EquippedAccessory.Value, _player.EquipmentComponent.EquippedAmmo.Value);
SfxDatabase.Instance.Play(SoundEffect.SortInventory);
InventoryMenu_VisibilityChanged();
}
}
private void Slot_ItemPressed(IItemSlot slot)
{
var item = slot.Item.Value;
InteractButton.Disabled = false;
ThrowButton.Disabled = false;
DropButton.Disabled = false;
InteractButton.FocusMode = FocusModeEnum.All;
ThrowButton.FocusMode = FocusModeEnum.All;
DropButton.FocusMode = FocusModeEnum.All;
if (item is EquipableItem equipable)
{
var itemIsEquipped = _player.EquipmentComponent.IsItemEquipped(equipable);
InteractButton.Text = itemIsEquipped ? "Unequip" : "Equip";
InteractButton.Disabled = itemIsEquipped && equipable.Glued;
ThrowButton.Disabled = itemIsEquipped;
ThrowButton.FocusMode = itemIsEquipped ? FocusModeEnum.None : FocusModeEnum.All;
DropButton.Disabled = itemIsEquipped;
DropButton.FocusMode = itemIsEquipped ? FocusModeEnum.None : FocusModeEnum.All;
InteractButton.GrabFocus();
}
else if (item is Plastique plastique)
{
InteractButton.Text = "Set";
InteractButton.GrabFocus();
}
else if (item is ThrowableItem throwable)
{
InteractButton.Disabled = true;
InteractButton.FocusMode = FocusModeEnum.None;
ThrowButton.GrabFocus();
}
else
{
InteractButton.Text = "Use";
InteractButton.GrabFocus();
}
ActionPanel.Show();
}
private void InventoryMenu_VisibilityChanged()
{
foreach (var item in ItemSlots)
item.Hide();
foreach (var item in ItemCountLabels)
item.Text = string.Empty;
for (var i = 0; i < _player.Inventory.Items.Count; i++)
{
var item = _player.Inventory.Items[i];
ItemSlots[i].Item.OnNext(item);
ItemSlots[i].Show();
ItemSlots[i].SetItemEquipmentStatus(_player.EquipmentComponent.IsItemEquipped(item));
if (item is IStackable stackable)
ItemCountLabels[i].Text = $"x{stackable.Count.Value:D2}";
}
if (_currentlySelected != null)
_currentlySelected.GrabFocus();
else
_currentlySelected = ItemSlots.First();
}
private void Slot_FocusEntered(IItemSlot slot)
{
if (_currentlySelected.Item.Value == null)
return;
_currentlySelected = slot;
var item = slot.Item.Value;
ItemName.Text = item.ItemName;
ItemFlavor.Text = item.Description;
}
private void CloseActionMenu()
{
_currentlySelected.GrabFocus();
ActionPanel.Hide();
}
}

View File

@@ -0,0 +1 @@
uid://yh8qxmn058w2

View File

@@ -0,0 +1,607 @@
[gd_scene load_steps=11 format=3 uid="uid://c3e6hbctay1us"]
[ext_resource type="Script" uid="uid://yh8qxmn058w2" path="res://src/ui/inventory_menu/InventoryMenu2.cs" id="1_x1to8"]
[ext_resource type="PackedScene" uid="uid://c005nd0m2eim" path="res://src/ui/inventory_menu/ItemSlot.tscn" id="2_44spe"]
[ext_resource type="FontFile" uid="uid://beh6d5lo5ihq0" path="res://src/ui/fonts/georgiai.ttf" id="2_g7ag1"]
[ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="3_smunm"]
[ext_resource type="StyleBox" uid="uid://bl15q835s4ene" path="res://src/options/UnselectedOptionsBox.tres" id="4_cq2sk"]
[ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="6_ejvue"]
[ext_resource type="LabelSettings" uid="uid://b6f8ggy3ulonb" path="res://src/ui/label_settings/GeorgiaItalic.tres" id="6_g7ag1"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cq2sk"]
bg_color = Color(0, 0, 0, 0.745098)
[sub_resource type="LabelSettings" id="LabelSettings_ejvue"]
line_spacing = 1.0
font = ExtResource("2_g7ag1")
font_size = 50
outline_size = 3
outline_color = Color(0, 0, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_g7ag1"]
bg_color = Color(0, 0, 0, 0.745098)
[node name="InventoryMenu2" type="Control"]
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_x1to8")
[node name="InventoryTitlePanel" type="Panel" parent="."]
layout_mode = 1
offset_left = 38.0
offset_top = 40.0
offset_right = 431.0
offset_bottom = 157.0
theme_override_styles/panel = SubResource("StyleBoxFlat_cq2sk")
[node name="MarginContainer" type="MarginContainer" parent="InventoryTitlePanel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryTitlePanel/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="InventoryLabel" type="Label" parent="InventoryTitlePanel/MarginContainer/ReferenceRect"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_font_sizes/font_size = 15
text = "INVENTORY"
label_settings = SubResource("LabelSettings_ejvue")
horizontal_alignment = 1
vertical_alignment = 1
[node name="ActionPanel" type="Panel" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.107
anchor_top = 0.86
anchor_right = 0.199
anchor_bottom = 0.915
offset_left = -164.44
offset_top = -35.8
offset_right = -159.08
offset_bottom = 70.8
grow_vertical = 0
focus_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_g7ag1")
[node name="MarginContainer" type="MarginContainer" parent="ActionPanel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="ReferenceRect" type="ReferenceRect" parent="ActionPanel/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="MarginContainer" type="MarginContainer" parent="ActionPanel/MarginContainer"]
layout_mode = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="VBoxContainer" type="VBoxContainer" parent="ActionPanel/MarginContainer/MarginContainer"]
layout_mode = 2
alignment = 1
[node name="InteractButton" type="Button" parent="ActionPanel/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_top = NodePath(".")
focus_neighbor_right = NodePath(".")
focus_neighbor_bottom = NodePath("../ThrowButton")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("3_smunm")
theme_override_styles/disabled_mirrored = ExtResource("4_cq2sk")
theme_override_styles/disabled = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed = ExtResource("4_cq2sk")
theme_override_styles/hover_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover = ExtResource("4_cq2sk")
theme_override_styles/pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/pressed = ExtResource("4_cq2sk")
theme_override_styles/normal_mirrored = ExtResource("4_cq2sk")
theme_override_styles/normal = ExtResource("4_cq2sk")
text = "Interact"
alignment = 0
[node name="ThrowButton" type="Button" parent="ActionPanel/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_top = NodePath("../InteractButton")
focus_neighbor_right = NodePath(".")
focus_neighbor_bottom = NodePath("../DropButton")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("3_smunm")
theme_override_styles/disabled_mirrored = ExtResource("4_cq2sk")
theme_override_styles/disabled = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed = ExtResource("4_cq2sk")
theme_override_styles/hover_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover = ExtResource("4_cq2sk")
theme_override_styles/pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/pressed = ExtResource("4_cq2sk")
theme_override_styles/normal_mirrored = ExtResource("4_cq2sk")
theme_override_styles/normal = ExtResource("4_cq2sk")
text = "Throw"
alignment = 0
[node name="DropButton" type="Button" parent="ActionPanel/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_top = NodePath("../ThrowButton")
focus_neighbor_right = NodePath(".")
focus_neighbor_bottom = NodePath(".")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("3_smunm")
theme_override_styles/disabled_mirrored = ExtResource("4_cq2sk")
theme_override_styles/disabled = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover_pressed = ExtResource("4_cq2sk")
theme_override_styles/hover_mirrored = ExtResource("4_cq2sk")
theme_override_styles/hover = ExtResource("4_cq2sk")
theme_override_styles/pressed_mirrored = ExtResource("4_cq2sk")
theme_override_styles/pressed = ExtResource("4_cq2sk")
theme_override_styles/normal_mirrored = ExtResource("4_cq2sk")
theme_override_styles/normal = ExtResource("4_cq2sk")
text = "Drop"
alignment = 0
[node name="InventoryList" type="Panel" parent="."]
layout_mode = 2
offset_left = 760.0
offset_top = 10.0
offset_right = 1419.0
offset_bottom = 1060.0
theme_override_styles/panel = SubResource("StyleBoxFlat_cq2sk")
[node name="MarginContainer" type="MarginContainer" parent="InventoryList"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 20
[node name="ReferenceRect" type="ReferenceRect" parent="InventoryList/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="MarginContainer" type="MarginContainer" parent="InventoryList/MarginContainer"]
layout_mode = 2
theme_override_constants/margin_left = 125
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="HBoxContainer" type="HBoxContainer" parent="InventoryList/MarginContainer/MarginContainer"]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 0
[node name="ItemSlot01" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot02" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot03" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot04" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot05" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot06" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot07" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot08" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot09" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot10" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot11" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot12" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot13" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot14" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot15" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot16" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot17" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot18" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot19" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="ItemSlot20" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_44spe")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 0
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
mouse_filter = 1
[node name="VBoxContainer2" type="VBoxContainer" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
theme_override_constants/separation = 0
[node name="ItemCount01" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount02" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount03" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount04" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount05" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount06" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount07" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount08" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount09" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount10" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount11" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount12" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount13" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount14" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount15" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount16" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount17" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount18" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount19" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemCount20" type="Label" parent="InventoryList/MarginContainer/MarginContainer/HBoxContainer/VBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
theme_override_fonts/font = ExtResource("6_ejvue")
theme_override_font_sizes/font_size = 25
vertical_alignment = 1
[node name="ItemDescriptionBox" type="Panel" parent="."]
layout_mode = 2
offset_left = 37.0
offset_top = 242.0
offset_right = 717.0
offset_bottom = 838.0
theme_override_styles/panel = SubResource("StyleBoxFlat_cq2sk")
[node name="MarginContainer" type="MarginContainer" parent="ItemDescriptionBox"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="ReferenceRect" type="ReferenceRect" parent="ItemDescriptionBox/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="MarginContainer" type="MarginContainer" parent="ItemDescriptionBox/MarginContainer"]
layout_mode = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 15
theme_override_constants/margin_bottom = 15
[node name="VBoxContainer" type="VBoxContainer" parent="ItemDescriptionBox/MarginContainer/MarginContainer"]
layout_mode = 2
theme_override_constants/separation = 50
[node name="ItemName" type="Label" parent="ItemDescriptionBox/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
label_settings = ExtResource("6_g7ag1")
[node name="ItemFlavor" type="Label" parent="ItemDescriptionBox/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(500, 150)
layout_mode = 2
label_settings = ExtResource("6_g7ag1")
vertical_alignment = 1
autowrap_mode = 2
[node name="ItemStats" type="Label" parent="ItemDescriptionBox/MarginContainer/MarginContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
label_settings = ExtResource("6_g7ag1")

View File

@@ -4,6 +4,7 @@ using Chickensoft.Introspection;
using Godot;
using System;
using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Implementation;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
@@ -15,105 +16,56 @@ public partial class ItemSlot : Button, IItemSlot
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Node] public Label Equipped { get; set; } = default!;
[Node] public TextureRect ItemTexture { get; set; } = default!;
[Node] public Label ItemName { get; set; } = default!;
[Node] public Label ItemCount { get; set; } = default!;
public AutoProp<InventoryItem> Item { get; } = new AutoProp<InventoryItem>(default);
private static LabelSettings ItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextBold.tres");
public event Action<IItemSlot> ItemPressed;
private static LabelSettings SelectedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontItalicized.tres");
private static LabelSettings EquippedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontEquipped.tres");
private static LabelSettings SelectedEquippedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontSelectedEquipped.tres");
public event Action<InventoryItem> ItemPressed;
public event Action<IItemSlot> ItemEnterFocus;
public event Action<IItemSlot> ItemExitFocus;
public event Action<IItemSlot> ItemSelected;
public bool IsSelected { get; set; } = false;
public void OnResolved()
{
Item.Changed += Item_Changed;
_player.EquipmentComponent.EquippedWeapon.Sync += EquipableItem_Sync;
_player.EquipmentComponent.EquippedArmor.Sync += EquipableItem_Sync;
_player.EquipmentComponent.EquippedAccessory.Sync += EquipableItem_Sync;
FocusEntered += ItemSlot_FocusEntered;
FocusExited += ItemSlot_FocusExited;
Pressed += ItemSlot_Pressed;
}
public void SetItemStyle()
public void SetItemEquipmentStatus(bool isEquipped)
{
if (_player.EquipmentComponent.IsItemEquipped(Item.Value) && IsSelected)
SetEquippedSelectedItemStyle();
else if (_player.EquipmentComponent.IsItemEquipped(Item.Value))
SetEquippedItemStyle();
else if (IsSelected)
SetSelectedItemStyle();
if (isEquipped)
Equipped.Text = "E";
else
SetToUnselectedStyle();
Equipped.Text = string.Empty;
}
public void SetToUnselectedStyle()
{
SetItemFont();
if (_player.EquipmentComponent.IsItemEquipped(Item.Value))
SetEquippedItemStyle();
}
private void EquipableItem_Sync(EquipableItem item) => SetItemStyle();
private void ItemSlot_FocusEntered() => ItemSelected?.Invoke(this);
private void ItemSlot_Pressed()
{
if (Item.Value == null)
return;
ItemPressed?.Invoke(Item.Value);
ItemPressed?.Invoke(this);
}
private void ItemSlot_FocusExited() => ItemExitFocus?.Invoke(this);
private void ItemSlot_FocusEntered() => ItemEnterFocus?.Invoke(this);
private void Item_Changed(InventoryItem obj)
{
if (obj == null)
return;
ItemName.Text = obj.ItemName;
Text = obj.ItemName;
ItemTexture.Texture = obj.GetTexture();
if (obj is IStackable stackableItem)
if (Item.Value is EquipableItem equipableItem && _player.EquipmentComponent.IsItemEquipped(equipableItem))
{
ItemCount.Text = $"{stackableItem.Count:D2}";
ItemCount.Visible = true;
Equipped.Text = "E";
}
else
{
ItemCount.Text = string.Empty;
ItemCount.Visible = false;
}
Equipped.Text = string.Empty;
}
private void SetToSelectedStyle() => SetSelectedItemStyle();
private void SetSelectedItemStyle()
{
if (_player.EquipmentComponent.IsItemEquipped(Item.Value))
ItemName.LabelSettings = SelectedEquippedItemFont;
else
ItemName.LabelSettings = SelectedItemFont;
}
private void SetItemFont() => ItemName.LabelSettings = ItemFont;
private void SetEquippedItemStyle() => ItemName.LabelSettings = EquippedItemFont;
private void SetEquippedSelectedItemStyle() => ItemName.LabelSettings = SelectedEquippedItemFont;
}

View File

@@ -1,65 +1,62 @@
[gd_scene load_steps=5 format=3 uid="uid://c005nd0m2eim"]
[ext_resource type="Script" uid="uid://cglxk7v8hpesn" path="res://src/ui/inventory_menu/ItemSlot.cs" id="1_yttxt"]
[ext_resource type="LabelSettings" uid="uid://dupifadnagodp" path="res://src/ui/label_settings/MainTextRegular.tres" id="3_rf22b"]
[ext_resource type="Script" uid="uid://b0rrpkpsfdga8" path="res://src/ui/inventory_menu/ItemLabel.cs" id="3_xlgl0"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_lt1pw"]
[ext_resource type="Texture2D" uid="uid://dymrg1fmwho35" path="res://src/items/weapons/textures/Cross Sword.png" id="2_rf22b"]
[ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="4_lt1pw"]
[ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="4_t6dim"]
[node name="ItemSlot" type="Button"]
custom_minimum_size = Vector2(100, 60)
custom_minimum_size = Vector2(100, 50)
anchors_preset = -1
anchor_right = 0.885
anchor_bottom = 0.093
offset_right = 0.799927
offset_bottom = -0.440002
theme_override_styles/focus = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/disabled_mirrored = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/disabled = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/hover_pressed_mirrored = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/hover_mirrored = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/hover = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/pressed_mirrored = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/normal_mirrored = SubResource("StyleBoxEmpty_lt1pw")
theme_override_styles/normal = SubResource("StyleBoxEmpty_lt1pw")
offset_left = 123.0
offset_right = -1414.2
offset_bottom = -50.44
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
mouse_filter = 2
theme_override_constants/h_separation = 20
theme_override_fonts/font = ExtResource("4_t6dim")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("4_lt1pw")
theme_override_styles/disabled_mirrored = ExtResource("4_lt1pw")
theme_override_styles/disabled = ExtResource("4_lt1pw")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_lt1pw")
theme_override_styles/hover_pressed = ExtResource("4_lt1pw")
theme_override_styles/hover_mirrored = ExtResource("4_lt1pw")
theme_override_styles/hover = ExtResource("4_lt1pw")
theme_override_styles/pressed_mirrored = ExtResource("4_lt1pw")
theme_override_styles/pressed = ExtResource("4_lt1pw")
theme_override_styles/normal_mirrored = ExtResource("4_lt1pw")
theme_override_styles/normal = ExtResource("4_lt1pw")
button_mask = 0
text = "Cross Sword"
flat = true
alignment = 0
script = ExtResource("1_yttxt")
[node name="HBox" type="HBoxContainer" parent="."]
custom_minimum_size = Vector2(100, 60)
[node name="ItemTexture" type="TextureRect" parent="."]
unique_name_in_owner = true
layout_mode = 0
offset_right = 1700.0
offset_bottom = 100.0
[node name="ReferenceRect" type="ReferenceRect" parent="HBox"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
[node name="ItemTexture" type="TextureRect" parent="HBox"]
unique_name_in_owner = true
layout_mode = 2
offset_left = -65.0
offset_top = 6.0
offset_right = -25.0
offset_bottom = 46.0
texture = ExtResource("2_rf22b")
expand_mode = 2
stretch_mode = 4
[node name="ReferenceRect2" type="ReferenceRect" parent="HBox"]
custom_minimum_size = Vector2(40, 0)
layout_mode = 2
[node name="ItemName" type="Label" parent="HBox"]
[node name="Equipped" type="Label" parent="."]
unique_name_in_owner = true
custom_minimum_size = Vector2(550, 50)
custom_minimum_size = Vector2(25, 50)
layout_mode = 2
text = "Mask of the Goddess of Destruction"
label_settings = ExtResource("3_rf22b")
offset_left = -122.0
offset_right = -78.0
offset_bottom = 50.0
theme_override_fonts/font = ExtResource("4_t6dim")
theme_override_font_sizes/font_size = 25
text = "E"
horizontal_alignment = 1
vertical_alignment = 1
script = ExtResource("3_xlgl0")
[node name="ItemCount" type="Label" parent="HBox"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "x99"
label_settings = ExtResource("3_rf22b")