Live-reload level list when clicking dropdown

This commit is contained in:
Sebastian Morr 2020-09-15 16:31:41 +02:00
parent 15ec7a0df4
commit d3149784cb
2 changed files with 9 additions and 2 deletions

10
main.gd
View file

@ -15,8 +15,7 @@ onready var active_repository = $Repositories/ActiveRepository
func _ready(): func _ready():
# Initialize level select. # Initialize level select.
var options = $LevelSelect.get_popup() var options = $LevelSelect.get_popup()
for level in list_levels(): repopulate_levels()
options.add_item(level)
options.connect("id_pressed", self, "load_level") options.connect("id_pressed", self, "load_level")
$LevelSelect.theme = Theme.new() $LevelSelect.theme = Theme.new()
$LevelSelect.theme.default_font = load("res://fonts/default.tres") $LevelSelect.theme.default_font = load("res://fonts/default.tres")
@ -149,3 +148,10 @@ func save_message():
func show_win_status(): func show_win_status():
$NextLevelButton.show() $NextLevelButton.show()
$LevelDescription.text = "Yay, you solved the puzzle! Enjoy the view or continue to the next level!" $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)

View file

@ -172,6 +172,7 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[connection signal="pressed" from="TextEditor/SaveButton" to="." method="save_message"] [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="NextLevelButton" to="." method="load_next_level"]
[connection signal="pressed" from="ReloadButton" to="." method="reload_level"] [connection signal="pressed" from="ReloadButton" to="." method="reload_level"]
[connection signal="data_received" from="Test/TCPServer" to="Test" method="data"] [connection signal="data_received" from="Test/TCPServer" to="Test" method="data"]