diff --git a/UI/Hotbar.cs b/UI/Inventory/Hotbar.cs similarity index 74% rename from UI/Hotbar.cs rename to UI/Inventory/Hotbar.cs index 5b311da..18e2db7 100644 --- a/UI/Hotbar.cs +++ b/UI/Inventory/Hotbar.cs @@ -1,19 +1,18 @@ using Godot; -using SupaLidlGame.Items; -namespace SupaLidlGame.UI; +namespace SupaLidlGame.UI.Inventory; public partial class Hotbar : GridContainer { [Export] - private Godot.Collections.Array _slots; + private Godot.Collections.Array _slots; public override void _Ready() { Events.EventBus.Instance.PlayerInventoryUpdate += OnInventoryUpdate; } - public void OnInventoryUpdate(Inventory inventory) + public void OnInventoryUpdate(Items.Inventory inventory) { GD.Print($"UPDATE: {inventory.SelectedIndex} is selected index."); for (int i = 0; i < 3; i++) diff --git a/UI/Hotbar.tscn b/UI/Inventory/Hotbar.tscn similarity index 61% rename from UI/Hotbar.tscn rename to UI/Inventory/Hotbar.tscn index 371c5c6..1ac1ab4 100644 --- a/UI/Hotbar.tscn +++ b/UI/Inventory/Hotbar.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://sfs8dpfitpdu"] -[ext_resource type="Script" path="res://UI/Hotbar.cs" id="1_2sak2"] -[ext_resource type="PackedScene" uid="uid://ctad0dkoyw8ad" path="res://UI/InventorySlot.tscn" id="1_ct3cn"] +[ext_resource type="Script" path="res://UI/Inventory/Hotbar.cs" id="1_2sak2"] +[ext_resource type="PackedScene" uid="uid://ctad0dkoyw8ad" path="res://UI/Inventory/InventorySlot.tscn" id="2_upggg"] [node name="Hotbar" type="GridContainer" node_paths=PackedStringArray("_slots")] anchors_preset = 1 @@ -15,11 +15,11 @@ columns = 3 script = ExtResource("1_2sak2") _slots = [NodePath("InventorySlot"), NodePath("InventorySlot2"), NodePath("InventorySlot3")] -[node name="InventorySlot" parent="." instance=ExtResource("1_ct3cn")] +[node name="InventorySlot" parent="." instance=ExtResource("2_upggg")] layout_mode = 2 -[node name="InventorySlot2" parent="." instance=ExtResource("1_ct3cn")] +[node name="InventorySlot2" parent="." instance=ExtResource("2_upggg")] layout_mode = 2 -[node name="InventorySlot3" parent="." instance=ExtResource("1_ct3cn")] +[node name="InventorySlot3" parent="." instance=ExtResource("2_upggg")] layout_mode = 2 diff --git a/UI/Inventory/HotbarSlot.cs b/UI/Inventory/HotbarSlot.cs new file mode 100644 index 0000000..3d972b0 --- /dev/null +++ b/UI/Inventory/HotbarSlot.cs @@ -0,0 +1,32 @@ +using Godot; +using GodotUtilities; +using GodotUtilities.SourceGenerators; + +namespace SupaLidlGame.UI.Inventory; + +[Scene] +public partial class HotbarSlot : InventorySlot +{ + [Node("TextureRect")] + private TextureRect _textureRect; + + [Node("Selected")] + private NinePatchRect _selected; + + private static Texture2D _placeholderTexture; + + private Items.ItemMetadata _item; + + private bool _isSelected = false; + + public bool IsSelected + { + get => _isSelected; + set + { + _isSelected = value; + _selected.Visible = _isSelected; + _frame.Visible = !_isSelected; + } + } +} diff --git a/UI/Inventory/InventoryGrid.cs b/UI/Inventory/InventoryGrid.cs new file mode 100644 index 0000000..e5364d1 --- /dev/null +++ b/UI/Inventory/InventoryGrid.cs @@ -0,0 +1,28 @@ +using Godot; +using SupaLidlGame.Items; + +namespace SupaLidlGame.UI.Inventory; + +public partial class InventoryGrid : GridContainer +{ + private SupaLidlGame.Items.Inventory _inventorySource; + + public SupaLidlGame.Items.Inventory InventorySource + { + set + { + _inventorySource = value; + } + get => _inventorySource; + } + + public override void _Ready() + { + + } + + public void Redraw() + { + + } +} diff --git a/UI/Inventory/InventoryGrid.tscn b/UI/Inventory/InventoryGrid.tscn new file mode 100644 index 0000000..74f26d5 --- /dev/null +++ b/UI/Inventory/InventoryGrid.tscn @@ -0,0 +1,8 @@ +[gd_scene format=3 uid="uid://chmokkxsy5vas"] + +[node name="InventoryGrid" type="GridContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/UI/InventorySlot.cs b/UI/Inventory/InventorySlot.cs similarity index 60% rename from UI/InventorySlot.cs rename to UI/Inventory/InventorySlot.cs index 2952419..e064fda 100644 --- a/UI/InventorySlot.cs +++ b/UI/Inventory/InventorySlot.cs @@ -2,21 +2,18 @@ using Godot; using GodotUtilities; using GodotUtilities.SourceGenerators; -namespace SupaLidlGame.UI; +namespace SupaLidlGame.UI.Inventory; [Scene] public partial class InventorySlot : ColorRect { [Node("TextureRect")] - private TextureRect _textureRect; + protected TextureRect _textureRect; [Node("Selected")] - private NinePatchRect _selected; + protected NinePatchRect _frame; - [Node("Unselected")] - private NinePatchRect _unselected; - - private static Texture2D _placeholderTexture; + protected static Texture2D _placeholderTexture; private Items.ItemMetadata _item; @@ -29,7 +26,6 @@ public partial class InventorySlot : ColorRect if (_item is null) { - //_textureRect.Texture = _placeholderTexture; _textureRect.Texture = null; } else @@ -39,19 +35,6 @@ public partial class InventorySlot : ColorRect } } - private bool _isSelected = false; - - public bool IsSelected - { - get => _isSelected; - set - { - _isSelected = value; - _selected.Visible = _isSelected; - _unselected.Visible = !_isSelected; - } - } - static InventorySlot() { _placeholderTexture = ResourceLoader.Load( @@ -66,9 +49,4 @@ public partial class InventorySlot : ColorRect } base._Notification(what); } - - public override void _Ready() - { - - } } diff --git a/UI/InventorySlot.tscn b/UI/Inventory/InventorySlot.tscn similarity index 59% rename from UI/InventorySlot.tscn rename to UI/Inventory/InventorySlot.tscn index 2179e07..bfc1161 100644 --- a/UI/InventorySlot.tscn +++ b/UI/Inventory/InventorySlot.tscn @@ -1,13 +1,12 @@ -[gd_scene load_steps=4 format=3 uid="uid://ctad0dkoyw8ad"] +[gd_scene load_steps=3 format=3 uid="uid://ctad0dkoyw8ad"] -[ext_resource type="Script" path="res://UI/InventorySlot.cs" id="1_llonk"] -[ext_resource type="Texture2D" uid="uid://bd81g8aivb2ql" path="res://Assets/Sprites/UI/menu-rect-no-bg-32.png" id="2_vvog5"] -[ext_resource type="Texture2D" uid="uid://b16461tjso0j7" path="res://Assets/Sprites/UI/hotbar-inactive.png" id="3_jr23q"] +[ext_resource type="Script" path="res://UI/Inventory/InventorySlot.cs" id="1_tj1me"] +[ext_resource type="Texture2D" uid="uid://dc1gcsbhkchvg" path="res://Assets/Sprites/UI/hotbar-active.png" id="2_m56j3"] [node name="InventorySlot" type="ColorRect"] custom_minimum_size = Vector2(32, 32) color = Color(1, 1, 1, 0) -script = ExtResource("1_llonk") +script = ExtResource("1_tj1me") [node name="TextureRect" type="TextureRect" parent="."] layout_mode = 1 @@ -26,7 +25,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -texture = ExtResource("2_vvog5") +texture = ExtResource("2_m56j3") [node name="Unselected" type="NinePatchRect" parent="."] self_modulate = Color(1, 1, 1, 0.5) @@ -36,4 +35,4 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -texture = ExtResource("3_jr23q") +texture = ExtResource("2_m56j3") diff --git a/UI/Inventory/ShopItem.tscn b/UI/Inventory/ShopItem.tscn new file mode 100644 index 0000000..11f5711 --- /dev/null +++ b/UI/Inventory/ShopItem.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=4 format=3 uid="uid://bsheehtfcdwhh"] + +[ext_resource type="Theme" uid="uid://cksjbu3vrup5" path="res://UI/Themes/supalidl.tres" id="1_elbte"] +[ext_resource type="Texture2D" uid="uid://dp7osg05ip5oo" path="res://Assets/Sprites/sword.png" id="2_5jpi0"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_idehr"] +bg_color = Color(0.976471, 0.956863, 0.956863, 1) + +[node name="ShopItem" type="BoxContainer"] +offset_right = 67.0 +offset_bottom = 16.0 +theme = ExtResource("1_elbte") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 +theme_override_constants/separation = 0 + +[node name="Item Margin" type="MarginContainer" parent="VBoxContainer"] +layout_mode = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Item Margin"] +layout_mode = 2 + +[node name="TextureRect" type="TextureRect" parent="VBoxContainer/Item Margin/HBoxContainer"] +layout_mode = 2 +texture = ExtResource("2_5jpi0") + +[node name="Label" type="Label" parent="VBoxContainer/Item Margin/HBoxContainer"] +layout_mode = 2 +text = "Your mom's Item" + +[node name="PanelContainer2" type="PanelContainer" parent="VBoxContainer"] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_idehr") + +[node name="DescriptionMargin" type="MarginContainer" parent="VBoxContainer/PanelContainer2"] +layout_mode = 2 +theme_override_constants/margin_top = 2 +theme_override_constants/margin_bottom = 2 + +[node name="Label" type="Label" parent="VBoxContainer/PanelContainer2/DescriptionMargin"] +layout_mode = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "250 Shillings" diff --git a/UI/Inventory/ShopMenu.tscn b/UI/Inventory/ShopMenu.tscn new file mode 100644 index 0000000..7147102 --- /dev/null +++ b/UI/Inventory/ShopMenu.tscn @@ -0,0 +1,78 @@ +[gd_scene load_steps=6 format=3 uid="uid://cyggkyqosjk36"] + +[ext_resource type="Texture2D" uid="uid://uhmowtsi3wfh" path="res://Assets/Sprites/UI/menu-rect-no-bg-white.png" id="2_puklu"] +[ext_resource type="FontFile" uid="uid://cgwa8bjiyv534" path="res://Assets/Fonts/alagard.ttf" id="3_aj4jx"] +[ext_resource type="PackedScene" uid="uid://ctad0dkoyw8ad" path="res://UI/Inventory/InventorySlot.tscn" id="4_wawb8"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gm1xk"] +bg_color = Color(0, 0, 0, 0.752941) +border_width_left = 16 +border_width_top = 16 +border_width_right = 16 +border_width_bottom = 16 +border_color = Color(0, 0, 0, 0) +border_blend = true +corner_radius_top_left = 16 +corner_radius_top_right = 16 +corner_radius_bottom_right = 16 +corner_radius_bottom_left = 16 + +[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_bvu21"] +texture = ExtResource("2_puklu") +texture_margin_left = 32.0 +texture_margin_top = 32.0 +texture_margin_right = 32.0 +texture_margin_bottom = 32.0 + +[node name="Panel" type="PanelContainer"] +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -236.0 +offset_top = -175.5 +offset_bottom = 175.5 +grow_horizontal = 0 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_gm1xk") + +[node name="PanelContainer" type="PanelContainer" parent="."] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxTexture_bvu21") + +[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"] +layout_mode = 2 + +[node name="Label" type="Label" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +theme_override_fonts/font = ExtResource("3_aj4jx") +text = "Snus Dealer" + +[node name="GridContainer" type="GridContainer" parent="PanelContainer/VBoxContainer"] +layout_mode = 2 +columns = 4 + +[node name="InventorySlot" parent="PanelContainer/VBoxContainer/GridContainer" instance=ExtResource("4_wawb8")] +layout_mode = 2 + +[node name="InventorySlot2" parent="PanelContainer/VBoxContainer/GridContainer" instance=ExtResource("4_wawb8")] +layout_mode = 2 + +[node name="InventorySlot3" parent="PanelContainer/VBoxContainer/GridContainer" instance=ExtResource("4_wawb8")] +layout_mode = 2 + +[node name="InventorySlot4" parent="PanelContainer/VBoxContainer/GridContainer" instance=ExtResource("4_wawb8")] +layout_mode = 2 + +[node name="InventorySlot5" parent="PanelContainer/VBoxContainer/GridContainer" instance=ExtResource("4_wawb8")] +layout_mode = 2 + +[node name="InventorySlot6" parent="PanelContainer/VBoxContainer/GridContainer" instance=ExtResource("4_wawb8")] +layout_mode = 2 + +[node name="InventorySlot7" parent="PanelContainer/VBoxContainer/GridContainer" instance=ExtResource("4_wawb8")] +layout_mode = 2 + +[node name="InventorySlot8" parent="PanelContainer/VBoxContainer/GridContainer" instance=ExtResource("4_wawb8")] +layout_mode = 2