Pause and ui mouse handling

This commit is contained in:
Laurent Tourte
2022-12-15 16:09:57 +01:00
parent 3c8f40c7d1
commit f845a423b8
4 changed files with 87 additions and 21 deletions
+5 -1
View File
@@ -4,6 +4,10 @@ class_name Minigame
@export var minigame_name: = "Minigame"
@export var lives: = 5
# Game root shall contain all the game tree.
# This node is pausable unlike the others, so the pause button can stop the game but not other essential processes.
@onready var game_root: = $GameRoot
var lesson: String
var minigame_difficulty: int
var lesson_difficulty: int
@@ -56,7 +60,7 @@ func _play_stimulus() -> void:
func _pause_game() -> void:
return
get_tree().paused = not get_tree().paused
func _play_kalulu() -> void:
@@ -4,10 +4,17 @@
[ext_resource type="PackedScene" uid="uid://r8rtrts18ax3" path="res://sources/minigames/base/minigame_ui.tscn" id="2_a3tib"]
[node name="BaseMinigame" type="Node2D"]
process_mode = 3
script = ExtResource("1_jdfsm")
[node name="MinigameUI" parent="." instance=ExtResource("2_a3tib")]
[node name="StimuliFinder" type="Node" parent="."]
process_mode = 3
[node name="GameRoot" type="Node2D" parent="."]
process_mode = 1
[connection signal="garden_button_pressed" from="MinigameUI" to="." method="_on_minigame_ui_garden_button_pressed"]
[connection signal="kalulu_button_pressed" from="MinigameUI" to="." method="_on_minigame_ui_kalulu_button_pressed"]
[connection signal="pause_button_pressed" from="MinigameUI" to="." method="_on_minigame_ui_pause_button_pressed"]
+74 -20
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=3 uid="uid://r8rtrts18ax3"]
[gd_scene load_steps=20 format=3 uid="uid://r8rtrts18ax3"]
[ext_resource type="Texture2D" uid="uid://dj0ygi5q6kbdw" path="res://resources/minigames/minigame_ui/button_back_to_menu_up.png" id="1_f1uy8"]
[ext_resource type="Script" path="res://sources/minigames/base/minigame_ui.gd" id="1_g5fl4"]
@@ -19,7 +19,10 @@
[ext_resource type="Texture2D" uid="uid://cfxpnn3uivakv" path="res://resources/minigames/minigame_ui/gauge_icon_ant_empty.png" id="17_a20nt"]
[ext_resource type="Texture2D" uid="uid://b0ck8jxhicyke" path="res://resources/minigames/minigame_ui/gauge_icon_ant_full.png" id="18_gpcjx"]
[sub_resource type="BitMap" id="BitMap_0odf6"]
[node name="MinigameUI" type="CanvasLayer"]
process_mode = 3
script = ExtResource("1_g5fl4")
[node name="MainControl" type="Control" parent="."]
@@ -29,30 +32,38 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="Interface" type="HBoxContainer" parent="MainControl"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="LeftMargin" type="MarginContainer" parent="MainControl/Interface"]
layout_mode = 2
offset_right = 389.0
offset_bottom = 1800.0
size_flags_horizontal = 3
size_flags_stretch_ratio = 2.0
mouse_filter = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 50
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50
[node name="LeftContainer" type="VBoxContainer" parent="MainControl/Interface/LeftMargin"]
layout_mode = 2
offset_left = 50.0
offset_top = 50.0
offset_right = 339.0
offset_bottom = 1750.0
mouse_filter = 2
[node name="GardenButton" type="TextureButton" parent="MainControl/Interface/LeftMargin/LeftContainer"]
unique_name_in_owner = true
layout_mode = 2
offset_right = 289.0
offset_bottom = 422.0
size_flags_vertical = 3
texture_normal = ExtResource("1_f1uy8")
texture_pressed = ExtResource("2_357qg")
@@ -62,32 +73,43 @@ texture_focused = ExtResource("1_f1uy8")
stretch_mode = 5
[node name="StimulusMargin" type="MarginContainer" parent="MainControl/Interface/LeftMargin/LeftContainer"]
layout_mode = 2
offset_top = 426.0
offset_right = 289.0
offset_bottom = 848.0
size_flags_horizontal = 5
size_flags_vertical = 3
mouse_filter = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_right = 50
[node name="StimulusButton" type="TextureButton" parent="MainControl/Interface/LeftMargin/LeftContainer/StimulusMargin"]
unique_name_in_owner = true
layout_mode = 2
offset_left = 50.0
offset_right = 239.0
offset_bottom = 422.0
texture_normal = ExtResource("4_r8wnf")
texture_pressed = ExtResource("5_lo8fb")
texture_hover = ExtResource("4_r8wnf")
texture_disabled = ExtResource("6_yxeeh")
texture_focused = ExtResource("4_r8wnf")
texture_click_mask = SubResource("BitMap_0odf6")
stretch_mode = 5
[node name="PauseMargin" type="MarginContainer" parent="MainControl/Interface/LeftMargin/LeftContainer"]
layout_mode = 2
offset_top = 852.0
offset_right = 289.0
offset_bottom = 1274.0
size_flags_horizontal = 5
size_flags_vertical = 3
mouse_filter = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_right = 50
[node name="PauseButton" type="TextureButton" parent="MainControl/Interface/LeftMargin/LeftContainer/PauseMargin"]
unique_name_in_owner = true
layout_mode = 2
offset_left = 50.0
offset_right = 239.0
offset_bottom = 422.0
texture_normal = ExtResource("7_vqw3l")
texture_pressed = ExtResource("8_e01yc")
texture_hover = ExtResource("7_vqw3l")
@@ -97,7 +119,9 @@ stretch_mode = 5
[node name="KaluluButton" type="TextureButton" parent="MainControl/Interface/LeftMargin/LeftContainer"]
unique_name_in_owner = true
layout_mode = 2
offset_top = 1278.0
offset_right = 289.0
offset_bottom = 1700.0
size_flags_vertical = 3
texture_normal = ExtResource("4_ea5op")
texture_pressed = ExtResource("5_kfd0f")
@@ -107,31 +131,43 @@ texture_focused = ExtResource("4_ea5op")
stretch_mode = 5
[node name="CentralPadMargin" type="MarginContainer" parent="MainControl/Interface"]
layout_mode = 2
offset_left = 393.0
offset_right = 2342.0
offset_bottom = 1800.0
size_flags_horizontal = 7
size_flags_vertical = 3
size_flags_stretch_ratio = 10.0
mouse_filter = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="RightMargin" type="MarginContainer" parent="MainControl/Interface"]
layout_mode = 2
offset_left = 2346.0
offset_right = 2560.0
offset_bottom = 1800.0
size_flags_horizontal = 3
mouse_filter = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 50
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50
[node name="RightContainer" type="VBoxContainer" parent="MainControl/Interface/RightMargin"]
layout_mode = 2
offset_left = 50.0
offset_top = 50.0
offset_right = 164.0
offset_bottom = 1750.0
size_flags_horizontal = 8
mouse_filter = 2
[node name="LivesContainer" type="MarginContainer" parent="MainControl/Interface/RightMargin/RightContainer"]
layout_mode = 2
offset_right = 114.0
offset_bottom = 164.0
size_flags_horizontal = 0
size_flags_vertical = 0
mouse_filter = 2
theme_override_constants/margin_left = 25
theme_override_constants/margin_top = 25
theme_override_constants/margin_right = 25
@@ -140,30 +176,43 @@ theme_override_constants/margin_bottom = 75
[node name="EmptyLivesRect" type="TextureRect" parent="MainControl/Interface/RightMargin/RightContainer/LivesContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
offset_left = 25.0
offset_top = 25.0
offset_right = 89.0
offset_bottom = 89.0
size_flags_horizontal = 0
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("13_mg1p3")
stretch_mode = 1
[node name="LivesRect" type="TextureRect" parent="MainControl/Interface/RightMargin/RightContainer/LivesContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
offset_left = 25.0
offset_top = 25.0
offset_right = 89.0
offset_bottom = 89.0
size_flags_horizontal = 0
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("14_p5sco")
stretch_mode = 1
[node name="ProgressionMargin" type="MarginContainer" parent="MainControl/Interface/RightMargin/RightContainer"]
layout_mode = 2
offset_left = 50.0
offset_top = 168.0
offset_right = 114.0
offset_bottom = 234.0
size_flags_horizontal = 8
size_flags_vertical = 0
mouse_filter = 2
[node name="ProgressionGauge" type="NinePatchRect" parent="MainControl/Interface/RightMargin/RightContainer/ProgressionMargin"]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
offset_right = 64.0
offset_bottom = 66.0
size_flags_horizontal = 8
size_flags_vertical = 0
texture = ExtResource("13_geo50")
@@ -173,18 +222,23 @@ patch_margin_bottom = 33
[node name="ProgressionEmptyIconsRect" type="TextureRect" parent="MainControl/Interface/RightMargin/RightContainer/ProgressionMargin"]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
offset_right = 64.0
offset_bottom = 64.0
size_flags_horizontal = 8
size_flags_vertical = 0
mouse_filter = 2
texture = ExtResource("17_a20nt")
stretch_mode = 1
[node name="ProgressionFullIconsRect" type="TextureRect" parent="MainControl/Interface/RightMargin/RightContainer/ProgressionMargin"]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
offset_top = 1.0
offset_right = 64.0
offset_bottom = 65.0
size_flags_horizontal = 8
size_flags_vertical = 4
mouse_filter = 2
texture = ExtResource("18_gpcjx")
stretch_mode = 1