Skip to content

Commit

Permalink
fix: add code to handle scenes run directly from the Godot editor and…
Browse files Browse the repository at this point in the history
… allow for the current room to be set in the object manager, allowing proper setup
  • Loading branch information
BHSDuncan authored and StraToN committed Apr 8, 2022
1 parent 2508786 commit c87e853
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,13 @@ func unregister_object(object: ESCObject, room_key: ESCRoomObjectsKey) -> void:
"ESCObjectManager:unregister_object()",
[
"Unable to unregister object.",
"Object with global ID %s room (%s, %s) not found." %
"Object with global ID %s room (%s, %s) not found. If this was" %
[
"?" if object == null else object.global_id,
room_key.room_global_id,
room_key.room_instance_id
]
],
"part of a 'forced' registration, ignore this warning."
]
)

Expand Down
5 changes: 4 additions & 1 deletion addons/escoria-core/game/core-scripts/log/esc_logger.gd
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ func error(string: String, args = [], do_savegame: bool = true):

_log(message, true)
escoria.set_game_paused(true)
escoria.main.current_scene.game.show_crash_popup(files_to_send)

if is_instance_valid(escoria.main.current_scene):
escoria.main.current_scene.game.show_crash_popup(files_to_send)

assert(false)


Expand Down
15 changes: 15 additions & 0 deletions addons/escoria-core/game/escoria.gd
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func _init():

# Load settings
func _ready():
_handle_direct_scene_run()

settings = save_manager.load_settings()
apply_settings(settings)
room_manager.register_reserved_globals()
Expand Down Expand Up @@ -361,3 +363,16 @@ func deregister_dialog_manager(manager_class: String):
# Function called to quit the game.
func quit():
get_tree().notification(MainLoop.NOTIFICATION_WM_QUIT_REQUEST)


# Handle anything necessary if the game started a scene directly.
func _handle_direct_scene_run() -> void:
var current_scene_root: Node = get_tree().get_current_scene()

if current_scene_root.filename == ProjectSettings.get_setting('application/run/main_scene'):
# This is a normal, full-game run, so there's nothing to do.
return

if current_scene_root is ESCRoom:
escoria.object_manager.set_current_room(current_scene_root)

0 comments on commit c87e853

Please sign in to comment.