From 0e83bfd6345d43dc633fdf2ab37290d994d1bd50 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sat, 18 Mar 2023 18:02:17 +0100 Subject: [PATCH] Added debug overlay support --- smgr.gd | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/smgr.gd b/smgr.gd index 1550381..81b203d 100644 --- a/smgr.gd +++ b/smgr.gd @@ -15,6 +15,7 @@ var ccr_menu_names = [] var ccr_cutscene = null var ccr_cutscene_inuse = false var ccr_debug = null +var ccr_debug_names = [] func add_game(scene:PackedScene) -> bool: Logger.info("smgr","Adding game scene") @@ -78,6 +79,28 @@ func remove_cutscene() -> bool: Logger.info("smgr","Removed cutscene scene") return true +func add_debug(scene_name:String,scene:PackedScene) -> bool: + Logger.info("smgr","Adding debug scene \"" + scene_name + "\"") + if ccr_debug_names.has(scene_name): + Logger.error("smgr","Failed adding debug scene: Debug scene with name \"" + scene_name + "\" already exists") + return false + ccr_debug.add_child(scene.instantiate()) + ccr_debug_names.append(scene_name) + Logger.info("smgr","Added debug scene \"" + scene_name + "\"") + return true + +func remove_debug(scene_name:String) -> bool: + Logger.info("smgr","Removing debug scene \"" + scene_name + "\"") + if !ccr_menu_names.has(scene_name): + Logger.error("smgr","Failed removing debug scene: Debug scene with name \"" + scene_name + "\" does not exist") + return false + for i in ccr_debug.get_children(): + if i.name == scene_name: + ccr_debug.remove_child(i) + break + ccr_debug_names.erase(scene_name) + return true + func _ready() -> void: Logger.info("smgr","Constructing CORE Scene Root (CCR)") ccr = Control.new() @@ -97,7 +120,6 @@ func _ready() -> void: Logger.info("smgr","COREBackground migration complete.") Logger.info("smgr","Adding overlays") add_overlays() - add_debug() available = true func add_overlays() -> void: @@ -117,7 +139,3 @@ func add_overlays() -> void: ccr_debug = Control.new() ccr_debug.name = "DebugOverlay" ccr.add_child(ccr_debug) - -func add_debug() -> void: - Logger.info("smgr","No debug scenes are available.") - return