diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-11-09 17:09:31 +0100 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-11-24 16:37:54 +0100 |
commit | aafa816946dbf06e71f48b2fc4c7a1edf1eec65c (patch) | |
tree | 59e06d70dbb6ab931c3aa14f961317785a77d273 /editor | |
parent | f6f8a48459f9bbe97ee76a7186b9ae37e71e724b (diff) |
Improve editor property capitalization
- Don't capitalize stop words such as "at", "in" or "to".
- Add more acronyms to capitalize.
Co-authored-by: RĂ©mi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_property_name_processor.cpp | 30 | ||||
-rw-r--r-- | editor/editor_property_name_processor.h | 1 |
2 files changed, 31 insertions, 0 deletions
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<String> 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<String, String>::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<String>({ + "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<String, String> capitalize_string_cache; HashMap<String, String> capitalize_string_remaps; + LocalVector<String> stop_words; // Exceptions that shouldn't be capitalized. // Capitalizes property path segments. String _capitalize_name(const String &p_name) const; |