New minigame selection screen

This commit is contained in:
Laurent Tourte
2024-05-22 17:17:14 +02:00
parent 6247701d00
commit 20d6542ea7
12 changed files with 404 additions and 241 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bb00fhnenbml5"
path="res://.godot/imported/big_button.png-2d1f065099914861a41cb711caf148c4.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/lesson_screen/big_button.png"
dest_files=["res://.godot/imported/big_button.png-2d1f065099914861a41cb711caf148c4.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
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+47 -123
View File
@@ -42,15 +42,13 @@ const look_and_learn_scene: = preload("res://sources/look_and_learn/look_and_lea
@onready var parallax_background: = %ParallaxBackground
@onready var minigame_selection: Control = %MinigameSelection
@onready var lesson_button: TextureButton = %LessonButton
@onready var exercise_button_1: TextureButton = %ExerciseButton1
@onready var exercise_button_2: TextureButton = %ExerciseButton2
@onready var exercise_button_3: TextureButton = %ExerciseButton3
@onready var minigame_choice_container: PanelContainer = %MinigameChoiceContainer
@onready var minigame_button_container: HBoxContainer = %MinigameButtonContainer
@onready var camera_2d: Camera2D = $Camera2D
@onready var back_button: TextureButton = %BackButton
@onready var right_audio_stream_player: AudioStreamPlayer = $RightAudioStreamPlayer
@onready var left_audio_stream_player: AudioStreamPlayer = $LeftAudioStreamPlayer
@onready var minigame_container_1: HFlowContainer = %MinigameContainer1
@onready var minigame_container_2: HFlowContainer = %MinigameContainer2
@onready var minigame_container_3: HFlowContainer = %MinigameContainer3
@onready var minigame_background: TextureRect = %MinigameBackground
var lessons: = {}
var points: = []
@@ -62,6 +60,7 @@ var in_minigame_selection: = false
var current_lesson_number: = -1
var current_garden: = -1
var current_button_global_position: = Vector2.ZERO
var current_button: TextureButton
static var transition_data: Dictionary
@@ -137,78 +136,23 @@ func _setup_minigame_selection() -> void:
var exercise2: String = exercises[1]
var exercise3: String = exercises[2]
if lesson_button:
if lesson_button and UserDataManager.student_progression:
var lesson_unlocks: Dictionary = UserDataManager.student_progression.unlocks[current_lesson_number]
lesson_button.text = lessons[current_lesson_number][0].grapheme
lesson_button.display_text = true
if exercise_button_1:
exercise_button_1.text = exercise1
if exercise1 == "Syllable":
exercise_button_1.images = syllable_minigames_icons
elif exercise1 == "Pairing":
exercise_button_1.images = pairing_minigames_icons
elif exercise1 == "Words":
exercise_button_1.images = words_minigames_icons
elif exercise1 == "Sentences":
exercise_button_1.images = sentences_minigames_icons
elif exercise1 == "Boss":
exercise_button_1.images = boss_minigames_icons
exercise_button_1.load_images()
if exercise_button_2:
exercise_button_2.text = exercise2
if exercise2 == "Syllable":
exercise_button_2.images = syllable_minigames_icons
elif exercise2 == "Pairing":
exercise_button_2.images = pairing_minigames_icons
elif exercise2 == "Words":
exercise_button_2.images = words_minigames_icons
elif exercise2 == "Sentences":
exercise_button_2.images = sentences_minigames_icons
elif exercise2 == "Boss":
exercise_button_2.images = boss_minigames_icons
exercise_button_2.load_images()
if exercise_button_3:
exercise_button_3.text = exercise3
if exercise3 == "Syllable":
exercise_button_3.images = syllable_minigames_icons
elif exercise3 == "Pairing":
exercise_button_3.images = pairing_minigames_icons
elif exercise3 == "Words":
exercise_button_3.images = words_minigames_icons
elif exercise3 == "Sentences":
exercise_button_3.images = sentences_minigames_icons
elif exercise3 == "Boss":
exercise_button_3.images = boss_minigames_icons
exercise_button_3.load_images()
if UserDataManager.student_progression :
var lesson_unlocks: Dictionary = UserDataManager.student_progression.unlocks[current_lesson_number]
if lesson_button:
if lesson_unlocks["look_and_learn"] == UserProgression.Status.Locked:
lesson_button.disabled = true
else:
lesson_button.completed = lesson_unlocks["look_and_learn"] == UserProgression.Status.Completed
if lesson_unlocks["look_and_learn"] == UserProgression.Status.Locked:
lesson_button.disabled = true
else:
lesson_button.completed = lesson_unlocks["look_and_learn"] == UserProgression.Status.Completed
if exercise_button_1:
if lesson_unlocks["games"][0] == UserProgression.Status.Locked:
exercise_button_1.disabled = true
else:
exercise_button_1.completed = lesson_unlocks["games"][0] == UserProgression.Status.Completed
if exercise_button_2:
if lesson_unlocks["games"][0] == UserProgression.Status.Locked:
exercise_button_2.disabled = true
else:
exercise_button_2.completed = lesson_unlocks["games"][1] == UserProgression.Status.Completed
if exercise_button_3:
if lesson_unlocks["games"][0] == UserProgression.Status.Locked:
exercise_button_3.disabled = true
else:
exercise_button_3.completed = lesson_unlocks["games"][2] == UserProgression.Status.Completed
_fill_minigame_choice(minigame_container_1, exercise1, lesson_unlocks["games"][0], current_lesson_number)
_fill_minigame_choice(minigame_container_2, exercise2, lesson_unlocks["games"][1], current_lesson_number)
_fill_minigame_choice(minigame_container_3, exercise3, lesson_unlocks["games"][2], current_lesson_number)
func _fill_minigame_choice(exercise_type: String, is_completed: bool, minigame_number: int) -> void:
for button in minigame_button_container.get_children():
func _fill_minigame_choice(container: HFlowContainer, exercise_type: String, status: UserProgression.Status, minigame_number: int) -> void:
for button in container.get_children():
button.queue_free()
var exercise_scenes: Array[PackedScene]
@@ -231,10 +175,13 @@ func _fill_minigame_choice(exercise_type: String, is_completed: bool, minigame_n
for i in range(exercise_scenes.size()):
var button: LessonTextureButton = lesson_texture_button_scene.instantiate()
minigame_button_container.add_child(button)
button.completed = is_completed
container.add_child(button)
button.completed = status == UserProgression.Status.Completed
button.texture = exercise_icons[i]
if status == UserProgression.Status.Locked:
button.disabled = true
button.pressed.connect(_on_minigame_button_pressed.bind(exercise_scenes[i], minigame_number))
@@ -288,9 +235,11 @@ func set_up_path() -> void:
locked_line.points = curve.get_baked_points()
func _on_garden_lesson_button_pressed(button: TextureButton, lesson_ind: int, garden_ind: int, button_global_position: = Vector2.ZERO, tween_duration: = 0.5) -> void:
func _on_garden_lesson_button_pressed(button: TextureButton, lesson_ind: int, garden_ind: int, button_global_position: = Vector2.ZERO, tween_duration: = 0.25) -> void:
if button:
button_global_position = button.global_position
current_button = button
current_button.visible = false
current_button_global_position = button_global_position
current_lesson_number = lesson_ind
current_garden = garden_ind
@@ -302,23 +251,18 @@ func _on_garden_lesson_button_pressed(button: TextureButton, lesson_ind: int, ga
for other_button: TextureButton in garden_parent.get_child(current_garden).lesson_button_controls:
other_button.disabled = true
var tween: = create_tween().set_parallel(true)
tween.tween_property(minigame_selection, "modulate:a", 1.0, tween_duration)
tween.tween_property(locked_line, "modulate:a", 0.0, tween_duration)
tween.tween_property(unlocked_line, "modulate:a", 0.0, tween_duration)
tween.tween_property(garden_parent.get_child(current_garden).buttons, "modulate:a", 0.0, tween_duration)
tween.tween_property(camera_2d, "zoom", Vector2(2.0, 2.0), tween_duration)
tween.tween_property(camera_2d, "global_position", button_global_position, tween_duration)
minigame_background.size = 300.0 * Vector2.ONE
minigame_background.global_position = current_button_global_position
minigame_background.visible = true
var tween: = create_tween().set_parallel(true).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK)
tween.tween_property(minigame_background, "scale", (1800.0 / 300.0) * Vector2.ONE, tween_duration)
tween.tween_property(minigame_background, "global_position", Vector2(380.0, 0), tween_duration)
tween.chain().tween_property(minigame_selection, "modulate:a", 1.0, tween_duration)
await tween.finished
locked_line.visible = false
unlocked_line.visible = false
garden_parent.get_child(current_garden).buttons.visible = false
back_button.disabled = false
lesson_button.disabled = false
exercise_button_1.disabled = false
exercise_button_2.disabled = false
exercise_button_3.disabled = false
func _on_lesson_button_pressed() -> void:
@@ -332,21 +276,6 @@ func _on_lesson_button_pressed() -> void:
get_tree().change_scene_to_packed(look_and_learn_scene)
func _on_exercise_button_1_pressed() -> void:
_fill_minigame_choice(exercise_button_1.text, exercise_button_1.completed, 0)
minigame_choice_container.visible = true
func _on_exercise_button_2_pressed() -> void:
_fill_minigame_choice(exercise_button_2.text, exercise_button_2.completed, 1)
minigame_choice_container.visible = true
func _on_exercise_button_3_pressed() -> void:
_fill_minigame_choice(exercise_button_3.text, exercise_button_3.completed, 2)
minigame_choice_container.visible = true
func _on_minigame_button_pressed(minigame_scene: PackedScene, minigame_number: int) -> void:
await OpeningCurtain.close()
@@ -457,36 +386,31 @@ func _on_scroll_container_gui_input(event: InputEvent) -> void:
func _on_back_button_pressed() -> void:
if in_minigame_selection:
minigame_choice_container.visible = false
locked_line.visible = true
unlocked_line.visible = true
garden_parent.get_child(current_garden).buttons.visible = true
lesson_button.disabled = true
exercise_button_1.disabled = true
exercise_button_2.disabled = true
exercise_button_3.disabled = true
var minigame_buttons: = minigame_container_1.get_children()
minigame_buttons.append_array(minigame_container_2.get_children())
minigame_buttons.append_array(minigame_container_3.get_children())
for minigame_button in minigame_buttons:
minigame_button.disabled = false
back_button.disabled = true
var tween: = create_tween().set_parallel(true)
tween.tween_property(minigame_selection, "modulate:a", 0.0, 0.5)
tween.tween_property(locked_line, "modulate:a", 1.0, 0.5)
tween.tween_property(unlocked_line, "modulate:a", 1.0, 0.5)
tween.tween_property(garden_parent.get_child(current_garden).buttons, "modulate:a", 1.0, 0.5)
tween.tween_property(camera_2d, "zoom", Vector2(1.0, 1.0), 0.5)
tween.tween_property(camera_2d, "global_position", Vector2(1280.0, 900.0), 0.5)
var tween: = create_tween().set_parallel(true).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK)
tween.tween_property(minigame_selection, "modulate:a", 0.0, 0.25)
var other_tween: = tween.chain()
other_tween.tween_property(minigame_background, "scale", Vector2.ONE, 0.25)
other_tween.tween_property(minigame_background, "global_position", current_button_global_position, 0.25)
await tween.finished
for other_button: TextureButton in garden_parent.get_child(current_garden).lesson_button_controls:
other_button.disabled = false
if current_button:
current_button.visible = true
in_minigame_selection = false
minigame_selection.visible = false
minigame_background.visible = false
back_button.disabled = false
else:
await OpeningCurtain.close()
get_tree().change_scene_to_file("res://sources/menus/brain/brain.tscn")
func _on_minigame_choice_back_button_pressed() -> void:
minigame_choice_container.visible = false
+67 -106
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=32 format=3 uid="uid://b1rkn0uwoyd7l"]
[gd_scene load_steps=30 format=3 uid="uid://b1rkn0uwoyd7l"]
[ext_resource type="Script" path="res://sources/gardens/gardens.gd" id="1_qlsw4"]
[ext_resource type="Resource" uid="uid://8v0g8bpx5mh0" path="res://resources/gardens/gardens_layout.tres" id="2_1i16w"]
@@ -18,14 +18,13 @@
[ext_resource type="PackedScene" uid="uid://df5oba70wj13y" path="res://sources/minigames/ants/ants_minigame.tscn" id="8_g4mhc"]
[ext_resource type="PackedScene" uid="uid://bw820nbyowrqy" path="res://sources/lesson_screen/lesson_label_button.tscn" id="8_pehag"]
[ext_resource type="Texture2D" uid="uid://c3okdxpi317x5" path="res://assets/minigames/monkeys/graphic/gauge_icon_monkey_full.png" id="9_68su4"]
[ext_resource type="PackedScene" uid="uid://btx8xh83urtuj" path="res://sources/lesson_screen/lesson_texture_button.tscn" id="9_p7tbh"]
[ext_resource type="Texture2D" uid="uid://re7qgivb3n5w" path="res://assets/minigames/frog/graphics/gauge_icon_frog_full.png" id="10_5wvwc"]
[ext_resource type="Texture2D" uid="uid://7sk0g1gcuu7d" path="res://assets/lesson_screen/back.png" id="10_wud4y"]
[ext_resource type="Texture2D" uid="uid://nwbekpbuu472" path="res://assets/minigames/ants/graphics/gauge_icon_ant_full.png" id="12_ohgqx"]
[ext_resource type="PackedScene" uid="uid://df5derhil64ca" path="res://sources/minigames/fish/fish_minigame.tscn" id="15_6dtg2"]
[ext_resource type="Texture2D" uid="uid://bc3e0qths2cvt" path="res://assets/minigames/fish/fish_icon_full.png" id="16_5rwfp"]
[ext_resource type="AudioStream" uid="uid://4bv1hr6r68op" path="res://assets/gardens/ui_transition_right.mp3" id="17_37f6y"]
[ext_resource type="AudioStream" uid="uid://bwgrj3quwtbvm" path="res://assets/gardens/ui_transition_left.mp3" id="18_bdar8"]
[ext_resource type="Texture2D" uid="uid://bb00fhnenbml5" path="res://assets/lesson_screen/big_button.png" id="20_elp7t"]
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_ey6av"]
blend_mode = 1
@@ -52,13 +51,6 @@ alpha_curve = SubResource("CurveTexture_upllx")
hue_variation_min = -1.0
hue_variation_max = 1.0
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_15vqv"]
bg_color = Color(0.34902, 0.133333, 0.74902, 1)
corner_radius_top_left = 42
corner_radius_top_right = 42
corner_radius_bottom_right = 42
corner_radius_bottom_left = 42
[node name="Gardens" type="Control"]
layout_mode = 3
anchors_preset = 15
@@ -87,13 +79,6 @@ bus = &"Effects"
stream = ExtResource("18_bdar8")
bus = &"Effects"
[node name="Camera2D" type="Camera2D" parent="."]
position = Vector2(1280, 900)
limit_left = 0
limit_top = 0
limit_right = 2560
limit_bottom = 1800
[node name="Background" type="Control" parent="."]
layout_mode = 1
anchors_preset = 15
@@ -171,16 +156,17 @@ width = 50.0
[node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="BackButton" type="TextureButton" parent="CanvasLayer"]
[node name="MinigameBackground" type="TextureRect" parent="CanvasLayer"]
unique_name_in_owner = true
offset_left = 80.0
offset_top = 80.0
offset_right = 220.0
offset_bottom = 220.0
scale = Vector2(1.5, 1.5)
texture_normal = ExtResource("4_neut5")
texture_pressed = ExtResource("5_2yuxn")
texture_disabled = ExtResource("6_gs6gi")
visible = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("20_elp7t")
expand_mode = 1
stretch_mode = 5
[node name="MinigameSelection" type="Control" parent="CanvasLayer"]
unique_name_in_owner = true
@@ -192,103 +178,78 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
pivot_offset = Vector2(1280, 900)
[node name="TextureRect" type="TextureRect" parent="CanvasLayer/MinigameSelection"]
layout_mode = 2
offset_left = 1024.0
offset_top = 644.0
offset_right = 1536.0
offset_bottom = 1156.0
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
texture = ExtResource("7_axgdc")
[node name="LessonButton" parent="CanvasLayer/MinigameSelection" instance=ExtResource("8_pehag")]
unique_name_in_owner = true
layout_mode = 0
offset_left = 1152.0
offset_top = 772.0
offset_right = 1408.0
offset_bottom = 1028.0
offset_left = 1088.0
offset_top = 708.0
offset_right = 1344.0
offset_bottom = 964.0
scale = Vector2(1.5, 1.5)
size_flags_horizontal = 1
size_flags_vertical = 1
disabled = true
[node name="ExerciseButton1" parent="CanvasLayer/MinigameSelection" instance=ExtResource("8_pehag")]
unique_name_in_owner = true
layout_mode = 0
offset_left = 1152.0
offset_top = 388.0
offset_right = 1408.0
offset_bottom = 644.0
size_flags_horizontal = 1
size_flags_vertical = 1
disabled = true
[node name="Label" parent="CanvasLayer/MinigameSelection/LessonButton" index="1"]
theme_override_font_sizes/font_size = 92
[node name="ExerciseButton2" parent="CanvasLayer/MinigameSelection" instance=ExtResource("8_pehag")]
unique_name_in_owner = true
layout_mode = 0
offset_left = 820.0
offset_top = 972.0
offset_right = 1076.0
offset_bottom = 1228.0
size_flags_horizontal = 1
size_flags_vertical = 1
disabled = true
[node name="ExerciseButton3" parent="CanvasLayer/MinigameSelection" instance=ExtResource("8_pehag")]
unique_name_in_owner = true
layout_mode = 0
offset_left = 1480.0
offset_top = 972.0
offset_right = 1736.0
offset_bottom = 1228.0
size_flags_horizontal = 1
size_flags_vertical = 1
disabled = true
[node name="MinigameChoiceContainer" type="PanelContainer" parent="CanvasLayer"]
unique_name_in_owner = true
visible = false
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -421.0
offset_top = -414.0
offset_right = 435.0
offset_bottom = 392.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_15vqv")
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/MinigameChoiceContainer"]
layout_mode = 2
theme_override_constants/margin_left = 300
theme_override_constants/margin_top = 200
theme_override_constants/margin_right = 300
theme_override_constants/margin_bottom = 200
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/MinigameChoiceContainer/MarginContainer"]
layout_mode = 2
theme_override_constants/separation = 150
[node name="MinigameButtonContainer" type="HBoxContainer" parent="CanvasLayer/MinigameChoiceContainer/MarginContainer/VBoxContainer"]
[node name="MinigameContainer1" type="HFlowContainer" parent="CanvasLayer/MinigameSelection"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/separation = 50
offset_left = 633.0
offset_top = 284.0
offset_right = 1149.0
offset_bottom = 800.0
size_flags_horizontal = 3
alignment = 1
reverse_fill = true
[node name="MinigameChoiceBackButton" parent="CanvasLayer/MinigameChoiceContainer/MarginContainer/VBoxContainer" instance=ExtResource("9_p7tbh")]
[node name="MinigameContainer2" type="HFlowContainer" parent="CanvasLayer/MinigameSelection"]
unique_name_in_owner = true
layout_mode = 2
texture = ExtResource("10_wud4y")
offset_left = 1411.0
offset_top = 284.0
offset_right = 1927.0
offset_bottom = 800.0
size_flags_horizontal = 3
alignment = 1
reverse_fill = true
[node name="MinigameContainer3" type="HFlowContainer" parent="CanvasLayer/MinigameSelection"]
unique_name_in_owner = true
layout_mode = 2
offset_left = 762.0
offset_top = 1229.0
offset_right = 1798.0
offset_bottom = 1745.0
size_flags_horizontal = 3
alignment = 1
[node name="BackButton" type="TextureButton" parent="CanvasLayer"]
unique_name_in_owner = true
offset_left = 80.0
offset_top = 80.0
offset_right = 220.0
offset_bottom = 220.0
scale = Vector2(1.5, 1.5)
texture_normal = ExtResource("4_neut5")
texture_pressed = ExtResource("5_2yuxn")
texture_disabled = ExtResource("6_gs6gi")
[connection signal="gui_input" from="ScrollContainer" to="." method="_on_scroll_container_gui_input"]
[connection signal="pressed" from="CanvasLayer/BackButton" to="." method="_on_back_button_pressed"]
[connection signal="pressed" from="CanvasLayer/MinigameSelection/LessonButton" to="." method="_on_lesson_button_pressed"]
[connection signal="pressed" from="CanvasLayer/MinigameSelection/ExerciseButton1" to="." method="_on_exercise_button_1_pressed"]
[connection signal="pressed" from="CanvasLayer/MinigameSelection/ExerciseButton2" to="." method="_on_exercise_button_2_pressed"]
[connection signal="pressed" from="CanvasLayer/MinigameSelection/ExerciseButton3" to="." method="_on_exercise_button_3_pressed"]
[connection signal="pressed" from="CanvasLayer/MinigameChoiceContainer/MarginContainer/VBoxContainer/MinigameChoiceBackButton" to="." method="_on_minigame_choice_back_button_pressed"]
[connection signal="pressed" from="CanvasLayer/BackButton" to="." method="_on_back_button_pressed"]
[editable path="CanvasLayer/MinigameSelection/LessonButton"]