aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/dvector.h28
-rw-r--r--core/func_ref.cpp6
-rw-r--r--core/globals.cpp33
-rw-r--r--core/globals.h3
-rw-r--r--core/image.cpp1
-rw-r--r--core/input_map.cpp4
-rw-r--r--core/input_map.h8
-rw-r--r--core/io/file_access_pack.cpp2
-rw-r--r--core/io/resource_format_binary.cpp3
-rw-r--r--core/io/resource_format_xml.cpp4
-rw-r--r--core/io/stream_peer.cpp1
-rw-r--r--core/math/math_2d.h9
-rw-r--r--core/math/triangulate.cpp5
-rw-r--r--core/math/vector3.cpp10
-rw-r--r--core/method_bind.h19
-rw-r--r--core/object.cpp146
-rw-r--r--core/object.h8
-rw-r--r--core/object_type_db.cpp9
-rw-r--r--core/object_type_db.h4
-rw-r--r--core/os/input.cpp2
-rw-r--r--core/os/input.h18
-rw-r--r--core/os/input_event.cpp50
-rw-r--r--core/os/os.cpp3
-rw-r--r--core/os/os.h8
-rw-r--r--core/script_debugger_remote.cpp6
-rw-r--r--core/script_language.cpp1
-rw-r--r--core/script_language.h6
-rw-r--r--core/translation.cpp438
-rw-r--r--core/undo_redo.cpp77
-rw-r--r--core/undo_redo.h12
-rw-r--r--core/variant.h2
-rw-r--r--core/variant_call.cpp18
-rw-r--r--core/variant_op.cpp2
33 files changed, 790 insertions, 156 deletions
diff --git a/core/dvector.h b/core/dvector.h
index a5519ed60..9a5464161 100644
--- a/core/dvector.h
+++ b/core/dvector.h
@@ -262,6 +262,34 @@ public:
w[bs+i]=r[i];
}
+ DVector<T> subarray(int p_from, int p_to) {
+
+ if (p_from<0) {
+ p_from=size()+p_from;
+ }
+ if (p_to<0) {
+ p_to=size()+p_to;
+ }
+ if (p_from<0 || p_from>=size()) {
+ DVector<T>& aux=*((DVector<T>*)0); // nullreturn
+ ERR_FAIL_COND_V(p_from<0 || p_from>=size(),aux)
+ }
+ if (p_to<0 || p_to>=size()) {
+ DVector<T>& aux=*((DVector<T>*)0); // nullreturn
+ ERR_FAIL_COND_V(p_to<0 || p_to>=size(),aux)
+ }
+
+ DVector<T> slice;
+ int span=1 + p_to - p_from;
+ slice.resize(span);
+ Read r = read();
+ Write w = slice.write();
+ for (int i=0; i<span; ++i) {
+ w[i] = r[p_from+i];
+ }
+
+ return slice;
+ }
Error insert(int p_pos,const T& p_val) {
diff --git a/core/func_ref.cpp b/core/func_ref.cpp
index 644d8b5b6..ca890111b 100644
--- a/core/func_ref.cpp
+++ b/core/func_ref.cpp
@@ -61,11 +61,7 @@ void FuncRef::_bind_methods() {
MethodInfo mi;
mi.name="call_func";
Vector<Variant> defargs;
- for(int i=0;i<10;i++) {
- mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
- defargs.push_back(Variant());
- }
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call_func:Variant",&FuncRef::call_func,mi,defargs);
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_func:Variant",&FuncRef::call_func,mi,defargs);
}
diff --git a/core/globals.cpp b/core/globals.cpp
index e760bc00d..b822f52f1 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -1332,17 +1332,18 @@ Variant _GLOBAL_DEF( const String& p_var, const Variant& p_default) {
void Globals::add_singleton(const Singleton &p_singleton) {
singletons.push_back(p_singleton);
+ singleton_ptrs[p_singleton.name]=p_singleton.ptr;
}
Object* Globals::get_singleton_object(const String& p_name) const {
- for(const List<Singleton>::Element *E=singletons.front();E;E=E->next()) {
- if (E->get().name == p_name) {
- return E->get().ptr;
- };
- };
- return NULL;
+ const Map<StringName,Object*>::Element *E=singleton_ptrs.find(p_name);
+ if (!E)
+ return NULL;
+ else
+ return E->get();
+
};
bool Globals::has_singleton(const String& p_name) const {
@@ -1375,6 +1376,25 @@ Vector<String> Globals::get_optimizer_presets() const {
}
+void Globals::_add_property_info_bind(const Dictionary& p_info) {
+
+ ERR_FAIL_COND(!p_info.has("name"));
+ ERR_FAIL_COND(!p_info.has("type"));
+
+ PropertyInfo pinfo;
+ pinfo.name = p_info["name"];
+ ERR_FAIL_COND(!props.has(pinfo.name));
+ pinfo.type = Variant::Type(p_info["type"].operator int());
+ ERR_FAIL_INDEX(pinfo.type, Variant::VARIANT_MAX);
+
+ if (p_info.has("hint"))
+ pinfo.hint = PropertyHint(p_info["hint"].operator int());
+ if (p_info.has("hint_string"))
+ pinfo.hint_string = p_info["hint_string"];
+
+ set_custom_property_info(pinfo.name, pinfo);
+}
+
void Globals::set_custom_property_info(const String& p_prop,const PropertyInfo& p_info) {
ERR_FAIL_COND(!props.has(p_prop));
@@ -1399,6 +1419,7 @@ void Globals::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_order","name"),&Globals::get_order);
ObjectTypeDB::bind_method(_MD("set_persisting","name","enable"),&Globals::set_persisting);
ObjectTypeDB::bind_method(_MD("is_persisting","name"),&Globals::is_persisting);
+ ObjectTypeDB::bind_method(_MD("add_property_info", "hint"),&Globals::_add_property_info_bind);
ObjectTypeDB::bind_method(_MD("clear","name"),&Globals::clear);
ObjectTypeDB::bind_method(_MD("localize_path","path"),&Globals::localize_path);
ObjectTypeDB::bind_method(_MD("globalize_path","path"),&Globals::globalize_path);
diff --git a/core/globals.h b/core/globals.h
index 68bb859ac..5e0bdb0e5 100644
--- a/core/globals.h
+++ b/core/globals.h
@@ -91,11 +91,14 @@ protected:
Error _save_settings_binary(const String& p_file,const Map<String,List<String> > &props,const CustomMap& p_custom=CustomMap());
List<Singleton> singletons;
+ Map<StringName,Object*> singleton_ptrs;
Error _save_custom_bnd(const String& p_file);
bool _load_resource_pack(const String& p_pack);
+ void _add_property_info_bind(const Dictionary& p_info);
+
protected:
static void _bind_methods();
diff --git a/core/image.cpp b/core/image.cpp
index d6ac3f28e..90051d7d0 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -2052,6 +2052,7 @@ Error Image::_decompress_bc() {
ht/=2;
} break;
+ default: {}
}
}
diff --git a/core/input_map.cpp b/core/input_map.cpp
index 08ee8138a..3a0f9596f 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -290,6 +290,10 @@ bool InputMap::event_is_joy_motion_action_pressed(const InputEvent& p_event) con
}
+const Map<StringName, InputMap::Action>& InputMap::get_action_map() const {
+ return input_map;
+}
+
void InputMap::load_from_globals() {
input_map.clear();;
diff --git a/core/input_map.h b/core/input_map.h
index dc5a91196..a224765d8 100644
--- a/core/input_map.h
+++ b/core/input_map.h
@@ -35,12 +35,14 @@
class InputMap : public Object {
OBJ_TYPE( InputMap, Object );
- static InputMap *singleton;
-
+public:
struct Action {
int id;
List<InputEvent> inputs;
};
+private:
+ static InputMap *singleton;
+
mutable Map<StringName, Action> input_map;
mutable Map<int,StringName> input_id_map;
@@ -72,7 +74,7 @@ public:
bool event_is_action(const InputEvent& p_event, const StringName& p_action) const;
bool event_is_joy_motion_action_pressed(const InputEvent& p_event) const;
-
+ const Map<StringName, Action>& get_action_map() const;
void load_from_globals();
void load_default();
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 5c8c741f2..1632b841c 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -409,6 +409,8 @@ Error DirAccessPack::change_dir(String p_dir) {
nd=nd.simplify_path();
+ if (nd == "") nd = ".";
+
if (nd.begins_with("/")) {
nd=nd.replace_first("/","") ;
absolute=true;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index a620dc0fe..0544fd6ba 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -2175,6 +2175,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
if (takeover_paths) {
r->set_path(p_path+"::"+itos(r->get_subindex()),true);
}
+#ifdef TOOLS_ENABLED
+ r->set_edited(false);
+#endif
} else {
save_unicode_string(r->get_path()); //actual external
}
diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp
index 0d545b16f..44fbaf02a 100644
--- a/core/io/resource_format_xml.cpp
+++ b/core/io/resource_format_xml.cpp
@@ -2800,6 +2800,10 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
if (takeover_paths) {
res->set_path(p_path+"::"+itos(idx),true);
}
+#ifdef TOOLS_ENABLED
+ res->set_edited(false);
+#endif
+
}
write_string("\n",false);
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 176d55ffd..baaeacaf1 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -544,6 +544,7 @@ Ref<StreamPeerBuffer> StreamPeerBuffer::duplicate() const {
Ref<StreamPeerBuffer> spb;
spb.instance();
spb->data=data;
+ return spb;
}
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index fbf700fb9..90aae9fe5 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -618,6 +618,15 @@ struct Matrix32 {
operator String() const;
+ Matrix32(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) {
+
+ elements[0][0] = xx;
+ elements[0][1] = xy;
+ elements[1][0] = yx;
+ elements[1][1] = yy;
+ elements[2][0] = ox;
+ elements[2][1] = oy;
+ }
Matrix32(real_t p_rot, const Vector2& p_pos);
Matrix32() { elements[0][0]=1.0; elements[1][1]=1.0; }
diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp
index 27b7c8667..1f5d5ed6b 100644
--- a/core/math/triangulate.cpp
+++ b/core/math/triangulate.cpp
@@ -157,7 +157,10 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result
m++;
/* remove v from remaining polygon */
- for(s=v,t=v+1;t<nv;s++,t++) V[s] = V[t]; nv--;
+ for(s=v,t=v+1;t<nv;s++,t++)
+ V[s] = V[t];
+
+ nv--;
/* resest error detection counter */
count = 2*nv;
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index 8afd73f48..b4a13d8f6 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -65,13 +65,9 @@ int Vector3::max_axis() const {
void Vector3::snap(float p_val) {
- x+=p_val/2.0;
- x-=Math::fmod(x,p_val);
- y+=p_val/2.0;
- y-=Math::fmod(y,p_val);
- z+=p_val/2.0;
- z-=Math::fmod(z,p_val);
-
+ x=Math::stepify(x,p_val);
+ y=Math::stepify(y,p_val);
+ z=Math::stepify(z,p_val);
}
Vector3 Vector3::snapped(float p_val) const {
diff --git a/core/method_bind.h b/core/method_bind.h
index 072953743..04ff5c22c 100644
--- a/core/method_bind.h
+++ b/core/method_bind.h
@@ -52,6 +52,7 @@ enum MethodFlags {
METHOD_FLAG_REVERSE=16, // used for events
METHOD_FLAG_VIRTUAL=32,
METHOD_FLAG_FROM_SCRIPT=64,
+ METHOD_FLAG_VARARG=128,
METHOD_FLAGS_DEFAULT=METHOD_FLAG_NORMAL,
};
@@ -229,7 +230,7 @@ public:
Vector<StringName> get_argument_names() const;
#endif
void set_hint_flags(uint32_t p_hint) { hint_flags=p_hint; }
- uint32_t get_hint_flags() const { return hint_flags|(is_const()?METHOD_FLAG_CONST:0); }
+ uint32_t get_hint_flags() const { return hint_flags|(is_const()?METHOD_FLAG_CONST:0)|(is_vararg()?METHOD_FLAG_VARARG:0); }
virtual String get_instance_type() const=0;
_FORCE_INLINE_ int get_argument_count() const { return argument_count; };
@@ -267,7 +268,7 @@ public:
_FORCE_INLINE_ int get_method_id() const { return method_id; }
_FORCE_INLINE_ bool is_const() const { return _const; }
_FORCE_INLINE_ bool has_return() const { return _returns; }
-
+ virtual bool is_vararg() const { return false; }
void set_default_arguments(const Vector<Variant>& p_defargs);
@@ -277,7 +278,7 @@ public:
template<class T>
-class MethodBindNative : public MethodBind {
+class MethodBindVarArg : public MethodBind {
public:
typedef Variant (T::*NativeCall)(const Variant**,int ,Variant::CallError &);
protected:
@@ -319,7 +320,9 @@ public:
}
#ifdef PTRCALL_ENABLED
- virtual void ptrcall(Object* p_object,const void** p_args,void* r_ret) {} //todo
+ virtual void ptrcall(Object* p_object,const void** p_args,void* r_ret) {
+ ERR_FAIL(); //can't call
+ } //todo
#endif
@@ -327,14 +330,16 @@ public:
virtual bool is_const() const { return false; }
virtual String get_instance_type() const { return T::get_type_static(); }
- MethodBindNative() { call_method=NULL; _set_returns(true);}
+ virtual bool is_vararg() const { return true; }
+
+ MethodBindVarArg() { call_method=NULL; _set_returns(true);}
};
template<class T >
-MethodBind* create_native_method_bind( Variant (T::*p_method)(const Variant**,int ,Variant::CallError &), const MethodInfo& p_info ) {
+MethodBind* create_vararg_method_bind( Variant (T::*p_method)(const Variant**,int ,Variant::CallError &), const MethodInfo& p_info ) {
- MethodBindNative<T > * a = memnew( (MethodBindNative<T >) );
+ MethodBindVarArg<T > * a = memnew( (MethodBindVarArg<T >) );
a->set_method(p_method);
a->set_method_info(p_info);
return a;
diff --git a/core/object.cpp b/core/object.cpp
index 26319d42d..8cd4e0709 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -59,30 +59,112 @@ struct _ObjectDebugLock {
#endif
+
+PropertyInfo::operator Dictionary() const {
+
+ Dictionary d;
+ d["name"]=name;
+ d["type"]=type;
+ d["hint"]=hint;
+ d["hint_string"]=hint_string;
+ d["usage"]=usage;
+ return d;
+
+}
+
+PropertyInfo PropertyInfo::from_dict(const Dictionary& p_dict) {
+
+ PropertyInfo pi;
+
+ if (p_dict.has("type"))
+ pi.type=Variant::Type(int(p_dict["type"]));
+
+ if (p_dict.has("name"))
+ pi.name=p_dict["name"];
+
+ if (p_dict.has("hint"))
+ pi.hint=PropertyHint(int(p_dict["hint"]));
+
+ if (p_dict.has("hint_string"))
+
+ pi.hint_string=p_dict["hint_string"];
+
+ if (p_dict.has("usage"))
+ pi.usage=p_dict["usage"];
+
+ return pi;
+}
+
+
Array convert_property_list(const List<PropertyInfo> * p_list) {
Array va;
for (const List<PropertyInfo>::Element *E=p_list->front();E;E=E->next()) {
- const PropertyInfo &pi = E->get();
- Dictionary d;
- d["name"]=pi.name;
- d["type"]=pi.type;
- d["hint"]=pi.hint;
- d["hint_string"]=pi.hint_string;
- d["usage"]=pi.usage;
- va.push_back(d);
+
+ va.push_back(Dictionary(E->get()));
}
return va;
}
+MethodInfo::operator Dictionary() const {
+
+
+ Dictionary d;
+ d["name"]=name;
+ d["args"]=convert_property_list(&arguments);
+ Array da;
+ for(int i=0;i<default_arguments.size();i++)
+ da.push_back(default_arguments[i]);
+ d["default_args"]=da;
+ d["flags"]=flags;
+ d["id"]=id;
+ Dictionary r = return_val;
+ d["return"]=r;
+ return d;
+
+}
+
MethodInfo::MethodInfo() {
id=0;
flags=METHOD_FLAG_NORMAL;
}
+MethodInfo MethodInfo::from_dict(const Dictionary& p_dict) {
+
+ MethodInfo mi;
+
+ if (p_dict.has("name"))
+ mi.name=p_dict["name"];
+ Array args;
+ if (p_dict.has("args")) {
+ args=p_dict["args"];
+ }
+
+ for(int i=0;i<args.size();i++) {
+ Dictionary d = args[i];
+ mi.arguments.push_back(PropertyInfo::from_dict(d));
+ }
+ Array defargs;
+ if (p_dict.has("default_args")) {
+ defargs=p_dict["default_args"];
+ }
+ for(int i=0;i<defargs.size();i++) {
+ mi.default_arguments.push_back(defargs[i]);
+ }
+
+ if (p_dict.has("return")) {
+ mi.return_val=PropertyInfo::from_dict(p_dict["return"]);
+ }
+
+ if (p_dict.has("flags"))
+ mi.flags=p_dict["flags"];
+
+ return mi;
+}
+
MethodInfo::MethodInfo(const String& p_name) {
id=0;
@@ -1012,25 +1094,6 @@ Array Object::_get_property_list_bind() const {
}
-static Dictionary _get_dict_from_method(const MethodInfo &mi) {
-
- Dictionary d;
- d["name"]=mi.name;
- d["args"]=convert_property_list(&mi.arguments);
- Array da;
- for(int i=0;i<mi.default_arguments.size();i++)
- da.push_back(mi.default_arguments[i]);
- d["default_args"]=da;
- d["flags"]=mi.flags;
- d["id"]=mi.id;
- Dictionary r;
- r["type"]=mi.return_val.type;
- r["hint"]=mi.return_val.hint;
- r["hint_string"]=mi.return_val.hint_string;
- d["return_type"]=r;
- return d;
-
-}
Array Object::_get_method_list_bind() const {
@@ -1040,7 +1103,7 @@ Array Object::_get_method_list_bind() const {
for(List<MethodInfo>::Element *E=ml.front();E;E=E->next()) {
- Dictionary d = _get_dict_from_method(E->get());
+ Dictionary d = E->get();
//va.push_back(d);
ret.push_back(d);
}
@@ -1305,7 +1368,7 @@ Array Object::_get_signal_list() const{
Array ret;
for (List<MethodInfo>::Element *E=signal_list.front();E;E=E->next()) {
- ret.push_back(_get_dict_from_method(E->get()));
+ ret.push_back(Dictionary(E->get()));
}
return ret;
@@ -1581,6 +1644,7 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
_clear_internal_resource_paths(d[E->get()]);
}
} break;
+ default: {}
}
}
@@ -1630,42 +1694,26 @@ void Object::_bind_methods() {
MethodInfo mi;
mi.name="emit_signal";
mi.arguments.push_back( PropertyInfo( Variant::STRING, "signal"));
- Vector<Variant> defargs;
- for(int i=0;i<VARIANT_ARG_MAX;i++) {
- mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
- defargs.push_back(Variant());
- }
-
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"emit_signal",&Object::_emit_signal,mi,defargs);
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"emit_signal",&Object::_emit_signal,mi);
}
{
MethodInfo mi;
mi.name="call";
mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
- Vector<Variant> defargs;
- for(int i=0;i<10;i++) {
- mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
- defargs.push_back(Variant());
- }
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call:Variant",&Object::_call_bind,mi,defargs);
+
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call:Variant",&Object::_call_bind,mi);
}
{
MethodInfo mi;
mi.name="call_deferred";
mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
- Vector<Variant> defargs;
- for(int i=0;i<VARIANT_ARG_MAX;i++) {
- mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
- defargs.push_back(Variant());
- }
-
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"call_deferred",&Object::_call_deferred_bind,mi,defargs);
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"call_deferred",&Object::_call_deferred_bind,mi);
}
ObjectTypeDB::bind_method(_MD("callv:Variant","method","arg_array"),&Object::callv);
diff --git a/core/object.h b/core/object.h
index 6ea794ec7..ac3fc51b3 100644
--- a/core/object.h
+++ b/core/object.h
@@ -126,6 +126,11 @@ struct PropertyInfo {
_FORCE_INLINE_ PropertyInfo added_usage(int p_fl) const { PropertyInfo pi=*this; pi.usage|=p_fl; return pi; }
+
+ operator Dictionary() const;
+
+ static PropertyInfo from_dict(const Dictionary& p_dict);
+
PropertyInfo() { type=Variant::NIL; hint=PROPERTY_HINT_NONE; usage = PROPERTY_USAGE_DEFAULT; }
PropertyInfo( Variant::Type p_type, const String p_name, PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_string="",uint32_t p_usage=PROPERTY_USAGE_DEFAULT) {
type=p_type; name=p_name; hint=p_hint; hint_string=p_hint_string; usage=p_usage;
@@ -150,6 +155,9 @@ struct MethodInfo {
inline bool operator<(const MethodInfo& p_method) const { return id==p_method.id?(name < p_method.name):(id<p_method.id); }
+ operator Dictionary() const;
+
+ static MethodInfo from_dict(const Dictionary& p_dict);
MethodInfo();
MethodInfo(const String& p_name);
MethodInfo(const String& p_name, const PropertyInfo& p_param1);
diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp
index ba98797a8..aa641923e 100644
--- a/core/object_type_db.cpp
+++ b/core/object_type_db.cpp
@@ -642,7 +642,7 @@ void ObjectTypeDB::get_property_list(StringName p_type, List<PropertyInfo> *p_li
TypeInfo *check=type;
while(check) {
- for(List<PropertyInfo>::Element *E=type->property_list.front();E;E=E->next()) {
+ for(List<PropertyInfo>::Element *E=check->property_list.front();E;E=E->next()) {
if (p_validator) {
@@ -866,21 +866,14 @@ MethodBind* ObjectTypeDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , c
Vector<Variant> defvals;
-#define PARSE_DEFVAL(m_defval)\
-if (d##m_defval.used) defvals.insert(0,d##m_defval.val);\
-else goto set_defvals;
-
defvals.resize(p_defcount);
for(int i=0;i<p_defcount;i++) {
defvals[i]=*p_defs[p_defcount-i-1];
}
- set_defvals:
-
p_bind->set_default_arguments(defvals);
p_bind->set_hint_flags(p_flags);
-#undef PARSE_DEFVAL
return p_bind;
}
diff --git a/core/object_type_db.h b/core/object_type_db.h
index 3fcd38aa3..725b424c9 100644
--- a/core/object_type_db.h
+++ b/core/object_type_db.h
@@ -415,13 +415,13 @@ public:
#endif
template<class M>
- static MethodBind* bind_native_method(uint32_t p_flags, StringName p_name, M p_method,const MethodInfo& p_info=MethodInfo(),const Vector<Variant>& p_default_args=Vector<Variant>()) {
+ static MethodBind* bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method,const MethodInfo& p_info=MethodInfo(),const Vector<Variant>& p_default_args=Vector<Variant>()) {
GLOBAL_LOCK_FUNCTION;
- MethodBind *bind = create_native_method_bind(p_method,p_info);
+ MethodBind *bind = create_vararg_method_bind(p_method,p_info);
ERR_FAIL_COND_V(!bind,NULL);
String rettype;
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 531db7383..401ab7ffe 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -53,6 +53,8 @@ void Input::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed);
ObjectTypeDB::bind_method(_MD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed);
ObjectTypeDB::bind_method(_MD("is_action_pressed","action"),&Input::is_action_pressed);
+ ObjectTypeDB::bind_method(_MD("is_action_just_pressed","action"),&Input::is_action_just_pressed);
+ ObjectTypeDB::bind_method(_MD("is_action_just_released","action"),&Input::is_action_just_released);
ObjectTypeDB::bind_method(_MD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false));
ObjectTypeDB::bind_method(_MD("remove_joy_mapping","guid"),&Input::remove_joy_mapping);
ObjectTypeDB::bind_method(_MD("is_joy_known","device"),&Input::is_joy_known);
diff --git a/core/os/input.h b/core/os/input.h
index 16bcc0ff9..665fb4ad9 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -55,12 +55,14 @@ public:
static Input *get_singleton();
- virtual bool is_key_pressed(int p_scancode)=0;
- virtual bool is_mouse_button_pressed(int p_button)=0;
- virtual bool is_joy_button_pressed(int p_device, int p_button)=0;
- virtual bool is_action_pressed(const StringName& p_action)=0;
+ virtual bool is_key_pressed(int p_scancode) const=0;
+ virtual bool is_mouse_button_pressed(int p_button) const=0;
+ virtual bool is_joy_button_pressed(int p_device, int p_button) const=0;
+ virtual bool is_action_pressed(const StringName& p_action) const=0;
+ virtual bool is_action_just_pressed(const StringName& p_action) const=0;
+ virtual bool is_action_just_released(const StringName& p_action) const=0;
- virtual float get_joy_axis(int p_device,int p_axis)=0;
+ virtual float get_joy_axis(int p_device,int p_axis) const=0;
virtual String get_joy_name(int p_idx)=0;
virtual Array get_connected_joysticks()=0;
virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid)=0;
@@ -80,9 +82,9 @@ public:
virtual void warp_mouse_pos(const Vector2& p_to)=0;
- virtual Vector3 get_accelerometer()=0;
- virtual Vector3 get_magnetometer()=0;
- virtual Vector3 get_gyroscope()=0;
+ virtual Vector3 get_accelerometer() const=0;
+ virtual Vector3 get_magnetometer() const=0;
+ virtual Vector3 get_gyroscope() const=0;
virtual void action_press(const StringName& p_action)=0;
virtual void action_release(const StringName& p_action)=0;
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 8c79657c6..9d920724e 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -34,8 +34,56 @@
*/
bool InputEvent::operator==(const InputEvent &p_event) const {
+ if (type != p_event.type){
+ return false;
+ }
- return true;
+ switch(type) {
+ case NONE:
+ return true;
+ case KEY:
+ return key.unicode == p_event.key.unicode
+ && key.scancode == p_event.key.scancode
+ && key.echo == p_event.key.echo
+ && key.pressed == p_event.key.pressed
+ && key.mod == p_event.key.mod;
+ case MOUSE_MOTION:
+ return mouse_motion.x == p_event.mouse_motion.x
+ && mouse_motion.y == p_event.mouse_motion.y
+ && mouse_motion.relative_x == p_event.mouse_motion.relative_y
+ && mouse_motion.button_mask == p_event.mouse_motion.button_mask
+ && key.mod == p_event.key.mod;
+ case MOUSE_BUTTON:
+ return mouse_button.pressed == p_event.mouse_button.pressed
+ && mouse_button.x == p_event.mouse_button.x
+ && mouse_button.y == p_event.mouse_button.y
+ && mouse_button.button_index == p_event.mouse_button.button_index
+ && mouse_button.button_mask == p_event.mouse_button.button_mask
+ && key.mod == p_event.key.mod;
+ case JOYSTICK_MOTION:
+ return joy_motion.axis == p_event.joy_motion.axis
+ && joy_motion.axis_value == p_event.joy_motion.axis_value;
+ case JOYSTICK_BUTTON:
+ return joy_button.pressed == p_event.joy_button.pressed
+ && joy_button.button_index == p_event.joy_button.button_index
+ && joy_button.pressure == p_event.joy_button.pressure;
+ case SCREEN_TOUCH:
+ return screen_touch.pressed == p_event.screen_touch.pressed
+ && screen_touch.index == p_event.screen_touch.index
+ && screen_touch.x == p_event.screen_touch.x
+ && screen_touch.y == p_event.screen_touch.y;
+ case SCREEN_DRAG:
+ return screen_drag.index == p_event.screen_drag.index
+ && screen_drag.x == p_event.screen_drag.x
+ && screen_drag.y == p_event.screen_drag.y;
+ case ACTION:
+ return action.action == p_event.action.action
+ && action.pressed == p_event.action.pressed;
+ default:
+ ERR_PRINT("No logic to compare InputEvents of this type, this shouldn't happen.");
+ }
+
+ return false;
}
InputEvent::operator String() const {
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 5f8696204..ee3247623 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -587,6 +587,9 @@ OS::OS() {
_time_scale=1.0;
_pixel_snap=false;
_allow_hidpi=true;
+ _fixed_frames=0;
+ _idle_frames=0;
+ _in_fixed=false;
Math::seed(1234567);
}
diff --git a/core/os/os.h b/core/os/os.h
index 2521d67e2..8e9293b3c 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -62,6 +62,10 @@ class OS {
bool _pixel_snap;
bool _allow_hidpi;
+ uint64_t _fixed_frames;
+ uint64_t _idle_frames;
+ bool _in_fixed;
+
char *last_error;
public:
@@ -282,6 +286,10 @@ public:
uint64_t get_frames_drawn();
+ uint64_t get_fixed_frames() const { return _fixed_frames; }
+ uint64_t get_idle_frames() const { return _idle_frames; }
+ bool is_in_fixed_frame() const { return _in_fixed; }
+
bool is_stdout_verbose() const;
enum CursorShape {
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 99d1e22c0..1ac090796 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -219,7 +219,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
if (F->get().get_type()==Variant::OBJECT) {
packet_peer_stream->put_var("*"+E->get());
- packet_peer_stream->put_var(safe_get_instance_id(F->get()));
+ String pretty_print = F->get().operator String();
+ packet_peer_stream->put_var(pretty_print.ascii().get_data());
} else {
packet_peer_stream->put_var(E->get());
packet_peer_stream->put_var(F->get());
@@ -242,7 +243,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
if (F->get().get_type()==Variant::OBJECT) {
packet_peer_stream->put_var("*"+E->get());
- packet_peer_stream->put_var(safe_get_instance_id(F->get()));
+ String pretty_print = F->get().operator String();
+ packet_peer_stream->put_var(pretty_print.ascii().get_data());
} else {
packet_peer_stream->put_var(E->get());
packet_peer_stream->put_var(F->get());
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 75d8b6d28..fa1d01d3e 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -33,6 +33,7 @@ int ScriptServer::_language_count=0;
bool ScriptServer::scripting_enabled=true;
bool ScriptServer::reload_scripts_on_save=false;
+ScriptEditRequestFunction ScriptServer::edit_request_func=NULL;
void Script::_notification( int p_what) {
diff --git a/core/script_language.h b/core/script_language.h
index 36ed11efe..1b037e908 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -38,6 +38,8 @@
class ScriptLanguage;
+typedef void (*ScriptEditRequestFunction)(const String& p_path);
+
class ScriptServer {
enum {
@@ -50,6 +52,8 @@ class ScriptServer {
static bool reload_scripts_on_save;
public:
+ static ScriptEditRequestFunction edit_request_func;
+
static void set_scripting_enabled(bool p_enabled);
static bool is_scripting_enabled();
static int get_language_count();
@@ -88,6 +92,8 @@ public:
virtual bool can_instance() const=0;
+ virtual Ref<Script> get_base_script() const=0; //for script inheritance
+
virtual StringName get_instance_base_type() const=0; // this may not work in all scripts, will return empty if so
virtual ScriptInstance* instance_create(Object *p_this)=0;
virtual bool instance_has(const Object *p_this) const=0;
diff --git a/core/translation.cpp b/core/translation.cpp
index 01789747e..4592d0059 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -32,11 +32,23 @@
#include "os/os.h"
static const char* locale_list[]={
+"aa", // Afar
+"aa_DJ", // Afar (Djibouti)
+"aa_ER", // Afar (Eritrea)
+"aa_ET", // Afar (Ethiopia)
+"af", // Afrikaans
+"af_ZA", // Afrikaans (South Africa)
+"agr_PE", // Aguaruna (Peru)
+"ak_GH", // Akan (Ghana)
+"am_ET", // Amharic (Ethiopia)
+"an_ES", // Aragonese (Spain)
+"anp_IN", // Angika (India)
"ar", // Arabic
"ar_AE", // Arabic (United Arab Emirates)
"ar_BH", // Arabic (Bahrain)
"ar_DZ", // Arabic (Algeria)
"ar_EG", // Arabic (Egypt)
+"ar_IN", // Arabic (India)
"ar_IQ", // Arabic (Iraq)
"ar_JO", // Arabic (Jordan)
"ar_KW", // Arabic (Kuwait)
@@ -47,48 +59,91 @@ static const char* locale_list[]={
"ar_QA", // Arabic (Qatar)
"ar_SA", // Arabic (Saudi Arabia)
"ar_SD", // Arabic (Sudan)
+"ar_SS", // Arabic (South Soudan)
"ar_SY", // Arabic (Syria)
"ar_TN", // Arabic (Tunisia)
"ar_YE", // Arabic (Yemen)
+"as_IN", // Assamese (India)
+"ast_ES", // Asturian (Spain)
+"ayc_PE", // Southern Aymara (Peru)
+"ay_PE", // Aymara (Peru)
+"az_AZ", // Azerbaijani (Azerbaijan)
"be", // Belarusian
"be_BY", // Belarusian (Belarus)
+"bem_ZM", // Bemba (Zambia)
+"ber_DZ", // Berber languages (Algeria)
+"ber_MA", // Berber languages (Morocco)
"bg", // Bulgarian
"bg_BG", // Bulgarian (Bulgaria)
+"bhb_IN", // Bhili (India)
+"bho_IN", // Bhojpuri (India)
+"bi_TV", // Bislama (Tuvalu)
"bn", // Bengali
"bn_BD", // Bengali (Bangladesh)
"bn_IN", // Bengali (India)
+"bo", // Tibetan
+"bo_CN", // Tibetan (China)
+"bo_IN", // Tibetan (India)
+"br_FR", // Breton (France)
+"brx_IN", // Bodo (India)
+"bs_BA", // Bosnian (Bosnia and Herzegovina)
+"byn_ER", // Bilin (Eritrea)
"ca", // Catalan
+"ca_AD", // Catalan (Andorra)
"ca_ES", // Catalan (Spain)
+"ca_FR", // Catalan (France)
+"ca_IT", // Catalan (Italy)
+"ce_RU", // Chechen (Russia)
+"chr_US", // Cherokee (United States)
+"cmn_TW", // Mandarin Chinese (Taiwan)
+"crh_UA", // Crimean Tatar (Ukraine)
+"csb_PL", // Kashubian (Poland)
"cs", // Czech
"cs_CZ", // Czech (Czech Republic)
+"cv_RU", // Chuvash (Russia)
+"cy_GB", // Welsh (United Kingdom)
"da", // Danish
"da_DK", // Danish (Denmark)
"de", // German
"de_AT", // German (Austria)
+"de_BE", // German (Belgium)
"de_CH", // German (Switzerland)
"de_DE", // German (Germany)
+"de_IT", // German (Italy)
"de_LU", // German (Luxembourg)
+"doi_IN", // Dogri (India)
+"dv_MV", // Dhivehi (Maldives)
+"dz_BT", // Dzongkha (Bhutan)
"el", // Greek
"el_CY", // Greek (Cyprus)
"el_GR", // Greek (Greece)
"en", // English
+"en_AG", // English (Antigua and Barbuda)
"en_AU", // English (Australia)
+"en_BW", // English (Botswana)
"en_CA", // English (Canada)
+"en_DK", // English (Denmark)
"en_GB", // English (United Kingdom)
+"en_HK", // English (Hong Kong)
"en_IE", // English (Ireland)
+"en_IL", // English (Israel)
"en_IN", // English (India)
-"en_MT", // English (Malta)
+"en_NG", // English (Nigeria)
"en_NZ", // English (New Zealand)
"en_PH", // English (Philippines)
"en_SG", // English (Singapore)
"en_US", // English (United States)
"en_ZA", // English (South Africa)
+"en_ZM", // English (Zambia)
+"en_ZW", // English (Zimbabwe)
+"eo", // Esperanto
"es", // Spanish
"es_AR", // Spanish (Argentina)
"es_BO", // Spanish (Bolivia)
"es_CL", // Spanish (Chile)
"es_CO", // Spanish (Colombia)
"es_CR", // Spanish (Costa Rica)
+"es_CU", // Spanish (Cuba)
"es_DO", // Spanish (Dominican Republic)
"es_EC", // Spanish (Ecuador)
"es_ES", // Spanish (Spain)
@@ -106,100 +161,252 @@ static const char* locale_list[]={
"es_VE", // Spanish (Venezuela)
"et", // Estonian
"et_EE", // Estonian (Estonia)
+"eu", // Basque
+"eu_ES", // Basque (Spain)
+"fa", // Persian
+"fa_IR", // Persian (Iran)
+"ff_SN", // Fulah (Senegal)
"fi", // Finnish
"fi_FI", // Finnish (Finland)
+"fil_PH", // Filipino (Philippines)
+"fo_FO", // Faroese (Faroe Islands)
"fr", // French
"fr_BE", // French (Belgium)
"fr_CA", // French (Canada)
"fr_CH", // French (Switzerland)
"fr_FR", // French (France)
"fr_LU", // French (Luxembourg)
+"fur_IT", // Friulian (Italy)
+"fy_DE", // Western Frisian (Germany)
+"fy_NL", // Western Frisian (Netherlands)
"ga", // Irish
"ga_IE", // Irish (Ireland)
-"hi", // Hindi (India)
+"gd_GB", // Scottish Gaelic (United Kingdom)
+"gez_ER", // Geez (Eritrea)
+"gez_ET", // Geez (Ethiopia)
+"gl_ES", // Galician (Spain)
+"gu_IN", // Gujarati (India)
+"gv_GB", // Manx (United Kingdom)
+"hak_TW", // Hakka Chinese (Taiwan)
+"ha_NG", // Hausa (Nigeria)
+"he", // Hebrew
+"he_IL", // Hebrew (Israel)
+"hi", // Hindi
"hi_IN", // Hindi (India)
+"hne_IN", // Chhattisgarhi (India)
"hr", // Croatian
"hr_HR", // Croatian (Croatia)
+"hsb_DE", // Upper Sorbian (Germany)
+"ht_HT", // Haitian (Haiti)
"hu", // Hungarian
"hu_HU", // Hungarian (Hungary)
-"in", // Indonesian
-"in_ID", // Indonesian (Indonesia)
+"hus_MX", // Huastec (Mexico)
+"hy_AM", // Armenian (Armenia)
+"ia_FR", // Interlingua (France)
+"id", // Indonesian
+"id_ID", // Indonesian (Indonesia)
+"ig_NG", // Igbo (Nigeria)
+"ik_CA", // Inupiaq (Canada)
"is", // Icelandic
"is_IS", // Icelandic (Iceland)
"it", // Italian
"it_CH", // Italian (Switzerland)
"it_IT", // Italian (Italy)
-"iw", // Hebrew
-"iw_IL", // Hebrew (Israel)
+"iu_CA", // Inuktitut (Canada)
"ja", // Japanese
"ja_JP", // Japanese (Japan)
-"ja_JP_JP", // Japanese (Japan,JP)
+"kab_DZ", // Kabyle (Algeria)
+"ka_GE", // Georgian (Georgia)
+"kk_KZ", // Kazakh (Kazakhstan)
+"kl_GL", // Kalaallisut (Greenland)
+"km_KH", // Central Khmer (Cambodia)
+"kn_IN", // Kannada (India)
+"kok_IN", // Konkani (India)
"ko", // Korean
"ko_KR", // Korean (South Korea)
+"ks_IN", // Kashmiri (India)
+"ku", // Kurdish
+"ku_TR", // Kurdish (Turkey)
+"kw_GB", // Cornish (United Kingdom)
+"ky_KG", // Kirghiz (Kyrgyzstan)
+"lb_LU", // Luxembourgish (Luxembourg)
+"lg_UG", // Ganda (Uganda)
+"li_BE", // Limburgan (Belgium)
+"li_NL", // Limburgan (Netherlands)
+"lij_IT", // Ligurian (Italy)
+"ln_CD", // Lingala (Congo)
+"lo_LA", // Lao (Laos)
"lt", // Lithuanian
"lt_LT", // Lithuanian (Lithuania)
"lv", // Latvian
"lv_LV", // Latvian (Latvia)
+"lzh_TW", // Literary Chinese (Taiwan)
+"mag_IN", // Magahi (India)
+"mai_IN", // Maithili (India)
+"mg_MG", // Malagasy (Madagascar)
+"mh_MH", // Marshallese (Marshall Islands)
+"mhr_RU", // Eastern Mari (Russia)
+"mi_NZ", // Maori (New Zealand)
+"miq_NI", // Mískito (Nicaragua)
"mk", // Macedonian
"mk_MK", // Macedonian (Macedonia)
+"ml_IN", // Malayalam (India)
+"mni_IN", // Manipuri (India)
+"mn_MN", // Mongolian (Mongolia)
+"mr_IN", // Marathi (India)
"ms", // Malay
"ms_MY", // Malay (Malaysia)
"mt", // Maltese
"mt_MT", // Maltese (Malta)
+"my_MM", // Burmese (Myanmar)
+"myv_RU", // Erzya (Russia)
+"nah_MX", // Nahuatl languages (Mexico)
+"nan_TW", // Min Nan Chinese (Taiwan)
+"nb", // Norwegian Bokmål
+"nb_NO", // Norwegian Bokmål (Norway)
+"nds_DE", // Low German (Germany)
+"nds_NL", // Low German (Netherlands)
+"ne_NP", // Nepali (Nepal)
+"nhn_MX", // Central Nahuatl (Mexico)
+"niu_NU", // Niuean (Niue)
+"niu_NZ", // Niuean (New Zealand)
"nl", // Dutch
+"nl_AW", // Dutch (Aruba)
"nl_BE", // Dutch (Belgium)
"nl_NL", // Dutch (Netherlands)
-"no", // Norwegian
-"no_NO", // Norwegian (Norway)
-"no_NO_NY", // Norwegian (Norway,Nynorsk)
+"nn", // Norwegian Nynorsk
+"nn_NO", // Norwegian Nynorsk (Norway)
+"nr_ZA", // South Ndebele (South Africa)
+"nso_ZA", // Pedi (South Africa)
+"oc_FR", // Occitan (France)
+"om", // Oromo
+"om_ET", // Oromo (Ethiopia)
+"om_KE", // Oromo (Kenya)
+"or_IN", // Oriya (India)
+"os_RU", // Ossetian (Russia)
+"pa_IN", // Panjabi (India)
+"pap", // Papiamento
+"pap_AN", // Papiamento (Netherlands Antilles)
+"pap_AW", // Papiamento (Aruba)
+"pap_CW", // Papiamento (Curaçao)
+"pa_PK", // Panjabi (Pakistan)
"pl", // Polish
"pl_PL", // Polish (Poland)
+"ps_AF", // Pushto (Afghanistan)
"pt", // Portuguese
"pt_BR", // Portuguese (Brazil)
"pt_PT", // Portuguese (Portugal)
+"quy_PE", // Ayacucho Quechua (Peru)
+"quz_PE", // Cusco Quechua (Peru)
+"raj_IN", // Rajasthani (India)
"ro", // Romanian
"ro_RO", // Romanian (Romania)
"ru", // Russian
"ru_RU", // Russian (Russia)
+"ru_UA", // Russian (Ukraine)
+"rw_RW", // Kinyarwanda (Rwanda)
+"sa_IN", // Sanskrit (India)
+"sat_IN", // Santali (India)
+"sc_IT", // Sardinian (Italy)
+"sd_IN", // Sindhi (India)
+"se_NO", // Northern Sami (Norway)
+"sgs_LT", // Samogitian (Lithuania)
+"shs_CA", // Shuswap (Canada)
+"sid_ET", // Sidamo (Ethiopia)
+"si_LK", // Sinhala (Sri Lanka)
"sk", // Slovak
"sk_SK", // Slovak (Slovakia)
"sl", // Slovenian
"sl_SI", // Slovenian (Slovenia)
+"so", // Somali
+"so_DJ", // Somali (Djibouti)
+"so_ET", // Somali (Ethiopia)
+"so_KE", // Somali (Kenya)
+"so_SO", // Somali (Somalia)
+"son_ML", // Songhai languages (Mali)
"sq", // Albanian
"sq_AL", // Albanian (Albania)
+"sq_KV", // Albanian (Kosovo)
+"sq_MK", // Albanian (Macedonia)
"sr", // Serbian
-"sr_BA", // Serbian (Bosnia and Herzegovina)
-"sr_CS", // Serbian (Serbia and Montenegro)
"sr_ME", // Serbian (Montenegro)
"sr_RS", // Serbian (Serbia)
+"ss_ZA", // Swati (South Africa)
+"st_ZA", // Southern Sotho (South Africa)
"sv", // Swedish
+"sv_FI", // Swedish (Finland)
"sv_SE", // Swedish (Sweden)
+"sw_KE", // Swahili (Kenya)
+"sw_TZ", // Swahili (Tanzania)
+"szl_PL", // Silesian (Poland)
+"ta", // Tamil
+"ta_IN", // Tamil (India)
+"ta_LK", // Tamil (Sri Lanka)
+"tcy_IN", // Tulu (India)
+"te_IN", // Telugu (India)
+"tg_TJ", // Tajik (Tajikistan)
+"the_NP", // Chitwania Tharu (Nepal)
"th", // Thai
"th_TH", // Thai (Thailand)
-"th_TH_TH", // Thai (Thailand,TH)
+"ti", // Tigrinya
+"ti_ER", // Tigrinya (Eritrea)
+"ti_ET", // Tigrinya (Ethiopia)
+"tig_ER", // Tigre (Eritrea)
+"tk_TM", // Turkmen (Turkmenistan)
+"tl_PH", // Tagalog (Philippines)
+"tn_ZA", // Tswana (South Africa)
"tr", // Turkish
+"tr_CY", // Turkish (Cyprus)
"tr_TR", // Turkish (Turkey)
+"ts_ZA", // Tsonga (South Africa)
+"tt_RU", // Tatar (Russia)
+"ug_CN", // Uighur (China)
"uk", // Ukrainian
"uk_UA", // Ukrainian (Ukraine)
+"unm_US", // Unami (United States)
"ur", // Urdu
"ur_IN", // Urdu (India)
"ur_PK", // Urdu (Pakistan)
+"uz", // Uzbek
+"uz_UZ", // Uzbek (Uzbekistan)
+"ve_ZA", // Venda (South Africa)
"vi", // Vietnamese
"vi_VN", // Vietnamese (Vietnam)
+"wa_BE", // Walloon (Belgium)
+"wae_CH", // Walser (Switzerland)
+"wal_ET", // Wolaytta (Ethiopia)
+"wo_SN", // Wolof (Senegal)
+"xh_ZA", // Xhosa (South Africa)
+"yi_US", // Yiddish (United States)
+"yo_NG", // Yoruba (Nigeria)
+"yue_HK", // Yue Chinese (Hong Kong)
"zh", // Chinese
"zh_CN", // Chinese (China)
"zh_HK", // Chinese (Hong Kong)
"zh_SG", // Chinese (Singapore)
"zh_TW", // Chinese (Taiwan)
+"zu_ZA", // Zulu (South Africa)
0
};
static const char* locale_names[]={
+"Afar",
+"Afar (Djibouti)",
+"Afar (Eritrea)",
+"Afar (Ethiopia)",
+"Afrikaans",
+"Afrikaans (South Africa)",
+"Aguaruna (Peru)",
+"Akan (Ghana)",
+"Amharic (Ethiopia)",
+"Aragonese (Spain)",
+"Angika (India)",
"Arabic",
"Arabic (United Arab Emirates)",
"Arabic (Bahrain)",
"Arabic (Algeria)",
"Arabic (Egypt)",
+"Arabic (India)",
"Arabic (Iraq)",
"Arabic (Jordan)",
"Arabic (Kuwait)",
@@ -210,48 +417,91 @@ static const char* locale_names[]={
"Arabic (Qatar)",
"Arabic (Saudi Arabia)",
"Arabic (Sudan)",
+"Arabic (South Soudan)",
"Arabic (Syria)",
"Arabic (Tunisia)",
"Arabic (Yemen)",
+"Assamese (India)",
+"Asturian (Spain)",
+"Southern Aymara (Peru)",
+"Aymara (Peru)",
+"Azerbaijani (Azerbaijan)",
"Belarusian",
"Belarusian (Belarus)",
+"Bemba (Zambia)",
+"Berber languages (Algeria)",
+"Berber languages (Morocco)",
"Bulgarian",
"Bulgarian (Bulgaria)",
+"Bhili (India)",
+"Bhojpuri (India)",
+"Bislama (Tuvalu)",
"Bengali",
"Bengali (Bangladesh)",
"Bengali (India)",
+"Tibetan",
+"Tibetan (China)",
+"Tibetan (India)",
+"Breton (France)",
+"Bodo (India)",
+"Bosnian (Bosnia and Herzegovina)",
+"Bilin (Eritrea)",
"Catalan",
+"Catalan (Andorra)",
"Catalan (Spain)",
+"Catalan (France)",
+"Catalan (Italy)",
+"Chechen (Russia)",
+"Cherokee (United States)",
+"Mandarin Chinese (Taiwan)",
+"Crimean Tatar (Ukraine)",
+"Kashubian (Poland)",
"Czech",
"Czech (Czech Republic)",
+"Chuvash (Russia)",
+"Welsh (United Kingdom)",
"Danish",
"Danish (Denmark)",
"German",
"German (Austria)",
+"German (Belgium)",
"German (Switzerland)",
"German (Germany)",
+"German (Italy)",
"German (Luxembourg)",
+"Dogri (India)",
+"Dhivehi (Maldives)",
+"Dzongkha (Bhutan)",
"Greek",
"Greek (Cyprus)",
"Greek (Greece)",
"English",
+"English (Antigua and Barbuda)",
"English (Australia)",
+"English (Botswana)",
"English (Canada)",
+"English (Denmark)",
"English (United Kingdom)",
+"English (Hong Kong)",
"English (Ireland)",
+"English (Israel)",
"English (India)",
-"English (Malta)",
+"English (Nigeria)",
"English (New Zealand)",
"English (Philippines)",
"English (Singapore)",
"English (United States)",
"English (South Africa)",
+"English (Zambia)",
+"English (Zimbabwe)",
+"Esperanto",
"Spanish",
"Spanish (Argentina)",
"Spanish (Bolivia)",
"Spanish (Chile)",
"Spanish (Colombia)",
"Spanish (Costa Rica)",
+"Spanish (Cuba)",
"Spanish (Dominican Republic)",
"Spanish (Ecuador)",
"Spanish (Spain)",
@@ -269,91 +519,231 @@ static const char* locale_names[]={
"Spanish (Venezuela)",
"Estonian",
"Estonian (Estonia)",
+"Basque",
+"Basque (Spain)",
+"Persian",
+"Persian (Iran)",
+"Fulah (Senegal)",
"Finnish",
"Finnish (Finland)",
+"Filipino (Philippines)",
+"Faroese (Faroe Islands)",
"French",
"French (Belgium)",
"French (Canada)",
"French (Switzerland)",
"French (France)",
"French (Luxembourg)",
+"Friulian (Italy)",
+"Western Frisian (Germany)",
+"Western Frisian (Netherlands)",
"Irish",
"Irish (Ireland)",
+"Scottish Gaelic (United Kingdom)",
+"Geez (Eritrea)",
+"Geez (Ethiopia)",
+"Galician (Spain)",
+"Gujarati (India)",
+"Manx (United Kingdom)",
+"Hakka Chinese (Taiwan)",
+"Hausa (Nigeria)",
+"Hebrew",
+"Hebrew (Israel)",
+"Hindi",
"Hindi (India)",
-"Hindi (India)",
+"Chhattisgarhi (India)",
"Croatian",
"Croatian (Croatia)",
+"Upper Sorbian (Germany)",
+"Haitian (Haiti)",
"Hungarian",
"Hungarian (Hungary)",
+"Huastec (Mexico)",
+"Armenian (Armenia)",
+"Interlingua (France)",
"Indonesian",
"Indonesian (Indonesia)",
+"Igbo (Nigeria)",
+"Inupiaq (Canada)",
"Icelandic",
"Icelandic (Iceland)",
"Italian",
"Italian (Switzerland)",
"Italian (Italy)",
-"Hebrew",
-"Hebrew (Israel)",
+"Inuktitut (Canada)",
"Japanese",
"Japanese (Japan)",
-"Japanese (Japan JP)",
+"Kabyle (Algeria)",
+"Georgian (Georgia)",
+"Kazakh (Kazakhstan)",
+"Kalaallisut (Greenland)",
+"Central Khmer (Cambodia)",
+"Kannada (India)",
+"Konkani (India)",
"Korean",
"Korean (South Korea)",
+"Kashmiri (India)",
+"Kurdish",
+"Kurdish (Turkey)",
+"Cornish (United Kingdom)",
+"Kirghiz (Kyrgyzstan)",
+"Luxembourgish (Luxembourg)",
+"Ganda (Uganda)",
+"Limburgan (Belgium)",
+"Limburgan (Netherlands)",
+"Ligurian (Italy)",
+"Lingala (Congo)",
+"Lao (Laos)",
"Lithuanian",
"Lithuanian (Lithuania)",
"Latvian",
"Latvian (Latvia)",
+"Literary Chinese (Taiwan)",
+"Magahi (India)",
+"Maithili (India)",
+"Malagasy (Madagascar)",
+"Marshallese (Marshall Islands)",
+"Eastern Mari (Russia)",
+"Maori (New Zealand)",
+"Mískito (Nicaragua)",
"Macedonian",
"Macedonian (Macedonia)",
+"Malayalam (India)",
+"Manipuri (India)",
+"Mongolian (Mongolia)",
+"Marathi (India)",
"Malay",
"Malay (Malaysia)",
"Maltese",
"Maltese (Malta)",
+"Burmese (Myanmar)",
+"Erzya (Russia)",
+"Nahuatl languages (Mexico)",
+"Min Nan Chinese (Taiwan)",
+"Norwegian Bokmål",
+"Norwegian Bokmål (Norway)",
+"Low German (Germany)",
+"Low German (Netherlands)",
+"Nepali (Nepal)",
+"Central Nahuatl (Mexico)",
+"Niuean (Niue)",
+"Niuean (New Zealand)",
"Dutch",
+"Dutch (Aruba)",
"Dutch (Belgium)",
"Dutch (Netherlands)",
-"Norwegian",
-"Norwegian (Norway)",
-"Norwegian (Norway Nynorsk)",
+"Norwegian Nynorsk",
+"Norwegian Nynorsk (Norway)",
+"South Ndebele (South Africa)",
+"Pedi (South Africa)",
+"Occitan (France)",
+"Oromo",
+"Oromo (Ethiopia)",
+"Oromo (Kenya)",
+"Oriya (India)",
+"Ossetian (Russia)",
+"Panjabi (India)",
+"Papiamento",
+"Papiamento (Netherlands Antilles)",
+"Papiamento (Aruba)",
+"Papiamento (Curaçao)",
+"Panjabi (Pakistan)",
"Polish",
"Polish (Poland)",
+"Pushto (Afghanistan)",
"Portuguese",
"Portuguese (Brazil)",
"Portuguese (Portugal)",
+"Ayacucho Quechua (Peru)",
+"Cusco Quechua (Peru)",
+"Rajasthani (India)",
"Romanian",
"Romanian (Romania)",
"Russian",
"Russian (Russia)",
+"Russian (Ukraine)",
+"Kinyarwanda (Rwanda)",
+"Sanskrit (India)",
+"Santali (India)",
+"Sardinian (Italy)",
+"Sindhi (India)",
+"Northern Sami (Norway)",
+"Samogitian (Lithuania)",
+"Shuswap (Canada)",
+"Sidamo (Ethiopia)",
+"Sinhala (Sri Lanka)",
"Slovak",
"Slovak (Slovakia)",
"Slovenian",
"Slovenian (Slovenia)",
+"Somali",
+"Somali (Djibouti)",
+"Somali (Ethiopia)",
+"Somali (Kenya)",
+"Somali (Somalia)",
+"Songhai languages (Mali)",
"Albanian",
"Albanian (Albania)",
+"Albanian (Kosovo)",
+"Albanian (Macedonia)",
"Serbian",
-"Serbian (Bosnia and Herzegovina)",
-"Serbian (Serbia and Montenegro)",
"Serbian (Montenegro)",
"Serbian (Serbia)",
+"Swati (South Africa)",
+"Southern Sotho (South Africa)",
"Swedish",
+"Swedish (Finland)",
"Swedish (Sweden)",
+"Swahili (Kenya)",
+"Swahili (Tanzania)",
+"Silesian (Poland)",
+"Tamil",
+"Tamil (India)",
+"Tamil (Sri Lanka)",
+"Tulu (India)",
+"Telugu (India)",
+"Tajik (Tajikistan)",
+"Chitwania Tharu (Nepal)",
"Thai",
"Thai (Thailand)",
-"Thai (Thailand TH)",
+"Tigrinya",
+"Tigrinya (Eritrea)",
+"Tigrinya (Ethiopia)",
+"Tigre (Eritrea)",
+"Turkmen (Turkmenistan)",
+"Tagalog (Philippines)",
+"Tswana (South Africa)",
"Turkish",
+"Turkish (Cyprus)",
"Turkish (Turkey)",
+"Tsonga (South Africa)",
+"Tatar (Russia)",
+"Uighur (China)",
"Ukrainian",
"Ukrainian (Ukraine)",
+"Unami (United States)",
"Urdu",
"Urdu (India)",
"Urdu (Pakistan)",
+"Uzbek",
+"Uzbek (Uzbekistan)",
+"Venda (South Africa)",
"Vietnamese",
"Vietnamese (Vietnam)",
+"Walloon (Belgium)",
+"Walser (Switzerland)",
+"Wolaytta (Ethiopia)",
+"Wolof (Senegal)",
+"Xhosa (South Africa)",
+"Yiddish (United States)",
+"Yoruba (Nigeria)",
+"Yue Chinese (Hong Kong)",
"Chinese",
"Chinese (China)",
"Chinese (Hong Kong)",
"Chinese (Singapore)",
"Chinese (Taiwan)",
+"Zulu (South Africa)",
0
};
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index d6d32ccae..e8a71d499 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -52,26 +52,46 @@ void UndoRedo::_discard_redo() {
}
-
-void UndoRedo::create_action(const String& p_name,bool p_mergeable) {
+void UndoRedo::create_action(const String& p_name,MergeMode p_mode) {
if (action_level==0) {
_discard_redo();
- if (p_mergeable && actions.size() && actions[actions.size()-1].name==p_name) {
- //old will replace new (it's mergeable after all)
- // should check references though!
+ // Check if the merge operation is valid
+ if (p_mode!=MERGE_DISABLE && actions.size() && actions[actions.size()-1].name==p_name) {
+
current_action=actions.size()-2;
- actions[current_action+1].do_ops.clear();
- //actions[current_action+1].undo_ops.clear(); - no, this is kept
- merging=true;
+
+ if (p_mode==MERGE_ENDS) {
+
+ // Clear all do ops from last action, and delete all object references
+ List<Operation>::Element *E=actions[current_action+1].do_ops.front();
+
+ while (E) {
+
+ if (E->get().type==Operation::TYPE_REFERENCE) {
+
+ Object *obj=ObjectDB::get_instance(E->get().object);
+
+ if (obj)
+ memdelete(obj);
+ }
+
+ E=E->next();
+ actions[current_action+1].do_ops.pop_front();
+ }
+ }
+
+ merge_mode=p_mode;
} else {
+
Action new_action;
new_action.name=p_name;
actions.push_back(new_action);
- merging=false;
+
+ merge_mode=MERGE_DISABLE;
}
}
@@ -102,8 +122,10 @@ void UndoRedo::add_undo_method(Object *p_object,const String& p_method,VARIANT_A
VARIANT_ARGPTRS
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
- if (merging)
- return; //- no undo if merging
+
+ // No undo if the merge mode is MERGE_ENDS
+ if (merge_mode==MERGE_ENDS)
+ return;
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
@@ -139,6 +161,10 @@ void UndoRedo::add_undo_property(Object *p_object,const String& p_property,const
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
+ // No undo if the merge mode is MERGE_ENDS
+ if (merge_mode==MERGE_ENDS)
+ return;
+
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
if (p_object->cast_to<Resource>())
@@ -167,6 +193,11 @@ void UndoRedo::add_undo_reference(Object *p_object) {
ERR_FAIL_COND(action_level<=0);
ERR_FAIL_COND((current_action+1)>=actions.size());
+
+ // No undo if the merge mode is MERGE_ENDS
+ if (merge_mode==MERGE_ENDS)
+ return;
+
Operation undo_op;
undo_op.object=p_object->get_instance_ID();
if (p_object->cast_to<Resource>())
@@ -352,7 +383,7 @@ UndoRedo::UndoRedo() {
action_level=0;
current_action=-1;
max_steps=-1;
- merging=true;
+ merge_mode=MERGE_DISABLE;
callback=NULL;
callback_ud=NULL;
@@ -448,7 +479,7 @@ Variant UndoRedo::_add_undo_method(const Variant** p_args, int p_argcount, Varia
void UndoRedo::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("create_action","name","mergeable"),&UndoRedo::create_action, DEFVAL(false) );
+ ObjectTypeDB::bind_method(_MD("create_action","name","merge_mode"),&UndoRedo::create_action, DEFVAL(MERGE_DISABLE) );
ObjectTypeDB::bind_method(_MD("commit_action"),&UndoRedo::commit_action);
//ObjectTypeDB::bind_method(_MD("add_do_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_do_method);
@@ -459,13 +490,9 @@ void UndoRedo::_bind_methods() {
mi.name="add_do_method";
mi.arguments.push_back( PropertyInfo( Variant::OBJECT, "object"));
mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
- Vector<Variant> defargs;
- for(int i=0;i<VARIANT_ARG_MAX;++i) {
- mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
- defargs.push_back(Variant());
- }
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"add_do_method",&UndoRedo::_add_do_method,mi,defargs);
+
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"add_do_method",&UndoRedo::_add_do_method,mi);
}
{
@@ -473,13 +500,9 @@ void UndoRedo::_bind_methods() {
mi.name="add_undo_method";
mi.arguments.push_back( PropertyInfo( Variant::OBJECT, "object"));
mi.arguments.push_back( PropertyInfo( Variant::STRING, "method"));
- Vector<Variant> defargs;
- for(int i=0;i<VARIANT_ARG_MAX;++i) {
- mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i)));
- defargs.push_back(Variant());
- }
- ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"add_undo_method",&UndoRedo::_add_undo_method,mi,defargs);
+
+ ObjectTypeDB::bind_vararg_method(METHOD_FLAGS_DEFAULT,"add_undo_method",&UndoRedo::_add_undo_method,mi);
}
ObjectTypeDB::bind_method(_MD("add_do_property","object", "property", "value:Variant"),&UndoRedo::add_do_property);
@@ -489,4 +512,8 @@ void UndoRedo::_bind_methods() {
ObjectTypeDB::bind_method(_MD("clear_history"),&UndoRedo::clear_history);
ObjectTypeDB::bind_method(_MD("get_current_action_name"),&UndoRedo::get_current_action_name);
ObjectTypeDB::bind_method(_MD("get_version"),&UndoRedo::get_version);
+
+ BIND_CONSTANT(MERGE_DISABLE);
+ BIND_CONSTANT(MERGE_ENDS);
+ BIND_CONSTANT(MERGE_ALL);
}
diff --git a/core/undo_redo.h b/core/undo_redo.h
index 7f63ba9ed..208eb6ed5 100644
--- a/core/undo_redo.h
+++ b/core/undo_redo.h
@@ -41,6 +41,12 @@ class UndoRedo : public Object {
OBJ_SAVE_TYPE( UndoRedo );
public:
+ enum MergeMode {
+ MERGE_DISABLE,
+ MERGE_ENDS,
+ MERGE_ALL
+ };
+
typedef void (*CommitNotifyCallback)(void *p_ud,const String& p_name);
Variant _add_do_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
Variant _add_undo_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
@@ -76,7 +82,7 @@ private:
int current_action;
int action_level;
int max_steps;
- bool merging;
+ MergeMode merge_mode;
uint64_t version;
void _pop_history_tail();
@@ -98,7 +104,7 @@ protected:
public:
- void create_action(const String& p_name="",bool p_mergeable=false);
+ void create_action(const String& p_name="",MergeMode p_mode=MERGE_DISABLE);
void add_do_method(Object *p_object,const String& p_method,VARIANT_ARG_LIST);
void add_undo_method(Object *p_object,const String& p_method,VARIANT_ARG_LIST);
@@ -128,4 +134,6 @@ public:
~UndoRedo();
};
+VARIANT_ENUM_CAST( UndoRedo::MergeMode );
+
#endif // UNDO_REDO_H
diff --git a/core/variant.h b/core/variant.h
index b8b028a76..90be593bd 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -426,7 +426,7 @@ public:
static void get_constructor_list(Variant::Type p_type, List<MethodInfo> *p_list);
static void get_numeric_constants_for_type(Variant::Type p_type, List<StringName> *p_constants);
static bool has_numeric_constant(Variant::Type p_type, const StringName& p_value);
- static int get_numeric_constant_value(Variant::Type p_type, const StringName& p_value);
+ static int get_numeric_constant_value(Variant::Type p_type, const StringName& p_value,bool *r_valid=NULL);
typedef String (*ObjectDeConstruct)(const Variant& p_object,void *ud);
typedef void (*ObjectConstruct)(const String& p_text,void *ud,Variant& r_value);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 069c20bc6..8473fdcd1 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -54,10 +54,10 @@ struct _VariantCall {
int arg_count;
Vector<Variant> default_args;
Vector<Variant::Type> arg_types;
-
-#ifdef DEBUG_ENABLED
Vector<StringName> arg_names;
Variant::Type return_type;
+
+#ifdef DEBUG_ENABLED
bool returns;
#endif
VariantFunc func;
@@ -518,6 +518,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(ByteArray,append);
VCALL_LOCALMEM1(ByteArray,append_array);
VCALL_LOCALMEM0(ByteArray,invert);
+ VCALL_LOCALMEM2R(ByteArray,subarray);
VCALL_LOCALMEM0R(IntArray,size);
VCALL_LOCALMEM2(IntArray,set);
@@ -1324,14 +1325,22 @@ bool Variant::has_numeric_constant(Variant::Type p_type, const StringName& p_val
return cd.value.has(p_value);
}
-int Variant::get_numeric_constant_value(Variant::Type p_type, const StringName& p_value) {
+int Variant::get_numeric_constant_value(Variant::Type p_type, const StringName& p_value, bool *r_valid) {
+
+ if (r_valid)
+ *r_valid=false;
ERR_FAIL_INDEX_V(p_type,Variant::VARIANT_MAX,0);
_VariantCall::ConstantData& cd = _VariantCall::constant_data[p_type];
Map<StringName,int>::Element *E = cd.value.find(p_value);
- ERR_FAIL_COND_V(!E,0);
+ if (!E) {
+ return -1;
+ }
+ if (r_valid)
+ *r_valid=true;
+
return E->get();
}
@@ -1584,6 +1593,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
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());
+ ADDFUNC2(RAW_ARRAY,RAW_ARRAY,ByteArray,subarray,INT,"from",INT,"to",varray());
ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_ascii,varray());
ADDFUNC0(RAW_ARRAY,STRING,ByteArray,get_string_from_utf8,varray());
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index c537ed230..fd64b58bd 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -3046,7 +3046,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const {
const String *str=reinterpret_cast<const String*>(_data._mem);
int idx = r_iter;
idx++;
- if (idx >= str->size())
+ if (idx >= str->length())
return false;
r_iter = idx;
return true;