summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/global_constants.cpp1
-rw-r--r--core/io/file_access_pack.cpp4
-rw-r--r--core/io/file_access_pack.h1
-rw-r--r--core/io/resource_format_binary.cpp10
-rw-r--r--core/io/resource_format_xml.cpp5
-rw-r--r--core/math/camera_matrix.cpp19
-rw-r--r--core/math/geometry.h4
-rw-r--r--core/math/math_2d.h162
-rw-r--r--core/object.cpp8
-rw-r--r--core/object.h1
-rw-r--r--core/os/dir_access.h1
-rw-r--r--core/ustring.cpp79
-rw-r--r--core/ustring.h5
-rw-r--r--core/variant_call.cpp10
-rw-r--r--core/variant_op.cpp19
15 files changed, 275 insertions, 54 deletions
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index ae4abc627d..fc48a105db 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -313,6 +313,7 @@ static _GlobalConstant _global_constants[]={
BIND_GLOBAL_CONSTANT( KEY_MASK_ALT ),
BIND_GLOBAL_CONSTANT( KEY_MASK_META ),
BIND_GLOBAL_CONSTANT( KEY_MASK_CTRL ),
+ BIND_GLOBAL_CONSTANT( KEY_MASK_CMD ),
BIND_GLOBAL_CONSTANT( KEY_MASK_KPAD ),
BIND_GLOBAL_CONSTANT( KEY_MASK_GROUP_SWITCH ),
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index 6e03819aac..afbd7e3d46 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -362,6 +362,10 @@ bool DirAccessPack::current_is_dir() const{
return cdir;
}
+bool DirAccessPack::current_is_hidden() const{
+
+ return false;
+}
void DirAccessPack::list_dir_end() {
list_dirs.clear();
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index 5fcc79aaf4..2d0cf5b32e 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -208,6 +208,7 @@ public:
virtual bool list_dir_begin();
virtual String get_next();
virtual bool current_is_dir() const;
+ virtual bool current_is_hidden() const;
virtual void list_dir_end();
virtual int get_drive_count();
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index e2371fe24f..ead6984650 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1778,6 +1778,11 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
f->store_32(VERSION_MINOR);
f->store_32(FORMAT_VERSION);
+ if (f->get_error()!=OK && f->get_error()!=ERR_FILE_EOF) {
+ f->close();
+ return ERR_CANT_CREATE;
+ }
+
//f->store_32(saved_resources.size()+external_resources.size()); // load steps -not needed
save_unicode_string(p_resource->get_type());
uint64_t md_at = f->get_pos();
@@ -1910,6 +1915,11 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
f->store_buffer((const uint8_t*)"RSRC",4); //magic at end
+ if (f->get_error()!=OK && f->get_error()!=ERR_FILE_EOF) {
+ f->close();
+ return ERR_CANT_CREATE;
+ }
+
f->close();
diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp
index 75384d4ab6..033b4d5e5a 100644
--- a/core/io/resource_format_xml.cpp
+++ b/core/io/resource_format_xml.cpp
@@ -2592,6 +2592,11 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
}
exit_tag("resource_file");
+ if (f->get_error()!=OK && f->get_error()!=ERR_FILE_EOF) {
+ f->close();
+ return ERR_CANT_CREATE;
+ }
+
f->close();
//memdelete(f);
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index a60dea7379..fbe5f8c741 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -121,7 +121,7 @@ void CameraMatrix::set_orthogonal(float p_size, float p_aspect, float p_znear, f
void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, float p_top, float p_near, float p_far) {
-
+#if 0
///@TODO, give a check to this. I'm not sure if it's working.
set_identity();
@@ -133,10 +133,27 @@ void CameraMatrix::set_frustum(float p_left, float p_right, float p_bottom, floa
matrix[2][3]=-(2*p_far*p_near) / (p_far-p_near);
matrix[3][2]=-1;
matrix[3][3]=0;
+#else
+ float *te = &matrix[0][0];
+ float x = 2 * p_near / ( p_right - p_left );
+ float y = 2 * p_near / ( p_top - p_bottom );
+
+ float a = ( p_right + p_left ) / ( p_right - p_left );
+ float b = ( p_top + p_bottom ) / ( p_top - p_bottom );
+ float c = - ( p_far + p_near ) / ( p_far - p_near );
+ float d = - 2 * p_far * p_near / ( p_far - p_near );
+
+ te[0] = x; te[4] = 0; te[8] = a; te[12] = 0;
+ te[1] = 0; te[5] = y; te[9] = b; te[13] = 0;
+ te[2] = 0; te[6] = 0; te[10] = c; te[14] = d;
+ te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0;
+
+#endif
}
+
float CameraMatrix::get_z_far() const {
const float * matrix = (const float*)this->matrix;
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 7e0cc01a22..4ad4db8523 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -519,9 +519,9 @@ public:
bool s_ab = (b.x-a.x)*as_y-(b.y-a.y)*as_x > 0;
- if((c.x-a.x)*as_y-(c.y-a.y)*as_x > 0 == s_ab) return false;
+ if(((c.x-a.x)*as_y-(c.y-a.y)*as_x > 0) == s_ab) return false;
- if((c.x-b.x)*(s.y-b.y)-(c.y-b.y)*(s.x-b.x) > 0 != s_ab) return false;
+ if(((c.x-b.x)*(s.y-b.y)-(c.y-b.y)*(s.x-b.x) > 0) != s_ab) return false;
return true;
}
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index fa40d305f5..5bc1b5f0be 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -159,8 +159,8 @@ struct Vector2 {
operator String() const { return String::num(x)+","+String::num(y); }
- inline Vector2(float p_x,float p_y) { x=p_x; y=p_y; }
- inline Vector2() { x=0; y=0; }
+ _FORCE_INLINE_ Vector2(float p_x,float p_y) { x=p_x; y=p_y; }
+ _FORCE_INLINE_ Vector2() { x=0; y=0; }
};
_FORCE_INLINE_ Vector2 Vector2::plane_project(real_t p_d, const Vector2& p_vec) const {
@@ -198,6 +198,8 @@ Vector2 Vector2::linear_interpolate(const Vector2& p_a, const Vector2& p_b,float
typedef Vector2 Size2;
typedef Vector2 Point2;
+struct Matrix32;
+
struct Rect2 {
@@ -224,6 +226,8 @@ struct Rect2 {
return true;
}
+ _FORCE_INLINE_ bool intersects_transformed(const Matrix32& p_xform, const Rect2& p_rect) const;
+
bool intersects_segment(const Point2& p_from, const Point2& p_to, Point2* r_pos=NULL, Point2* r_normal=NULL) const;
inline bool encloses(const Rect2& p_rect) const {
@@ -597,6 +601,160 @@ struct Matrix32 {
};
+bool Rect2::intersects_transformed(const Matrix32& p_xform, const Rect2& p_rect) const {
+
+ //SAT intersection between local and transformed rect2
+
+ Vector2 xf_points[4]={
+ p_xform.xform(p_rect.pos),
+ p_xform.xform(Vector2(p_rect.pos.x+p_rect.size.x,p_rect.pos.y)),
+ p_xform.xform(Vector2(p_rect.pos.x,p_rect.pos.y+p_rect.size.y)),
+ p_xform.xform(Vector2(p_rect.pos.x+p_rect.size.x,p_rect.pos.y+p_rect.size.y)),
+ };
+
+ real_t low_limit;
+
+ //base rect2 first (faster)
+
+ if (xf_points[0].y>pos.y)
+ goto next1;
+ if (xf_points[1].y>pos.y)
+ goto next1;
+ if (xf_points[2].y>pos.y)
+ goto next1;
+ if (xf_points[3].y>pos.y)
+ goto next1;
+
+ return false;
+
+ next1:
+
+ low_limit=pos.y+size.y;
+
+ if (xf_points[0].y<low_limit)
+ goto next2;
+ if (xf_points[1].y<low_limit)
+ goto next2;
+ if (xf_points[2].y<low_limit)
+ goto next2;
+ if (xf_points[3].y<low_limit)
+ goto next2;
+
+ return false;
+
+ next2:
+
+ if (xf_points[0].x>pos.x)
+ goto next3;
+ if (xf_points[1].x>pos.x)
+ goto next3;
+ if (xf_points[2].x>pos.x)
+ goto next3;
+ if (xf_points[3].x>pos.x)
+ goto next3;
+
+ return false;
+
+ next3:
+
+ low_limit=pos.x+size.x;
+
+ if (xf_points[0].x<low_limit)
+ goto next4;
+ if (xf_points[1].x<low_limit)
+ goto next4;
+ if (xf_points[2].x<low_limit)
+ goto next4;
+ if (xf_points[3].x<low_limit)
+ goto next4;
+
+ return false;
+
+ next4:
+
+ Vector2 xf_points2[4]={
+ pos,
+ Vector2(pos.x+size.x,pos.y),
+ Vector2(pos.x,pos.y+size.y),
+ Vector2(pos.x+size.x,pos.y+size.y),
+ };
+
+ real_t maxa=p_xform.elements[0].dot(xf_points2[0]);
+ real_t mina=maxa;
+
+ real_t dp = p_xform.elements[0].dot(xf_points2[1]);
+ maxa=MAX(dp,maxa);
+ mina=MIN(dp,mina);
+
+ dp = p_xform.elements[0].dot(xf_points2[2]);
+ maxa=MAX(dp,maxa);
+ mina=MIN(dp,mina);
+
+ dp = p_xform.elements[0].dot(xf_points2[3]);
+ maxa=MAX(dp,maxa);
+ mina=MIN(dp,mina);
+
+ real_t maxb=p_xform.elements[0].dot(xf_points[0]);
+ real_t minb=maxb;
+
+ dp = p_xform.elements[0].dot(xf_points[1]);
+ maxb=MAX(dp,maxb);
+ minb=MIN(dp,minb);
+
+ dp = p_xform.elements[0].dot(xf_points[2]);
+ maxb=MAX(dp,maxb);
+ minb=MIN(dp,minb);
+
+ dp = p_xform.elements[0].dot(xf_points[3]);
+ maxb=MAX(dp,maxb);
+ minb=MIN(dp,minb);
+
+
+ if ( mina > maxb )
+ return false;
+ if ( minb > maxa )
+ return false;
+
+ maxa=p_xform.elements[1].dot(xf_points2[0]);
+ mina=maxa;
+
+ dp = p_xform.elements[1].dot(xf_points2[1]);
+ maxa=MAX(dp,maxa);
+ mina=MIN(dp,mina);
+
+ dp = p_xform.elements[1].dot(xf_points2[2]);
+ maxa=MAX(dp,maxa);
+ mina=MIN(dp,mina);
+
+ dp = p_xform.elements[1].dot(xf_points2[3]);
+ maxa=MAX(dp,maxa);
+ mina=MIN(dp,mina);
+
+ maxb=p_xform.elements[1].dot(xf_points[0]);
+ minb=maxb;
+
+ dp = p_xform.elements[1].dot(xf_points[1]);
+ maxb=MAX(dp,maxb);
+ minb=MIN(dp,minb);
+
+ dp = p_xform.elements[1].dot(xf_points[2]);
+ maxb=MAX(dp,maxb);
+ minb=MIN(dp,minb);
+
+ dp = p_xform.elements[1].dot(xf_points[3]);
+ maxb=MAX(dp,maxb);
+ minb=MIN(dp,minb);
+
+
+ if ( mina > maxb )
+ return false;
+ if ( minb > maxa )
+ return false;
+
+
+ return true;
+
+}
Vector2 Matrix32::basis_xform(const Vector2& v) const {
diff --git a/core/object.cpp b/core/object.cpp
index 82144ab4be..2b83f728d1 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1033,6 +1033,13 @@ void Object::add_user_signal(const MethodInfo& p_signal) {
signal_map[p_signal.name]=s;
}
+bool Object::_has_user_signal(const StringName& p_name) const {
+
+ if (!signal_map.has(p_name))
+ return false;
+ return signal_map[p_name].user.name.length()>0;
+}
+
struct _ObjectSignalDisconnectData {
StringName signal;
@@ -1431,6 +1438,7 @@ void Object::_bind_methods() {
// ObjectTypeDB::bind_method(_MD("call_deferred","method","arg1","arg2","arg3","arg4"),&Object::_call_deferred_bind,DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()),DEFVAL(Variant()));
ObjectTypeDB::bind_method(_MD("add_user_signal","signal","arguments"),&Object::_add_user_signal,DEFVAL(Array()));
+ ObjectTypeDB::bind_method(_MD("has_user_signal","signal"),&Object::_has_user_signal);
// ObjectTypeDB::bind_method(_MD("emit_signal","signal","arguments"),&Object::_emit_signal,DEFVAL(Array()));
diff --git a/core/object.h b/core/object.h
index 97ca50cb1a..eb885f5d20 100644
--- a/core/object.h
+++ b/core/object.h
@@ -386,6 +386,7 @@ friend void postinitialize_handler(Object*);
Dictionary metadata;
void _add_user_signal(const String& p_name, const Array& p_pargs=Array());
+ bool _has_user_signal(const StringName& p_name) const;
Variant _emit_signal(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
Array _get_signal_list() const;
Array _get_signal_connection_list(const String& p_signal) const;
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index d8672218bd..dc56f2308e 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -78,6 +78,7 @@ public:
virtual String get_next(bool* p_is_dir); // compatibility
virtual String get_next()=0;
virtual bool current_is_dir() const=0;
+ virtual bool current_is_hidden() const=0;
virtual void list_dir_end()=0; ///<
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 476ab3f936..497e8f29ed 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -482,7 +482,7 @@ void String::erase(int p_pos, int p_chars) {
String String::capitalize() const {
- String aux=this->replace("_"," ").to_lower();
+ String aux=this->camelcase_to_underscore().replace("_"," ").to_lower();
String cap;
for (int i=0;i<aux.get_slice_count(" ");i++) {
@@ -498,6 +498,29 @@ String String::capitalize() const {
return cap;
}
+
+
+String String::camelcase_to_underscore() const {
+ const CharType * cstr = c_str();
+ String newString;
+ const char A = 'A', Z = 'Z';
+ int startIndex = 0;
+
+ for ( int i = 1; i < this->size()-1; i++ ) {
+ bool isCapital = cstr[i] >= A && cstr[i] <= Z;
+
+ if ( isCapital ) {
+ newString += "_" + this->substr(startIndex, i-startIndex);
+ startIndex = i;
+ }
+ }
+
+ newString += "_" + this->substr(startIndex, this->size()-startIndex);
+
+ return newString;
+}
+
+
int String::get_slice_count(String p_splitter) const{
if (empty())
@@ -3550,8 +3573,8 @@ String String::lpad(int min_length, const String& character) const {
// sprintf is implemented in GDScript via:
// "fish %s pie" % "frog"
// "fish %s %d pie" % ["frog", 12]
-String String::sprintf(const Array& values) const {
-
+// In case of an error, the string returned is the error description and "error" is true.
+String String::sprintf(const Array& values, bool* error) const {
String formatted;
CharType* self = (CharType*)c_str();
int num_items = values.size();
@@ -3564,6 +3587,7 @@ String String::sprintf(const Array& values) const {
bool left_justified;
bool show_sign;
+ *error = true;
for (; *self; self++) {
const CharType c = *self;
@@ -3580,13 +3604,11 @@ String String::sprintf(const Array& values) const {
case 'x': // Hexadecimal (lowercase)
case 'X': { // Hexadecimal (uppercase)
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
if (!values[value_index].is_num()) {
- ERR_EXPLAIN("a number is required");
- ERR_FAIL_V("");
+ return "a number is required";
}
int64_t value = values[value_index];
@@ -3622,13 +3644,11 @@ String String::sprintf(const Array& values) const {
}
case 'f': { // Float
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
if (!values[value_index].is_num()) {
- ERR_EXPLAIN("a number is required");
- ERR_FAIL_V("");
+ return "a number is required";
}
double value = values[value_index];
@@ -3657,8 +3677,7 @@ String String::sprintf(const Array& values) const {
}
case 's': { // String
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
String str = values[value_index];
@@ -3676,8 +3695,7 @@ String String::sprintf(const Array& values) const {
}
case 'c': {
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
// Convert to character.
@@ -3685,22 +3703,18 @@ String String::sprintf(const Array& values) const {
if (values[value_index].is_num()) {
int value = values[value_index];
if (value < 0) {
- ERR_EXPLAIN("unsigned byte integer is lower than maximum")
- ERR_FAIL_V("");
+ return "unsigned byte integer is lower than maximum";
} else if (value > 255) {
- ERR_EXPLAIN("unsigned byte integer is greater than maximum")
- ERR_FAIL_V("");
+ return "unsigned byte integer is greater than maximum";
}
str = chr(values[value_index]);
} else if (values[value_index].get_type() == Variant::STRING) {
str = values[value_index];
if (str.length() != 1) {
- ERR_EXPLAIN("%c requires number or single-character string");
- ERR_FAIL_V("");
+ return "%c requires number or single-character string";
}
} else {
- ERR_EXPLAIN("%c requires number or single-character string");
- ERR_FAIL_V("");
+ return "%c requires number or single-character string";
}
// Padding.
@@ -3741,8 +3755,7 @@ String String::sprintf(const Array& values) const {
}
case '.': { // Float separtor.
if (in_decimals) {
- ERR_EXPLAIN("too many decimal points in format");
- ERR_FAIL_V("");
+ return "too many decimal points in format";
}
in_decimals = true;
min_decimals = 0; // We want to add the value manually.
@@ -3751,13 +3764,11 @@ String String::sprintf(const Array& values) const {
case '*': { // Dyanmic width, based on value.
if (value_index >= values.size()) {
- ERR_EXPLAIN("not enough arguments for format string");
- ERR_FAIL_V("");
+ return "not enough arguments for format string";
}
if (!values[value_index].is_num()) {
- ERR_EXPLAIN("* wants number");
- ERR_FAIL_V("");
+ return "* wants number";
}
int size = values[value_index];
@@ -3773,8 +3784,7 @@ String String::sprintf(const Array& values) const {
}
default: {
- ERR_EXPLAIN("unsupported format character");
- ERR_FAIL_V("");
+ return "unsupported format character";
}
}
} else { // Not in format string.
@@ -3796,14 +3806,13 @@ String String::sprintf(const Array& values) const {
}
if (in_format) {
- ERR_EXPLAIN("incomplete format");
- ERR_FAIL_V("");
+ return "incomplete format";
}
if (value_index != values.size()) {
- ERR_EXPLAIN("not all arguments converted during string formatting");
- ERR_FAIL_V("");
+ return "not all arguments converted during string formatting";
}
+ *error = false;
return formatted;
}
diff --git a/core/ustring.h b/core/ustring.h
index af5ffb7c35..f79e5ce306 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -130,7 +130,7 @@ public:
String pad_zeros(int p_digits) const;
String lpad(int min_length,const String& character=" ") const;
String rpad(int min_length,const String& character=" ") const;
- String sprintf(const Array& values) const;
+ String sprintf(const Array& values, bool* error) const;
static String num(double p_num,int p_decimals=-1);
static String num_scientific(double p_num);
static String num_real(double p_num);
@@ -149,6 +149,7 @@ public:
static double to_double(const CharType* p_str, const CharType **r_end=NULL);
static int64_t to_int(const CharType* p_str,int p_len=-1);
String capitalize() const;
+ String camelcase_to_underscore() const;
int get_slice_count(String p_splitter) const;
String get_slice(String p_splitter,int p_slice) const;
@@ -225,8 +226,6 @@ public:
String(const char *p_str);
String(const CharType *p_str,int p_clip_to_len=-1);
String(const StrRange& p_range);
-
-
};
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 50a60390e5..c6b498ff28 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -511,7 +511,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1(ColorArray,append_array);
#define VCALL_PTR0(m_type,m_method)\
-static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(); }
+static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(); }
#define VCALL_PTR0R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(); }
#define VCALL_PTR1(m_type,m_method)\
@@ -519,7 +519,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
#define VCALL_PTR1R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0]); }
#define VCALL_PTR2(m_type,m_method)\
-static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); }
+static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); }
#define VCALL_PTR2R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1]); }
#define VCALL_PTR3(m_type,m_method)\
@@ -531,7 +531,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
#define VCALL_PTR4R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); }
#define VCALL_PTR5(m_type,m_method)\
-static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); }
+static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); }
#define VCALL_PTR5R(m_type,m_method)\
static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { r_ret=reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3],*p_args[4]); }
@@ -685,7 +685,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_PTR0R( InputEvent, is_pressed );
VCALL_PTR1R( InputEvent, is_action );
VCALL_PTR0R( InputEvent, is_echo );
- //VCALL_PTR2( InputEvent, set_as_action );
+ VCALL_PTR2( InputEvent, set_as_action );
struct ConstructData {
@@ -1496,7 +1496,7 @@ _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());
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 */
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 21bbc8c7ee..87d9738b06 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -552,6 +552,9 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
if (p_b.type==MATRIX32) {
_RETURN( *p_a._data._matrix32 * *p_b._data._matrix32 );
};
+ if (p_b.type==VECTOR2) {
+ _RETURN( p_a._data._matrix32->xform( *(const Vector2*)p_b._data._mem) );
+ };
r_valid=false;
return;
} break;
@@ -738,18 +741,22 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
_RETURN( p_a._data._int % p_b._data._int );
} else if (p_a.type==STRING) {
- const String *str=reinterpret_cast<const String*>(p_a._data._mem);
+ const String* format=reinterpret_cast<const String*>(p_a._data._mem);
+ String result;
+ bool error;
if (p_b.type==ARRAY) {
// e.g. "frog %s %d" % ["fish", 12]
- const Array *arr=reinterpret_cast<const Array*>(p_b._data._mem);
- _RETURN(str->sprintf(*arr));
+ const Array* args=reinterpret_cast<const Array*>(p_b._data._mem);
+ result=format->sprintf(*args, &error);
} else {
// e.g. "frog %d" % 12
- Array arr;
- arr.push_back(p_b);
- _RETURN(str->sprintf(arr));
+ Array args;
+ args.push_back(p_b);
+ result=format->sprintf(args, &error);
}
+ r_valid = !error;
+ _RETURN(result);
}
r_valid=false;