seems like a decent restore before I broke everything earlier

This commit is contained in:
derek
2025-02-28 15:53:01 -06:00
parent 3356f9e191
commit dba1be2034
7 changed files with 48 additions and 28 deletions

View File

@@ -50,4 +50,4 @@ func resume():
func _on_main_menu_pressed() -> void:
get_tree().change_scene_to_file("res://scenes/asset_checker.tscn")
get_tree().change_scene_to_file("res://MainMenu.tscn")

View File

@@ -4,7 +4,7 @@ extends Node
@export var generate_playlist_now = false
@export var checksum_test = false
@export var load_playlist_from_file = false
@export var maps_in_rotation : Array[String] = []
@export var maps_in_rotation : Array[level_resource] = []
@export var gamemodes_in_rotation : Array[gamemode]= []
@export var levels_per_round : int = 5
@export var rounds_per_match : int = 3
@@ -33,14 +33,16 @@ func generate_playlist() -> void:
for i in rounds_per_match:
var round = []
for x in levels_per_round:
var gamemode_path = gamemodes_in_rotation.pick_random().resource_path
var level_selection = maps_in_rotation.pick_random()
var level_details = {
"map" : maps_in_rotation.pick_random(),
"gamemode" : gamemodes_in_rotation.pick_random()
"level_path" : level_selection.level_path,
"level_name" : level_selection.level_name,
"gamemode_path" : gamemode_path
}
round.append(level_details)
matches.append(round)
playlist.append(matches)
print("PLAYLIST : ", playlist)
save_playlist(playlist)
generate_playlist_now = false
@@ -75,9 +77,6 @@ func load_playlist():
GameGlobals.playlist_test = playlist
GameGlobals.current_match = playlist[0]
file.close()
print("PLAYLIST: ")
print("------------------------------------------------------------------------------------")
print(playlist)
else:
print("no data saved, generating new playlist...")
generate_playlist()

View File

@@ -2,6 +2,7 @@ extends Node
@onready var playlist_generator: Control = $"../Playlist Generator"
var round_id = 2
var portals = []
# Called when the node enters the scene tree for the first time.
@@ -11,15 +12,10 @@ func _ready() -> void:
for i in get_tree().current_scene.get_children():
if i.is_in_group("portal"):
portals.append(i)
print("PORTALS")
var id = 0
for i in portals:
i.scene_path = str(GameGlobals.current_match[0][id]["map"])
i.scene_name = str(GameGlobals.current_match[0][id]["map"])
i.scene_path = str(GameGlobals.current_match[round_id][id]["level_path"])
i.scene_name = str(GameGlobals.current_match[round_id][id]["level_name"])
i.level_gamemode = load(GameGlobals.current_match[round_id][id]["gamemode_path"])
id += 1
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
print("CURRENT MATCH ",GameGlobals.current_match[0])

View File

@@ -47,7 +47,7 @@ func load_persistent_data():
print("No file found...")
func save_user_data():
var user_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_leaderboard","_data.save")
var user_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_data.save")
var file = FileAccess.open(user_save_path, FileAccess.WRITE)
#cache data before saving and creating checksum in case it changes between data saving and checksum generating
@@ -80,7 +80,7 @@ func save_user_data():
file.close()
func check_user_data_exists():
var user_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_leaderboard","_data.save")
var user_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_data.save")
if FileAccess.file_exists(user_save_path):
return true
else:
@@ -88,7 +88,7 @@ func check_user_data_exists():
func load_user_data():
print("ALL LEADERBOARDS: ",GameGlobals.all_user_leaderboards[0][0])
var user_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_leaderboard","_data.save")
var user_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_data.save")
if FileAccess.file_exists(user_save_path):
var file = FileAccess.open(user_save_path, FileAccess.READ)
GameGlobals.last_hit_path = file.get_var()
@@ -146,7 +146,7 @@ func load_user_data():
func save_game_data(level_name):
var level_control = get_tree().current_scene
var player = level_control.player
var game_save_path = str("user://",GameGlobals.current_leaderboard_name,"_",level_name,"_gamesave.save")
var game_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_last_level","_data.save")
var file = FileAccess.open(game_save_path, FileAccess.WRITE)
#ASSIGN DATA TO VARIABLES
data_cleared = false
@@ -170,7 +170,7 @@ func save_game_data(level_name):
file.close()
func check_save_game_exists(level_name):
var game_save_path = str("user://",GameGlobals.leaderboard_name,"_",level_name,"_gamesave.save")
var game_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_last_level","_data.save")
if FileAccess.file_exists(game_save_path):
return true
else:
@@ -179,7 +179,8 @@ func check_save_game_exists(level_name):
func load_save_game_data(level_name):
var level_control = get_tree().current_scene
var player = level_control.player
var game_save_path = str("user://",GameGlobals.leaderboard_name,"_",level_name,"_gamesave.save")
var game_save_path = str("user://user_",str(GameGlobals.user_id),"_",str(GameGlobals.all_user_leaderboards[GameGlobals.user_id][GameGlobals.last_leaderboard_id]),"_last_level","_data.save")
print("GAME SAVE PATH : ",game_save_path)
if FileAccess.file_exists(game_save_path):
var file = FileAccess.open(game_save_path, FileAccess.READ)