diff --git a/main.gd b/main.gd index 27084d6..56c3151 100644 --- a/main.gd +++ b/main.gd @@ -15,8 +15,7 @@ onready var active_repository = $Repositories/ActiveRepository func _ready(): # Initialize level select. var options = $LevelSelect.get_popup() - for level in list_levels(): - options.add_item(level) + repopulate_levels() options.connect("id_pressed", self, "load_level") $LevelSelect.theme = Theme.new() $LevelSelect.theme.default_font = load("res://fonts/default.tres") @@ -149,3 +148,10 @@ func save_message(): func show_win_status(): $NextLevelButton.show() $LevelDescription.text = "Yay, you solved the puzzle! Enjoy the view or continue to the next level!" + + +func repopulate_levels(): + var options = $LevelSelect.get_popup() + options.clear() + for level in list_levels(): + options.add_item(level) diff --git a/main.tscn b/main.tscn index 472bfe2..0078b53 100644 --- a/main.tscn +++ b/main.tscn @@ -172,6 +172,7 @@ __meta__ = { "_edit_use_anchors_": false } [connection signal="pressed" from="TextEditor/SaveButton" to="." method="save_message"] +[connection signal="button_down" from="LevelSelect" to="." method="repopulate_levels"] [connection signal="pressed" from="NextLevelButton" to="." method="load_next_level"] [connection signal="pressed" from="ReloadButton" to="." method="reload_level"] [connection signal="data_received" from="Test/TCPServer" to="Test" method="data"]