Started implementation of information about item used screen

This commit is contained in:
2026-03-02 01:57:43 -08:00
parent 46f0e78405
commit bc010a7d82
8 changed files with 182 additions and 38 deletions

View File

@@ -45,10 +45,16 @@ public partial class InventoryMenu : Control, IInventoryMenu
[Node] public Label StatusLabel { get; set; }
[Node] public PanelContainer ItemActionResultContainer { get; set; }
[Node] public Label ItemActionResultLabel { get; set; }
private List<IItemSlot> ItemSlots;
private IItemSlot _currentlySelected;
private bool _blocking = false;
public void OnResolved()
{
ItemSlots = [.. Inventory.GetChildren().OfType<IItemSlot>()];
@@ -68,13 +74,11 @@ public partial class InventoryMenu : Control, IInventoryMenu
AttackChanged(0);
DefenseChanged(0);
StatusLabel.Text = string.Empty;
ItemActionResultLabel.Text = string.Empty;
_game.InventoryEventNotification += InventoryEventNotification_Changed;
Hide();
}
private void AttackChanged(int obj) => PlayerATKLabel.Text = $"{_player.AttackComponent.CurrentAttack.Value:D2}/{_player.AttackComponent.MaximumAttack.Value:D2}+{_player.EquipmentComponent.BonusAttack}";
private void DefenseChanged(int obj) => PlayerDEFLabel.Text = $"{_player.DefenseComponent.CurrentDefense.Value:D2}/{_player.DefenseComponent.MaximumDefense.Value:D2}+{_player.EquipmentComponent.BonusDefense}";
public override void _Input(InputEvent @event)
{
var validSelectableItems = _player.Inventory.Items.ToList();
@@ -98,6 +102,9 @@ public partial class InventoryMenu : Control, IInventoryMenu
private void ActionPanel_AugmentMenuRequested()
{
if (_blocking)
return;
ReleaseFocus();
ItemSlots.ForEach(x => x.ItemPressed -= ItemPressed);
ItemSlots.ForEach(x => x.ItemSelected -= ItemSelected);
@@ -114,6 +121,9 @@ public partial class InventoryMenu : Control, IInventoryMenu
private void ItemPressed(IItemSlot selectedItem)
{
if (_blocking)
return;
SetProcessInput(false);
ActionPanel.SetProcessInput(true);
ActionPanel.ShowPanel(selectedItem.Item.Value);
@@ -156,6 +166,22 @@ public partial class InventoryMenu : Control, IInventoryMenu
ActionPanel.Hide();
}
private async void InventoryEventNotification_Changed(string obj)
{
_blocking = true;
ItemActionResultContainer.Show();
ItemActionResultContainer.GrabFocus();
ItemActionResultLabel.Text = obj;
await ToSignal(GetTree().CreateTimer(2f), "timeout");
ItemActionResultContainer.Hide();
ItemActionResultLabel.Text = string.Empty;
_blocking = false;
}
private void AttackChanged(int obj) => PlayerATKLabel.Text = $"{_player.AttackComponent.CurrentAttack.Value:D2}/{_player.AttackComponent.MaximumAttack.Value:D2}+{_player.EquipmentComponent.BonusAttack}";
private void DefenseChanged(int obj) => PlayerDEFLabel.Text = $"{_player.DefenseComponent.CurrentDefense.Value:D2}/{_player.DefenseComponent.MaximumDefense.Value:D2}+{_player.EquipmentComponent.BonusDefense}";
private void ClearDescriptionBox()
{
ItemName.Text = string.Empty;

View File

@@ -436,6 +436,43 @@ layout_mode = 2
[node name="ItemSlot20" parent="Panel/MarginContainer/PanelContainer/MenuPanel/InventoryList/Panel/MarginContainer2/Inventory" instance=ExtResource("6_unikd")]
layout_mode = 2
[node name="ItemActionResultContainer" type="PanelContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel"]
unique_name_in_owner = true
visible = false
custom_minimum_size = Vector2(200, 250)
layout_mode = 2
offset_top = 775.0
offset_right = 574.0
offset_bottom = 1025.0
focus_mode = 2
[node name="ItemActionResultPanel" type="Panel" parent="Panel/MarginContainer/PanelContainer/MenuPanel/ItemActionResultContainer"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_cq2sk")
[node name="MarginContainer" type="MarginContainer" parent="Panel/MarginContainer/PanelContainer/MenuPanel/ItemActionResultContainer"]
layout_mode = 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="Panel/MarginContainer/PanelContainer/MenuPanel/ItemActionResultContainer/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="ItemActionResultLabel" type="Label" parent="Panel/MarginContainer/PanelContainer/MenuPanel/ItemActionResultContainer/MarginContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(275, 125)
layout_mode = 2
text = "Mask of the Goddess of Suffering And Long Text Equipped."
label_settings = ExtResource("7_we8a6")
horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 2
[node name="AugmentMenu" parent="." instance=ExtResource("6_xwkpe")]
unique_name_in_owner = true
visible = false