Call queue_free() on scenes during removal

This commit is contained in:
JeremyStar™ 2024-03-31 16:19:22 +02:00
parent 5ab659c9f7
commit 52c6d029d9

View file

@ -77,11 +77,21 @@ func remove_scene(sname: String, force_remove: bool = false) -> bool:
if force_remove: await logger.crashf("Sms", "force_remove = true is not allowed", true)
logger.verbf("Sms", "Removing scene \"" + sname + "\"")
match(exists(sname)):
CoreTypes.SceneType.DEBUG: scenes_debug.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.CUTSCENE: scenes_cutscene.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.MENU: scenes_menu.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.MAIN: scenes_main.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.BACKGROUND: scenes_background.remove_child(scenes[sname]["class"])
CoreTypes.SceneType.DEBUG:
scenes_debug.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.CUTSCENE:
scenes_cutscene.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.MENU:
scenes_menu.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.MAIN:
scenes_main.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.BACKGROUND:
scenes_background.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
CoreTypes.SceneType.NONE:
logger.errorf("Sms", "Scene \"" + sname + "\" does not exist")
return false