From aafa816946dbf06e71f48b2fc4c7a1edf1eec65c Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 9 Nov 2022 17:09:31 +0100 Subject: Improve editor property capitalization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Don't capitalize stop words such as "at", "in" or "to". - Add more acronyms to capitalize. Co-authored-by: RĂ©mi Verschelde --- editor/editor_property_name_processor.cpp | 30 ++++++++++++++++++++++++++++++ editor/editor_property_name_processor.h | 1 + 2 files changed, 31 insertions(+) (limited to 'editor') diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp index a2dfa4f80e..bd8b753720 100644 --- a/editor/editor_property_name_processor.cpp +++ b/editor/editor_property_name_processor.cpp @@ -64,6 +64,10 @@ String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const Vector parts = p_name.split("_", false); for (int i = 0; i < parts.size(); i++) { + // Articles/conjunctions/prepositions which should only be capitalized if first word. + if (i != 0 && stop_words.find(parts[i]) != -1) { + continue; + } HashMap::ConstIterator remap = capitalize_string_remaps.find(parts[i]); if (remap) { parts.write[i] = remap->value; @@ -143,6 +147,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["gdscript"] = "GDScript"; capitalize_string_remaps["ggx"] = "GGX"; capitalize_string_remaps["gi"] = "GI"; + capitalize_string_remaps["gl"] = "GL"; capitalize_string_remaps["glb"] = "GLB"; capitalize_string_remaps["gles2"] = "GLES2"; capitalize_string_remaps["gles3"] = "GLES3"; @@ -157,6 +162,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["html"] = "HTML"; capitalize_string_remaps["http"] = "HTTP"; capitalize_string_remaps["id"] = "ID"; + capitalize_string_remaps["ids"] = "IDs"; capitalize_string_remaps["igd"] = "IGD"; capitalize_string_remaps["ik"] = "IK"; capitalize_string_remaps["image@2x"] = "Image @2x"; @@ -223,6 +229,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["svg"] = "SVG"; capitalize_string_remaps["taa"] = "TAA"; capitalize_string_remaps["tcp"] = "TCP"; + capitalize_string_remaps["tls"] = "TLS"; capitalize_string_remaps["ui"] = "UI"; capitalize_string_remaps["url"] = "URL"; capitalize_string_remaps["urls"] = "URLs"; @@ -237,6 +244,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["vector2"] = "Vector2"; capitalize_string_remaps["vpn"] = "VPN"; capitalize_string_remaps["vram"] = "VRAM"; + capitalize_string_remaps["vrs"] = "VRS"; capitalize_string_remaps["vsync"] = "V-Sync"; capitalize_string_remaps["wap"] = "WAP"; capitalize_string_remaps["webp"] = "WebP"; @@ -246,9 +254,31 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() { capitalize_string_remaps["wifi"] = "Wi-Fi"; capitalize_string_remaps["x86"] = "x86"; capitalize_string_remaps["xr"] = "XR"; + capitalize_string_remaps["xray"] = "X-Ray"; capitalize_string_remaps["xy"] = "XY"; capitalize_string_remaps["xz"] = "XZ"; capitalize_string_remaps["yz"] = "YZ"; + + // Articles, conjunctions, prepositions. + stop_words = LocalVector({ + "a", + "an", + "and", + "as", + "at", + "by", + "for", + "in", + "not", + "of", + "on", + "or", + "over", + "per", + "the", + "then", + "to", + }); } EditorPropertyNameProcessor::~EditorPropertyNameProcessor() { diff --git a/editor/editor_property_name_processor.h b/editor/editor_property_name_processor.h index 37d905c806..fcabbfd9d3 100644 --- a/editor/editor_property_name_processor.h +++ b/editor/editor_property_name_processor.h @@ -40,6 +40,7 @@ class EditorPropertyNameProcessor : public Node { mutable HashMap capitalize_string_cache; HashMap capitalize_string_remaps; + LocalVector stop_words; // Exceptions that shouldn't be capitalized. // Capitalizes property path segments. String _capitalize_name(const String &p_name) const; -- cgit v1.2.3