diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 13 | ||||
-rw-r--r-- | core/bind/core_bind.h | 2 | ||||
-rw-r--r-- | core/event_queue.cpp | 2 | ||||
-rw-r--r-- | core/hq2x.cpp | 4 | ||||
-rw-r--r-- | core/image_quantize.cpp | 5 | ||||
-rw-r--r-- | core/io/marshalls.cpp | 3 | ||||
-rw-r--r-- | core/io/resource_format_xml.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 1 | ||||
-rw-r--r-- | core/io/translation_loader_po.cpp | 3 | ||||
-rw-r--r-- | core/math/triangle_mesh.cpp | 14 | ||||
-rw-r--r-- | core/message_queue.cpp | 2 | ||||
-rw-r--r-- | core/object.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_db.cpp | 2 | ||||
-rw-r--r-- | core/path_remap.cpp | 19 | ||||
-rw-r--r-- | core/pool_allocator.cpp | 1 | ||||
-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/ustring.cpp | 1 | ||||
-rw-r--r-- | core/variant.cpp | 18 | ||||
-rw-r--r-- | core/variant_call.cpp | 122 | ||||
-rw-r--r-- | core/variant_op.cpp | 24 |
24 files changed, 232 insertions, 102 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index ace7e7c7b7..6edc292b62 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -435,6 +435,18 @@ String _OS::get_locale() const { return OS::get_singleton()->get_locale(); } +String _OS::get_latin_keyboard_variant() const { + switch( OS::get_singleton()->get_latin_keyboard_variant() ) { + case OS::LATIN_KEYBOARD_QWERTY: return "QWERTY"; + case OS::LATIN_KEYBOARD_QWERTZ: return "QWERTZ"; + case OS::LATIN_KEYBOARD_AZERTY: return "AZERTY"; + case OS::LATIN_KEYBOARD_QZERTY: return "QZERTY"; + case OS::LATIN_KEYBOARD_DVORAK: return "DVORAK"; + case OS::LATIN_KEYBOARD_NEO : return "NEO"; + default: return "ERROR"; + } +} + String _OS::get_model_name() const { return OS::get_singleton()->get_model_name(); @@ -1097,6 +1109,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_ticks_msec"),&_OS::get_ticks_msec); ObjectTypeDB::bind_method(_MD("get_splash_tick_msec"),&_OS::get_splash_tick_msec); ObjectTypeDB::bind_method(_MD("get_locale"),&_OS::get_locale); + ObjectTypeDB::bind_method(_MD("get_latin_keyboard_variant"),&_OS::get_latin_keyboard_variant); ObjectTypeDB::bind_method(_MD("get_model_name"),&_OS::get_model_name); ObjectTypeDB::bind_method(_MD("get_custom_level"),&_OS::get_custom_level); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 856d942d02..5bd427578a 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -192,6 +192,8 @@ public: Vector<String> get_cmdline_args(); String get_locale() const; + String get_latin_keyboard_variant() const; + String get_model_name() const; MainLoop *get_main_loop() const; 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/hq2x.cpp b/core/hq2x.cpp index 6495c77b2a..7ebb505d64 100644 --- a/core/hq2x.cpp +++ b/core/hq2x.cpp @@ -91,7 +91,7 @@ _FORCE_INLINE_ static bool isDifferent( #define HQX_MIX_2(C0,C1,W0,W1) \ ((((C0 & MASK_RB) * W0 + (C1 & MASK_RB) * W1) / (W0 + W1)) & MASK_RB) | \ ((((C0 & MASK_G) * W0 + (C1 & MASK_G) * W1) / (W0 + W1)) & MASK_G) | \ - (((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1) / (W0 + W1)) << 8) & MASK_A + ((((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1) / (W0 + W1)) << 8) & MASK_A) /** * @brief Mixes three colors using the given weights. @@ -99,7 +99,7 @@ _FORCE_INLINE_ static bool isDifferent( #define HQX_MIX_3(C0,C1,C2,W0,W1,W2) \ ((((C0 & MASK_RB) * W0 + (C1 & MASK_RB) * W1 + (C2 & MASK_RB) * W2) / (W0 + W1 + W2)) & MASK_RB) | \ ((((C0 & MASK_G) * W0 + (C1 & MASK_G) * W1 + (C2 & MASK_G) * W2) / (W0 + W1 + W2)) & MASK_G) | \ - (((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1 + ((C2 & MASK_A) >> 8) * W2) / (W0 + W1 + W2)) << 8) & MASK_A + ((((((C0 & MASK_A) >> 8) * W0 + ((C1 & MASK_A) >> 8) * W1 + ((C2 & MASK_A) >> 8) * W2) / (W0 + W1 + W2)) << 8) & MASK_A) #define MIX_00_4 *output = w[4]; diff --git a/core/image_quantize.cpp b/core/image_quantize.cpp index b8d4658fda..f6fe7a88a0 100644 --- a/core/image_quantize.cpp +++ b/core/image_quantize.cpp @@ -59,7 +59,6 @@ int Image::MCBlock::get_longest_axis_index() const { for(int i=0;i<4;i++) { int d = max_color.color.col[i]-min_color.color.col[i]; - //printf(" ai:%i - %i\n",i,d); if (d>max_dist) { max_index=i; max_dist=d; @@ -71,13 +70,11 @@ int Image::MCBlock::get_longest_axis_index() const { int Image::MCBlock::get_longest_axis_length() const { int max_dist=-1; - int max_index=0; for(int i=0;i<4;i++) { int d = max_color.color.col[i]-min_color.color.col[i]; if (d>max_dist) { - max_index=i; max_dist=d; } } @@ -117,8 +114,6 @@ void Image::MCBlock::shrink() { void Image::quantize() { - Image::Format orig_format=format; - bool has_alpha = detect_alpha()!=ALPHA_NONE; bool quantize_fast=OS::get_singleton()->has_environment("QUANTIZE_FAST"); diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 60617e1237..c9bd38c654 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -685,7 +685,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * if (count) { varray.resize(count); DVector<Vector2>::Write w = varray.write(); - const float *r = (const float*)buf; for(int i=0;i<(int)count;i++) { @@ -724,7 +723,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * if (count) { varray.resize(count); DVector<Vector3>::Write w = varray.write(); - const float *r = (const float*)buf; for(int i=0;i<(int)count;i++) { @@ -764,7 +762,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * if (count) { carray.resize(count); DVector<Color>::Write w = carray.write(); - const float *r = (const float*)buf; for(int i=0;i<(int)count;i++) { diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index a42a922baf..0d545b16f5 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -1862,8 +1862,6 @@ void ResourceInteractiveLoaderXML::open(FileAccess *p_f) { } int major = version.get_slicec('.',0).to_int(); - int minor = version.get_slicec('.',1).to_int(); - if (major>VERSION_MAJOR) { error=ERR_FILE_UNRECOGNIZED; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 1bb80e74eb..f414f85df8 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -443,7 +443,6 @@ String ResourceLoader::get_resource_type(const String &p_path) { String remapped_path = PathRemap::get_singleton()->get_remap(local_path); String extension=remapped_path.extension(); - bool found=false; for (int i=0;i<loader_count;i++) { String result = loader[i]->get_resource_type(local_path); diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 4ddb276a27..a22c57b941 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -47,7 +47,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S String msg_id; String msg_str; String config; - int msg_line=0; if (r_error) *r_error=ERR_FILE_CORRUPT; @@ -97,7 +96,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S status=STATUS_READING_ID; msg_id=""; msg_str=""; - msg_line=line; } if (l.begins_with("msgstr")) { @@ -111,7 +109,6 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error, const S l=l.substr(6,l.length()).strip_edges(); status=STATUS_READING_STRING; - msg_line=line; } if (l=="" || l.begins_with("#")) { diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index adb9861092..7aea32a8a0 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -195,9 +195,6 @@ Vector3 TriangleMesh::get_area_normal(const AABB& p_aabb) const { int n_count=0; Vector3 n; - //for(int i=0;i<max_depth;i++) - // stack[i]=0; - int level=0; DVector<Triangle>::Read trianglesr = triangles.read(); @@ -205,7 +202,6 @@ Vector3 TriangleMesh::get_area_normal(const AABB& p_aabb) const { DVector<BVH>::Read bvhr=bvh.read(); const Triangle *triangleptr=trianglesr.ptr(); - const Vector3 *vertexptr=verticesr.ptr(); int pos=bvh.size()-1; const BVH *bvhptr = bvhr.ptr(); @@ -301,14 +297,7 @@ bool TriangleMesh::intersect_segment(const Vector3& p_begin,const Vector3& p_end real_t d=1e10; bool inters=false; - //for(int i=0;i<max_depth;i++) - // stack[i]=0; - int level=0; - //AABB ray_aabb; - //ray_aabb.pos=p_begin; - //ray_aabb.expand_to(p_end); - DVector<Triangle>::Read trianglesr = triangles.read(); DVector<Vector3>::Read verticesr=vertices.read(); @@ -431,9 +420,6 @@ bool TriangleMesh::intersect_ray(const Vector3& p_begin,const Vector3& p_dir,Vec real_t d=1e20; bool inters=false; - //for(int i=0;i<max_depth;i++) - // stack[i]=0; - int level=0; DVector<Triangle>::Read trianglesr = triangles.read(); 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/object.cpp b/core/object.cpp index 99d4a1f46a..dc3d531927 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1495,7 +1495,7 @@ void Object::disconnect(const StringName& p_signal, Object *p_to_object, const S ERR_EXPLAIN("Disconnecting nonexistent signal '"+p_signal+"', slot: "+itos(target._id)+":"+target.method); ERR_FAIL(); } - int prev = p_to_object->connections.size(); + p_to_object->connections.erase(s->slot_map[target].cE); s->slot_map.erase(target); 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_db.cpp b/core/path_db.cpp index 7545088978..0956c4cd3f 100644 --- a/core/path_db.cpp +++ b/core/path_db.cpp @@ -329,7 +329,6 @@ NodePath::NodePath(const String& p_path) { Vector<StringName> subpath; int absolute=(path[0]=='/')?1:0;; - bool valid=false; bool last_is_slash=true; int slices=0; int subpath_pos=path.find(":"); @@ -373,7 +372,6 @@ NodePath::NodePath(const String& p_path) { if (last_is_slash) slices++; - valid=true; last_is_slash=false; } } 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/pool_allocator.cpp b/core/pool_allocator.cpp index 849fd75f50..9f5fcf5f50 100644 --- a/core/pool_allocator.cpp +++ b/core/pool_allocator.cpp @@ -372,7 +372,6 @@ Error PoolAllocator::resize(ID p_mem,int p_new_size) { } //p_new_size = align(p_new_size) - int _total = pool_size; // - static_area_size; int _free = free_mem; // - static_area_size; if ((_free + aligned(e->len)) - alloc_size < 0) { 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/ustring.cpp b/core/ustring.cpp index 3c22de35f1..6788ada1bb 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3836,7 +3836,6 @@ String String::lpad(int min_length, const String& character) const { String String::sprintf(const Array& values, bool* error) const { String formatted; CharType* self = (CharType*)c_str(); - int num_items = values.size(); bool in_format = false; int value_index = 0; int min_chars; diff --git a/core/variant.cpp b/core/variant.cpp index 81d10f379a..31321dc0f3 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1559,72 +1559,78 @@ Variant::operator String() const { case VECTOR2_ARRAY: { DVector<Vector2> vec = operator DVector<Vector2>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+Variant( vec[i] ); } + str += "]"; return str; } break; case VECTOR3_ARRAY: { DVector<Vector3> vec = operator DVector<Vector3>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+Variant( vec[i] ); } + str += "]"; return str; } break; case STRING_ARRAY: { DVector<String> vec = operator DVector<String>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+vec[i]; } + str += "]"; return str; } break; case INT_ARRAY: { DVector<int> vec = operator DVector<int>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+itos(vec[i]); } + str += "]"; return str; } break; case REAL_ARRAY: { DVector<real_t> vec = operator DVector<real_t>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+rtos(vec[i]); } + str += "]"; return str; } break; case ARRAY: { Array arr = operator Array(); - String str; + String str("["); for (int i=0; i<arr.size(); i++) { if (i) str+=", "; str += String(arr[i]); }; + str += "]"; return str; } break; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 7b9dea4eab..7da4cef115 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -947,10 +947,22 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var struct ConstantData { Map<StringName,int> value; +#ifdef DEBUG_ENABLED + List<StringName> value_ordered; +#endif }; static ConstantData* constant_data; + static void add_constant(int p_type, StringName p_constant_name, int p_constant_value) { + + constant_data[p_type].value[p_constant_name] = p_constant_value; +#ifdef DEBUG_ENABLED + constant_data[p_type].value_ordered.push_back(p_constant_name); +#endif + + } + }; _VariantCall::TypeFunc* _VariantCall::type_funcs=NULL; @@ -1241,9 +1253,15 @@ void Variant::get_numeric_constants_for_type(Variant::Type p_type, List<StringNa _VariantCall::ConstantData& cd = _VariantCall::constant_data[p_type]; +#ifdef DEBUG_ENABLED + for(List<StringName>::Element *E=cd.value_ordered.front();E;E=E->next()) { + + p_constants->push_back(E->get()); +#else for(Map<StringName,int>::Element *E=cd.value.front();E;E=E->next()) { p_constants->push_back(E->key()); +#endif } } @@ -1649,10 +1667,10 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_pressed,varray()); ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action,STRING,"action",varray()); - ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_pressed,STRING,"is_action_pressed",varray()); - ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_released,STRING,"is_action_released",varray()); + ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_pressed,STRING,"action",varray()); + ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_released,STRING,"action",varray()); ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_echo,varray()); - ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray()); + ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray()); /* REGISTER CONSTRUCTORS */ @@ -1671,7 +1689,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl _VariantCall::add_constructor(_VariantCall::Plane_init3,Variant::PLANE,"normal",Variant::VECTOR3,"d",Variant::REAL); _VariantCall::add_constructor(_VariantCall::Quat_init1,Variant::QUAT,"x",Variant::REAL,"y",Variant::REAL,"z",Variant::REAL,"w",Variant::REAL); - _VariantCall::add_constructor(_VariantCall::Quat_init2,Variant::QUAT,"axis",Variant::VECTOR3,"angle",Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Quat_init2,Variant::QUAT,"axis",Variant::VECTOR3,"angle",Variant::REAL); _VariantCall::add_constructor(_VariantCall::Color_init1,Variant::COLOR,"r",Variant::REAL,"g",Variant::REAL,"b",Variant::REAL,"a",Variant::REAL); _VariantCall::add_constructor(_VariantCall::Color_init2,Variant::COLOR,"r",Variant::REAL,"g",Variant::REAL,"b",Variant::REAL); @@ -1688,54 +1706,54 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl /* REGISTER CONSTANTS */ - _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_X"]=Vector3::AXIS_X; - _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_Y"]=Vector3::AXIS_Y; - _VariantCall::constant_data[Variant::VECTOR3].value["AXIS_Z"]=Vector3::AXIS_Z; - - _VariantCall::constant_data[Variant::INPUT_EVENT].value["NONE"]=InputEvent::NONE; - _VariantCall::constant_data[Variant::INPUT_EVENT].value["KEY"]=InputEvent::KEY; - _VariantCall::constant_data[Variant::INPUT_EVENT].value["MOUSE_MOTION"]=InputEvent::MOUSE_MOTION; - _VariantCall::constant_data[Variant::INPUT_EVENT].value["MOUSE_BUTTON"]=InputEvent::MOUSE_BUTTON; - _VariantCall::constant_data[Variant::INPUT_EVENT].value["JOYSTICK_MOTION"]=InputEvent::JOYSTICK_MOTION; - _VariantCall::constant_data[Variant::INPUT_EVENT].value["JOYSTICK_BUTTON"]=InputEvent::JOYSTICK_BUTTON; - _VariantCall::constant_data[Variant::INPUT_EVENT].value["SCREEN_TOUCH"]=InputEvent::SCREEN_TOUCH; - _VariantCall::constant_data[Variant::INPUT_EVENT].value["SCREEN_DRAG"]=InputEvent::SCREEN_DRAG; - _VariantCall::constant_data[Variant::INPUT_EVENT].value["ACTION"]=InputEvent::ACTION; - - _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_BC"]=Image::COMPRESS_BC; - _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_PVRTC2"]=Image::COMPRESS_PVRTC2; - _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_PVRTC4"]=Image::COMPRESS_PVRTC4; - _VariantCall::constant_data[Variant::IMAGE].value["COMPRESS_ETC"]=Image::COMPRESS_ETC; - - - - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_GRAYSCALE"]=Image::FORMAT_GRAYSCALE; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INTENSITY"]=Image::FORMAT_INTENSITY; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_GRAYSCALE_ALPHA"]=Image::FORMAT_GRAYSCALE_ALPHA; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_RGB"]=Image::FORMAT_RGB; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_RGBA"]=Image::FORMAT_RGBA; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INDEXED"]=Image::FORMAT_INDEXED; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_INDEXED_ALPHA"]=Image::FORMAT_INDEXED_ALPHA; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_YUV_422"]=Image::FORMAT_YUV_422; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_YUV_444"]=Image::FORMAT_YUV_444; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC1"]=Image::FORMAT_BC1; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC2"]=Image::FORMAT_BC2; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC3"]=Image::FORMAT_BC3; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC4"]=Image::FORMAT_BC4; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_BC5"]=Image::FORMAT_BC5; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC2"]=Image::FORMAT_PVRTC2; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC2_ALPHA"]=Image::FORMAT_PVRTC2_ALPHA; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4"]=Image::FORMAT_PVRTC4; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4_ALPHA"]=Image::FORMAT_PVRTC4_ALPHA; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ETC"]=Image::FORMAT_ETC; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC"]=Image::FORMAT_ATC; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_EXPLICIT"]=Image::FORMAT_ATC_ALPHA_EXPLICIT; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_INTERPOLATED"]=Image::FORMAT_ATC_ALPHA_INTERPOLATED; - _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_CUSTOM"]=Image::FORMAT_CUSTOM; - - _VariantCall::constant_data[Variant::IMAGE].value["INTERPOLATE_NEAREST"]=Image::INTERPOLATE_NEAREST; - _VariantCall::constant_data[Variant::IMAGE].value["INTERPOLATE_BILINEAR"]=Image::INTERPOLATE_BILINEAR; - _VariantCall::constant_data[Variant::IMAGE].value["INTERPOLATE_CUBIC"]=Image::INTERPOLATE_CUBIC; + _VariantCall::add_constant(Variant::VECTOR3,"AXIS_X",Vector3::AXIS_X); + _VariantCall::add_constant(Variant::VECTOR3,"AXIS_Y",Vector3::AXIS_Y); + _VariantCall::add_constant(Variant::VECTOR3,"AXIS_Z",Vector3::AXIS_Z); + + + _VariantCall::add_constant(Variant::INPUT_EVENT,"NONE",InputEvent::NONE); + _VariantCall::add_constant(Variant::INPUT_EVENT,"KEY",InputEvent::KEY); + _VariantCall::add_constant(Variant::INPUT_EVENT,"MOUSE_MOTION",InputEvent::MOUSE_MOTION); + _VariantCall::add_constant(Variant::INPUT_EVENT,"MOUSE_BUTTON",InputEvent::MOUSE_BUTTON); + _VariantCall::add_constant(Variant::INPUT_EVENT,"JOYSTICK_MOTION",InputEvent::JOYSTICK_MOTION); + _VariantCall::add_constant(Variant::INPUT_EVENT,"JOYSTICK_BUTTON",InputEvent::JOYSTICK_BUTTON); + _VariantCall::add_constant(Variant::INPUT_EVENT,"SCREEN_TOUCH",InputEvent::SCREEN_TOUCH); + _VariantCall::add_constant(Variant::INPUT_EVENT,"SCREEN_DRAG",InputEvent::SCREEN_DRAG); + _VariantCall::add_constant(Variant::INPUT_EVENT,"ACTION",InputEvent::ACTION); + + + _VariantCall::add_constant(Variant::IMAGE,"COMPRESS_BC",Image::COMPRESS_BC); + _VariantCall::add_constant(Variant::IMAGE,"COMPRESS_PVRTC2",Image::COMPRESS_PVRTC2); + _VariantCall::add_constant(Variant::IMAGE,"COMPRESS_PVRTC4",Image::COMPRESS_PVRTC4); + _VariantCall::add_constant(Variant::IMAGE,"COMPRESS_ETC",Image::COMPRESS_ETC); + + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_GRAYSCALE",Image::FORMAT_GRAYSCALE); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_INTENSITY",Image::FORMAT_INTENSITY); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_GRAYSCALE_ALPHA",Image::FORMAT_GRAYSCALE_ALPHA); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_RGB",Image::FORMAT_RGB); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_RGBA",Image::FORMAT_RGBA); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_INDEXED",Image::FORMAT_INDEXED); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_INDEXED_ALPHA",Image::FORMAT_INDEXED_ALPHA); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_YUV_422",Image::FORMAT_YUV_422); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_YUV_444",Image::FORMAT_YUV_444); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC1",Image::FORMAT_BC1); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC2",Image::FORMAT_BC2); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC3",Image::FORMAT_BC3); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC4",Image::FORMAT_BC4); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_BC5",Image::FORMAT_BC5); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_PVRTC2",Image::FORMAT_PVRTC2); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_PVRTC2_ALPHA",Image::FORMAT_PVRTC2_ALPHA); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_PVRTC4",Image::FORMAT_PVRTC4); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_PVRTC4_ALPHA",Image::FORMAT_PVRTC4_ALPHA); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_ETC",Image::FORMAT_ETC); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_ATC",Image::FORMAT_ATC); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_ATC_ALPHA_EXPLICIT",Image::FORMAT_ATC_ALPHA_EXPLICIT); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_ATC_ALPHA_INTERPOLATED",Image::FORMAT_ATC_ALPHA_INTERPOLATED); + _VariantCall::add_constant(Variant::IMAGE,"FORMAT_CUSTOM",Image::FORMAT_CUSTOM); + + _VariantCall::add_constant(Variant::IMAGE,"INTERPOLATE_NEAREST",Image::INTERPOLATE_NEAREST); + _VariantCall::add_constant(Variant::IMAGE,"INTERPOLATE_BILINEAR",Image::INTERPOLATE_BILINEAR); + _VariantCall::add_constant(Variant::IMAGE,"INTERPOLATE_CUBIC",Image::INTERPOLATE_CUBIC); } void unregister_variant_methods() { diff --git a/core/variant_op.cpp b/core/variant_op.cpp index e549161de9..9182dcde1a 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -2911,6 +2911,14 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const { return ret; } break; + case STRING: { + + const String *str=reinterpret_cast<const String*>(_data._mem); + if (str->empty()) + return false; + r_iter = 0; + return true; + } break; case DICTIONARY: { const Dictionary *dic=reinterpret_cast<const Dictionary*>(_data._mem); @@ -3028,6 +3036,17 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { return ret; } break; + + case STRING: { + + const String *str=reinterpret_cast<const String*>(_data._mem); + int idx = r_iter; + idx++; + if (idx >= str->size()) + return false; + r_iter = idx; + return true; + } break; case DICTIONARY: { const Dictionary *dic=reinterpret_cast<const Dictionary*>(_data._mem); @@ -3158,6 +3177,11 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const { return ret; } break; + case STRING: { + + const String *str=reinterpret_cast<const String*>(_data._mem); + return str->substr(r_iter,1); + } break; case DICTIONARY: { return r_iter; //iterator is the same as the key |