summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-07 20:22:09 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-07 20:22:09 -0300
commite336306e9176bb3e9e459a63344ef54c1e57c9cd (patch)
tree020db36d856f01442056763596fb84b4035fccb3
parent219fce737c05405db06cb268520d6abf0386db38 (diff)
parent21eb3b2a83fd59f6d667688c95b4a198b3b6f689 (diff)
downloadredot-engine-e336306e9176bb3e9e459a63344ef54c1e57c9cd.tar.gz
Merge pull request #1554 from NateWardawg/inspectorupdate
Camel casing being capitalized only happens in the inspector now.
-rw-r--r--core/ustring.cpp21
-rw-r--r--core/ustring.h1
-rw-r--r--tools/editor/property_editor.cpp2
3 files changed, 23 insertions, 1 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 09d3d95b68..edb5da2bd2 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -498,6 +498,27 @@ String String::capitalize() const {
return cap;
}
+
+String String::camelcase_to_underscore() const {
+ const CharType * cstr = c_str();
+ String newString;
+ const char A = 'A', Z = 'Z';
+ int startIndex = 0;
+
+ for ( int i = 1; i < this->size()-1; i++ ) {
+ bool isCapital = cstr[i] >= A && cstr[i] <= Z;
+
+ if ( isCapital ) {
+ newString += "_" + this->substr(startIndex, i-startIndex);
+ startIndex = i;
+ }
+ }
+
+ newString += "_" + this->substr(startIndex, this->size()-startIndex);
+
+ return newString;
+}
+
int String::get_slice_count(String p_splitter) const{
if (empty())
diff --git a/core/ustring.h b/core/ustring.h
index d4b854ea76..f9f47d69c9 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -149,6 +149,7 @@ public:
static double to_double(const CharType* p_str, const CharType **r_end=NULL);
static int64_t to_int(const CharType* p_str,int p_len=-1);
String capitalize() const;
+ String camelcase_to_underscore() const;
int get_slice_count(String p_splitter) const;
String get_slice(String p_splitter,int p_slice) const;
diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp
index 078a177ca1..3fd713c5b0 100644
--- a/tools/editor/property_editor.cpp
+++ b/tools/editor/property_editor.cpp
@@ -2258,7 +2258,7 @@ void PropertyEditor::update_tree() {
}
if (capitalize_paths)
- item->set_text( 0, name.capitalize() );
+ item->set_text( 0, name.camelcase_to_underscore().capitalize() );
else
item->set_text( 0, name );