2020-12-23 12:01:07 +01:00
extends Control
2023-09-06 16:04:23 +02:00
@ onready var level_list = $ ScrollContainer / MarginContainer / Levels
2020-12-23 12:01:07 +01:00
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
2023-09-06 16:04:23 +02:00
get_tree ( ) . change_scene_to_file ( " res://scenes/main.tscn " )
2021-01-05 13:27:52 +01:00
func back ( ) :
2023-09-06 16:04:23 +02:00
get_tree ( ) . change_scene_to_file ( " res://scenes/title.tscn " )
2021-01-05 13:27:52 +01:00
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
2023-09-06 16:04:23 +02:00
l . set ( " theme_override_fonts/font " , preload ( " res://fonts/big.tres " ) )
#l.align = HORIZONTAL_ALIGNMENT_CENTER
l . horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
2020-12-23 12:01:07 +01:00
level_list . add_child ( l )
for level in chapter . levels :
2021-01-21 15:08:59 +01:00
var hb = HBoxContainer . new ( )
2020-12-23 12:01:07 +01:00
var b = Button . new ( )
b . text = level . title
2023-09-06 16:04:23 +02:00
#b.align = HORIZONTAL_ALIGNMENT_CENTER #ToDo align?
2021-01-21 15:08:59 +01:00
b . size_flags_horizontal = SIZE_EXPAND_FILL
2023-09-06 16:04:23 +02:00
b . connect ( " pressed " , Callable ( self , " load " ) . bind ( 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 " ] :
2023-09-06 16:04:23 +02:00
b . set ( " theme_override_colors/font_color " , Color ( 0.1 , 0.8 , 0.1 , 1 ) )
b . set ( " theme_override_colors/font_hover_color " , Color ( 0.1 , 0.8 , 0.1 , 1 ) )
b . set ( " theme_override_colors/font_pressed_color " , Color ( 0.1 , 0.8 , 0.1 , 1 ) )
2021-01-21 15:08:59 +01:00
hb . add_child ( b )
#
2023-09-06 16:04:23 +02:00
var badge = preload ( " res://scenes/cli_badge.tscn " ) . instantiate ( )
2021-01-21 15:08:59 +01:00
hb . add_child ( badge )
badge . active = slug in game . state [ " cli_badge " ]
badge . sparkling = false
level_list . add_child ( hb )
2021-02-04 15:19:54 +01:00
if badge . active :
game . notify ( " You get a golden badge for each level you solve without using the playing cards! Can you solve them all using the command line? " , badge , " cli-badge " )
2020-12-23 12:01:07 +01:00
level_id += 1
chapter_id += 1
2021-01-28 11:28:47 +01:00
2021-01-28 11:55:53 +01:00
2021-02-04 16:11:56 +01:00
2021-02-11 10:46:08 +01:00
2021-02-04 16:11:56 +01:00