Compare commits
2 Commits
60928c520c
...
inventory
| Author | SHA1 | Date | |
|---|---|---|---|
| ec5d42068e | |||
| 8fdb395ae8 |
@@ -1,12 +1,15 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://cgjc4wurbgimy"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://cgjc4wurbgimy"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://hg7jay2kt441" path="res://scripts/CSharp/Common/Inventory/InventoryUi.cs" id="1_6wusm"]
|
||||
[ext_resource type="Script" uid="uid://b2jhdxcrhtm2d" path="res://scripts/CSharp/Common/Inventory/InventoryTestScript.cs" id="3_exrk4"]
|
||||
[ext_resource type="Texture2D" uid="uid://3ln8aleyxgp1" path="res://art/ui/UI/UI_bag_export_01.png" id="3_vvo7l"]
|
||||
[ext_resource type="Resource" uid="uid://datee0flk1e84" path="res://resources/items/pickaxe.tres" id="4_5fdxq"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcidjcsqk12p1" path="res://art/ui/UI/UI_bag_export_02.png" id="4_df8i8"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7wqla0mbu3np" path="res://art/ui/babushka_ui_tmp_inventory_select.png" id="4_tiss4"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0kmdjeqkqrwv" path="res://prefabs/UI/Inventory/Slot.tscn" id="5_u7kje"]
|
||||
[ext_resource type="Resource" uid="uid://blr8tine5m0ma" path="res://resources/items/tomato.tres" id="7_l3npx"]
|
||||
[ext_resource type="Resource" uid="uid://c5yg3lx756v4v" path="res://resources/items/hoe.tres" id="7_vvo7l"]
|
||||
[ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="8_nw1un"]
|
||||
[ext_resource type="Resource" uid="uid://c7viddcd3kywp" path="res://resources/items/axe.tres" id="10_o7h8q"]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer"]
|
||||
layer = 90
|
||||
@@ -370,4 +373,4 @@ offset_bottom = 612.0
|
||||
|
||||
[node name="InventoryTester" type="Node" parent="Inventory"]
|
||||
script = ExtResource("3_exrk4")
|
||||
_testItemToCreate = ExtResource("4_5fdxq")
|
||||
_testItemsToCreate = Array[Object]([ExtResource("7_l3npx"), ExtResource("7_l3npx"), ExtResource("8_nw1un"), ExtResource("7_vvo7l"), ExtResource("10_o7h8q"), ExtResource("7_l3npx"), ExtResource("8_nw1un"), ExtResource("8_nw1un"), ExtResource("8_nw1un"), ExtResource("8_nw1un"), ExtResource("7_vvo7l")])
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c0kmdjeqkqrwv"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://c0kmdjeqkqrwv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bh6wcyxh1f0cv" path="res://scripts/CSharp/Common/Inventory/SlotUi.cs" id="1_au0l0"]
|
||||
[ext_resource type="Texture2D" uid="uid://0p52bm8b1nrl" path="res://art/ui/UI/inventory_standard.png" id="2_7emux"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfxibry711o16" path="res://art/ui/UI/icons/icon-scythe.png" id="3_n5ryf"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_7emux"]
|
||||
font_size = 15
|
||||
@@ -15,7 +16,7 @@ offset_right = 100.0
|
||||
offset_bottom = 100.0
|
||||
script = ExtResource("1_au0l0")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
[node name="SlotBackground" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -57,4 +58,18 @@ theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
text = "999"
|
||||
horizontal_alignment = 2
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 10.0
|
||||
offset_top = 10.0
|
||||
offset_right = -10.0
|
||||
offset_bottom = -10.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("3_n5ryf")
|
||||
expand_mode = 1
|
||||
|
||||
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://dpbbroif2tnil"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://btusf04xnywhm" path="res://scripts/CSharp/Common/Inventory/ItemOnGround2D.cs" id="1_tlhp6"]
|
||||
[ext_resource type="Script" uid="uid://c8suoi3i6kqai" path="res://scripts/CSharp/Common/Inventory/ItemOnGroundSpawnWith.cs" id="3_xu8me"]
|
||||
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interaction_area_2d.tscn" id="4_xu8me"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfxibry711o16" path="res://art/ui/UI/icons/icon-scythe.png" id="5_harr4"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_tlhp6"]
|
||||
default_font_size = 80
|
||||
|
||||
[sub_resource type="Theme" id="Theme_harr4"]
|
||||
default_font_size = 40
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_tlhp6"]
|
||||
resource_local_to_scene = true
|
||||
radius = 300.0
|
||||
|
||||
[sub_resource type="Theme" id="Theme_xu8me"]
|
||||
default_font_size = 75
|
||||
|
||||
[node name="GenericItemOnGround" type="Node2D"]
|
||||
script = ExtResource("1_tlhp6")
|
||||
|
||||
[node name="SpawnWithItem" type="Node" parent="."]
|
||||
script = ExtResource("3_xu8me")
|
||||
|
||||
[node name="ItemLabel" type="Label" parent="."]
|
||||
offset_left = -264.0
|
||||
offset_top = -396.0
|
||||
offset_right = 269.0
|
||||
offset_bottom = -197.0
|
||||
theme = SubResource("Theme_tlhp6")
|
||||
text = "test"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="PickupErrorLabel" type="Label" parent="."]
|
||||
offset_left = -237.0
|
||||
offset_top = -330.0
|
||||
offset_right = 236.0
|
||||
offset_bottom = -232.0
|
||||
theme = SubResource("Theme_harr4")
|
||||
text = "thewe waf a pwoblem wiph picking up te item UWU"
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="InteractionArea2" parent="." instance=ExtResource("4_xu8me")]
|
||||
|
||||
[node name="CollisionShape3D" parent="InteractionArea2/Area2D" index="0"]
|
||||
shape = SubResource("CircleShape2D_tlhp6")
|
||||
|
||||
[node name="Label" parent="InteractionArea2" index="1"]
|
||||
offset_left = -142.0
|
||||
offset_top = -278.0
|
||||
offset_right = 1.0
|
||||
offset_bottom = -170.0
|
||||
theme = SubResource("Theme_xu8me")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Icon" type="Sprite2D" parent="."]
|
||||
position = Vector2(5, -300)
|
||||
scale = Vector2(0.868852, 0.868852)
|
||||
texture = ExtResource("5_harr4")
|
||||
|
||||
[connection signal="Interacted" from="InteractionArea2" to="." method="TryPickUp"]
|
||||
|
||||
[editable path="InteractionArea2"]
|
||||
@@ -1,10 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://cndd64batns31"]
|
||||
[gd_resource type="Resource" script_class="ItemResource" load_steps=3 format=3 uid="uid://cndd64batns31"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cbskymrxs6ksu" path="res://scripts/CSharp/Common/Inventory/ItemResource.cs" id="1_8k5aa"]
|
||||
[ext_resource type="Texture2D" uid="uid://bh7oo5mypstyp" path="res://art/ui/UI/icons/icon-watercan.png" id="1_roi0v"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_8k5aa")
|
||||
name = "Buck the Bucket"
|
||||
name = "Can"
|
||||
color = Color(0.336269, 0.489145, 0.825324, 1)
|
||||
icon = ExtResource("1_roi0v")
|
||||
maxStack = 1
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://c5yg3lx756v4v"]
|
||||
[gd_resource type="Resource" script_class="ItemResource" load_steps=3 format=3 uid="uid://c5yg3lx756v4v"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cbskymrxs6ksu" path="res://scripts/CSharp/Common/Inventory/ItemResource.cs" id="1_06nef"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfxibry711o16" path="res://art/ui/UI/icons/icon-scythe.png" id="1_jd58x"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_06nef")
|
||||
name = "Your Mom"
|
||||
name = "Hoe"
|
||||
color = Color(0.751421, 0.329615, 0.570911, 1)
|
||||
icon = ExtResource("1_jd58x")
|
||||
maxStack = 1
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="ItemResource" load_steps=3 format=3 uid="uid://blr8tine5m0ma"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://c3wht0nakaki1" path="res://art/ui/UI/icons/icon-fruit-tomatoe.png" id="1_k7rt3"]
|
||||
[ext_resource type="Script" uid="uid://cbskymrxs6ksu" path="res://scripts/CSharp/Common/Inventory/ItemResource.cs" id="1_olvff"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_olvff")
|
||||
name = "Tomato"
|
||||
color = Color(0.941176, 0, 0, 1)
|
||||
icon = ExtResource("1_k7rt3")
|
||||
maxStack = 20
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
@@ -1,10 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://d1uuxp1lp4aro"]
|
||||
[gd_resource type="Resource" script_class="ItemResource" load_steps=3 format=3 uid="uid://d1uuxp1lp4aro"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cbskymrxs6ksu" path="res://scripts/CSharp/Common/Inventory/ItemResource.cs" id="1_dustj"]
|
||||
[ext_resource type="Texture2D" uid="uid://ce04nexh36uwe" path="res://art/ui/UI/icons/icon-seed-tomatoe.png" id="1_u15c2"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_dustj")
|
||||
name = "Tomato Seed"
|
||||
color = Color(0.135039, 0.307214, 0.333128, 1)
|
||||
icon = ExtResource("1_u15c2")
|
||||
maxStack = 20
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=52 format=3 uid="uid://gigb28qk8t12"]
|
||||
[gd_scene load_steps=58 format=3 uid="uid://gigb28qk8t12"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/Player2D.tscn" id="1_7wfwe"]
|
||||
[ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"]
|
||||
@@ -25,8 +25,12 @@
|
||||
[ext_resource type="Texture2D" uid="uid://3ed3dgq3irn2" path="res://art/farm/farming/farmobjekte/zaun/tilable fence end part2.png" id="21_if5vh"]
|
||||
[ext_resource type="Texture2D" uid="uid://dg7rlugnq0t45" path="res://art/farm/farming/farmobjekte/brünnen.png" id="21_ualyd"]
|
||||
[ext_resource type="Script" uid="uid://dhxtdhfqx3bte" path="res://scripts/CSharp/Common/Farming/FieldService2D.cs" id="25_0qu0h"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpbbroif2tnil" path="res://prefabs/interactions/generic_item_on_ground_2d.tscn" id="25_hukxv"]
|
||||
[ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/bucket.tres" id="26_2nee2"]
|
||||
[ext_resource type="Resource" uid="uid://c5yg3lx756v4v" path="res://resources/items/hoe.tres" id="26_ipqaa"]
|
||||
[ext_resource type="Resource" uid="uid://c7viddcd3kywp" path="res://resources/items/axe.tres" id="27_ipqaa"]
|
||||
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interaction_area_2d.tscn" id="27_klb81"]
|
||||
[ext_resource type="PackedScene" uid="uid://ce0mc0ddijmyi" path="res://prefabs/interactions/sprite_switcher_2d.tscn" id="28_p6n74"]
|
||||
[ext_resource type="PackedScene" path="res://prefabs/interactions/sprite_switcher_2d.tscn" id="28_p6n74"]
|
||||
[ext_resource type="Texture2D" uid="uid://x8hr8287ff2n" path="res://art/farm/farming/farmobjekte/tools atlas.png" id="29_p6n74"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgjc4wurbgimy" path="res://prefabs/UI/Inventory/Inventory.tscn" id="32_2nee2"]
|
||||
|
||||
@@ -100,6 +104,14 @@ size = Vector2(728, 368)
|
||||
resource_local_to_scene = true
|
||||
radius = 600.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_2nee2"]
|
||||
resource_local_to_scene = true
|
||||
radius = 300.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ipqaa"]
|
||||
resource_local_to_scene = true
|
||||
radius = 300.0
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_lhtpe"]
|
||||
shader = ExtResource("13_7p0hq")
|
||||
shader_parameter/hue_shift = 0.0
|
||||
@@ -693,6 +705,33 @@ _id = 1
|
||||
position = Vector2(80, -368)
|
||||
shape = SubResource("CircleShape2D_p6n74")
|
||||
|
||||
[node name="HoeGenericPickup" parent="YSorted" instance=ExtResource("25_hukxv")]
|
||||
position = Vector2(4482, 1978)
|
||||
|
||||
[node name="SpawnWithItem" parent="YSorted/HoeGenericPickup" index="0"]
|
||||
_blueprint = ExtResource("26_ipqaa")
|
||||
|
||||
[node name="CollisionShape3D" parent="YSorted/HoeGenericPickup/InteractionArea2/Area2D" index="0"]
|
||||
shape = SubResource("CircleShape2D_2nee2")
|
||||
|
||||
[node name="GenericPickupWithoutIcon" parent="YSorted" instance=ExtResource("25_hukxv")]
|
||||
position = Vector2(3657, 1978)
|
||||
|
||||
[node name="SpawnWithItem" parent="YSorted/GenericPickupWithoutIcon" index="0"]
|
||||
_blueprint = ExtResource("27_ipqaa")
|
||||
|
||||
[node name="CollisionShape3D" parent="YSorted/GenericPickupWithoutIcon/InteractionArea2/Area2D" index="0"]
|
||||
shape = SubResource("CircleShape2D_2nee2")
|
||||
|
||||
[node name="CanGenericPickup" parent="YSorted" instance=ExtResource("25_hukxv")]
|
||||
position = Vector2(2795, 2001)
|
||||
|
||||
[node name="SpawnWithItem" parent="YSorted/CanGenericPickup" index="0"]
|
||||
_blueprint = ExtResource("26_2nee2")
|
||||
|
||||
[node name="CollisionShape3D" parent="YSorted/CanGenericPickup/InteractionArea2/Area2D" index="0"]
|
||||
shape = SubResource("CircleShape2D_ipqaa")
|
||||
|
||||
[node name="Farm visuals" type="Node2D" parent="YSorted"]
|
||||
position = Vector2(-60, 122)
|
||||
|
||||
@@ -797,6 +836,12 @@ _inventoryOpenedOffset = -600.0
|
||||
|
||||
[editable path="YSorted/Player2d"]
|
||||
[editable path="YSorted/Brünnen/InteractionArea"]
|
||||
[editable path="YSorted/HoeGenericPickup"]
|
||||
[editable path="YSorted/HoeGenericPickup/InteractionArea2"]
|
||||
[editable path="YSorted/GenericPickupWithoutIcon"]
|
||||
[editable path="YSorted/GenericPickupWithoutIcon/InteractionArea2"]
|
||||
[editable path="YSorted/CanGenericPickup"]
|
||||
[editable path="YSorted/CanGenericPickup/InteractionArea2"]
|
||||
[editable path="Hoe Pickup"]
|
||||
[editable path="Watercan Pickup"]
|
||||
[editable path="Watercan Pickup/ActiveInactive"]
|
||||
|
||||
@@ -6,11 +6,11 @@ public partial class InteractionArea2D : Node2D
|
||||
{
|
||||
[Export] private Area2D _area;
|
||||
[Export] private Label _label;
|
||||
[Export] private SpriteSwitcher2D _sprites;
|
||||
[Export] private SpriteSwitcher2D _sprites; // TODO: remove
|
||||
[Export] private bool _showLabel = true;
|
||||
[Export] private int _id;
|
||||
[Export] private int _id; // TODO: remove
|
||||
|
||||
[Signal] public delegate void InteractedToolEventHandler(int id);
|
||||
[Signal] public delegate void InteractedToolEventHandler(int id); // TODO: remove
|
||||
[Signal] public delegate void InteractedEventHandler();
|
||||
|
||||
public void OnPlayerEntered(Node2D player)
|
||||
@@ -34,7 +34,7 @@ public partial class InteractionArea2D : Node2D
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSpriteActiveState(bool success, int id)
|
||||
public void SetSpriteActiveState(bool success, int id) // TODO: remove
|
||||
{
|
||||
if (_id == id)
|
||||
{
|
||||
|
||||
@@ -3,15 +3,14 @@ namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
public partial class InventoryTestScript : Node
|
||||
{
|
||||
[Export]
|
||||
private ItemResource _testItemToCreate;
|
||||
[Export(PropertyHint.ArrayType)]
|
||||
private ItemResource[] _testItemsToCreate;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
InventoryManager.Instance.CreateItem(_testItemToCreate, InventoryManager.Instance.playerInventory);
|
||||
InventoryManager.Instance.CreateItem(_testItemToCreate, InventoryManager.Instance.playerInventory);
|
||||
InventoryManager.Instance.CreateItem(_testItemToCreate, InventoryManager.Instance.playerInventory);
|
||||
InventoryManager.Instance.CreateItem(_testItemToCreate, InventoryManager.Instance.playerInventory);
|
||||
GD.Print("Added items");
|
||||
foreach (var itemResource in _testItemsToCreate)
|
||||
{
|
||||
InventoryManager.Instance.CreateItem(itemResource, InventoryManager.Instance.playerInventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class InventoryUi : Control
|
||||
|
||||
[Export]
|
||||
private float _inventoryClosedOffset = 0f;
|
||||
|
||||
|
||||
[Export]
|
||||
private float _inventoryOpenedOffset = 200f;
|
||||
|
||||
@@ -46,15 +46,37 @@ public partial class InventoryUi : Control
|
||||
var inventorySlot = _playerInventory.Slots[i];
|
||||
var uiSlot = _slots.GetChild(i) as SlotUi;
|
||||
|
||||
uiSlot!.nameLabel.Text = inventorySlot.itemInstance?.blueprint.name ?? "";
|
||||
uiSlot!.nameLabel.LabelSettings = uiSlot!.nameLabel.LabelSettings.Duplicate() as LabelSettings;
|
||||
uiSlot!.nameLabel.LabelSettings!.FontColor = inventorySlot.itemInstance?.blueprint.color ?? Colors.White;
|
||||
if (inventorySlot.itemInstance != null)
|
||||
{
|
||||
var blueprint = inventorySlot.itemInstance.blueprint;
|
||||
var amount = inventorySlot.itemInstance.amount;
|
||||
|
||||
var amountText = inventorySlot.itemInstance != null &&
|
||||
inventorySlot.itemInstance.amount != 1
|
||||
? inventorySlot.itemInstance.amount.ToString()
|
||||
: "";
|
||||
uiSlot!.amountLabel.Text = amountText;
|
||||
if (blueprint.icon != null)
|
||||
{
|
||||
// show icon
|
||||
uiSlot!.nameLabel.Text = "";
|
||||
|
||||
uiSlot.icon.Texture = blueprint.icon;
|
||||
}
|
||||
else
|
||||
{
|
||||
// show name label
|
||||
uiSlot!.nameLabel.Text = inventorySlot.itemInstance.blueprint.name;
|
||||
uiSlot!.nameLabel.LabelSettings = uiSlot!.nameLabel.LabelSettings.Duplicate() as LabelSettings;
|
||||
uiSlot!.nameLabel.LabelSettings!.FontColor = inventorySlot.itemInstance?.blueprint.color ?? Colors.White;
|
||||
|
||||
uiSlot.icon.Texture = null;
|
||||
}
|
||||
|
||||
// amount
|
||||
uiSlot!.amountLabel.Text = amount != 1 ? amount.ToString() : "";
|
||||
}
|
||||
else
|
||||
{
|
||||
uiSlot!.nameLabel.Text = "";
|
||||
uiSlot!.icon.Texture = null;
|
||||
uiSlot!.amountLabel.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +96,7 @@ public partial class InventoryUi : Control
|
||||
_slots.AddChild(slotInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SubscribeSlots()
|
||||
{
|
||||
for (var index = 0; index < _playerInventory.Slots.Count; index++)
|
||||
@@ -167,4 +189,4 @@ public partial class InventoryUi : Control
|
||||
_slotOnMouse = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public partial class ItemOnGround2D : Node
|
||||
|
||||
private Label _itemLabel => GetNode<Label>("ItemLabel");
|
||||
private Label _pickupErrorLabel => GetNode<Label>("PickupErrorLabel");
|
||||
private Sprite2D _iconSprite => GetNode<Sprite2D>("Icon");
|
||||
|
||||
public ItemInstance itemInstance
|
||||
{
|
||||
@@ -22,6 +23,12 @@ public partial class ItemOnGround2D : Node
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
UpdateVisuals();
|
||||
_pickupErrorLabel.Text = "";
|
||||
}
|
||||
|
||||
public void TryPickUp()
|
||||
{
|
||||
GD.Print("Trying to pick up item");
|
||||
@@ -45,6 +52,14 @@ public partial class ItemOnGround2D : Node
|
||||
|
||||
public void UpdateVisuals()
|
||||
{
|
||||
_itemLabel.Text = itemInstance.blueprint?.name ?? "Error Item";
|
||||
}
|
||||
}
|
||||
_iconSprite.Texture = itemInstance?.blueprint?.icon;
|
||||
if (_iconSprite.Texture == null)
|
||||
{
|
||||
_itemLabel.Text = itemInstance?.blueprint?.name ?? "Error Item";
|
||||
}
|
||||
else
|
||||
{
|
||||
_itemLabel.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class ItemOnGroundSpawnWith : Node
|
||||
{
|
||||
if(_blueprint == null) return;
|
||||
|
||||
var parent = GetParent<ItemOnGround>();
|
||||
var parent = GetParent<ItemOnGround2D>();
|
||||
parent.itemInstance = new ItemInstance { blueprint = _blueprint };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ public partial class ItemResource : Resource
|
||||
[Export]
|
||||
public Color color;
|
||||
|
||||
[Export]
|
||||
public Texture2D? icon;
|
||||
|
||||
[Export]
|
||||
public int maxStack;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ public partial class SlotUi : Control
|
||||
public Label nameLabel;
|
||||
public int index;
|
||||
public Label amountLabel;
|
||||
public TextureRect icon;
|
||||
|
||||
[Signal] public delegate void ClickedEventHandler(int index);
|
||||
|
||||
@@ -15,6 +16,7 @@ public partial class SlotUi : Control
|
||||
{
|
||||
nameLabel = GetNode<Label>("NameLabel");
|
||||
amountLabel = GetNode<Label>("AmountLabel");
|
||||
icon = GetNode<TextureRect>("Icon");
|
||||
}
|
||||
|
||||
public void _on_gui_input(InputEvent ev)
|
||||
|
||||
Reference in New Issue
Block a user