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>
(cherry picked from commit aafa816946
)
This commit is contained in:
parent
57c429975c
commit
2363d0f9ba
2 changed files with 28 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
const Map<String, String>::Element *remap = capitalize_string_remaps.find(parts[i]);
|
||||
if (remap) {
|
||||
parts.write[i] = remap->get();
|
||||
|
@ -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";
|
||||
|
@ -222,6 +228,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
|
|||
capitalize_string_remaps["sv"] = "SV";
|
||||
capitalize_string_remaps["svg"] = "SVG";
|
||||
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";
|
||||
|
@ -248,9 +255,29 @@ 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.push_back("a");
|
||||
stop_words.push_back("an");
|
||||
stop_words.push_back("and");
|
||||
stop_words.push_back("as");
|
||||
stop_words.push_back("at");
|
||||
stop_words.push_back("by");
|
||||
stop_words.push_back("for");
|
||||
stop_words.push_back("in");
|
||||
stop_words.push_back("not");
|
||||
stop_words.push_back("of");
|
||||
stop_words.push_back("on");
|
||||
stop_words.push_back("or");
|
||||
stop_words.push_back("over");
|
||||
stop_words.push_back("per");
|
||||
stop_words.push_back("the");
|
||||
stop_words.push_back("then");
|
||||
stop_words.push_back("to");
|
||||
}
|
||||
|
||||
EditorPropertyNameProcessor::~EditorPropertyNameProcessor() {
|
||||
|
|
|
@ -40,6 +40,7 @@ class EditorPropertyNameProcessor : public Node {
|
|||
|
||||
mutable Map<String, String> capitalize_string_cache;
|
||||
Map<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;
|
||||
|
|
Loading…
Reference in a new issue