Overhaul item and inventory and clean up bits and pieces

This commit is contained in:
2026-02-15 01:19:27 -08:00
parent a1f4a29eb3
commit 69b25aacb9
219 changed files with 4378 additions and 2355 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://b1muxus5qdbeu"]
[gd_scene load_steps=12 format=3 uid="uid://b8tclvmc7j7dl"]
[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"]
@@ -6,13 +6,12 @@
[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="Texture2D" uid="uid://dnt8myee0ju3v" path="res://src/ui/UI Front with Transparency.png" id="7_higkc"]
[ext_resource type="PackedScene" uid="uid://8f3dk16nj0dn" path="res://src/menu/DebugMenu.tscn" id="7_llomk"]
[ext_resource type="PackedScene" uid="uid://c3e6hbctay1us" path="res://src/ui/inventory_menu/InventoryMenu2.tscn" id="9_ur8ag"]
[ext_resource type="Texture2D" uid="uid://dnt8myee0ju3v" path="res://src/ui/UI Front with Transparency.png" id="9_f46co"]
[ext_resource type="PackedScene" uid="uid://cbxw70qa7gifp" path="res://src/ui/inventory_menu/InventoryMenu.tscn" id="9_ur8ag"]
[ext_resource type="PackedScene" uid="uid://dwa7o6hkkwjg1" path="res://src/ui/inventory_menu/ItemRescueMenu.tscn" id="10_higkc"]
[sub_resource type="StyleBoxLine" id="StyleBoxLine_ur8ag"]
color = Color(0.792157, 0.698039, 0.643137, 1)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_higkc"]
[node name="InGameUI" type="Control"]
process_mode = 3
@@ -76,18 +75,36 @@ visible = false
custom_minimum_size = Vector2(1440, 1080)
layout_mode = 2
[node name="Panel" type="ColorRect" parent="HBoxContainer"]
custom_minimum_size = Vector2(480, 0)
layout_mode = 2
color = Color(0, 0, 0, 1)
[node name="InventoryMenu" parent="." instance=ExtResource("9_ur8ag")]
unique_name_in_owner = true
layout_mode = 1
[node name="MinimapZone" type="Panel" parent="HBoxContainer/Panel"]
layout_mode = 2
offset_top = 14.0
offset_right = 480.0
offset_bottom = 14.0
[node name="ItemRescueMenu" parent="." instance=ExtResource("10_higkc")]
unique_name_in_owner = true
visible = false
layout_mode = 1
[node name="MiniMap" parent="HBoxContainer/Panel/MinimapZone" instance=ExtResource("2_6sfje")]
[node name="Sidebar Container" type="PanelContainer" parent="."]
custom_minimum_size = Vector2(459, 0)
layout_mode = 1
anchors_preset = 11
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 0
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_higkc")
[node name="MinimapContainer" type="MarginContainer" parent="Sidebar Container"]
layout_mode = 2
theme_override_constants/margin_left = 15
theme_override_constants/margin_top = 0
[node name="MinimapZone" type="Panel" parent="Sidebar Container/MinimapContainer"]
layout_mode = 2
size_flags_vertical = 3
[node name="MiniMap" parent="Sidebar Container/MinimapContainer/MinimapZone" instance=ExtResource("2_6sfje")]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
@@ -101,48 +118,26 @@ offset_top = 354.0
offset_right = 423.0
offset_bottom = 620.0
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/Panel"]
texture_filter = 2
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_bottom = 1072.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("7_higkc")
stretch_mode = 4
[node name="Sidebar Texture" type="TextureRect" parent="Sidebar Container"]
layout_mode = 2
texture = ExtResource("9_f46co")
[node name="PlayerInfoUI" parent="HBoxContainer/Panel" instance=ExtResource("4_46s5l")]
[node name="PlayerInfoContainer" type="MarginContainer" parent="Sidebar Container"]
layout_mode = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 200
[node name="PlayerInfoUI" parent="Sidebar Container/PlayerInfoContainer" instance=ExtResource("4_46s5l")]
unique_name_in_owner = true
layout_mode = 2
anchors_preset = 0
offset_left = 29.0
offset_top = 197.0
offset_right = 29.0
offset_bottom = -746.0
[node name="HSeparator" type="HSeparator" parent="HBoxContainer/Panel"]
layout_mode = 2
offset_left = 99.0
offset_top = 326.0
offset_right = 391.0
offset_bottom = 332.0
theme_override_styles/separator = SubResource("StyleBoxLine_ur8ag")
[node name="Sigil Marker" type="ReferenceRect" parent="HBoxContainer/Panel"]
layout_mode = 2
offset_left = 75.0
offset_top = 813.0
offset_right = 267.0
offset_bottom = 1004.0
size_flags_vertical = 3
[node name="InventoryMenu" parent="." instance=ExtResource("9_ur8ag")]
unique_name_in_owner = true
layout_mode = 1
[node name="SigilContainer" type="MarginContainer" parent="Sidebar Container"]
layout_mode = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 800
theme_override_constants/margin_right = 175
theme_override_constants/margin_bottom = 50
[node name="ItemRescueMenu" parent="." instance=ExtResource("10_higkc")]
unique_name_in_owner = true
visible = false
layout_mode = 1
[node name="ReferenceRect" type="ReferenceRect" parent="Sidebar Container/SigilContainer"]
layout_mode = 2

View File

@@ -0,0 +1,165 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using System;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
[Meta(typeof(IAutoNode))]
public partial class ActionPanel : Panel
{
public override void _Notification(int what) => this.Notify(what);
private IBaseInventoryItem _currentlySelected;
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Dependency] private IGame _game => this.DependOn<IGame>();
[Node] public Button InteractButton { get; set; }
[Node] public Button ThrowButton { get; set; }
[Node] public Button DropButton { get; set; }
public event Action ActionPanelClosing;
public event Action ReturnToGameAction;
public event Action AugmentMenuRequested;
public void OnResolved()
{
InteractButton.Pressed += InteractButton_Pressed;
ThrowButton.Pressed += ThrowButton_Pressed;
DropButton.Pressed += DropButton_Pressed;
}
public void ShowPanel(IBaseInventoryItem selectedItem)
{
_currentlySelected = selectedItem;
SetOptions(selectedItem);
Show();
}
public void FocusActionPanel()
{
InteractButton.GrabFocus();
}
public void HideActionPanel()
{
InteractButton.Disabled = false;
ThrowButton.Disabled = false;
DropButton.Disabled = false;
ThrowButton.FocusMode = FocusModeEnum.All;
DropButton.FocusMode = FocusModeEnum.All;
ActionPanelClosing?.Invoke();
}
public override void _Input(InputEvent @event)
{
if (Visible && Input.IsActionJustPressed(GameInputs.Interact))
{
GetViewport().SetInputAsHandled();
HideActionPanel();
}
}
private void InteractButton_Pressed()
{
PerformAction((dynamic)_currentlySelected);
}
private void ThrowButton_Pressed()
{
_game.ThrowItem(_currentlySelected);
_currentlySelected = null;
ActionPanelClosing?.Invoke();
ReturnToGameAction?.Invoke();
}
private void DropButton_Pressed()
{
_game.DropItem(_currentlySelected);
_currentlySelected = null;
ActionPanelClosing?.Invoke();
ReturnToGameAction?.Invoke();
}
private void SetOptions(IBaseInventoryItem item)
{
SetOptionsInternal((dynamic)item);
}
private void ResetActionPanel()
{
InteractButton.Disabled = false;
ThrowButton.Disabled = false;
DropButton.Disabled = false;
ThrowButton.FocusMode = FocusModeEnum.All;
DropButton.FocusMode = FocusModeEnum.All;
}
private void SetOptionsInternal(IEquipableItem equipable)
{
var isItemEquipped = _player.EquipmentComponent.IsItemEquipped(equipable);
InteractButton.Text = isItemEquipped ? "Unequip" : "Equip";
InteractButton.Disabled = equipable.Glued;
ThrowButton.Disabled = equipable.Glued || isItemEquipped;
DropButton.Disabled = equipable.Glued || isItemEquipped;
ThrowButton.FocusMode = ThrowButton.Disabled ? FocusModeEnum.None : FocusModeEnum.All;
DropButton.FocusMode = DropButton.Disabled ? FocusModeEnum.None : FocusModeEnum.All;
}
private void SetOptionsInternal(IAugmentItem equipable)
{
InteractButton.Text = "Augment";
}
private void SetOptionsInternal(IBaseInventoryItem baseItem)
{
InteractButton.Text = "Use";
}
private void PerformAction(IEquipableItem equipable)
{
if (_player.EquipmentComponent.IsItemEquipped(equipable))
{
_player.EquipmentComponent.Unequip(equipable);
SfxDatabase.Instance.Play(SoundEffect.Unequip);
}
else
{
_player.EquipmentComponent.Equip(equipable);
SfxDatabase.Instance.Play(SoundEffect.Equip);
}
_currentlySelected = null;
ActionPanelClosing?.Invoke();
}
private void PerformAction(Plastique plastique)
{
SfxDatabase.Instance.Play(SoundEffect.SelectUI);
_game.SetItem(plastique);
_currentlySelected = null;
ActionPanelClosing?.Invoke();
ReturnToGameAction?.Invoke();
}
private void PerformAction(Jewel jewel)
{
SfxDatabase.Instance.Play(SoundEffect.SelectUI);
ActionPanelClosing?.Invoke();
AugmentMenuRequested?.Invoke();
}
private void PerformAction(IBaseInventoryItem item)
{
SfxDatabase.Instance.Play(SoundEffect.SelectUI);
_game.UseItem(item);
_currentlySelected = null;
ActionPanelClosing?.Invoke();
}
}

