capitalize categories properly in add node menu (#49)

closes #34

Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/49
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
Lera Elvoé 2024-01-20 05:11:38 +00:00 committed by yagich
parent 7ef913c13b
commit bb7b7d0adb
2 changed files with 12 additions and 1 deletions

View file

@ -13,6 +13,11 @@ const NODE_INDEX_CACHE_PATH := "user://nodes_index.json"
## Filepath where the the list of Favorite Nodes is stored. ## Filepath where the the list of Favorite Nodes is stored.
const FAVORITE_NODES_PATH := "user://favorite_nodes.json" const FAVORITE_NODES_PATH := "user://favorite_nodes.json"
## A map of [code]snake_case[/code] category names for proper capitalization.
const CATEGORY_CAPITALIZATION := {
"obs": "OBS"
}
## [Array] used for storing all the "Favorite" Nodes that were set in the [AddNodeMenu] ## [Array] used for storing all the "Favorite" Nodes that were set in the [AddNodeMenu]
var favorite_nodes: Array[String] var favorite_nodes: Array[String]
@ -128,6 +133,12 @@ func load_favorites() -> void:
func is_node_favorite(node_type: String) -> bool: func is_node_favorite(node_type: String) -> bool:
return node_type in favorite_nodes return node_type in favorite_nodes
## Returns a capitalized category string.
func get_category_capitalization(category: String) -> String:
return CATEGORY_CAPITALIZATION.get(category, category.capitalize())
## Used for storing the shorthand data of a [DeckNode]. ## Used for storing the shorthand data of a [DeckNode].
## ##
## Allows for more simply storing [DeckNode]s properties without needing to ## Allows for more simply storing [DeckNode]s properties without needing to

View file

@ -25,7 +25,7 @@ func _ready() -> void:
## Add a new category to the menu. ## Add a new category to the menu.
func add_category(category_name: String) -> void: func add_category(category_name: String) -> void:
var c := Category.new(category_name.capitalize()) var c := Category.new(NodeDB.get_category_capitalization(category_name))
categories[category_name] = c categories[category_name] = c
scroll_content_container.add_child(c) scroll_content_container.add_child(c)
c.collapse_toggled.connect(_on_category_collapse_toggled.bind(category_name)) c.collapse_toggled.connect(_on_category_collapse_toggled.bind(category_name))