Rename sms.gd arguments to something meaningful

This commit is contained in:
JeremyStar™ 2024-04-14 23:52:12 +02:00
parent 15d78eb0d7
commit 8455c2e1eb
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
2 changed files with 56 additions and 56 deletions

View file

@ -44,28 +44,28 @@ Do not modify this.
A list of all loaded scenes A list of all loaded scenes
## Functions ## Functions
### *bool* <u>add_scene</u>(*String* <u>sname</u>, *Node* <u>sclass</u>, *CoreTypes.SceneType* <u>type</u>) ### *bool* <u>add_scene</u>(*String* <u>scene_name</u>, *Node* <u>scene_class</u>, *CoreTypes.SceneType* <u>scene_type</u>)
Adds a scene to some scene collection. Adds a scene to some scene collection.
### *bool* <u>remove_scene</u>(*String* <u>sname</u>, *bool* <u>force_remove</u> = *false*) ### *bool* <u>remove_scene</u>(*String* <u>scene_name</u>, *bool* <u>force_remove</u> = *false*)
:::danger :::danger
Don't set `force_remove` to `true`, thanks! Don't set `force_remove` to `true`, thanks!
::: :::
Removes a scene from some scene collection. Removes a scene from some scene collection.
### *Node* <u>get_scene</u>(*String* <u>sname</u>) ### *Node* <u>get_scene</u>(*String* <u>scene_name</u>)
Returns a scene from some scene collection. \ Returns a scene from some scene collection. \
\ \
Returns `null` if no scene with that name was found. Returns `null` if no scene with that name was found.
### *Node* <u>get_scene_collection</u>(*CoreTypes.SceneType* <u>type</u>) ### *Node* <u>get_scene_collection</u>(*CoreTypes.SceneType* <u>scene_type</u>)
:::danger :::danger
Don't change any properties of the scene collection or free it, otherwise you may cause breakage. Don't change any properties of the scene collection or free it, otherwise you may cause breakage.
::: :::
Returns a scene collection node. \ Returns a scene collection node. \
Useful if you want to change a child's index. Useful if you want to change a child's index.
### *Array[Node]* <u>get_scene_collection_list</u>(*CoreTypes.SceneType* <u>type</u>) ### *Array[Node]* <u>get_scene_collection_list</u>(*CoreTypes.SceneType* <u>scene_type</u>)
Returns a list of all loaded scenes in some scene collection. Returns a list of all loaded scenes in some scene collection.
### *int* <u>get_scene_collection_count</u>(*CoreTypes.SceneType* <u>type</u>) ### *int* <u>get_scene_collection_count</u>(*CoreTypes.SceneType* <u>scene_type</u>)
Returns the number of loaded scenes in some scene collection. Returns the number of loaded scenes in some scene collection.
### *CoresTypes.SceneType* <u>exists</u>(*String* <u>sname</u>) ### *CoresTypes.SceneType* <u>exists</u>(*String* <u>scene_name</u>)
Returns the scene collection a scene is loaded in. Returns the scene collection a scene is loaded in.
Returns `CoreTypes.SceneType.NONE` if no scene with that name was found. Returns `CoreTypes.SceneType.NONE` if no scene with that name was found.

View file

