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
## 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.
### *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
Don't set `force_remove` to `true`, thanks!
:::
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 `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
Don't change any properties of the scene collection or free it, otherwise you may cause breakage.
:::
Returns a scene collection node. \
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.
### *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.
### *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 `CoreTypes.SceneType.NONE` if no scene with that name was found.

View file

@ -64,109 +64,109 @@ func _pull_config() -> void:
# +++ scene management +++
## 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
loggeri.verb("Adding scene \"" + sname + "\" of type " + str(type))
if exists(sname) != CoreTypes.SceneType.NONE:
loggeri.error("Scene with name \"" + sname + "\" already exists")
loggeri.verb("Adding scene \"" + scene_name + "\" of type " + str(scene_type))
if exists(scene_name) != CoreTypes.SceneType.NONE:
loggeri.error("Scene with name \"" + scene_name + "\" already exists")
return false
if typeof(sclass) != TYPE_OBJECT or !sclass.is_class("Node"):
loggeri.error("Scene class \"" + sname + "\" is not of type Node")
if typeof(scene_class) != TYPE_OBJECT or !scene_class.is_class("Node"):
loggeri.error("Scene class \"" + scene_name + "\" is not of type Node")
return false
sclass.name = sname
match(type):
CoreTypes.SceneType.DEBUG: scenes_debug.add_child(sclass)
CoreTypes.SceneType.CUTSCENE: scenes_cutscene.add_child(sclass)
CoreTypes.SceneType.MENU: scenes_menu.add_child(sclass)
CoreTypes.SceneType.MAIN: scenes_main.add_child(sclass)
CoreTypes.SceneType.BACKGROUND: scenes_background.add_child(sclass)
scene_class.name = scene_name
match(scene_type):
CoreTypes.SceneType.DEBUG: scenes_debug.add_child(scene_class)
CoreTypes.SceneType.CUTSCENE: scenes_cutscene.add_child(scene_class)
CoreTypes.SceneType.MENU: scenes_menu.add_child(scene_class)
CoreTypes.SceneType.MAIN: scenes_main.add_child(scene_class)
CoreTypes.SceneType.BACKGROUND: scenes_background.add_child(scene_class)
CoreTypes.SceneType.NONE:
loggeri.error("CoreTypes.SceneType.NONE is not a valid scene type")
return false
_: await loggeri.crash("Invalid SceneType " + str(type))
scenes.merge({ sname: { "type": type, "class": sclass } })
_: await loggeri.crash("Invalid SceneType " + str(scene_type))
scenes.merge({ scene_name: { "type": scene_type, "class": scene_class } })
return true
## 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]
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 force_remove: await loggeri.crash("force_remove = true is not allowed")
loggeri.verb("Removing scene \"" + sname + "\"")
match(exists(sname)):
loggeri.verb("Removing scene \"" + scene_name + "\"")
match(exists(scene_name)):
CoreTypes.SceneType.DEBUG:
scenes_debug.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
scenes_debug.remove_child(scenes[scene_name]["class"])
scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.CUTSCENE:
scenes_cutscene.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
scenes_cutscene.remove_child(scenes[scene_name]["class"])
scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.MENU:
scenes_menu.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
scenes_menu.remove_child(scenes[scene_name]["class"])
scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.MAIN:
scenes_main.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
scenes_main.remove_child(scenes[scene_name]["class"])
scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.BACKGROUND:
scenes_background.remove_child(scenes[sname]["class"])
scenes[sname]["class"].queue_free()
scenes_background.remove_child(scenes[scene_name]["class"])
scenes[scene_name]["class"].queue_free()
CoreTypes.SceneType.NONE:
loggeri.error("Scene \"" + sname + "\" does not exist")
loggeri.error("Scene \"" + scene_name + "\" does not exist")
return false
_: await loggeri.crash("Invalid SceneType " + str(exists(sname)))
scenes.erase(sname)
_: await loggeri.crash("Invalid SceneType " + str(exists(scene_name)))
scenes.erase(scene_name)
return true
# +++ getters +++
## Returns a scene from some scene collection.[br]
## [br]
## 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
match(exists(sname)):
CoreTypes.SceneType.DEBUG: return scenes[sname]["class"]
CoreTypes.SceneType.CUTSCENE: return scenes[sname]["class"]
CoreTypes.SceneType.MENU: return scenes[sname]["class"]
CoreTypes.SceneType.MAIN: return scenes[sname]["class"]
CoreTypes.SceneType.BACKGROUND: return scenes[sname]["class"]
CoreTypes.SceneType.NONE: loggeri.error("Scene \"" + sname + "\" does not exist")
_: await loggeri.crash("Invalid SceneType " + str(exists(sname)))
match(exists(scene_name)):
CoreTypes.SceneType.DEBUG: return scenes[scene_name]["class"]
CoreTypes.SceneType.CUTSCENE: return scenes[scene_name]["class"]
CoreTypes.SceneType.MENU: return scenes[scene_name]["class"]
CoreTypes.SceneType.MAIN: return scenes[scene_name]["class"]
CoreTypes.SceneType.BACKGROUND: return scenes[scene_name]["class"]
CoreTypes.SceneType.NONE: loggeri.error("Scene \"" + scene_name + "\" does not exist")
_: await loggeri.crash("Invalid SceneType " + str(exists(scene_name)))
return null
## Returns a scene collection node.[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]
func get_scene_collection(type: CoreTypes.SceneType) -> Node:
func get_scene_collection(scene_type: CoreTypes.SceneType) -> Node:
if core.config.headless: return null
match(type):
match(scene_type):
CoreTypes.SceneType.DEBUG: return scenes_debug
CoreTypes.SceneType.CUTSCENE: return scenes_cutscene
CoreTypes.SceneType.MENU: return scenes_menu
CoreTypes.SceneType.MAIN: return scenes_main
CoreTypes.SceneType.BACKGROUND: return scenes_background
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
## 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] = []
for scene in scenes:
if scenes[scene]["type"] == type:
if scenes[scene]["type"] == scene_type:
list.append(scenes[scene]["class"])
return list
## 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
for scene in scenes:
if scenes[scene]["type"] == type:
if scenes[scene]["type"] == scene_type:
amount += 1
return amount
## Returns the scene collection a scene is loaded in.[br]
## [br]
## [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:
if scene == sname: return scenes[scene]["type"]
if scene == scene_name: return scenes[scene]["type"]
return CoreTypes.SceneType.NONE