From bb7b7d0adbad838b7dfa77a44d163adcb8883f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Sat, 20 Jan 2024 05:11:38 +0000 Subject: [PATCH] capitalize categories properly in add node menu (#49) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #34 Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/49 Co-authored-by: Lera ElvoƩ Co-committed-by: Lera ElvoƩ --- classes/deck/node_db.gd | 11 +++++++++++ graph_node_renderer/add_node_menu.gd | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/classes/deck/node_db.gd b/classes/deck/node_db.gd index e91e9ab..e12d0a9 100644 --- a/classes/deck/node_db.gd +++ b/classes/deck/node_db.gd @@ -13,6 +13,11 @@ const NODE_INDEX_CACHE_PATH := "user://nodes_index.json" ## Filepath where the the list of Favorite Nodes is stored. 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] var favorite_nodes: Array[String] @@ -128,6 +133,12 @@ func load_favorites() -> void: func is_node_favorite(node_type: String) -> bool: 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]. ## ## Allows for more simply storing [DeckNode]s properties without needing to diff --git a/graph_node_renderer/add_node_menu.gd b/graph_node_renderer/add_node_menu.gd index 395c1ec..cd3e20f 100644 --- a/graph_node_renderer/add_node_menu.gd +++ b/graph_node_renderer/add_node_menu.gd @@ -25,7 +25,7 @@ func _ready() -> void: ## Add a new category to the menu. 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 scroll_content_container.add_child(c) c.collapse_toggled.connect(_on_category_collapse_toggled.bind(category_name))