fix: loading order, savegame directory creation

This commit is contained in:
tiger tiger tiger 2025-12-12 16:33:06 +01:00
parent 59497838fe
commit ec38d8edef
7 changed files with 45 additions and 29 deletions

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GdProjectSettingsState">
<annotators>warn</annotators>
</component>
</project>

View File

@ -6,6 +6,7 @@ class_name ThemedButton extends Button
@onready var lower_corner_decor := load("res://import/interface-elements/lower_corner.png")
func _ready() -> void:
print(owner)
rebuild()
theme_changed.connect(rebuild)
resized.connect(rebuild)

View File

@ -215,9 +215,7 @@ func validate_board_state() -> bool:
if not (sticky is int or sticky is Vector2 or board_state.cards.keys().has(sticky)):
push_error("Save %s could not be parsed: Corrupted Sticky Notes.")
return false
return true
return false
func parse_vec_from_string(string: String) -> Vector2:

View File

@ -1,7 +1,5 @@
extends Control
signal room_loaded
var has_stage: bool = false
# set(stage):
# has_stage = stage
@ -20,6 +18,14 @@ var has_stage: bool = false
@onready var state_machine = menu_animation["parameters/playback"]
@onready var focus_forward = %MainMenu
func _ready() -> void:
await get_tree().create_timer(1.0).timeout
print("main.gd: ready()")
main_menu.has_stage = true
# TODO: Find out if we want this.
signal room_loaded
#
#var in_game = false
#

View File

@ -1146,7 +1146,7 @@ states/reveal_pause_menu/position = Vector2(783.91, -112.734)
states/start_game/node = SubResource("AnimationNodeAnimation_5umfs")
states/start_game/position = Vector2(698, 32)
transitions = ["Start", "init", SubResource("AnimationNodeStateMachineTransition_dxdg4"), "init", "loading", SubResource("AnimationNodeStateMachineTransition_0hpxy"), "loading", "loading_done", SubResource("AnimationNodeStateMachineTransition_ipapo"), "loading_done", "start_game", SubResource("AnimationNodeStateMachineTransition_0t1lp"), "start_game", "init", SubResource("AnimationNodeStateMachineTransition_66nmg"), "loading_done", "load_savegame", SubResource("AnimationNodeStateMachineTransition_6b86u"), "load_savegame", "loading_game", SubResource("AnimationNodeStateMachineTransition_y626i"), "loading_game", "start_game", SubResource("AnimationNodeStateMachineTransition_52bss"), "start_game", "credits_roll", SubResource("AnimationNodeStateMachineTransition_x8oth"), "credits_roll", "loading_done", SubResource("AnimationNodeStateMachineTransition_5ge3a"), "loading_done", "credits_roll", SubResource("AnimationNodeStateMachineTransition_44pd3"), "start_game", "reveal_pause_menu", SubResource("AnimationNodeStateMachineTransition_pc6pe"), "reveal_pause_menu", "hide_pause_menu", SubResource("AnimationNodeStateMachineTransition_dx61n"), "hide_pause_menu", "start_game", SubResource("AnimationNodeStateMachineTransition_lp1dx"), "hide_pause_menu", "init", SubResource("AnimationNodeStateMachineTransition_mqlnh")]
graph_offset = Vector2(163.75, -42.73401)
graph_offset = Vector2(166.75, -196.73401)
[sub_resource type="Shader" id="Shader_cegan"]
code = "shader_type canvas_item;

View File

@ -3,25 +3,25 @@ class_name MainMenu extends Panel
var has_stage: bool = false:
set(value):
has_stage = value
if is_node_ready():
if save_game_handle.get_most_recent_save().current_room == 0:
continue_button.visible = false
continue_button.disabled = true
new_game_button.theme_type_variation = "H1Button"
assert(is_node_ready(), "MainMenu node not ready yet!")
if save_game_handle.get_most_recent_save().current_room == 0:
continue_button.visible = false
continue_button.disabled = true
new_game_button.theme_type_variation = "H1Button"
else:
continue_button.visible = true
continue_button.disabled = not has_stage
new_game_button.theme_type_variation = ""
load_game_button.disabled = not save_game_handle.has_existing_saves()
for child: Control in $PanelContainer.get_children():
child.focus_mode = FOCUS_ALL if has_stage else FOCUS_NONE
child.modulate = Color.WHITE if has_stage else Color.WEB_GRAY
child.mouse_filter = Control.MOUSE_FILTER_STOP if has_stage else Control.MOUSE_FILTER_IGNORE
if has_stage:
if continue_button.visible:
continue_button.grab_focus()
else:
continue_button.visible = true
continue_button.disabled = not has_stage
new_game_button.theme_type_variation = ""
load_game_button.disabled = not save_game_handle.has_existing_saves()
for child: Control in $PanelContainer.get_children():
child.focus_mode = FOCUS_ALL if has_stage else FOCUS_NONE
child.modulate = Color.WHITE if has_stage else Color.WEB_GRAY
child.mouse_filter = Control.MOUSE_FILTER_STOP if has_stage else Control.MOUSE_FILTER_IGNORE
if has_stage:
if continue_button.visible:
continue_button.grab_focus()
else:
new_game_button.grab_focus()
new_game_button.grab_focus()
signal start_game(savegame: SaveGame)
signal open_settings(new_game: bool)
@ -43,6 +43,7 @@ var await_new_game: bool = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
print("main_menu.gd: ready()")
save_game_handle.picked.connect(_on_save_picked)
if save_game_handle.get_most_recent_save().current_room == 0:
continue_button.disabled = true
@ -56,7 +57,7 @@ func _ready() -> void:
quit_button.pressed.connect(get_tree().quit)
credits_button.pressed.connect(roll_credits.emit)
State.take_stage(self)
#State.take_stage(self)
func _on_save_picked(save: SaveGame):
start_game.emit(save)

View File

@ -23,14 +23,18 @@ func _validate_property(property: Dictionary) -> void:
func _ready() -> void:
var dir = DirAccess.open(State.user_saves_path)
if DirAccess.get_open_error() != OK:
printerr("Error while opening User Save Directory: %s" % error_string(DirAccess.get_open_error()))
# Invalid Error being raised when Directory does not exist.
var dir := DirAccess.open(State.user_saves_path)
# Create dir if needed.
if DirAccess.get_open_error() == ERR_INVALID_PARAMETER:
dir = DirAccess.open("user://")
dir.make_dir_recursive(State.user_saves_path)
dir.make_dir_recursive(State.user_saves_path)
if DirAccess.get_open_error() != OK:
printerr("Error while opening User Save Directory: %s" % error_string(DirAccess.get_open_error()))
load_games()
for i in range(save_buttons.size()):
save_buttons[i].pressed.connect(func(): picked.emit(saves[i]))