Add remove_ methods for all overlays

i don't know why i forgot them in #1
This commit is contained in:
JeremyStar™ 2023-08-25 16:47:04 +02:00
parent b6a97946f0
commit 2b757dd64e

57
smgr.gd
View file

@ -69,7 +69,7 @@ func add_debug(resource_name:String) -> int:
if debug_overlay_scene.has(resource_name) and !debug_overlay.get_children().has(resource):
core.exception("SceneManager","debug_overlay does not contain \"" + resource_name + "\" but debug_overlay_scene does")
return core.Errors.CORE_EXCEPTION
# Add scene to debug overlay
resource.name = resource_name
debug_overlay.add_child(resource)
debug_overlay_scene.merge({resource_name:resource},true)
return core.Errors.OK
@ -97,6 +97,7 @@ func add_menu(resource_name:String) -> int:
if menu_overlay_scene.has(resource_name) and !menu_overlay.get_children().has(resource):
core.exception("SceneManager","menu_overlay does not contain \"" + resource_name + "\" but menu_overlay_scene does")
return core.Errors.CORE_EXCEPTION
resource.name = resource_name
menu_overlay.add_child(resource)
menu_overlay_scene.merge({resource_name:resource},true)
return core.Errors.OK
@ -124,6 +125,7 @@ func add_cutscene(resource_name:String) -> int:
if cutscene_overlay_scene == resource_name and !cutscene_overlay.get_children().has(resource):
core.exception("SceneManager","cutscene_overlay does not contain \"" + resource_name + "\" but cutscene_overlay_scene does")
return core.Errors.CORE_EXCEPTION
resource.name = resource_name
cutscene_overlay.add_child(resource)
cutscene_overlay_scene = resource_name
return core.Errors.OK
@ -151,6 +153,59 @@ func add_action(resource_name:String) -> int:
if action_overlay_scene == resource_name and !action_overlay.get_children().has(resource):
core.exception("SceneManager","action_overlay does not contain \"" + resource_name + "\" but action_overlay_scene does")
return core.Errors.CORE_EXCEPTION
resource.name = resource_name
action_overlay.add_child(resource)
action_overlay_scene = resource_name
return core.Errors.OK
func remove_debug(resource_name:String) -> int:
if core.protection_mode: return core.Errors.CORE_PROTECTIONMODE
logger.diag("CORE/smgr.gd","Removing debug scene \"" + resource_name + "\"")
for child in debug_overlay.get_children():
if child.name == resource_name:
debug_overlay.remove_child(child)
break
else:
core.exception("SceneManager","Could not remove \"" + resource_name + "\" from the debug overlay as debug_overlay does have a child with that name")
return core.Errors.CORE_EXCEPTION
debug_overlay_scene.erase(resource_name)
return core.Errors.OK
func remove_cutscene(resource_name:String) -> int:
if core.protection_mode: return core.Errors.CORE_PROTECTIONMODE
logger.diag("CORE/smgr.gd","Removing cutscene scene \"" + resource_name + "\"")
for child in cutscene_overlay.get_children():
if child.name == resource_name:
cutscene_overlay.remove_child(child)
break
else:
core.exception("SceneManager","Could not remove \"" + resource_name + "\" from the cutscene overlay as cutscene_overlay does have a child with that name")
return core.Errors.CORE_EXCEPTION
cutscene_overlay_scene = ""
return core.Errors.OK
func remove_menu(resource_name:String) -> int:
if core.protection_mode: return core.Errors.CORE_PROTECTIONMODE
logger.diag("CORE/smgr.gd","Removing menu scene \"" + resource_name + "\"")
for child in menu_overlay.get_children():
if child.name == resource_name:
menu_overlay.remove_child(child)
break
else:
core.exception("SceneManager","Could not remove \"" + resource_name + "\" from the menu overlay as menu_overlay does have a child with that name")
return core.Errors.CORE_EXCEPTION
menu_overlay_scene.erase(resource_name)
return core.Errors.OK
func remove_action(resource_name:String) -> int:
if core.protection_mode: return core.Errors.CORE_PROTECTIONMODE
logger.diag("CORE/smgr.gd","Removing action scene \"" + resource_name + "\"")
for child in action_overlay.get_children():
if child.name == resource_name:
action_overlay.remove_child(child)
break
else:
core.exception("SceneManager","Could not remove \"" + resource_name + "\" from the action overlay as action_overlay does have a child with that name")
return core.Errors.CORE_EXCEPTION
action_overlay_scene = ""
return core.Errors.OK