summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/globals.cpp1
-rw-r--r--core/object_type_db.cpp19
-rw-r--r--core/object_type_db.h4
-rw-r--r--core/os/input.cpp43
-rw-r--r--core/os/input.h7
-rw-r--r--core/os/os.cpp4
-rw-r--r--core/ustring.cpp31
-rw-r--r--core/ustring.h1
8 files changed, 106 insertions, 4 deletions
diff --git a/core/globals.cpp b/core/globals.cpp
index 731c5b7dff..d252d4e280 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -1477,7 +1477,6 @@ Globals::Globals() {
custom_prop_info["render/mipmap_policy"]=PropertyInfo(Variant::INT,"render/mipmap_policy",PROPERTY_HINT_ENUM,"Allow,Allow For Po2,Disallow");
custom_prop_info["render/thread_model"]=PropertyInfo(Variant::INT,"render/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded");
custom_prop_info["physics_2d/thread_model"]=PropertyInfo(Variant::INT,"physics_2d/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded");
- set("display/emulate_touchscreen",false);
using_datapack=false;
}
diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp
index c291714573..a64b3d2715 100644
--- a/core/object_type_db.cpp
+++ b/core/object_type_db.cpp
@@ -746,6 +746,25 @@ bool ObjectTypeDB::has_method(StringName p_type,StringName p_method,bool p_no_in
}
+bool ObjectTypeDB::get_setter_and_type_for_property(const StringName& p_class, const StringName& p_prop, StringName& r_class, StringName& r_setter) {
+
+ TypeInfo *type=types.getptr(p_class);
+ TypeInfo *check=type;
+ while(check) {
+
+ if (check->property_setget.has(p_prop)) {
+ r_class=check->name;
+ r_setter=check->property_setget[p_prop].setter;
+ return true;
+ }
+
+ check=check->inherits_ptr;
+ }
+
+ return false;
+
+}
+
#ifdef DEBUG_METHODS_ENABLED
MethodBind* ObjectTypeDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) {
StringName mdname=method_name.name;
diff --git a/core/object_type_db.h b/core/object_type_db.h
index caa5baddd5..bfa0f921e5 100644
--- a/core/object_type_db.h
+++ b/core/object_type_db.h
@@ -475,7 +475,9 @@ public:
static void get_integer_constant_list(const StringName& p_type, List<String> *p_constants, bool p_no_inheritance=false);
static int get_integer_constant(const StringName& p_type, const StringName &p_name, bool *p_success=NULL);
static StringName get_category(const StringName& p_node);
-
+
+ static bool get_setter_and_type_for_property(const StringName& p_class, const StringName& p_prop, StringName& r_class, StringName& r_setter);
+
static void set_type_enabled(StringName p_type,bool p_enable);
static bool is_type_enabled(StringName p_type);
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 2b939ede46..cf2938f5cd 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -271,6 +271,38 @@ void InputDefault::parse_input_event(const InputEvent& p_event) {
mouse_button_mask|=(1<<p_event.mouse_button.button_index);
else
mouse_button_mask&=~(1<<p_event.mouse_button.button_index);
+
+ if (main_loop && emulate_touch && p_event.mouse_button.button_index==1) {
+ InputEventScreenTouch touch_event;
+ touch_event.index=0;
+ touch_event.pressed=p_event.mouse_button.pressed;
+ touch_event.x=p_event.mouse_button.x;
+ touch_event.y=p_event.mouse_button.y;
+ InputEvent ev;
+ ev.type=InputEvent::SCREEN_TOUCH;
+ ev.screen_touch=touch_event;
+ main_loop->input_event(ev);
+ }
+ } break;
+ case InputEvent::MOUSE_MOTION: {
+
+ if (main_loop && emulate_touch && p_event.mouse_motion.button_mask&1) {
+ InputEventScreenDrag drag_event;
+ drag_event.index=0;
+ drag_event.x=p_event.mouse_motion.x;
+ drag_event.y=p_event.mouse_motion.y;
+ drag_event.relative_x=p_event.mouse_motion.relative_x;
+ drag_event.relative_y=p_event.mouse_motion.relative_y;
+ drag_event.speed_x=p_event.mouse_motion.speed_x;
+ drag_event.speed_y=p_event.mouse_motion.speed_y;
+
+ InputEvent ev;
+ ev.type=InputEvent::SCREEN_DRAG;
+ ev.screen_drag=drag_event;
+
+ main_loop->input_event(ev);
+ }
+
} break;
case InputEvent::JOYSTICK_BUTTON: {
@@ -362,8 +394,19 @@ void InputDefault::action_release(const StringName& p_action){
}
}
+void InputDefault::set_emulate_touch(bool p_emulate) {
+
+ emulate_touch=p_emulate;
+}
+
+bool InputDefault::is_emulating_touchscreen() const {
+
+ return emulate_touch;
+}
+
InputDefault::InputDefault() {
mouse_button_mask=0;
+ emulate_touch=false;
main_loop=NULL;
}
diff --git a/core/os/input.h b/core/os/input.h
index ce14c2166e..5c69ced825 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -78,6 +78,8 @@ public:
void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
+ virtual bool is_emulating_touchscreen() const=0;
+
Input();
};
@@ -99,6 +101,8 @@ class InputDefault : public Input {
Vector2 mouse_pos;
MainLoop *main_loop;
+ bool emulate_touch;
+
struct SpeedTrack {
uint64_t last_tick;
@@ -147,6 +151,9 @@ public:
void iteration(float p_step);
+ void set_emulate_touch(bool p_emulate);
+ virtual bool is_emulating_touchscreen() const;
+
InputDefault();
};
diff --git a/core/os/os.cpp b/core/os/os.cpp
index efcd492230..2db926e556 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -31,7 +31,7 @@
#include <stdarg.h>
#include "dir_access.h"
#include "globals.h"
-
+#include "input.h"
OS* OS::singleton=NULL;
@@ -363,7 +363,7 @@ Error OS::set_cwd(const String& p_cwd) {
bool OS::has_touchscreen_ui_hint() const {
//return false;
- return GLOBAL_DEF("display/emulate_touchscreen",false);
+ return Input::get_singleton() && Input::get_singleton()->is_emulating_touchscreen();
}
int OS::get_free_static_memory() const {
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 3cfc1e4a3c..ff7c8984fa 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -3048,6 +3048,37 @@ bool String::is_valid_identifier() const {
//kind of poor should be rewritten properly
+String String::world_wrap(int p_chars_per_line) const {
+
+ int from=0;
+ int last_space=0;
+ String ret;
+ for(int i=0;i<length();i++) {
+ if (i-from>=p_chars_per_line) {
+ if (last_space==-1) {
+ ret+=substr(from,i-from+1)+"\n";
+ } else {
+ ret+=substr(from,last_space-from)+"\n";
+ i=last_space; //rewind
+ }
+ from=i+1;
+ last_space=-1;
+ } else if (operator[](i)==' ' || operator[](i)=='\t') {
+ last_space=i;
+ } else if (operator[](i)=='\n') {
+ ret+=substr(from,i-from);
+ from=i+1;
+ last_space=-1;
+ }
+ }
+
+ if (from<length()) {
+ ret+=substr(from,length());
+ }
+
+ return ret;
+}
+
String String::c_unescape() const {
String escaped=*this;
diff --git a/core/ustring.h b/core/ustring.h
index 1000c1cc8a..fa25a07eb0 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -209,6 +209,7 @@ public:
String xml_unescape() const;
String c_escape() const;
String c_unescape() const;
+ String world_wrap(int p_chars_per_line) const;
String percent_encode() const;
String percent_decode() const;