60 lines
1.6 KiB
GDScript
60 lines
1.6 KiB
GDScript
extends Node
|
|
|
|
var last_scene
|
|
|
|
@onready var playlist_generator: Node = $PlaylistGenerator
|
|
|
|
@onready var continue_button: Button = $MarginContainer/VBoxContainer/Continue
|
|
@onready var option_button: OptionButton = $MarginContainer/VBoxContainer/HBoxContainer/OptionButton
|
|
@onready var add_leaderboard: Button = $"MarginContainer/VBoxContainer/HBoxContainer/Add Leaderboard"
|
|
@onready var add_leaderboard_menu: Control = $"Add Leaderboard Menu"
|
|
|
|
|
|
func _enter_tree() -> void:
|
|
SaveLoad.load_persistent_data()
|
|
SaveLoad.load_user_data()
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
playlist_generator.load_playlist()
|
|
option_button.clear()
|
|
for i in GameGlobals.all_user_leaderboards[GameGlobals.user_id]:
|
|
option_button.add_item(i)
|
|
option_button.selected = GameGlobals.last_leaderboard_id
|
|
continue_text_check()
|
|
|
|
|
|
func _on_continue_pressed() -> void:
|
|
var level
|
|
var load_to_gamemode
|
|
|
|
|
|
playlist_generator.load_playlist()
|
|
|
|
|
|
if GameGlobals.current_level == null:
|
|
level = "res://scenes/HUBWORLD.tscn"
|
|
load_to_gamemode = "res://GameModes/hubworld.tres"
|
|
else:
|
|
level = GameGlobals.current_level
|
|
load_to_gamemode = GameGlobals.current_gamemode
|
|
|
|
SaveLoad.save_persistent_data()
|
|
SaveLoad.load_user_data()
|
|
SaveLoad.save_user_data()
|
|
get_tree().change_scene_to_file(level)
|
|
print("LEVEL : ",GameGlobals.current_level)
|
|
|
|
func _on_exit_pressed() -> void:
|
|
get_tree().quit()
|
|
|
|
func continue_text_check():
|
|
if SaveLoad.check_user_data_exists():
|
|
continue_button.text = "Continue"
|
|
else:
|
|
continue_button.text = "New Game"
|
|
|
|
|
|
func _on_add_leaderboard_pressed() -> void:
|
|
add_leaderboard_menu.visible = true
|