Move files to UI.Inventory namespace
parent
b13eb48b99
commit
71f14c5121
|
@ -1,19 +1,18 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using SupaLidlGame.Items;
|
|
||||||
|
|
||||||
namespace SupaLidlGame.UI;
|
namespace SupaLidlGame.UI.Inventory;
|
||||||
|
|
||||||
public partial class Hotbar : GridContainer
|
public partial class Hotbar : GridContainer
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
private Godot.Collections.Array<InventorySlot> _slots;
|
private Godot.Collections.Array<HotbarSlot> _slots;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Events.EventBus.Instance.PlayerInventoryUpdate += OnInventoryUpdate;
|
Events.EventBus.Instance.PlayerInventoryUpdate += OnInventoryUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnInventoryUpdate(Inventory inventory)
|
public void OnInventoryUpdate(Items.Inventory inventory)
|
||||||
{
|
{
|
||||||
GD.Print($"UPDATE: {inventory.SelectedIndex} is selected index.");
|
GD.Print($"UPDATE: {inventory.SelectedIndex} is selected index.");
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://sfs8dpfitpdu"]
|
[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="Script" path="res://UI/Inventory/Hotbar.cs" id="1_2sak2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ctad0dkoyw8ad" path="res://UI/InventorySlot.tscn" id="1_ct3cn"]
|
[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")]
|
[node name="Hotbar" type="GridContainer" node_paths=PackedStringArray("_slots")]
|
||||||
anchors_preset = 1
|
anchors_preset = 1
|
||||||
|
@ -15,11 +15,11 @@ columns = 3
|
||||||
script = ExtResource("1_2sak2")
|
script = ExtResource("1_2sak2")
|
||||||
_slots = [NodePath("InventorySlot"), NodePath("InventorySlot2"), NodePath("InventorySlot3")]
|
_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
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="InventorySlot2" parent="." instance=ExtResource("1_ct3cn")]
|
[node name="InventorySlot2" parent="." instance=ExtResource("2_upggg")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="InventorySlot3" parent="." instance=ExtResource("1_ct3cn")]
|
[node name="InventorySlot3" parent="." instance=ExtResource("2_upggg")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
|
@ -2,21 +2,18 @@ using Godot;
|
||||||
using GodotUtilities;
|
using GodotUtilities;
|
||||||
using GodotUtilities.SourceGenerators;
|
using GodotUtilities.SourceGenerators;
|
||||||
|
|
||||||
namespace SupaLidlGame.UI;
|
namespace SupaLidlGame.UI.Inventory;
|
||||||
|
|
||||||
[Scene]
|
[Scene]
|
||||||
public partial class InventorySlot : ColorRect
|
public partial class InventorySlot : ColorRect
|
||||||
{
|
{
|
||||||
[Node("TextureRect")]
|
[Node("TextureRect")]
|
||||||
private TextureRect _textureRect;
|
protected TextureRect _textureRect;
|
||||||
|
|
||||||
[Node("Selected")]
|
[Node("Selected")]
|
||||||
private NinePatchRect _selected;
|
protected NinePatchRect _frame;
|
||||||
|
|
||||||
[Node("Unselected")]
|
protected static Texture2D _placeholderTexture;
|
||||||
private NinePatchRect _unselected;
|
|
||||||
|
|
||||||
private static Texture2D _placeholderTexture;
|
|
||||||
|
|
||||||
private Items.ItemMetadata _item;
|
private Items.ItemMetadata _item;
|
||||||
|
|
||||||
|
@ -29,7 +26,6 @@ public partial class InventorySlot : ColorRect
|
||||||
|
|
||||||
if (_item is null)
|
if (_item is null)
|
||||||
{
|
{
|
||||||
//_textureRect.Texture = _placeholderTexture;
|
|
||||||
_textureRect.Texture = null;
|
_textureRect.Texture = null;
|
||||||
}
|
}
|
||||||
else
|
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()
|
static InventorySlot()
|
||||||
{
|
{
|
||||||
_placeholderTexture = ResourceLoader.Load<Texture2D>(
|
_placeholderTexture = ResourceLoader.Load<Texture2D>(
|
||||||
|
@ -66,9 +49,4 @@ public partial class InventorySlot : ColorRect
|
||||||
}
|
}
|
||||||
base._Notification(what);
|
base._Notification(what);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -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="Script" path="res://UI/Inventory/InventorySlot.cs" id="1_tj1me"]
|
||||||
[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://dc1gcsbhkchvg" path="res://Assets/Sprites/UI/hotbar-active.png" id="2_m56j3"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b16461tjso0j7" path="res://Assets/Sprites/UI/hotbar-inactive.png" id="3_jr23q"]
|
|
||||||
|
|
||||||
[node name="InventorySlot" type="ColorRect"]
|
[node name="InventorySlot" type="ColorRect"]
|
||||||
custom_minimum_size = Vector2(32, 32)
|
custom_minimum_size = Vector2(32, 32)
|
||||||
color = Color(1, 1, 1, 0)
|
color = Color(1, 1, 1, 0)
|
||||||
script = ExtResource("1_llonk")
|
script = ExtResource("1_tj1me")
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="."]
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
@ -26,7 +25,7 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
texture = ExtResource("2_vvog5")
|
texture = ExtResource("2_m56j3")
|
||||||
|
|
||||||
[node name="Unselected" type="NinePatchRect" parent="."]
|
[node name="Unselected" type="NinePatchRect" parent="."]
|
||||||
self_modulate = Color(1, 1, 1, 0.5)
|
self_modulate = Color(1, 1, 1, 0.5)
|
||||||
|
@ -36,4 +35,4 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
texture = ExtResource("3_jr23q")
|
texture = ExtResource("2_m56j3")
|
|
@ -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"
|
|
@ -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
|
Loading…
Reference in New Issue