summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/event_queue.cpp2
-rw-r--r--core/message_queue.cpp2
-rw-r--r--core/os/input_event.cpp59
-rw-r--r--core/os/input_event.h4
-rw-r--r--core/path_remap.cpp19
-rw-r--r--core/resource.cpp28
-rw-r--r--core/resource.h2
-rw-r--r--core/script_language.cpp14
-rw-r--r--core/script_language.h2
-rw-r--r--core/typedefs.h1
-rw-r--r--core/variant_call.cpp14
11 files changed, 138 insertions, 9 deletions
diff --git a/core/event_queue.cpp b/core/event_queue.cpp
index 53638c5431..958ef41132 100644
--- a/core/event_queue.cpp
+++ b/core/event_queue.cpp
@@ -92,7 +92,7 @@ Error EventQueue::push_call(uint32_t p_instance_ID, const StringName& p_method,
*v=p_arg5;
}
- if (buffer_max_used>buffer_end);
+ if (buffer_end > buffer_max_used)
buffer_max_used=buffer_end;
return OK;
diff --git a/core/message_queue.cpp b/core/message_queue.cpp
index c69021f4f0..f3daa46c3d 100644
--- a/core/message_queue.cpp
+++ b/core/message_queue.cpp
@@ -320,7 +320,7 @@ void MessageQueue::_call_function(Object* p_target, const StringName& p_func, co
void MessageQueue::flush() {
- if (buffer_max_used<buffer_end); {
+ if (buffer_end > buffer_max_used) {
buffer_max_used=buffer_end;
//statistics();
}
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 2d47645a66..8c79657c64 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -199,3 +199,62 @@ uint32_t InputEventKey::get_scancode_with_modifiers() const {
return sc;
}
+
+InputEvent InputEvent::xform_by(const Matrix32& p_xform) const {
+
+
+ InputEvent ev=*this;
+
+ switch(ev.type) {
+
+ case InputEvent::MOUSE_BUTTON: {
+
+ Vector2 g = p_xform.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
+ Vector2 l = p_xform.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y));
+ ev.mouse_button.x=l.x;
+ ev.mouse_button.y=l.y;
+ ev.mouse_button.global_x=g.x;
+ ev.mouse_button.global_y=g.y;
+
+ } break;
+ case InputEvent::MOUSE_MOTION: {
+
+ Vector2 g = p_xform.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
+ Vector2 l = p_xform.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y));
+ Vector2 r = p_xform.basis_xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y));
+ Vector2 s = p_xform.basis_xform(Vector2(ev.mouse_motion.speed_x,ev.mouse_motion.speed_y));
+ ev.mouse_motion.x=l.x;
+ ev.mouse_motion.y=l.y;
+ ev.mouse_motion.global_x=g.x;
+ ev.mouse_motion.global_y=g.y;
+ ev.mouse_motion.relative_x=r.x;
+ ev.mouse_motion.relative_y=r.y;
+ ev.mouse_motion.speed_x=s.x;
+ ev.mouse_motion.speed_y=s.y;
+
+ } break;
+ case InputEvent::SCREEN_TOUCH: {
+
+
+ Vector2 t = p_xform.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y));
+ ev.screen_touch.x=t.x;
+ ev.screen_touch.y=t.y;
+
+ } break;
+ case InputEvent::SCREEN_DRAG: {
+
+
+ Vector2 t = p_xform.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y));
+ Vector2 r = p_xform.basis_xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
+ Vector2 s = p_xform.basis_xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
+ ev.screen_drag.x=t.x;
+ ev.screen_drag.y=t.y;
+ ev.screen_drag.relative_x=r.x;
+ ev.screen_drag.relative_y=r.y;
+ ev.screen_drag.speed_x=s.x;
+ ev.screen_drag.speed_y=s.y;
+ } break;
+ }
+
+ return ev;
+}
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 0588374790..1c4f1dcf96 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -33,7 +33,7 @@
#include "typedefs.h"
#include "os/copymem.h"
#include "ustring.h"
-
+#include "math_2d.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -297,6 +297,8 @@ struct InputEvent {
bool is_echo() const;
void set_as_action(const String& p_action, bool p_pressed);
+
+ InputEvent xform_by(const Matrix32& p_xform) const;
bool operator==(const InputEvent &p_event) const;
operator String() const;
InputEvent() { zeromem(this,sizeof(InputEvent)); }
diff --git a/core/path_remap.cpp b/core/path_remap.cpp
index d4cb883f41..8f189187f2 100644
--- a/core/path_remap.cpp
+++ b/core/path_remap.cpp
@@ -59,12 +59,20 @@ String PathRemap::get_remap(const String& p_from) const {
return p_from;
} else {
+ const RemapData *ptr2=NULL;
+
String locale = TranslationServer::get_singleton()->get_locale();
if (ptr->locale.has(locale)) {
if (OS::get_singleton()->is_stdout_verbose())
print_line("remap found: "+p_from+" -> "+ptr->locale[locale]);
- return ptr->locale[locale];
+
+ ptr2=remap.getptr(ptr->locale[locale]);
+
+ if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too
+ return ptr2->always;
+ else
+ return ptr->locale[locale];
}
int p = locale.find("_");
@@ -73,7 +81,14 @@ String PathRemap::get_remap(const String& p_from) const {
if (ptr->locale.has(locale)) {
if (OS::get_singleton()->is_stdout_verbose())
print_line("remap found: "+p_from+" -> "+ptr->locale[locale]);
- return ptr->locale[locale];
+
+ ptr2=remap.getptr(ptr->locale[locale]);
+
+ if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too
+ return ptr2->always;
+ else
+ return ptr->locale[locale];
+
}
}
diff --git a/core/resource.cpp b/core/resource.cpp
index 97dee3e1d7..b80ec7012d 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -30,7 +30,7 @@
#include "core_string_names.h"
#include <stdio.h>
#include "os/file_access.h"
-
+#include "io/resource_loader.h"
void ResourceImportMetadata::set_editor(const String& p_editor) {
@@ -218,14 +218,36 @@ String Resource::get_name() const {
return name;
}
-bool Resource::can_reload_from_file() {
+bool Resource::editor_can_reload_from_file() {
- return false;
+ return true; //by default yes
}
void Resource::reload_from_file() {
+ String path=get_path();
+ if (!path.is_resource_file())
+ return;
+
+ Ref<Resource> s = ResourceLoader::load(path,get_type(),true);
+
+ if (!s.is_valid())
+ return;
+
+ List<PropertyInfo> pi;
+ s->get_property_list(&pi);
+
+ for (List<PropertyInfo>::Element *E=pi.front();E;E=E->next()) {
+
+ if (!(E->get().usage&PROPERTY_USAGE_STORAGE))
+ continue;
+ if (E->get().name=="resource/path")
+ continue; //do not change path
+
+ set(E->get().name,s->get(E->get().name));
+
+ }
}
diff --git a/core/resource.h b/core/resource.h
index 958414f62b..0673a4e89d 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -121,7 +121,7 @@ protected:
void _take_over_path(const String& p_path);
public:
- virtual bool can_reload_from_file();
+ virtual bool editor_can_reload_from_file();
virtual void reload_from_file();
void register_owner(Object *p_owner);
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 466242d39d..75d8b6d285 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -85,6 +85,20 @@ void ScriptServer::register_language(ScriptLanguage *p_language) {
_languages[_language_count++]=p_language;
}
+void ScriptServer::unregister_language(ScriptLanguage *p_language) {
+
+
+ for(int i=0;i<_language_count;i++) {
+ if (_languages[i]==p_language) {
+ _language_count--;
+ if (i<_language_count) {
+ SWAP(_languages[i],_languages[_language_count]);
+ }
+ return;
+ }
+ }
+}
+
void ScriptServer::init_languages() {
for(int i=0;i<_language_count;i++) {
diff --git a/core/script_language.h b/core/script_language.h
index de725d8d08..6d75b83aaf 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -55,6 +55,7 @@ public:
static int get_language_count();
static ScriptLanguage *get_language(int p_idx);
static void register_language(ScriptLanguage *p_language);
+ static void unregister_language(ScriptLanguage *p_language);
static void set_reload_scripts_on_save(bool p_enable);
static bool is_reload_scripts_on_save_enabled();
@@ -77,6 +78,7 @@ class Script : public Resource {
protected:
+ virtual bool editor_can_reload_from_file() { return false; } // this is handled by editor better
void _notification( int p_what);
static void _bind_methods();
diff --git a/core/typedefs.h b/core/typedefs.h
index 6f9bb58958..30a75e66da 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -296,5 +296,6 @@ struct _GlobalLock {
#define __STR(m_index) __STRX(m_index)
+
#endif /* typedefs.h */
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index c0f8930eed..7b9dea4eab 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -516,6 +516,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(ByteArray,remove);
VCALL_LOCALMEM1(ByteArray,append);
VCALL_LOCALMEM1(ByteArray,append_array);
+ VCALL_LOCALMEM0(ByteArray,invert);
VCALL_LOCALMEM0R(IntArray,size);
VCALL_LOCALMEM2(IntArray,set);
@@ -526,6 +527,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(IntArray,remove);
VCALL_LOCALMEM1(IntArray,append);
VCALL_LOCALMEM1(IntArray,append_array);
+ VCALL_LOCALMEM0(IntArray,invert);
VCALL_LOCALMEM0R(RealArray,size);
VCALL_LOCALMEM2(RealArray,set);
@@ -536,6 +538,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(RealArray,remove);
VCALL_LOCALMEM1(RealArray,append);
VCALL_LOCALMEM1(RealArray,append_array);
+ VCALL_LOCALMEM0(RealArray,invert);
VCALL_LOCALMEM0R(StringArray,size);
VCALL_LOCALMEM2(StringArray,set);
@@ -546,6 +549,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(StringArray,remove);
VCALL_LOCALMEM1(StringArray,append);
VCALL_LOCALMEM1(StringArray,append_array);
+ VCALL_LOCALMEM0(StringArray,invert);
VCALL_LOCALMEM0R(Vector2Array,size);
VCALL_LOCALMEM2(Vector2Array,set);
@@ -556,6 +560,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(Vector2Array,remove);
VCALL_LOCALMEM1(Vector2Array,append);
VCALL_LOCALMEM1(Vector2Array,append_array);
+ VCALL_LOCALMEM0(Vector2Array,invert);
VCALL_LOCALMEM0R(Vector3Array,size);
VCALL_LOCALMEM2(Vector3Array,set);
@@ -566,6 +571,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(Vector3Array,remove);
VCALL_LOCALMEM1(Vector3Array,append);
VCALL_LOCALMEM1(Vector3Array,append_array);
+ VCALL_LOCALMEM0(Vector3Array,invert);
VCALL_LOCALMEM0R(ColorArray,size);
VCALL_LOCALMEM2(ColorArray,set);
@@ -576,6 +582,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(ColorArray,remove);
VCALL_LOCALMEM1(ColorArray,append);
VCALL_LOCALMEM1(ColorArray,append_array);
+ VCALL_LOCALMEM0(ColorArray,invert);
#define VCALL_PTR0(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(); }
@@ -1506,6 +1513,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(RAW_ARRAY,NIL,ByteArray,remove,INT,"idx",varray());
ADDFUNC2(RAW_ARRAY,INT,ByteArray,insert,INT,"idx",INT,"byte",varray());
ADDFUNC1(RAW_ARRAY,NIL,ByteArray,resize,INT,"idx",varray());
+ ADDFUNC0(RAW_ARRAY,NIL,ByteArray,invert,varray());
ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_ascii,varray());
ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_utf8,varray());
@@ -1519,6 +1527,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(INT_ARRAY,NIL,IntArray,remove,INT,"idx",varray());
ADDFUNC2(INT_ARRAY,INT,IntArray,insert,INT,"idx",INT,"integer",varray());
ADDFUNC1(INT_ARRAY,NIL,IntArray,resize,INT,"idx",varray());
+ ADDFUNC0(INT_ARRAY,NIL,IntArray,invert,varray());
ADDFUNC0(REAL_ARRAY,INT,RealArray,size,varray());
ADDFUNC2(REAL_ARRAY,NIL,RealArray,set,INT,"idx",REAL,"value",varray());
@@ -1528,6 +1537,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(REAL_ARRAY,NIL,RealArray,remove,INT,"idx",varray());
ADDFUNC2(REAL_ARRAY,INT,RealArray,insert,INT,"idx",REAL,"value",varray());
ADDFUNC1(REAL_ARRAY,NIL,RealArray,resize,INT,"idx",varray());
+ ADDFUNC0(REAL_ARRAY,NIL,RealArray,invert,varray());
ADDFUNC0(STRING_ARRAY,INT,StringArray,size,varray());
ADDFUNC2(STRING_ARRAY,NIL,StringArray,set,INT,"idx",STRING,"string",varray());
@@ -1537,6 +1547,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(STRING_ARRAY,NIL,StringArray,remove,INT,"idx",varray());
ADDFUNC2(STRING_ARRAY,INT,StringArray,insert,INT,"idx",STRING,"string",varray());
ADDFUNC1(STRING_ARRAY,NIL,StringArray,resize,INT,"idx",varray());
+ ADDFUNC0(STRING_ARRAY,NIL,StringArray,invert,varray());
ADDFUNC0(VECTOR2_ARRAY,INT,Vector2Array,size,varray());
ADDFUNC2(VECTOR2_ARRAY,NIL,Vector2Array,set,INT,"idx",VECTOR2,"vector2",varray());
@@ -1546,6 +1557,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,remove,INT,"idx",varray());
ADDFUNC2(VECTOR2_ARRAY,INT,Vector2Array,insert,INT,"idx",VECTOR2,"vector2",varray());
ADDFUNC1(VECTOR2_ARRAY,NIL,Vector2Array,resize,INT,"idx",varray());
+ ADDFUNC0(VECTOR2_ARRAY,NIL,Vector2Array,invert,varray());
ADDFUNC0(VECTOR3_ARRAY,INT,Vector3Array,size,varray());
ADDFUNC2(VECTOR3_ARRAY,NIL,Vector3Array,set,INT,"idx",VECTOR3,"vector3",varray());
@@ -1555,6 +1567,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,remove,INT,"idx",varray());
ADDFUNC2(VECTOR3_ARRAY,INT,Vector3Array,insert,INT,"idx",VECTOR3,"vector3",varray());
ADDFUNC1(VECTOR3_ARRAY,NIL,Vector3Array,resize,INT,"idx",varray());
+ ADDFUNC0(VECTOR3_ARRAY,NIL,Vector3Array,invert,varray());
ADDFUNC0(COLOR_ARRAY,INT,ColorArray,size,varray());
ADDFUNC2(COLOR_ARRAY,NIL,ColorArray,set,INT,"idx",COLOR,"color",varray());
@@ -1564,6 +1577,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,remove,INT,"idx",varray());
ADDFUNC2(COLOR_ARRAY,INT,ColorArray,insert,INT,"idx",COLOR,"color",varray());
ADDFUNC1(COLOR_ARRAY,NIL,ColorArray,resize,INT,"idx",varray());
+ ADDFUNC0(COLOR_ARRAY,NIL,ColorArray,invert,varray());
//pointerbased