View File

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

View File

@@ -0,0 +1,113 @@
[gd_scene load_steps=5 format=3 uid="uid://b648lhohtue70"]
[ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="1_kxuil"]
[ext_resource type="Script" uid="uid://dmbykkr6oev1q" path="res://src/ui/inventory_menu/ActionPanel.cs" id="1_r13ox"]
[ext_resource type="StyleBox" uid="uid://bl15q835s4ene" path="res://src/options/UnselectedOptionsBox.tres" id="2_r13ox"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_g7ag1"]
bg_color = Color(0, 0, 0, 0.745098)
[node name="ActionPanel" type="Panel"]
custom_minimum_size = Vector2(200, 200)
focus_mode = 2
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_g7ag1")
script = ExtResource("1_r13ox")
[node name="MarginContainer" type="MarginContainer" parent="."]
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="MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
border_width = 2.0
editor_only = false
[node name="MarginContainer" type="MarginContainer" parent="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="MarginContainer/MarginContainer"]
layout_mode = 2
alignment = 1
[node name="InteractButton" type="Button" parent="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("1_kxuil")
theme_override_styles/disabled_mirrored = ExtResource("2_r13ox")
theme_override_styles/disabled = ExtResource("2_r13ox")
theme_override_styles/hover_pressed_mirrored = ExtResource("2_r13ox")
theme_override_styles/hover_pressed = ExtResource("2_r13ox")
theme_override_styles/hover_mirrored = ExtResource("2_r13ox")
theme_override_styles/hover = ExtResource("2_r13ox")
theme_override_styles/pressed_mirrored = ExtResource("2_r13ox")
theme_override_styles/pressed = ExtResource("2_r13ox")
theme_override_styles/normal_mirrored = ExtResource("2_r13ox")
theme_override_styles/normal = ExtResource("2_r13ox")
text = "Interact"
alignment = 0
[node name="ThrowButton" type="Button" parent="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("1_kxuil")
theme_override_styles/disabled_mirrored = ExtResource("2_r13ox")
theme_override_styles/disabled = ExtResource("2_r13ox")
theme_override_styles/hover_pressed_mirrored = ExtResource("2_r13ox")
theme_override_styles/hover_pressed = ExtResource("2_r13ox")
theme_override_styles/hover_mirrored = ExtResource("2_r13ox")
theme_override_styles/hover = ExtResource("2_r13ox")
theme_override_styles/pressed_mirrored = ExtResource("2_r13ox")
theme_override_styles/pressed = ExtResource("2_r13ox")
theme_override_styles/normal_mirrored = ExtResource("2_r13ox")
theme_override_styles/normal = ExtResource("2_r13ox")
text = "Throw"
alignment = 0
[node name="DropButton" type="Button" parent="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("1_kxuil")
theme_override_styles/disabled_mirrored = ExtResource("2_r13ox")
theme_override_styles/disabled = ExtResource("2_r13ox")
theme_override_styles/hover_pressed_mirrored = ExtResource("2_r13ox")
theme_override_styles/hover_pressed = ExtResource("2_r13ox")
theme_override_styles/hover_mirrored = ExtResource("2_r13ox")
theme_override_styles/hover = ExtResource("2_r13ox")
theme_override_styles/pressed_mirrored = ExtResource("2_r13ox")
theme_override_styles/pressed = ExtResource("2_r13ox")
theme_override_styles/normal_mirrored = ExtResource("2_r13ox")
theme_override_styles/normal = ExtResource("2_r13ox")
text = "Drop"
alignment = 0

View File

@@ -0,0 +1,106 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
[Meta(typeof(IAutoNode))]
public partial class AugmentableItemsMenu : Control
{
public override void _Notification(int what) => this.Notify(what);
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Node] public VBoxContainer Inventory { get; set; }
[Node] public Button CancelAugmentButton { get; set; }
[Node] public Button ConfirmAugmentButton { get; set; }
[Node] public Control ConfirmAugmentContainer { get; set; }
private List<IItemSlot> ItemSlots;
private IItemSlot _currentlySelected;
private IAugmentItem _augmentingItem;
public event Action AugmentMenuClosing;
public void OnResolved()
{
ItemSlots = [.. Inventory.GetChildren().OfType<IItemSlot>()];
ItemSlots.ForEach(x => x.ItemPressed += ItemPressed);
ItemSlots.ForEach(x => x.ItemSelected += ItemSelected);
CancelAugmentButton.Pressed += CancelAugmentButton_Pressed;
ConfirmAugmentButton.Pressed += ConfirmAugmentButton_Pressed;
}
private void ConfirmAugmentButton_Pressed()
{
_player.ApplyNewAugment(_augmentingItem, _currentlySelected.Item.Value as IAugmentableItem);
ConfirmAugmentContainer.Hide();
AugmentMenuClosing?.Invoke();
SfxDatabase.Instance.Play(SoundEffect.SelectUI);
}
private void CancelAugmentButton_Pressed()
{
CloseAugmentMenu();
}
private void CloseAugmentMenu()
{
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
ConfirmAugmentContainer.Hide();
AugmentMenuClosing?.Invoke();
}
public void OpenAugmentMenu(IAugmentItem augmentingItem)
{
_augmentingItem = augmentingItem;
var inventory = _player.Inventory.Items;
ItemSlots.ForEach(x => x.SetEmpty());
var slotIndex = 0;
foreach (var item in inventory)
{
if (item is IAugmentableItem augmentable && augmentable.Augment == null)
ItemSlots[slotIndex++].SetItemToSlot(item);
}
Show();
ItemSlots.First().FocusItem();
}
public override void _Input(InputEvent @event)
{
if (Visible && Input.IsActionJustPressed(GameInputs.Interact))
{
GetViewport().SetInputAsHandled();
if (ConfirmAugmentContainer.Visible)
{
if (ConfirmAugmentButton.HasFocus())
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
CancelAugmentButton.GrabFocus();
}
else
CloseAugmentMenu();
}
}
private void ItemSelected(IItemSlot selectedItem)
{
_currentlySelected = selectedItem;
}
private void ItemPressed(IItemSlot slot)
{
ConfirmAugmentContainer.Show();
ConfirmAugmentButton.GrabFocus();
}
}

View File

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

View File

@@ -0,0 +1,245 @@
[gd_scene load_steps=11 format=3 uid="uid://tpqh7q0xh63c"]
[ext_resource type="PackedScene" uid="uid://c005nd0m2eim" path="res://src/ui/inventory_menu/ItemSlot.tscn" id="1_a5r0f"]
[ext_resource type="Script" uid="uid://brtic4hw6thox" path="res://src/ui/inventory_menu/AugmentableItemsMenu.cs" id="1_ukqf2"]
[ext_resource type="FontFile" uid="uid://beh6d5lo5ihq0" path="res://src/ui/fonts/georgiai.ttf" id="2_ukqf2"]
[ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="3_qtvkp"]
[ext_resource type="StyleBox" uid="uid://bxuy4tnftibfq" path="res://src/options/SelectedOptionsBox.tres" id="4_p84pf"]
[ext_resource type="StyleBox" uid="uid://bl15q835s4ene" path="res://src/options/UnselectedOptionsBox.tres" id="5_rxojm"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_l0byb"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7co7g"]
bg_color = Color(0, 0, 0, 0.745098)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_unikd"]
bg_color = Color(0, 0, 0, 1)
[sub_resource type="LabelSettings" id="LabelSettings_unikd"]
line_spacing = 1.0
font = ExtResource("2_ukqf2")
font_size = 40
outline_size = 3
outline_color = Color(0, 0, 0, 1)
[node name="AugmentMenu" type="Panel"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxEmpty_l0byb")
script = ExtResource("1_ukqf2")
[node name="CenterContainer2" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -400.0
offset_right = 400.0
offset_bottom = 1025.0
grow_horizontal = 2
[node name="AugmentableItemsList" type="PanelContainer" parent="CenterContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(800, 1025)
layout_mode = 2
[node name="Panel" type="Panel" parent="CenterContainer2/AugmentableItemsList"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_7co7g")
[node name="MarginContainer" type="MarginContainer" parent="CenterContainer2/AugmentableItemsList/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 = 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="CenterContainer2/AugmentableItemsList/Panel/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
editor_only = false
[node name="MarginContainer2" type="MarginContainer" parent="CenterContainer2/AugmentableItemsList/Panel"]
layout_mode = 2
offset_right = 800.0
offset_bottom = 1050.0
theme_override_constants/margin_left = 25
theme_override_constants/margin_top = 15
theme_override_constants/margin_right = 25
theme_override_constants/margin_bottom = 15
[node name="Inventory" type="VBoxContainer" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 0
theme_override_constants/separation = 0
[node name="AugmentableSlot" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot2" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot3" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot4" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot5" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot6" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot7" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot8" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot9" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot10" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot11" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot12" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot13" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot14" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot15" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot16" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot17" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot18" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot19" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="AugmentableSlot20" parent="CenterContainer2/AugmentableItemsList/Panel/MarginContainer2/Inventory" instance=ExtResource("1_a5r0f")]
layout_mode = 2
[node name="ConfirmAugmentContainer" type="Panel" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="CenterContainer" type="CenterContainer" parent="ConfirmAugmentContainer"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -40.0
grow_horizontal = 2
grow_vertical = 2
[node name="PanelContainer" type="PanelContainer" parent="ConfirmAugmentContainer/CenterContainer"]
layout_mode = 2
[node name="Panel" type="Panel" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer"]
custom_minimum_size = Vector2(400, 250)
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_unikd")
[node name="MarginContainer" type="MarginContainer" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer"]
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="ConfirmAugmentContainer/CenterContainer/PanelContainer/MarginContainer"]
layout_mode = 2
border_color = Color(1, 1, 1, 1)
editor_only = false
[node name="CenterContainer" type="CenterContainer" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer"]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer"]
layout_mode = 2
theme_override_constants/separation = 25
[node name="Label" type="Label" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer"]
layout_mode = 2
text = "Augment Item?"
label_settings = SubResource("LabelSettings_unikd")
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 20
alignment = 1
[node name="CancelAugmentButton" type="Button" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
focus_neighbor_left = NodePath(".")
focus_neighbor_top = NodePath(".")
focus_neighbor_right = NodePath("../ConfirmAugmentButton")
focus_neighbor_bottom = NodePath(".")
theme_override_fonts/font = ExtResource("3_qtvkp")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("4_p84pf")
theme_override_styles/disabled_mirrored = ExtResource("5_rxojm")
theme_override_styles/disabled = ExtResource("5_rxojm")
theme_override_styles/hover_pressed_mirrored = ExtResource("5_rxojm")
theme_override_styles/hover_pressed = ExtResource("5_rxojm")
theme_override_styles/hover_mirrored = ExtResource("5_rxojm")
theme_override_styles/hover = ExtResource("5_rxojm")
theme_override_styles/pressed_mirrored = ExtResource("5_rxojm")
theme_override_styles/pressed = ExtResource("5_rxojm")
theme_override_styles/normal_mirrored = ExtResource("5_rxojm")
theme_override_styles/normal = ExtResource("5_rxojm")
text = "Cancel"
[node name="ConfirmAugmentButton" type="Button" parent="ConfirmAugmentContainer/CenterContainer/PanelContainer/CenterContainer/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
focus_neighbor_left = NodePath("../CancelAugmentButton")
focus_neighbor_top = NodePath(".")
focus_neighbor_right = NodePath(".")
focus_neighbor_bottom = NodePath(".")
theme_override_fonts/font = ExtResource("3_qtvkp")
theme_override_font_sizes/font_size = 25
theme_override_styles/focus = ExtResource("4_p84pf")
theme_override_styles/disabled_mirrored = ExtResource("5_rxojm")
theme_override_styles/disabled = ExtResource("5_rxojm")
theme_override_styles/hover_pressed_mirrored = ExtResource("5_rxojm")
theme_override_styles/hover_pressed = ExtResource("5_rxojm")
theme_override_styles/hover_mirrored = ExtResource("5_rxojm")
theme_override_styles/hover = ExtResource("5_rxojm")
theme_override_styles/pressed_mirrored = ExtResource("5_rxojm")
theme_override_styles/pressed = ExtResource("5_rxojm")
theme_override_styles/normal_mirrored = ExtResource("5_rxojm")
theme_override_styles/normal = ExtResource("5_rxojm")
text = "Confirm"

View File

@@ -1,15 +1,18 @@
using Chickensoft.Collections;
using Chickensoft.GodotNodeInterfaces;
using System;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
public interface IItemSlot : IButton
public interface IItemSlot : IControl
{
public AutoProp<InventoryItem> Item { get; }
public AutoProp<IBaseInventoryItem> Item { get; }
public void SetItemEquipmentStatus(bool isEquipped);
public void SetEmpty();
public void SetItemToSlot(IBaseInventoryItem item);
public void FocusItem();
public event Action<IItemSlot> ItemPressed;

View File

@@ -0,0 +1,139 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
using System.Collections.Generic;
using System.Linq;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
[Meta(typeof(IAutoNode))]
public partial class InventoryMenu : 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 ActionPanel ActionPanel { get; set; }
[Node] public VBoxContainer Inventory { get; set; }
[Node] public Control MenuPanel { get; set; }
[Node] public AugmentableItemsMenu AugmentMenu { get; set; }
private List<IItemSlot> ItemSlots;
private IItemSlot _currentlySelected;
public void OnResolved()
{
ItemSlots = [.. Inventory.GetChildren().OfType<IItemSlot>()];
ItemSlots.ForEach(x => x.ItemPressed += ItemPressed);
ItemSlots.ForEach(x => x.ItemSelected += ItemSelected);
VisibilityChanged += ResetInventoryState;
ActionPanel.ActionPanelClosing += ActionPanel_ActionPanelClosing;
ActionPanel.ReturnToGameAction += ActionPanel_ReturnToGameAction;
ActionPanel.AugmentMenuRequested += ActionPanel_AugmentMenuRequested;
AugmentMenu.AugmentMenuClosing += AugmentMenu_AugmentMenuClosing;
AugmentMenu.FocusMode = FocusModeEnum.None;
ClearDescriptionBox();
}
public override void _Input(InputEvent @event)
{
if (Input.IsActionJustPressed(GameInputs.MoveUp) && _currentlySelected != ItemSlots.First())
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
if (Input.IsActionJustPressed(GameInputs.MoveDown) && _currentlySelected != ItemSlots.Last(x => x.Item.Value != null))
SfxDatabase.Instance.Play(SoundEffect.MoveUI);
}
private void ActionPanel_AugmentMenuRequested()
{
ReleaseFocus();
ItemSlots.ForEach(x => x.ItemPressed -= ItemPressed);
ItemSlots.ForEach(x => x.ItemSelected -= ItemSelected);
MenuPanel.Hide();
MenuPanel.FocusMode = FocusModeEnum.None;
AugmentMenu.FocusMode = FocusModeEnum.All;
SetProcessInput(false);
AugmentMenu.SetProcessInput(true);
AugmentMenu.OpenAugmentMenu(_currentlySelected.Item.Value as IAugmentItem);
}
private void ActionPanel_ReturnToGameAction()
{
_gameRepo.CloseInventory();
}
private void ItemPressed(IItemSlot selectedItem)
{
SetProcessInput(false);
ActionPanel.SetProcessInput(true);
ActionPanel.ShowPanel(selectedItem.Item.Value);
ActionPanel.FocusActionPanel();
SfxDatabase.Instance.Play(SoundEffect.SelectUI);
}
private void ItemSelected(IItemSlot selectedItem)
{
_currentlySelected = selectedItem;
ItemName.Text = selectedItem.Item.Value.ItemName;
ItemFlavor.Text = selectedItem.Item.Value.Description;
}
private void ResetInventoryState()
{
var inventory = _player.Inventory.Items;
ItemSlots.ForEach(x => x.SetEmpty());
ClearDescriptionBox();
for (var i = 0; i < inventory.Count; i++)
ItemSlots[i].SetItemToSlot(inventory[i]);
if (_currentlySelected == null && inventory.Any())
_currentlySelected = ItemSlots.First();
if (inventory.Any())
_currentlySelected.FocusItem();
ActionPanel.Hide();
}
private void ClearDescriptionBox()
{
ItemName.Text = string.Empty;
ItemFlavor.Text = string.Empty;
ItemStats.Text = string.Empty;
}
private void ActionPanel_ActionPanelClosing()
{
ActionPanel.Hide();
SetProcessInput(true);
ActionPanel.SetProcessInput(false);
if (!_player.Inventory.Items.Contains(_currentlySelected.Item.Value))
_currentlySelected = null;
ResetInventoryState();
}
private void AugmentMenu_AugmentMenuClosing()
{
ItemSlots.ForEach(x => x.ItemPressed += ItemPressed);
ItemSlots.ForEach(x => x.ItemSelected += ItemSelected);
MenuPanel.Show();
MenuPanel.FocusMode = FocusModeEnum.All;
AugmentMenu.FocusMode = FocusModeEnum.None;
SetProcessInput(true);
AugmentMenu.SetProcessInput(false);
AugmentMenu.Hide();
ResetInventoryState();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,351 +0,0 @@
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;
private bool _augmentMode = false;
private Jewel _augmentingJewel;
#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 += ResetInventoryState;
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 (_augmentMode)
{
_player.ApplyNewAugment(_augmentingJewel, item as EquipableItem);
_augmentMode = false;
ResetInventoryState();
}
else if (item is EquipableItem equipable)
{
if (_player.EquipmentComponent.IsItemEquipped(equipable))
_player.Unequip(equipable);
else
{
_player.Equip(equipable);
}
ResetInventoryState();
}
else if (item is Plastique plastique)
{
_game.SetItem(plastique);
ResetInventoryState();
}
else if (item is Jewel jewel)
{
_augmentMode = true;
AugmentMode(jewel);
}
else
{
_game.UseItem(_currentlySelected.Item.Value);
ResetInventoryState();
}
CloseActionMenu();
}
}
private void DropButton_Pressed()
{
var previousItemInList = Mathf.Max(0, ItemSlots.IndexOf(_currentlySelected) - 1);
_game.DropItem(_currentlySelected.Item.Value);
CloseActionMenu();
_gameRepo.CloseInventory();
if (_currentlySelected != null && !_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 (_currentlySelected != null && !_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();
}
else if (_augmentMode && !ActionPanel.Visible && Input.IsActionJustPressed(GameInputs.Interact))
{
GetViewport().SetInputAsHandled();
_augmentMode = false;
SfxDatabase.Instance.Play(SoundEffect.CancelUI);
ResetInventoryState();
}
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);
ResetInventoryState();
}
}
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 (_augmentMode)
{
InteractButton.Text = "Augment";
ThrowButton.Disabled = true;
DropButton.Disabled = true;
InteractButton.GrabFocus();
}
else if (item is EquipableItem equipable)
{
var itemIsEquipped = _player.EquipmentComponent.IsItemEquipped(equipable);
InteractButton.Text = itemIsEquipped ? "Unequip" : "Equip";
ThrowButton.Disabled = itemIsEquipped;
ThrowButton.FocusMode = itemIsEquipped ? FocusModeEnum.None : FocusModeEnum.All;
DropButton.Disabled = itemIsEquipped;
DropButton.FocusMode = itemIsEquipped ? FocusModeEnum.None : FocusModeEnum.All;
InteractButton.GrabFocus();
if ((item is Weapon weapon && _player.EquipmentComponent.EquippedWeapon.Value.Glued) ||
(item is Armor && _player.EquipmentComponent.EquippedArmor.Value.Glued) ||
(item is Accessory && _player.EquipmentComponent.EquippedAccessory.Value.Glued))
{
InteractButton.Disabled = true;
InteractButton.FocusMode = FocusModeEnum.None;
ThrowButton.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 if (item is Jewel jewel)
{
InteractButton.Text = "Augment";
InteractButton.GrabFocus();
}
else
{
InteractButton.Text = "Use";
InteractButton.GrabFocus();
}
ActionPanel.Show();
}
private void ResetInventoryState()
{
foreach (var item in ItemSlots)
{
item.Hide();
item.Disabled = true;
item.FocusMode = FocusModeEnum.None;
}
foreach (var item in ItemCountLabels)
item.Text = string.Empty;
ItemName.Text = string.Empty;
ItemFlavor.Text = string.Empty;
ItemStats.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 (item is EquipableItem equipable && equipable.Glued)
{
ItemSlots[i].FocusMode = FocusModeEnum.None;
ItemSlots[i].Disabled = true;
}
else
{
ItemSlots[i].FocusMode = FocusModeEnum.All;
ItemSlots[i].Disabled = false;
}
}
if (_currentlySelected == null || _currentlySelected.Disabled || _currentlySelected.FocusMode == FocusModeEnum.None)
_currentlySelected = ItemSlots.FirstOrDefault(x => !x.Disabled);
if (_currentlySelected != null)
_currentlySelected.GrabFocus();
}
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 AugmentMode(Jewel jewel)
{
_augmentingJewel = jewel;
foreach (var item in ItemSlots)
{
item.Disabled = true;
item.FocusMode = FocusModeEnum.None;
if (item.Item.Value is EquipableItem equipable && equipable is not Ammo && equipable.Augment == null)
{
item.Disabled = false;
item.FocusMode = FocusModeEnum.All;
}
}
var itemToSelect = ItemSlots.First(x => !x.Disabled);
itemToSelect.GrabFocus();
}
private void CloseActionMenu()
{
if (_currentlySelected != null)
_currentlySelected.GrabFocus();
ActionPanel.Hide();
}
}

View File

@@ -1,608 +0,0 @@
[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"]
process_mode = 2
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

@@ -155,42 +155,42 @@ public partial class ItemRescueMenu : Control
private void ResetInventoryState()
{
foreach (var item in ItemSlots)
{
item.Hide();
item.Disabled = true;
item.FocusMode = FocusModeEnum.None;
ItemFlavor.Text = string.Empty;
ItemName.Text = string.Empty;
ItemStats.Text = string.Empty;
}
//foreach (var item in ItemSlots)
//{
// item.Hide();
// item.Disabled = true;
// item.FocusMode = FocusModeEnum.None;
// ItemFlavor.Text = string.Empty;
// ItemName.Text = string.Empty;
// ItemStats.Text = string.Empty;
//}
foreach (var item in ItemCountLabels)
item.Text = string.Empty;
//foreach (var item in ItemCountLabels)
// item.Text = string.Empty;
for (var i = 0; i < _game.RescuedItems.Items.Count; i++)
{
var item = _game.RescuedItems.Items[i];
ItemSlots[i].Item.OnNext(item);
ItemSlots[i].FocusMode = FocusModeEnum.All;
ItemSlots[i].Disabled = false;
ItemSlots[i].Show();
if (item is IStackable stackable)
ItemCountLabels[i].Text = $"x{stackable.Count.Value:D2}";
}
//for (var i = 0; i < _game.RescuedItems.Items.Count; i++)
//{
// var item = _game.RescuedItems.Items[i];
// ItemSlots[i].Item.OnNext(item);
// ItemSlots[i].FocusMode = FocusModeEnum.All;
// ItemSlots[i].Disabled = false;
// ItemSlots[i].Show();
// if (item is IStackable stackable)
// ItemCountLabels[i].Text = $"x{stackable.Count.Value:D2}";
//}
if (_player.Inventory.AtCapacity())
{
foreach (var item in ItemSlots)
{
item.Disabled = true;
item.FocusMode = FocusModeEnum.None;
}
}
else if (_currentlySelected != null)
_currentlySelected.GrabFocus();
else
_currentlySelected = ItemSlots.First();
//if (_player.Inventory.AtCapacity())
//{
// foreach (var item in ItemSlots)
// {
// item.Disabled = true;
// item.FocusMode = FocusModeEnum.None;
// }
//}
//else if (_currentlySelected != null)
// _currentlySelected.GrabFocus();
//else
// _currentlySelected = ItemSlots.First();
}
private void Slot_FocusEntered(IItemSlot slot)

View File

@@ -3,24 +3,29 @@ using Chickensoft.Collections;
using Chickensoft.Introspection;
using Godot;
using System;
using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Implementation;
using Zennysoft.Ma.Adapter;
namespace Zennysoft.Game.Ma;
[Meta(typeof(IAutoNode))]
public partial class ItemSlot : Button, IItemSlot
public partial class ItemSlot : Control, IItemSlot
{
public override void _Notification(int what) => this.Notify(what);
[Dependency] private IPlayer _player => this.DependOn<IPlayer>();
[Node] public Label Equipped { get; set; } = default!;
[Node] public Label EquippedLabel { get; set; } = default!;
[Node] public Button ItemName { get; set; } = default!;
[Node] public TextureRect ItemTexture { get; set; } = default!;
public AutoProp<InventoryItem> Item { get; } = new AutoProp<InventoryItem>(default);
[Node] public TextureRect AugmentTexture { get; set; } = default!;
[Node] public Label ItemCountLabel { get; set; } = default!;
public AutoProp<IBaseInventoryItem> Item { get; } = new AutoProp<IBaseInventoryItem>(default);
public event Action<IItemSlot> ItemPressed;
@@ -31,19 +36,68 @@ public partial class ItemSlot : Button, IItemSlot
public void OnResolved()
{
Item.Changed += Item_Changed;
FocusEntered += ItemSlot_FocusEntered;
Pressed += ItemSlot_Pressed;
ItemName.Pressed += ItemSlot_Pressed;
ItemName.FocusEntered += FocusItemInternal;
}
public void SetItemToSlot(IBaseInventoryItem item)
{
Item.OnNext(item);
ItemTexture.Texture = item.GetTexture();
ItemName.Disabled = false;
ItemName.Text = item.ItemName;
if (item is IStackable stackable)
SetItemCount(stackable.Count.Value);
if (item is IEquipableItem equipableItem)
{
SetItemEquipmentStatus(_player.EquipmentComponent.IsItemEquipped(equipableItem));
ItemName.Disabled = equipableItem.Glued;
ItemName.FocusMode = ItemName.Disabled ? FocusModeEnum.None : FocusModeEnum.All;
}
if (item is IAugmentableItem augmentableItem)
SetAugmentStatus(augmentableItem.Augment != null);
Show();
}
public void SetEmpty()
{
Hide();
ItemName.Disabled = true;
ItemName.Text = string.Empty;
Item.Clear();
ItemTexture.Texture = null;
SetItemEquipmentStatus(false);
SetAugmentStatus(false);
SetItemCount(0);
}
public void SetItemEquipmentStatus(bool isEquipped)
{
if (isEquipped)
Equipped.Text = "E";
EquippedLabel.Text = "E";
else
Equipped.Text = string.Empty;
EquippedLabel.Text = string.Empty;
}
private void ItemSlot_FocusEntered() => ItemSelected?.Invoke(this);
public void SetAugmentStatus(bool isAugmented) => AugmentTexture.Visible = isAugmented;
public void SetItemCount(int count) => ItemCountLabel.Text = count > 0 ? $"x{count:D2}" : string.Empty;
public void FocusItem()
{
ItemName.GrabFocus();
ItemSelected?.Invoke(this);
}
private void FocusItemInternal()
{
ItemName.GrabFocus();
ItemSelected?.Invoke(this);
}
private void ItemSlot_Pressed()
{
@@ -53,19 +107,15 @@ public partial class ItemSlot : Button, IItemSlot
ItemPressed?.Invoke(this);
}
private void Item_Changed(InventoryItem obj)
private void Item_Changed(IBaseInventoryItem obj)
{
if (obj == null)
return;
Text = obj.ItemName;
ItemTexture.Texture = obj.GetTexture();
if (Item.Value is EquipableItem equipableItem && _player.EquipmentComponent.IsItemEquipped(equipableItem))
{
Equipped.Text = "E";
}
else
Equipped.Text = string.Empty;
ItemName.Text = obj.ItemName;
if (obj is IEquipableItem equipable)
SetItemEquipmentStatus(_player.EquipmentComponent.IsItemEquipped(equipable));
if (obj is IAugmentableItem augmentable)
SetAugmentStatus(augmentable.Augment != null);
}
}

View File

@@ -1,62 +1,85 @@
[gd_scene load_steps=5 format=3 uid="uid://c005nd0m2eim"]
[gd_scene load_steps=7 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="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="StyleBox" uid="uid://bl15q835s4ene" path="res://src/options/UnselectedOptionsBox.tres" id="4_rf22b"]
[ext_resource type="FontFile" uid="uid://0syyay37admf" path="res://src/ui/fonts/georgiab.ttf" id="4_t6dim"]
[ext_resource type="Texture2D" uid="uid://d3bx1j5irhdes" path="res://src/items/jewels/texture/Igneous Jewel.png" id="5_lt1pw"]
[node name="ItemSlot" type="Button"]
custom_minimum_size = Vector2(100, 50)
anchors_preset = -1
anchor_right = 0.885
anchor_bottom = 0.093
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
[node name="ItemSlot" type="HBoxContainer"]
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -215.0
offset_right = 215.0
offset_bottom = 50.0
grow_horizontal = 2
size_flags_horizontal = 3
size_flags_vertical = 0
script = ExtResource("1_yttxt")
[node name="ItemTexture" type="TextureRect" parent="."]
unique_name_in_owner = true
layout_mode = 0
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="ItemInfo" type="HBoxContainer" parent="."]
layout_mode = 2
theme_override_constants/separation = 20
alignment = 1
[node name="Equipped" type="Label" parent="."]
[node name="EquippedLabel" type="Label" parent="ItemInfo"]
unique_name_in_owner = true
custom_minimum_size = Vector2(25, 50)
layout_mode = 2
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
[node name="ItemTexture" type="TextureRect" parent="ItemInfo"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
texture = ExtResource("2_rf22b")
[node name="Control" type="HBoxContainer" parent="ItemInfo"]
layout_mode = 2
theme_override_constants/separation = 20
[node name="ItemName" type="Button" parent="ItemInfo/Control"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 4
focus_neighbor_left = NodePath(".")
focus_neighbor_right = NodePath(".")
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_rf22b")
theme_override_styles/disabled = ExtResource("4_rf22b")
theme_override_styles/hover_pressed_mirrored = ExtResource("4_rf22b")
theme_override_styles/hover_pressed = ExtResource("4_rf22b")
theme_override_styles/hover_mirrored = ExtResource("4_rf22b")
theme_override_styles/hover = ExtResource("4_rf22b")
theme_override_styles/pressed_mirrored = ExtResource("4_rf22b")
theme_override_styles/pressed = ExtResource("4_rf22b")
theme_override_styles/normal_mirrored = ExtResource("4_rf22b")
theme_override_styles/normal = ExtResource("4_rf22b")
button_mask = 0
text = "Cross Sword"
[node name="AugmentTexture" type="TextureRect" parent="ItemInfo/Control"]
unique_name_in_owner = true
custom_minimum_size = Vector2(15, 20)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("5_lt1pw")
stretch_mode = 2
[node name="ItemCountLabel" type="Label" parent="."]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 10
theme_override_fonts/font = ExtResource("4_t6dim")
theme_override_font_sizes/font_size = 25
text = "x99"
horizontal_alignment = 2
vertical_alignment = 1

View File

@@ -5,7 +5,6 @@ using Chickensoft.Introspection;
using Godot;
using System;
using System.Linq;
using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
@@ -66,7 +65,7 @@ public partial class LoadNextLevel : Control, IFloorClearMenu
private void CurrentFloorNumber_Sync(int _) => FloorNumber.Text = _map.CurrentFloorNumber.Value.ToString("D2");
private void EquipmentComponent_EquipmentChanged(EquipableItem obj)
private void EquipmentComponent_EquipmentChanged(IEquipableItem obj)
{
Attack_Sync(0);
Defense_Sync(0);
@@ -82,16 +81,16 @@ public partial class LoadNextLevel : Control, IFloorClearMenu
private void ExitButton_Pressed()
{
ContinueButton.Disabled = true;
ExitButton.Disabled = true;
ContinueButton.FocusMode = FocusModeEnum.None;
ExitButton.FocusMode = FocusModeEnum.None;
FadeOut();
Exit?.Invoke();
}
private void ContinueButton_Pressed()
{
ContinueButton.Disabled = true;
ExitButton.Disabled = true;
ContinueButton.FocusMode = FocusModeEnum.None;
ExitButton.FocusMode = FocusModeEnum.None;
GoToNextFloor?.Invoke();
}
@@ -101,14 +100,13 @@ public partial class LoadNextLevel : Control, IFloorClearMenu
{
_fadingIn = true;
_map.CurrentFloor.FadeOutAudio();
ContinueButton.Disabled = true;
ExitButton.Disabled = true;
ContinueButton.CallDeferred(MethodName.GrabFocus);
ContinueButton.FocusMode = FocusModeEnum.None;
ExitButton.FocusMode = FocusModeEnum.None;
}
if (animName == "fade_out")
{
_fadingIn = false;
CallDeferred(MethodName.ReleaseFocus);
ContinueButton.CallDeferred(MethodName.ReleaseFocus);
}
}
@@ -116,9 +114,10 @@ public partial class LoadNextLevel : Control, IFloorClearMenu
{
if (animName == "fade_in")
{
ContinueButton.CallDeferred(MethodName.GrabFocus);
_fadingIn = false;
ContinueButton.Disabled = false;
ExitButton.Disabled = false;
ContinueButton.FocusMode = FocusModeEnum.All;
ExitButton.FocusMode = FocusModeEnum.All;
}
if (animName == "fade_out")
TransitionCompleted?.Invoke();

View File

@@ -33,7 +33,7 @@ public partial class PauseDebugMenu : Control, IDebugMenu
private readonly string _floorFilePath = @"res://src/map/dungeon/floors/";
private readonly string _enemyFilePath = @"res://src/enemy/enemy_types";
private ImmutableList<InventoryItem> _spawnableItems;
private ImmutableList<IBaseInventoryItem> _spawnableItems;
private ImmutableList<string> _spawnableEnemies;
private ItemDatabase _itemDatabase;
@@ -110,7 +110,7 @@ public partial class PauseDebugMenu : Control, IDebugMenu
private void SpawnItemDropDown_ItemSelected(long index)
{
var itemToSpawn = _spawnableItems.ElementAt((int)index);
var itemToSpawn = _spawnableItems.ElementAt((int)index) as Node3D;
var duplicated = itemToSpawn.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
_game.AddChild(duplicated);
duplicated.GlobalPosition = new Vector3(_player.GlobalPosition.X, _player.GlobalPosition.Y + 1, _player.GlobalPosition.Z) + (-_player.GlobalBasis.Z * 2);