diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/event_queue.cpp | 2 | ||||
-rw-r--r-- | core/message_queue.cpp | 2 | ||||
-rw-r--r-- | core/os/input_event.cpp | 59 | ||||
-rw-r--r-- | core/os/input_event.h | 4 | ||||
-rw-r--r-- | core/path_remap.cpp | 19 | ||||
-rw-r--r-- | core/resource.cpp | 28 | ||||
-rw-r--r-- | core/resource.h | 2 | ||||
-rw-r--r-- | core/script_language.h | 1 | ||||
-rw-r--r-- | core/typedefs.h | 1 |
9 files changed, 109 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.h b/core/script_language.h index 51fb351fde..6d75b83aaf 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -78,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 */ |