diff --git a/assets/outfits/dragons.tres b/assets/outfits/dragons.tres new file mode 100644 index 0000000..272f0ec --- /dev/null +++ b/assets/outfits/dragons.tres @@ -0,0 +1,11 @@ +[gd_resource type="Resource" script_class="DragonOutfit" load_steps=5 format=3 uid="uid://bcs60f2k7h0jc"] + +[ext_resource type="Texture2D" uid="uid://dl87ffgh2hl68" path="res://assets/sprites/dragons/DragonPet_drac01.png" id="1_3e6qx"] +[ext_resource type="Texture2D" uid="uid://davsy68qknywo" path="res://assets/sprites/dragons/DragonPet_drac02.png" id="2_lvc22"] +[ext_resource type="Texture2D" uid="uid://c4l1h6ecobnsu" path="res://assets/sprites/dragons/DragonPet_drac03.png" id="3_8ji77"] +[ext_resource type="Script" uid="uid://rw26nny160xh" path="res://src/dragon_outfit.gd" id="4_sxi2r"] + +[resource] +script = ExtResource("4_sxi2r") +outfits = Array[Texture2D]([ExtResource("1_3e6qx"), ExtResource("2_lvc22"), ExtResource("3_8ji77")]) +metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/assets/outfits/hats.tres b/assets/outfits/hats.tres index d865452..dd7f690 100644 --- a/assets/outfits/hats.tres +++ b/assets/outfits/hats.tres @@ -10,5 +10,6 @@ [resource] script = ExtResource("1_e7uo0") +allow_null = true outfits = Array[Texture2D]([ExtResource("1_jhy4n"), ExtResource("2_cmu3h"), ExtResource("3_330df"), ExtResource("4_7rdvc"), ExtResource("5_1scq7"), ExtResource("6_2f5tc")]) metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/assets/outfits/shirts.tres b/assets/outfits/shirts.tres index 93159cb..f8bee6d 100644 --- a/assets/outfits/shirts.tres +++ b/assets/outfits/shirts.tres @@ -8,5 +8,6 @@ [resource] script = ExtResource("1_yaxr2") +allow_null = true outfits = Array[Texture2D]([ExtResource("1_8ueji"), ExtResource("2_rue66"), ExtResource("3_rq2qf"), ExtResource("4_tgfck")]) metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/assets/outfits/shoes.tres b/assets/outfits/shoes.tres index 13d42a3..64b63c1 100644 --- a/assets/outfits/shoes.tres +++ b/assets/outfits/shoes.tres @@ -7,5 +7,6 @@ [resource] script = ExtResource("1_lu1y3") +allow_null = true outfits = Array[Texture2D]([ExtResource("1_5pwyu"), ExtResource("2_d5wid"), ExtResource("3_yasvr")]) metadata/_custom_type_script = "uid://rw26nny160xh" diff --git a/assets/sprites/hat.png b/assets/sprites/hat.png deleted file mode 100644 index 4179ea7..0000000 Binary files a/assets/sprites/hat.png and /dev/null differ diff --git a/assets/sprites/hat.png.import b/assets/sprites/hat.png.import deleted file mode 100644 index 959d7b4..0000000 --- a/assets/sprites/hat.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://s1gx0l4qciqn" -path="res://.godot/imported/hat.png-d10ab25b5ff6a88ab50e6c69248a3ef0.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://assets/sprites/hat.png" -dest_files=["res://.godot/imported/hat.png-d10ab25b5ff6a88ab50e6c69248a3ef0.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/assets/sprites/shirt.png b/assets/sprites/shirt.png deleted file mode 100644 index 95ec17d..0000000 Binary files a/assets/sprites/shirt.png and /dev/null differ diff --git a/assets/sprites/shirt.png.import b/assets/sprites/shirt.png.import deleted file mode 100644 index 9449f3e..0000000 --- a/assets/sprites/shirt.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://dc2uk6tqtwl4n" -path="res://.godot/imported/shirt.png-e59b3d32b60ac1a259719e0f7d9fdc17.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://assets/sprites/shirt.png" -dest_files=["res://.godot/imported/shirt.png-e59b3d32b60ac1a259719e0f7d9fdc17.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/assets/sprites/shoes.png b/assets/sprites/shoes.png deleted file mode 100644 index 5c8c653..0000000 Binary files a/assets/sprites/shoes.png and /dev/null differ diff --git a/assets/sprites/shoes.png.import b/assets/sprites/shoes.png.import deleted file mode 100644 index 814b173..0000000 --- a/assets/sprites/shoes.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://8srlwinjr3tt" -path="res://.godot/imported/shoes.png-47dd2ca75c2aff89c900c933c1df27c2.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://assets/sprites/shoes.png" -dest_files=["res://.godot/imported/shoes.png-47dd2ca75c2aff89c900c933c1df27c2.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 diff --git a/scenes/dragon_adder/dragon_adder.tscn b/scenes/dragon_adder/dragon_adder.tscn index c0d2b3c..ec18f25 100644 --- a/scenes/dragon_adder/dragon_adder.tscn +++ b/scenes/dragon_adder/dragon_adder.tscn @@ -29,6 +29,7 @@ offset_top = -31.0 offset_right = 32.0 grow_horizontal = 2 grow_vertical = 0 +focus_mode = 0 text = "afegeix" [node name="LineEdit" type="LineEdit" parent="CanvasLayer"] diff --git a/scenes/dragon_editor/dragon_editor.gd b/scenes/dragon_editor/dragon_editor.gd index 2185701..f2c5018 100644 --- a/scenes/dragon_editor/dragon_editor.gd +++ b/scenes/dragon_editor/dragon_editor.gd @@ -5,10 +5,12 @@ class_name DragonEditor @onready var hat: TextureRect = $CanvasLayer/Dragon/Hat @onready var shirt: TextureRect = $CanvasLayer/Dragon/Shirt @onready var shoes: TextureRect = $CanvasLayer/Dragon/Shoes +@onready var dragon: TextureRect = $CanvasLayer/Dragon @export var hat_outfits: DragonOutfit @export var shirt_outfits: DragonOutfit @export var shoes_outfits: DragonOutfit +@export var dragon_colors: DragonOutfit @onready var dragon_name: LineEdit = $CanvasLayer/LineEdit @@ -25,6 +27,14 @@ func _on_close_requested() -> void: queue_free() +func _on_next_color_pressed() -> void: + dragon.texture = dragon_colors.pick_next() + + +func _on_previous_color_pressed() -> void: + dragon.texture = dragon_colors.pick_previous() + + func _on_change_hat_pressed() -> void: hat.texture = hat_outfits.pick_next() diff --git a/scenes/dragon_editor/dragon_editor.tscn b/scenes/dragon_editor/dragon_editor.tscn index cf53f76..4313713 100644 --- a/scenes/dragon_editor/dragon_editor.tscn +++ b/scenes/dragon_editor/dragon_editor.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=10 format=3 uid="uid://fut42ruut302"] +[gd_scene load_steps=11 format=3 uid="uid://fut42ruut302"] [ext_resource type="Script" uid="uid://bfuos2kgfgber" path="res://scenes/dragon_editor/dragon_editor.gd" id="1_8vkll"] [ext_resource type="Resource" uid="uid://cnhwn6kfcbjl5" path="res://assets/outfits/hats.tres" id="2_vvtct"] [ext_resource type="Resource" uid="uid://etegcak2sphs" path="res://assets/outfits/shirts.tres" id="3_xhgxf"] [ext_resource type="Resource" uid="uid://ba5684xylts3f" path="res://assets/outfits/shoes.tres" id="4_1ivi1"] +[ext_resource type="Resource" uid="uid://bcs60f2k7h0jc" path="res://assets/outfits/dragons.tres" id="5_1ivi1"] [ext_resource type="Texture2D" uid="uid://dl87ffgh2hl68" path="res://assets/sprites/dragons/DragonPet_drac01.png" id="5_xhgxf"] [ext_resource type="Texture2D" uid="uid://12fv5nymaljj" path="res://assets/sprites/hats/DragonPet_barret_barretina.png" id="6_1ivi1"] [ext_resource type="Texture2D" uid="uid://cs0ke244c33t2" path="res://assets/sprites/shirts/DragonPet_roba_armadura.png" id="7_giwys"] @@ -20,29 +21,71 @@ script = ExtResource("1_8vkll") hat_outfits = ExtResource("2_vvtct") shirt_outfits = ExtResource("3_xhgxf") shoes_outfits = ExtResource("4_1ivi1") +dragon_colors = ExtResource("5_1ivi1") [node name="CanvasLayer" type="CanvasLayer" parent="."] -[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer"] -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -89.0 -offset_bottom = 101.0 -grow_horizontal = 0 - -[node name="change_hat" type="Button" parent="CanvasLayer/VBoxContainer"] -layout_mode = 2 +[node name="change_hat" type="Button" parent="CanvasLayer"] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -130.0 +offset_top = -206.0 +offset_right = -62.0 +offset_bottom = -175.0 +grow_horizontal = 2 +grow_vertical = 2 +focus_mode = 0 text = "barret" -[node name="change_shirt" type="Button" parent="CanvasLayer/VBoxContainer"] -layout_mode = 2 +[node name="change_shirt" type="Button" parent="CanvasLayer"] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -47.0 +offset_top = -242.0 +offset_right = 42.0 +offset_bottom = -211.0 +grow_horizontal = 2 +grow_vertical = 2 +focus_mode = 0 text = "samarreta" -[node name="change_shoes" type="Button" parent="CanvasLayer/VBoxContainer"] -layout_mode = 2 +[node name="change_shoes" type="Button" parent="CanvasLayer"] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = 54.0 +offset_top = -206.0 +offset_right = 114.0 +offset_bottom = -175.0 +grow_horizontal = 2 +grow_vertical = 2 +focus_mode = 0 text = "sabata" +[node name="dragon_previous" type="Button" parent="CanvasLayer"] +offset_left = 40.0 +offset_top = 232.0 +offset_right = 58.0 +offset_bottom = 263.0 +focus_mode = 0 +text = "<" + +[node name="dragon_next" type="Button" parent="CanvasLayer"] +offset_left = 235.0 +offset_top = 232.0 +offset_right = 253.0 +offset_bottom = 263.0 +focus_mode = 0 +text = ">" + [node name="create" type="Button" parent="CanvasLayer"] anchors_preset = 3 anchor_left = 1.0 @@ -53,6 +96,7 @@ offset_left = -42.0 offset_top = -31.0 grow_horizontal = 0 grow_vertical = 0 +focus_mode = 0 text = "crea" [node name="Dragon" type="TextureRect" parent="CanvasLayer"] @@ -125,7 +169,9 @@ max_length = 8 script = ExtResource("9_xhgxf") [connection signal="close_requested" from="." to="." method="_on_close_requested"] -[connection signal="pressed" from="CanvasLayer/VBoxContainer/change_hat" to="." method="_on_change_hat_pressed"] -[connection signal="pressed" from="CanvasLayer/VBoxContainer/change_shirt" to="." method="_on_change_shirt_pressed"] -[connection signal="pressed" from="CanvasLayer/VBoxContainer/change_shoes" to="." method="_on_change_shoes_pressed"] +[connection signal="pressed" from="CanvasLayer/change_hat" to="." method="_on_change_hat_pressed"] +[connection signal="pressed" from="CanvasLayer/change_shirt" to="." method="_on_change_shirt_pressed"] +[connection signal="pressed" from="CanvasLayer/change_shoes" to="." method="_on_change_shoes_pressed"] +[connection signal="pressed" from="CanvasLayer/dragon_previous" to="." method="_on_previous_color_pressed"] +[connection signal="pressed" from="CanvasLayer/dragon_next" to="." method="_on_next_color_pressed"] [connection signal="pressed" from="CanvasLayer/create" to="." method="_on_create_pressed"] diff --git a/scenes/main.tscn b/scenes/main.tscn index f1f53fe..cc638e2 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -38,6 +38,7 @@ offset_top = 50.0 offset_right = -57.0 offset_bottom = 150.0 grow_horizontal = 0 +focus_mode = 0 text = "crea" script = ExtResource("4_tbgi4") dragon_editor = ExtResource("5_tefeu") @@ -51,6 +52,7 @@ offset_top = 168.0 offset_right = -56.0 offset_bottom = 268.0 grow_horizontal = 0 +focus_mode = 0 text = "tanca" [node name="List" type="Button" parent="CanvasLayer"] @@ -62,6 +64,7 @@ offset_top = 288.0 offset_right = -56.0 offset_bottom = 388.0 grow_horizontal = 0 +focus_mode = 0 text = "llista" script = ExtResource("9_choun") dragon_list = ExtResource("10_ya4ey") @@ -75,6 +78,7 @@ offset_top = 407.0 offset_right = -56.0 offset_bottom = 507.0 grow_horizontal = 0 +focus_mode = 0 text = "afegeix" script = ExtResource("11_eb6dy") dragon_adder = ExtResource("12_trceg") diff --git a/src/dragon_outfit.gd b/src/dragon_outfit.gd index b59e364..9015ca2 100644 --- a/src/dragon_outfit.gd +++ b/src/dragon_outfit.gd @@ -2,6 +2,7 @@ extends Resource class_name DragonOutfit +@export var allow_null: bool @export var outfits: Array[Texture2D] var index: int = 0 @@ -12,6 +13,21 @@ func _init(outfits: Array[Texture2D] = []): func pick_next() -> Texture2D: index += 1 + if allow_null: + return _pick_nullable() + else: + return _pick_non_nullable() + + +func pick_previous() -> Texture2D: + index -= 1 + if allow_null: + return _pick_nullable() + else: + return _pick_non_nullable() + + +func _pick_nullable(): index %= (len(outfits) + 1) if index == 0: return null @@ -19,6 +35,11 @@ func pick_next() -> Texture2D: return outfits[index - 1] +func _pick_non_nullable(): + index %= len(outfits) + return outfits[index] + + func get_index(texture: Texture2D) -> int: return outfits.find(texture)