This commit is contained in:
2026-02-23 11:37:27 +01:00
commit 13dbb551c8
94 changed files with 2682 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
class_name LevelButton
extends Button
var level_nr: int
signal select_level(level_nr: int)
func _ready() -> void:
text = str(level_nr)
func _on_pressed() -> void:
select_level.emit(level_nr)

View File

@@ -0,0 +1 @@
uid://dwav7d4amw8yu

View File

@@ -0,0 +1,12 @@
[gd_scene format=3 uid="uid://ccrodv5x16nay"]
[ext_resource type="Script" uid="uid://dwav7d4amw8yu" path="res://ui/screens/level-select-screen/level_button.gd" id="1_ej8yx"]
[node name="LevelButton" type="Button" unique_id=923151870]
custom_minimum_size = Vector2(90, 90)
offset_right = 8.0
offset_bottom = 8.0
theme_override_font_sizes/font_size = 56
script = ExtResource("1_ej8yx")
[connection signal="pressed" from="." to="." method="_on_pressed"]

View File

@@ -0,0 +1,43 @@
extends Control
@export var buttonContainer: Container
var level_buttons: Array[Button] = []
var completed_levels: Array[bool] = []
signal start_level(level_nr: int)
signal test_level()
signal exit()
func init_buttons(max_level: int, completed_level_information: Array[bool]) -> void:
if max_level > 0:
$VBoxContainer/Label.visible = false
completed_levels = completed_level_information
for i in range(max_level):
var b: LevelButton = load("res://ui/screens/level-select-screen/level_button.tscn").instantiate()
b.level_nr = i + 1
b.select_level.connect(_level_button_pressed)
b.disabled = not completed_levels[i]
level_buttons.append(b)
buttonContainer.add_child(b)
func _level_button_pressed(level_nr: int) -> void:
print("Start Level ",level_nr)
start_level.emit(level_nr)
queue_free()
func _return_to_title() -> void:
exit.emit()
queue_free()
func _on_unlock_levels_toggled(toggled_on: bool) -> void:
for i in range(len(level_buttons)):
if toggled_on:
level_buttons[i].disabled = false
else:
level_buttons[i].disabled = !completed_levels[i]
func _on_test_level_pressed() -> void:
test_level.emit()
queue_free()

View File

@@ -0,0 +1 @@
uid://d2i8k7votngvg

View File

@@ -0,0 +1,66 @@
[gd_scene format=3 uid="uid://cv82k2twxie3n"]
[ext_resource type="Theme" uid="uid://hheneshfv1b2" path="res://ui/themes/your_theme.tres" id="1_cpj7q"]
[ext_resource type="Script" uid="uid://d2i8k7votngvg" path="res://ui/screens/level-select-screen/level_select.gd" id="2_lcog6"]
[sub_resource type="LabelSettings" id="LabelSettings_mfdjd"]
font_size = 60
[node name="LevelSelect" type="MarginContainer" unique_id=1286521924 node_paths=PackedStringArray("buttonContainer")]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_cpj7q")
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
script = ExtResource("2_lcog6")
buttonContainer = NodePath("VBoxContainer/HFlowContainer")
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1716877818]
layout_mode = 2
[node name="LevelSelectTitle" type="Label" parent="VBoxContainer" unique_id=1290767086]
custom_minimum_size = Vector2(731.345, 0)
layout_mode = 2
text = "Level Select"
label_settings = SubResource("LabelSettings_mfdjd")
horizontal_alignment = 1
autowrap_mode = 2
[node name="Spacer" type="Control" parent="VBoxContainer" unique_id=1769227168]
custom_minimum_size = Vector2(0, 28)
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer" unique_id=878866277]
layout_mode = 2
text = "This Level Select Screen is provided by the template.
Numbered buttons related to a given level will be displayed here, if multiple_levels is enabled and the max number of levels is larger than zero.
The default location for levels ist the 'levels/' Folder with levels using the \"level_x.tscn\" naming scheme."
horizontal_alignment = 1
[node name="HFlowContainer" type="HFlowContainer" parent="VBoxContainer" unique_id=2027526310]
layout_mode = 2
alignment = 1
[node name="Control" type="HBoxContainer" parent="VBoxContainer" unique_id=1711230144]
layout_mode = 2
size_flags_vertical = 10
[node name="UnlockLevels" type="CheckButton" parent="VBoxContainer/Control" unique_id=1583371876]
layout_mode = 2
size_flags_horizontal = 10
text = "Unlock all Levels"
[node name="Return" type="Button" parent="VBoxContainer" unique_id=2120122741]
layout_mode = 2
size_flags_horizontal = 4
text = "Return to Main Menu"
[connection signal="toggled" from="VBoxContainer/Control/UnlockLevels" to="." method="_on_unlock_levels_toggled"]
[connection signal="pressed" from="VBoxContainer/Return" to="." method="_return_to_title"]