@ -64,109 +64,109 @@ func _pull_config() -> void:
# +++ scene management +++ # +++ scene management +++
## Adds a scene to some scene collection. ## Adds a scene to some scene collection.
func add_scene(sname: String, sclass: Node, type: CoreTypes.SceneType) -> bool: func add_scene(scene_name: String, scene_class: Node, scene_type: CoreTypes.SceneType) -> bool:
if core.config.headless: return false if core.config.headless: return false
loggeri.verb("Adding scene \"" + sname + "\" of type " + str(type)) loggeri.verb("Adding scene \"" + scene_name + "\" of type " + str(scene_type))
if exists(sname) != CoreTypes.SceneType.NONE: if exists(scene_name) != CoreTypes.SceneType.NONE:
loggeri.error("Scene with name \"" + sname + "\" already exists") loggeri.error("Scene with name \"" + scene_name + "\" already exists")
return false return false
if typeof(sclass) != TYPE_OBJECT or !sclass.is_class("Node"): if typeof(scene_class) != TYPE_OBJECT or !scene_class.is_class("Node"):
loggeri.error("Scene class \"" + sname + "\" is not of type Node") loggeri.error("Scene class \"" + scene_name + "\" is not of type Node")
return false return false
sclass.name = sname scene_class.name = scene_name
match(type): match(scene_type):
CoreTypes.SceneType.DEBUG: scenes_debug.add_child(sclass) CoreTypes.SceneType.DEBUG: scenes_debug.add_child(scene_class)
CoreTypes.SceneType.CUTSCENE: scenes_cutscene.add_child(sclass) CoreTypes.SceneType.CUTSCENE: scenes_cutscene.add_child(scene_class)
CoreTypes.SceneType.MENU: scenes_menu.add_child(sclass) CoreTypes.SceneType.MENU: scenes_menu.add_child(scene_class)
CoreTypes.SceneType.MAIN: scenes_main.add_child(sclass) CoreTypes.SceneType.MAIN: scenes_main.add_child(scene_class)
CoreTypes.SceneType.BACKGROUND: scenes_background.add_child(sclass) CoreTypes.SceneType.BACKGROUND: scenes_background.add_child(scene_class)
CoreTypes.SceneType.NONE: CoreTypes.SceneType.NONE:
loggeri.error("CoreTypes.SceneType.NONE is not a valid scene type") loggeri.error("CoreTypes.SceneType.NONE is not a valid scene type")
return false return false
_: await loggeri.crash("Invalid SceneType " + str(type)) _: await loggeri.crash("Invalid SceneType " + str(scene_type))
scenes.merge({ sname: { "type": type, "class": sclass } }) scenes.merge({ scene_name: { "type": scene_type, "class": scene_class } })
return true return true
## Removes a scene from some scene collection.[br] ## Removes a scene from some scene collection.[br]
## [b]Danger: [i]Don't set [code]force_remove[/code] to [code]true[/code], thanks![/i][/b] ## [b]Danger: [i]Don't set [code]force_remove[/code] to [code]true[/code], thanks![/i][/b]
func remove_scene(sname: String, force_remove: bool = false) -> bool: func remove_scene(scene_name: String, force_remove: bool = false) -> bool:
if core.config.headless and !force_remove: return false if core.config.headless and !force_remove: return false
if force_remove: await loggeri.crash("force_remove = true is not allowed") if force_remove: await loggeri.crash("force_remove = true is not allowed")
loggeri.verb("Removing scene \"" + sname + "\"") loggeri.verb("Removing scene \"" + scene_name + "\"")
match(exists(sname)): match(exists(scene_name)):
CoreTypes.SceneType.DEBUG: CoreTypes.SceneType.DEBUG:
scenes_debug.remove_child(scenes[sname]["class"]) scenes_debug.remove_child(scenes[scene_name]["class"])
scenes[sname]["class"].queue_free() scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.CUTSCENE: CoreTypes.SceneType.CUTSCENE:
scenes_cutscene.remove_child(scenes[sname]["class"]) scenes_cutscene.remove_child(scenes[scene_name]["class"])
scenes[sname]["class"].queue_free() scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.MENU: CoreTypes.SceneType.MENU:
scenes_menu.remove_child(scenes[sname]["class"]) scenes_menu.remove_child(scenes[scene_name]["class"])
scenes[sname]["class"].queue_free() scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.MAIN: CoreTypes.SceneType.MAIN:
scenes_main.remove_child(scenes[sname]["class"]) scenes_main.remove_child(scenes[scene_name]["class"])
scenes[sname]["class"].queue_free() scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.BACKGROUND: CoreTypes.SceneType.BACKGROUND:
scenes_background.remove_child(scenes[sname]["class"]) scenes_background.remove_child(scenes[scene_name]["class"])
scenes[sname]["class"].queue_free() scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.NONE: CoreTypes.SceneType.NONE:
loggeri.error("Scene \"" + sname + "\" does not exist") loggeri.error("Scene \"" + scene_name + "\" does not exist")
return false return false
_: await loggeri.crash("Invalid SceneType " + str(exists(sname))) _: await loggeri.crash("Invalid SceneType " + str(exists(scene_name)))
scenes.erase(sname) scenes.erase(scene_name)
return true return true
# +++ getters +++ # +++ getters +++
## Returns a scene from some scene collection.[br] ## Returns a scene from some scene collection.[br]
## [br] ## [br]
## Returns [code]null[/code] if no scene with that name was found. ## Returns [code]null[/code] if no scene with that name was found.
func get_scene(sname: String) -> Node: func get_scene(scene_name: String) -> Node:
if core.config.headless: return null if core.config.headless: return null
match(exists(sname)): match(exists(scene_name)):
CoreTypes.SceneType.DEBUG: return scenes[sname]["class"] CoreTypes.SceneType.DEBUG: return scenes[scene_name]["class"]
CoreTypes.SceneType.CUTSCENE: return scenes[sname]["class"] CoreTypes.SceneType.CUTSCENE: return scenes[scene_name]["class"]
CoreTypes.SceneType.MENU: return scenes[sname]["class"] CoreTypes.SceneType.MENU: return scenes[scene_name]["class"]
CoreTypes.SceneType.MAIN: return scenes[sname]["class"] CoreTypes.SceneType.MAIN: return scenes[scene_name]["class"]
CoreTypes.SceneType.BACKGROUND: return scenes[sname]["class"] CoreTypes.SceneType.BACKGROUND: return scenes[scene_name]["class"]
CoreTypes.SceneType.NONE: loggeri.error("Scene \"" + sname + "\" does not exist") CoreTypes.SceneType.NONE: loggeri.error("Scene \"" + scene_name + "\" does not exist")
_: await loggeri.crash("Invalid SceneType " + str(exists(sname))) _: await loggeri.crash("Invalid SceneType " + str(exists(scene_name)))
return null return null
## Returns a scene collection node.[br] ## Returns a scene collection node.[br]
## Useful if you want to change a child's index.[br] ## Useful if you want to change a child's index.[br]
## [b]Danger: [i]Don't change any properties of the scene collection or free it, otherwise you may cause breakage.[/i][/b] ## [b]Danger: [i]Don't change any properties of the scene collection or free it, otherwise you may cause breakage.[/i][/b]
func get_scene_collection(type: CoreTypes.SceneType) -> Node: func get_scene_collection(scene_type: CoreTypes.SceneType) -> Node:
if core.config.headless: return null if core.config.headless: return null
match(type): match(scene_type):
CoreTypes.SceneType.DEBUG: return scenes_debug CoreTypes.SceneType.DEBUG: return scenes_debug
CoreTypes.SceneType.CUTSCENE: return scenes_cutscene CoreTypes.SceneType.CUTSCENE: return scenes_cutscene
CoreTypes.SceneType.MENU: return scenes_menu CoreTypes.SceneType.MENU: return scenes_menu
CoreTypes.SceneType.MAIN: return scenes_main CoreTypes.SceneType.MAIN: return scenes_main
CoreTypes.SceneType.BACKGROUND: return scenes_background CoreTypes.SceneType.BACKGROUND: return scenes_background
CoreTypes.SceneType.NONE: loggeri.error("No scene collection was found for CoreTypes.SceneType.NONE") CoreTypes.SceneType.NONE: loggeri.error("No scene collection was found for CoreTypes.SceneType.NONE")
_: await loggeri.crash("Invalid SceneType " + str(type)) _: await loggeri.crash("Invalid SceneType " + str(scene_type))
return null return null
## Returns a list of all loaded scenes in some scene collection. ## Returns a list of all loaded scenes in some scene collection.
func get_scene_collection_list(type: CoreTypes.SceneType) -> Array[Node]: func get_scene_collection_list(scene_type: CoreTypes.SceneType) -> Array[Node]:
var list: Array[Node] = [] var list: Array[Node] = []
for scene in scenes: for scene in scenes:
if scenes[scene]["type"] == type: if scenes[scene]["type"] == scene_type:
list.append(scenes[scene]["class"]) list.append(scenes[scene]["class"])
return list return list
## Returns the number of loaded scenes in some scene collection. ## Returns the number of loaded scenes in some scene collection.
func get_scene_collection_count(type: CoreTypes.SceneType) -> int: func get_scene_collection_count(scene_type: CoreTypes.SceneType) -> int:
var amount: int = 0 var amount: int = 0
for scene in scenes: for scene in scenes:
if scenes[scene]["type"] == type: if scenes[scene]["type"] == scene_type:
amount += 1 amount += 1
return amount return amount
## Returns the scene collection a scene is loaded in.[br] ## Returns the scene collection a scene is loaded in.[br]
## [br] ## [br]
## [enum CoreTypes.SceneType][code].NONE[/code] if no scene with that name was found. ## [enum CoreTypes.SceneType][code].NONE[/code] if no scene with that name was found.
func exists(sname: String) -> CoreTypes.SceneType: func exists(scene_name: String) -> CoreTypes.SceneType:
for scene in scenes: for scene in scenes:
if scene == sname: return scenes[scene]["type"] if scene == scene_name: return scenes[scene]["type"]
return CoreTypes.SceneType.NONE return CoreTypes.SceneType.NONE