2020-09-29 19:40:17 +02:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
var chapters
|
|
|
|
|
|
|
|
func _ready():
|
2021-09-15 16:26:41 +02:00
|
|
|
var lang = game.lang
|
2020-09-29 19:40:17 +02:00
|
|
|
reload()
|
|
|
|
|
|
|
|
func reload():
|
|
|
|
chapters = []
|
|
|
|
|
|
|
|
var dir = Directory.new()
|
2021-09-08 17:00:51 +02:00
|
|
|
dir.open("res://levels/" + game.lang)
|
2020-09-29 19:40:17 +02:00
|
|
|
dir.list_dir_begin()
|
|
|
|
|
|
|
|
var chapter_names = []
|
|
|
|
|
|
|
|
while true:
|
|
|
|
var file = dir.get_next()
|
|
|
|
if file == "":
|
|
|
|
break
|
2020-10-22 14:01:08 +02:00
|
|
|
elif not file.begins_with(".") and file != "sequence":
|
2020-09-29 19:40:17 +02:00
|
|
|
chapter_names.append(file)
|
|
|
|
|
|
|
|
dir.list_dir_end()
|
|
|
|
chapter_names.sort()
|
|
|
|
|
2020-10-22 14:01:08 +02:00
|
|
|
var final_chapter_sequence = []
|
|
|
|
|
2021-09-08 17:00:51 +02:00
|
|
|
var chapter_sequence = Array(helpers.read_file("res://levels/" + game.lang + "/sequence", "").split("\n"))
|
2020-10-22 14:01:08 +02:00
|
|
|
|
|
|
|
for chapter in chapter_sequence:
|
|
|
|
if chapter == "":
|
|
|
|
continue
|
|
|
|
if not chapter_names.has(chapter):
|
|
|
|
helpers.crash("Chapter '%s' is specified in the sequence, but could not be found" % chapter)
|
|
|
|
chapter_names.erase(chapter)
|
|
|
|
final_chapter_sequence.push_back(chapter)
|
|
|
|
|
2021-01-13 17:30:32 +01:00
|
|
|
#final_chapter_sequence += chapter_names
|
2020-10-22 14:01:08 +02:00
|
|
|
|
|
|
|
for c in final_chapter_sequence:
|
2020-09-29 19:40:17 +02:00
|
|
|
var chapter = Chapter.new()
|
2021-09-08 17:00:51 +02:00
|
|
|
chapter.load("res://levels/" + game.lang + "/%s" % c)
|
2020-09-29 19:40:17 +02:00
|
|
|
chapters.push_back(chapter)
|