summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp13
-rw-r--r--core/bind/core_bind.h3
-rw-r--r--core/object.cpp2
-rw-r--r--core/os/os.cpp11
-rw-r--r--core/os/os.h5
-rw-r--r--core/ustring.cpp100
6 files changed, 127 insertions, 7 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index ba27c2cdd6..570ed33a5a 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -306,6 +306,16 @@ MainLoop *_OS::get_main_loop() const {
return OS::get_singleton()->get_main_loop();
}
+
+void _OS::set_time_scale(float p_scale) {
+ OS::get_singleton()->set_time_scale(p_scale);
+}
+
+float _OS::get_time_scale() {
+
+ return OS::get_singleton()->get_time_scale();
+}
+
/*
enum Weekday {
DAY_SUNDAY,
@@ -613,6 +623,9 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps);
ObjectTypeDB::bind_method(_MD("get_target_fps"),&_OS::get_target_fps);
+ ObjectTypeDB::bind_method(_MD("set_time_scale","time_scale"),&_OS::set_time_scale);
+ ObjectTypeDB::bind_method(_MD("get_time_scale"),&_OS::get_time_scale);
+
ObjectTypeDB::bind_method(_MD("has_touchscreen_ui_hint"),&_OS::has_touchscreen_ui_hint);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index cac2de314d..0ef70e4b13 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -201,6 +201,9 @@ public:
String get_data_dir() const;
+ void set_time_scale(float p_scale);
+ float get_time_scale();
+
static _OS *get_singleton() { return singleton; }
_OS();
diff --git a/core/object.cpp b/core/object.cpp
index 8a844577a8..b011d1ad3d 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1505,10 +1505,12 @@ void Object::_bind_methods() {
BIND_VMETHOD( miget );
MethodInfo plget("_get_property_list");
+
plget.return_val.type=Variant::ARRAY;
BIND_VMETHOD( plget );
#endif
+ BIND_VMETHOD( MethodInfo("_init") );
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 819ecd2f22..53ca7c3a49 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -474,6 +474,16 @@ OS::MouseMode OS::get_mouse_mode() const{
return MOUSE_MODE_VISIBLE;
}
+void OS::set_time_scale(float p_scale) {
+
+ _time_scale=p_scale;
+}
+
+float OS::get_time_scale() const {
+
+ return _time_scale;
+}
+
OS::OS() {
last_error=NULL;
@@ -489,6 +499,7 @@ OS::OS() {
_fps=1;
_target_fps=0;
_render_thread_mode=RENDER_THREAD_SAFE;
+ _time_scale=1.0;
Math::seed(1234567);
}
diff --git a/core/os/os.h b/core/os/os.h
index 71f53330c7..ed7e1e4324 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -55,6 +55,7 @@ class OS {
int _orientation;
float _fps;
int _target_fps;
+ float _time_scale;
char *last_error;
@@ -332,6 +333,10 @@ public:
virtual Error dialog_show(String p_title, String p_description, Vector<String> p_buttons, Object* p_obj, String p_callback);
virtual Error dialog_input_text(String p_title, String p_description, String p_partial, Object* p_obj, String p_callback);
+
+ void set_time_scale(float p_scale);
+ float get_time_scale() const;
+
OS();
virtual ~OS();
diff --git a/core/ustring.cpp b/core/ustring.cpp
index cb0540dbb0..cd33c276a8 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -2467,13 +2467,8 @@ int String::findn(String p_str,int p_from) const {
};
- CharType src=srcd[read_pos];
- CharType dst=p_str[j];
-
- if (src>='a' && src<='z')
- src-='a'-'A';
- if (dst>='a' && dst<='z')
- dst-='a'-'A';
+ CharType src=_find_lower(srcd[read_pos]);
+ CharType dst=_find_lower(p_str[j]);
if (src!=dst) {
found=false;
@@ -2490,10 +2485,101 @@ int String::findn(String p_str,int p_from) const {
int String::rfind(String p_str,int p_from) const {
+ //stabilish a limit
+ int limit = length()-p_str.length();
+ if (limit<0)
+ return -1;
+
+ //stabilish a starting point
+ if (p_from<0)
+ p_from=limit;
+ else if (p_from>limit)
+ p_from=limit;
+
+ int src_len=p_str.length();
+ int len=length();
+
+ if(src_len==0 || len==0)
+ return -1; //wont find anything!
+
+
+ const CharType *src = c_str();
+
+ for (int i=p_from;i>=0;i--) {
+
+ bool found=true;
+ for (int j=0;j<src_len;j++) {
+
+ int read_pos=i+j;
+
+ if (read_pos>=len) {
+
+ ERR_PRINT("read_pos>=len");
+ return -1;
+ };
+
+
+ if (src[read_pos]!=p_str[j]) {
+ found=false;
+ break;
+ }
+ }
+
+ if (found)
+ return i;
+ }
+
return -1;
}
int String::rfindn(String p_str,int p_from) const {
+ //stabilish a limit
+ int limit = length()-p_str.length();
+ if (limit<0)
+ return -1;
+
+ //stabilish a starting point
+ if (p_from<0)
+ p_from=limit;
+ else if (p_from>limit)
+ p_from=limit;
+
+ int src_len=p_str.length();
+ int len=length();
+
+ if(src_len==0 || len==0)
+ return -1; //wont find anything!
+
+
+ const CharType *src = c_str();
+
+ for (int i=p_from;i>=0;i--) {
+
+ bool found=true;
+ for (int j=0;j<src_len;j++) {
+
+ int read_pos=i+j;
+
+ if (read_pos>=len) {
+
+ ERR_PRINT("read_pos>=len");
+ return -1;
+ };
+
+ CharType srcc=_find_lower(src[read_pos]);
+ CharType dstc=_find_lower(p_str[j]);
+
+
+ if (srcc!=dstc) {
+ found=false;
+ break;
+ }
+ }
+
+ if (found)
+ return i;
+ }
+
return -1;
}