2020-12-23 12:01:07 +01:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
onready var level_list = $ScrollContainer/MarginContainer/Levels
|
|
|
|
|
|
|
|
func _ready():
|
2021-01-05 13:27:52 +01:00
|
|
|
reload()
|
|
|
|
|
|
|
|
func load(chapter_id, level_id):
|
|
|
|
game.current_chapter = chapter_id
|
|
|
|
game.current_level = level_id
|
|
|
|
get_tree().change_scene("res://scenes/main.tscn")
|
|
|
|
|
|
|
|
func back():
|
|
|
|
get_tree().change_scene("res://scenes/title.tscn")
|
|
|
|
|
|
|
|
|
|
|
|
func reload():
|
|
|
|
for child in level_list.get_children():
|
|
|
|
child.queue_free()
|
|
|
|
|
2020-12-23 12:01:07 +01:00
|
|
|
var chapter_id = 0
|
|
|
|
|
2021-01-05 13:05:46 +01:00
|
|
|
levels.reload()
|
|
|
|
|
2020-12-23 12:01:07 +01:00
|
|
|
for chapter in levels.chapters:
|
|
|
|
var level_id = 0
|
|
|
|
|
|
|
|
var l = Label.new()
|
|
|
|
l.text = chapter.slug
|
|
|
|
l.set("custom_fonts/font", preload("res://fonts/big.tres"))
|
|
|
|
l.align = HALIGN_CENTER
|
|
|
|
level_list.add_child(l)
|
|
|
|
|
|
|
|
for level in chapter.levels:
|
|
|
|
var b = Button.new()
|
|
|
|
b.text = level.title
|
|
|
|
b.align = HALIGN_LEFT
|
|
|
|
b.connect("pressed", self, "load", [chapter_id, level_id])
|
2021-01-07 11:36:11 +01:00
|
|
|
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))
|
2020-12-23 12:01:07 +01:00
|
|
|
level_list.add_child(b)
|
|
|
|
level_id += 1
|
|
|
|
|
|
|
|
chapter_id += 1
|