diff --git a/scenes/file_browser.gd b/scenes/file_browser.gd index 906c026..2076747 100644 --- a/scenes/file_browser.gd +++ b/scenes/file_browser.gd @@ -48,6 +48,8 @@ func update(): wd_files.pop_back() wd_files = helpers.map(wd_files, self, "substr2") + var files = wd_files + var head_files var index_files @@ -61,13 +63,12 @@ func update(): # The last entry is an empty string, remove it. index_files.pop_back() - var files = wd_files - for f in head_files: - if not f in files: - files.push_back(f) - for f in index_files: - if not f in files: - files.push_back(f) + for f in head_files: + if not f in files: + files.push_back(f) + for f in index_files: + if not f in files: + files.push_back(f) files.sort_custom(self, "very_best_sort") diff --git a/scenes/game.gd b/scenes/game.gd index 412d11d..9728efc 100644 --- a/scenes/game.gd +++ b/scenes/game.gd @@ -28,7 +28,7 @@ func copy_script_to_game_env(name): global_shell.run("chmod u+x '%s'" % (tmp_prefix + name)) func _initial_state(): - return {"history": []} + return {"history": [], "solved_levels": []} func save_state(): var savegame = File.new() diff --git a/scenes/level_select.gd b/scenes/level_select.gd index 18def77..026a640 100644 --- a/scenes/level_select.gd +++ b/scenes/level_select.gd @@ -36,6 +36,11 @@ func reload(): b.text = level.title b.align = HALIGN_LEFT b.connect("pressed", self, "load", [chapter_id, level_id]) + var slug = chapter.slug + "/" + level.slug + if slug in game.state["solved_levels"]: + b.set("custom_colors/font_color", Color(0.1, 0.8, 0.1, 1)) + b.set("custom_colors/font_color_hover", Color(0.1, 0.8, 0.1, 1)) + b.set("custom_colors/font_color_pressed", Color(0.1, 0.8, 0.1, 1)) level_list.add_child(b) level_id += 1 diff --git a/scenes/main.gd b/scenes/main.gd index d4e4a5d..3fa3a30 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -143,6 +143,12 @@ func show_win_status(win_states): level_description.hide() level_congrats.show() $SuccessSound.play() + if not game.state.has("solved_levels"): + game.state["solved_levels"] = [] + var slug = levels.chapters[game.current_chapter].slug + "/" + level.slug + if not slug in game.state["solved_levels"]: + game.state["solved_levels"].push_back(slug) + game.save_state() func repopulate_levels(): levels.reload()