mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-13 19:04:54 +01:00
Savegames!
This commit is contained in:
parent
76c4aab834
commit
5c1f1ce722
4 changed files with 20 additions and 8 deletions
|
@ -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,7 +63,6 @@ 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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue