2025-12-10 17:52:09 +00:00
|
|
|
extends Control
|
2023-12-02 16:37:42 +00:00
|
|
|
|
2024-10-18 15:31:46 +00:00
|
|
|
signal room_loaded
|
|
|
|
|
|
2025-12-10 17:52:09 +00:00
|
|
|
var has_stage: bool = false
|
|
|
|
|
# set(stage):
|
|
|
|
|
# has_stage = stage
|
|
|
|
|
# if in_game and has_stage:
|
|
|
|
|
# in_game = false
|
|
|
|
|
# _return_to_menu()
|
2024-10-18 15:31:46 +00:00
|
|
|
|
2024-10-01 23:30:03 +00:00
|
|
|
@export_file(".tscn") var youth_room_path: String
|
2024-10-16 10:29:20 +00:00
|
|
|
@export_file(".tscn") var transition_room_path: String
|
|
|
|
|
@export_file(".tscn") var adulthood_room_path: String
|
|
|
|
|
@export_file(".tscn") var ending_path: String
|
2024-10-01 23:30:03 +00:00
|
|
|
|
2025-12-10 17:52:09 +00:00
|
|
|
@onready var main_menu:MainMenu = %MainMenu
|
2025-02-24 15:00:20 +00:00
|
|
|
@onready var pause_menu = %PauseMenu
|
2024-10-07 09:21:36 +00:00
|
|
|
@onready var menu_animation: AnimationTree = %MenuAnimationTree
|
2025-10-29 21:48:41 +00:00
|
|
|
@onready var state_machine = menu_animation["parameters/playback"]
|
2025-12-10 17:52:09 +00:00
|
|
|
@onready var focus_forward = %MainMenu
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
#var in_game = false
|
|
|
|
|
#
|
|
|
|
|
#var current_room: RoomTemplate
|
|
|
|
|
#var currently_loading_room: String = "":
|
|
|
|
|
# set(path):
|
|
|
|
|
# if path != "":
|
|
|
|
|
# ResourceLoader.load_threaded_request(path, "PackedScene")
|
|
|
|
|
# menu_animation["parameters/conditions/loading_done"] = false
|
|
|
|
|
# menu_animation["parameters/conditions/load_save"] = true
|
|
|
|
|
# else:
|
|
|
|
|
# menu_animation["parameters/conditions/loading_done"] = true
|
|
|
|
|
# menu_animation["parameters/conditions/load_save"] = false
|
|
|
|
|
#
|
|
|
|
|
# currently_loading_room = path
|
|
|
|
|
#
|
|
|
|
|
## Called when the node enters the scene tree for the first time.
|
|
|
|
|
#func _ready():
|
|
|
|
|
# main_menu.start_game.connect(load_save)
|
|
|
|
|
# main_menu.roll_credits.connect(func(): state_machine.travel("credits_roll"))
|
|
|
|
|
# get_tree().tree_process_mode_changed.connect(pause_mode_changed)
|
|
|
|
|
# await get_tree().process_frame
|
|
|
|
|
# currently_loading_room = get_room_path_from_id(main_menu.save_game_handle.get_most_recent_save().current_room)
|
|
|
|
|
# State.pass_stage_to(main_menu)
|
|
|
|
|
#
|
|
|
|
|
# Scenes.scene_starting.connect(prepare_transition)
|
|
|
|
|
# Scenes.scene_finished.connect(transition)
|
|
|
|
|
#
|
|
|
|
|
#func _process(_delta: float) -> void:
|
|
|
|
|
# if currently_loading_room != "" and not await_swap:
|
|
|
|
|
# if ResourceLoader.load_threaded_get_status(currently_loading_room) == 3:
|
|
|
|
|
# if not current_room == null:
|
|
|
|
|
# current_room.queue_free()
|
|
|
|
|
# State.onready_room = get_room_id_from_path(currently_loading_room)
|
|
|
|
|
# current_room = ResourceLoader.load_threaded_get(currently_loading_room).instantiate()
|
|
|
|
|
# print("add room")
|
|
|
|
|
# add_child(current_room)
|
|
|
|
|
# State.onready_room = State.rooms.NULL
|
|
|
|
|
# move_child(current_room, 0)
|
|
|
|
|
# currently_loading_room = ""
|
|
|
|
|
# room_loaded.emit()
|
|
|
|
|
#
|
|
|
|
|
# if Input.is_action_just_pressed("reset_demo") and (OS.has_feature("demo") or true):
|
|
|
|
|
# State.stage_list = [self]
|
|
|
|
|
# _return_to_menu()
|
|
|
|
|
#
|
|
|
|
|
#func _unhandled_input(event: InputEvent) -> void:
|
|
|
|
|
# if event is InputEvent and in_game:
|
|
|
|
|
# if event.is_action_pressed("ui_menu"):
|
|
|
|
|
# toggle_pause_menu()
|
|
|
|
|
#
|
2025-03-03 14:29:52 +00:00
|
|
|
func toggle_pause_menu():
|
2025-12-10 17:52:09 +00:00
|
|
|
pass
|
|
|
|
|
# if not get_tree().paused:
|
|
|
|
|
# get_tree().paused = true
|
|
|
|
|
# var state_machine := menu_animation["parameters/playback"]
|
|
|
|
|
# state_machine.travel("reveal_pause_menu")
|
|
|
|
|
# Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
|
|
|
# else:
|
|
|
|
|
# get_tree().paused = false
|
|
|
|
|
# var state_machine := menu_animation["parameters/playback"]
|
|
|
|
|
# state_machine.travel("start_game")
|
|
|
|
|
#
|
|
|
|
|
# if State.stage_list[0] is Player:
|
|
|
|
|
# Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
|
|
|
|
|
|
|
|
#func debug_youth():
|
|
|
|
|
# get_child(1).hide()
|
|
|
|
|
# get_child(2).hide()
|
|
|
|
|
# get_child(3).hide()
|
|
|
|
|
# get_child(0).get_ready()
|
|
|
|
|
# get_child(0).start()
|
|
|
|
|
#
|
|
|
|
|
#func _return_to_menu():
|
|
|
|
|
# State.active_save_game = null
|
|
|
|
|
#
|
|
|
|
|
# menu_animation["parameters/conditions/start_game"] = false
|
|
|
|
|
#
|
|
|
|
|
# State.pass_stage_to(main_menu)
|
|
|
|
|
#
|
|
|
|
|
# currently_loading_room = get_room_path_from_id(main_menu.save_game_handle.get_most_recent_save().current_room)
|
|
|
|
|
#
|
|
|
|
|
# menu_animation["parameters/conditions/return_to_menu"] = true
|
|
|
|
|
# await(get_tree().create_timer(0.5).timeout)
|
|
|
|
|
# menu_animation["parameters/conditions/return_to_menu"] = false
|
|
|
|
|
# _on_ready_to_unload()
|
|
|
|
|
#
|
|
|
|
|
#func load_save(save: SaveGame):
|
|
|
|
|
#
|
|
|
|
|
# if currently_loading_room != "":
|
|
|
|
|
# await(room_loaded)
|
|
|
|
|
#
|
|
|
|
|
# if save.current_room != current_room.id:
|
|
|
|
|
# # TODO Prevent race condition from appearing when save is loaded while room is still loading.
|
|
|
|
|
# currently_loading_room = get_room_path_from_id(save.current_room)
|
|
|
|
|
# await(room_loaded)
|
|
|
|
|
#
|
|
|
|
|
# menu_animation["parameters/conditions/start_game"] = true
|
|
|
|
|
#
|
|
|
|
|
# State.active_save_game = save
|
|
|
|
|
# in_game = true
|
|
|
|
|
# current_room.start_room()
|
|
|
|
|
#
|
|
|
|
|
#func _on_ready_to_unload():
|
|
|
|
|
# if get_child(0) is Node3D:
|
|
|
|
|
# get_child(0).free()
|
|
|
|
|
#
|
|
|
|
|
#func get_room_path_from_id(id: State.rooms) -> String:
|
|
|
|
|
# match id:
|
|
|
|
|
# State.rooms.YOUTH, State.rooms.NULL:
|
|
|
|
|
# return youth_room_path
|
|
|
|
|
# State.rooms.TRANSITION:
|
|
|
|
|
# return transition_room_path
|
|
|
|
|
# State.rooms.ADULTHOOD:
|
|
|
|
|
# return adulthood_room_path
|
|
|
|
|
# _:
|
|
|
|
|
# return ending_path
|
|
|
|
|
#
|
|
|
|
|
#func get_room_id_from_path(path: String) -> State.rooms:
|
|
|
|
|
# match path:
|
|
|
|
|
# youth_room_path:
|
|
|
|
|
# return State.rooms.YOUTH
|
|
|
|
|
# transition_room_path:
|
|
|
|
|
# return State.rooms.TRANSITION
|
|
|
|
|
# adulthood_room_path:
|
|
|
|
|
# return State.rooms.ADULTHOOD
|
|
|
|
|
# _:
|
|
|
|
|
# return State.rooms.NULL
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
#func start_demo():
|
|
|
|
|
# #FIXME this causes the room to reload
|
|
|
|
|
# #load_save(SaveGame.new())
|
|
|
|
|
# current_room.start_room()
|
|
|
|
|
# in_game = true
|
|
|
|
|
#
|
|
|
|
|
#func pause_mode_changed():
|
|
|
|
|
# print(get_tree().paused)
|
|
|
|
|
#
|
|
|
|
|
#var await_swap: bool = false
|
|
|
|
|
#func prepare_transition(scene_id: Scenes.id, _repeat):
|
|
|
|
|
# if scene_id == Scenes.id.TRANSITION:
|
|
|
|
|
# await_swap = true
|
|
|
|
|
# #FIXME: this does not need to be part of the sequence
|
|
|
|
|
# await(get_tree().process_frame)
|
|
|
|
|
# current_room.prepare_transition()
|
|
|
|
|
# if not _repeat:
|
|
|
|
|
# currently_loading_room = get_room_path_from_id(State.rooms.TRANSITION)
|
|
|
|
|
# else:
|
|
|
|
|
#
|
|
|
|
|
# currently_loading_room = get_room_path_from_id(State.rooms.ADULTHOOD)
|
|
|
|
|
#
|
|
|
|
|
#func transition(scene_id: Scenes.id, _repeat):
|
|
|
|
|
# if scene_id == Scenes.id.TRANSITION:
|
|
|
|
|
# State.reset_focus()
|
|
|
|
|
# await_swap = false
|
|
|
|
|
# await room_loaded
|
|
|
|
|
# if not _repeat:
|
|
|
|
|
# State.queue_for_stage(current_room)
|
|
|
|
|
# Scenes.end_current_sequence()
|
|
|
|
|
# else:
|
|
|
|
|
# State.pass_stage_to(current_room)
|