From 96eb97cbbf8acd38a44ecb914e12aeda322d0bd4 Mon Sep 17 00:00:00 2001 From: Pawel Kowal Date: Sat, 2 Jul 2016 19:03:35 +0200 Subject: Array has(var value) function --- core/array.cpp | 4 ++++ core/array.h | 1 + core/variant_call.cpp | 2 ++ 3 files changed, 7 insertions(+) (limited to 'core') diff --git a/core/array.cpp b/core/array.cpp index bb8e52730..23792f90f 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -200,6 +200,10 @@ int Array::count(const Variant& p_value) const { return amount; } +bool Array::has(const Variant& p_value) const { + return _p->array.find(p_value, 0) != -1; +} + void Array::remove(int p_pos) { _p->array.remove(p_pos); diff --git a/core/array.h b/core/array.h index 096660653..dfc902525 100644 --- a/core/array.h +++ b/core/array.h @@ -75,6 +75,7 @@ public: int rfind(const Variant& p_value, int p_from=-1) const; int find_last(const Variant& p_value) const; int count(const Variant& p_value) const; + bool has(const Variant& p_value) const; void erase(const Variant& p_value); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index a5927bb6f..a56627970 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -474,6 +474,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM2R(Array,rfind); VCALL_LOCALMEM1R(Array,find_last); VCALL_LOCALMEM1R(Array,count); + VCALL_LOCALMEM1R(Array,has); VCALL_LOCALMEM1(Array,erase); VCALL_LOCALMEM0(Array,sort); VCALL_LOCALMEM2(Array,sort_custom); @@ -1516,6 +1517,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC2(ARRAY,INT,Array,rfind,NIL,"what",INT,"from",varray(-1)); ADDFUNC1(ARRAY,INT,Array,find_last,NIL,"value",varray()); ADDFUNC1(ARRAY,INT,Array,count,NIL,"value",varray()); + ADDFUNC1(ARRAY,BOOL,Array,has,NIL,"value",varray()); ADDFUNC0(ARRAY,NIL,Array,pop_back,varray()); ADDFUNC0(ARRAY,NIL,Array,pop_front,varray()); ADDFUNC0(ARRAY,NIL,Array,sort,varray()); -- cgit v1.2.3-70-g09d2 From 5d52146ff783e8966562b1feb144ef1fee03a6f5 Mon Sep 17 00:00:00 2001 From: Johan Manuel Date: Sat, 23 Jul 2016 14:47:49 +0200 Subject: Fix warnings in core/variant_op.cpp Adds default cases in switches where needed, and replaces '0;' with ';;' in macro expansions (as suggested by @vnen in #5587). --- core/variant_op.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 9182dcde1..c537ed230 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -600,6 +600,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& case REAL: { _RETURN( *reinterpret_cast(p_a._data._mem) * p_b._data._real); } break; + default: {} }; r_valid=false; return; @@ -618,6 +619,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& _RETURN( *p_a._data._matrix3 * *p_b._data._matrix3 ); }; + default: {} } ; r_valid=false; return; @@ -635,6 +637,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& _RETURN( *p_a._data._transform * *p_b._data._transform ); }; + default: {} } ; r_valid=false; return; @@ -999,7 +1002,7 @@ Variant Variant::get_named(const StringName& p_index, bool *r_valid) const { DEFAULT_OP_ARRAY_CMD(m_name, DVector, if(skip_cond) return;, arr->set(index, p_value);return) #define DEFAULT_OP_DVECTOR_GET(m_name, dv_type)\ - DEFAULT_OP_ARRAY_CMD(m_name, const DVector, 0, return arr->get(index)) + DEFAULT_OP_ARRAY_CMD(m_name, const DVector, ;, return arr->get(index)) void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) { @@ -2417,7 +2420,7 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const { return *res; } } break; // 20 - DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, 0, return (*arr)[index]) + DEFAULT_OP_ARRAY_CMD(ARRAY, const Array, ;, return (*arr)[index]) DEFAULT_OP_DVECTOR_GET(RAW_ARRAY, uint8_t) DEFAULT_OP_DVECTOR_GET(INT_ARRAY, int) DEFAULT_OP_DVECTOR_GET(REAL_ARRAY, real_t) @@ -2994,6 +2997,7 @@ bool Variant::iter_init(Variant& r_iter,bool &valid) const { return true; } break; + default: {} } @@ -3137,6 +3141,7 @@ bool Variant::iter_next(Variant& r_iter,bool &valid) const { r_iter=idx; return true; } break; + default: {} } @@ -3279,6 +3284,7 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const { #endif return arr->get(idx); } break; + default: {} } -- cgit v1.2.3-70-g09d2 From 308d405c31f83ce538fea76d6e88931718afc012 Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Sun, 24 Jul 2016 00:02:19 +0200 Subject: Turn some prints to error logs, remove others Fixes #5876 in passing. --- core/io/image_loader.cpp | 3 +-- core/math/geometry.cpp | 14 +++++++------- core/object_type_db.cpp | 2 +- tools/editor/editor_file_system.cpp | 2 +- tools/editor/io_plugins/editor_mesh_import_plugin.cpp | 1 - 5 files changed, 10 insertions(+), 12 deletions(-) (limited to 'core') diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 05bad97e9..ac6c00dc6 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -51,7 +51,7 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom Error err; f=FileAccess::open(p_file,FileAccess::READ,&err); if (!f) { - print_line("ERROR OPENING FILE: "+p_file); + ERR_PRINTS("Error opening file: "+p_file); return err; } } @@ -76,7 +76,6 @@ Error ImageLoader::load_image(String p_file,Image *p_image, FileAccess *p_custom } - print_line("NO LOADER?"); if (!p_custom) memdelete(f); diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 5b767212f..790903eff 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -629,7 +629,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro // create and initialize cells to zero - print_line("Wrapper: Initializing Cells"); + //print_line("Wrapper: Initializing Cells"); uint8_t ***cell_status=memnew_arr(uint8_t**,div_x); for(int i=0;i Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro } // plot faces into cells - print_line("Wrapper (1/6): Plotting Faces"); + //print_line("Wrapper (1/6): Plotting Faces"); for (int i=0;i Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro // determine which cells connect to the outside by traversing the outside and recursively flood-fill marking - print_line("Wrapper (2/6) Flood Filling"); + //print_line("Wrapper (2/6): Flood Filling"); for (int i=0;i Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro // build faces for the inside-outside cell divisors - print_line("Wrapper (3/6): Building Faces"); + //print_line("Wrapper (3/6): Building Faces"); DVector wrapped_faces; @@ -709,7 +709,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro } } - print_line("Wrapper (4/6): Transforming Back Vertices"); + //print_line("Wrapper (4/6): Transforming Back Vertices"); // transform face vertices to global coords @@ -728,7 +728,7 @@ DVector< Face3 > Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro } // clean up grid - print_line("Wrapper (5/6): Grid Cleanup"); + //print_line("Wrapper (5/6): Grid Cleanup"); for(int i=0;i Geometry::wrap_geometry( DVector< Face3 > p_array,float *p_erro if (p_error) *p_error=voxelsize.length(); - print_line("Wrapper (6/6): Finished."); + //print_line("Wrapper (6/6): Finished."); return wrapped_faces; } diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp index 5f97df39a..499826396 100644 --- a/core/object_type_db.cpp +++ b/core/object_type_db.cpp @@ -828,7 +828,7 @@ MethodBind* ObjectTypeDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , c TypeInfo *type=types.getptr(instance_type); if (!type) { - print_line("couldn't bind method "+mdname+" for instance: "+instance_type); + ERR_PRINTS("Couldn't bind method '"+mdname+"' for instance: "+instance_type); memdelete(p_bind); ERR_FAIL_COND_V(!type,NULL); } diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index cb7cefea2..582b9e249 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -657,7 +657,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir,DirAccess da->change_dir(".."); } } else { - ERR_PRINTS(TTR("Cannot go into subdir:")+" "+E->get()); + ERR_PRINTS("Cannot go into subdir: "+E->get()); } p_progress.update(idx,total); diff --git a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp index 2c3ed2afd..da608292c 100644 --- a/tools/editor/io_plugins/editor_mesh_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_mesh_import_plugin.cpp @@ -496,7 +496,6 @@ Error EditorMeshImportPlugin::import(const String& p_path, const Refulimit) - break; - p_step*=10.0; - max--; - i++; + double as=absf(p_step); + for(int i=0;i=sd[i]) { + return i; + } } - return i; - + return maxn; } double Math::ease(double p_x, double p_c) { diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 2e1b9c989..fc76d96b2 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -66,7 +66,7 @@ public: static double floor(double p_x); static double ceil(double p_x); static double ease(double p_x, double p_c); - static int decimals(double p_step); + static int step_decimals(double p_step); static double stepify(double p_value,double p_step); static void seed(uint32_t x=0); static void randomize(); diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index b9815a5ef..a565e866d 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -304,7 +304,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va case MATH_DECIMALS: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); - r_ret=Math::decimals(*p_args[0]); + r_ret=Math::step_decimals(*p_args[0]); } break; case MATH_STEPIFY: { VALIDATE_ARG_COUNT(2); diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 2b64d36a8..98e1a32ae 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -39,7 +39,7 @@ Size2 SpinBox::get_minimum_size() const { void SpinBox::_value_changed(double) { - String value = String::num(get_val(),Math::decimals(get_step())); + String value = String::num(get_val(),Math::step_decimals(get_step())); if (prefix!="") value=prefix+" "+value; if (suffix!="") diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 82459ba0a..487f62ed4 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1179,8 +1179,8 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& Ref updown = cache.updown; - //String valtext = String::num( p_item->cells[i].val, Math::decimals( p_item->cells[i].step ) ); - String valtext = rtos( p_item->cells[i].val ); + String valtext = String::num( p_item->cells[i].val, Math::step_decimals( p_item->cells[i].step ) ); + //String valtext = rtos( p_item->cells[i].val ); font->draw( ci, text_pos, valtext, col, item_rect.size.x-updown->get_width()); if (!p_item->cells[i].editable) @@ -1746,7 +1746,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ } else { - editor_text=String::num( p_item->cells[col].val, Math::decimals( p_item->cells[col].step ) ); + editor_text=String::num( p_item->cells[col].val, Math::step_decimals( p_item->cells[col].step ) ); if (select_mode==SELECT_MULTI && get_tree()->get_last_event_id() == focus_in_id) bring_up_editor=false; @@ -2521,7 +2521,7 @@ bool Tree::edit_selected() { text_editor->set_pos( textedpos ); text_editor->set_size( rect.size); text_editor->clear(); - text_editor->set_text( c.mode==TreeItem::CELL_MODE_STRING?c.text:rtos(c.val) ); + text_editor->set_text( c.mode==TreeItem::CELL_MODE_STRING?c.text:String::num( c.val, Math::step_decimals( c.step ) ) ); text_editor->select_all(); if (c.mode==TreeItem::CELL_MODE_RANGE || c.mode==TreeItem::CELL_MODE_RANGE_EXPRESSION ) { -- cgit v1.2.3-70-g09d2 From 2150855fafd76f881bf5b1389d7740216981aaf0 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Wed, 27 Jul 2016 17:59:42 +0300 Subject: Fix reading of empty StringArray-s in .tscn Closes #5912 --- core/variant_parser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index dce873a30..023605a95 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -1233,7 +1233,9 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in } get_token(p_stream,token,line,r_err_str); - if (token.type!=TK_STRING) { + if (token.type==TK_PARENTHESIS_CLOSE) { + break; + } else if (token.type!=TK_STRING) { r_err_str="Expected string"; return ERR_PARSE_ERROR; } -- cgit v1.2.3-70-g09d2 From eefca1ada97a6bc5db38936d23da323a78b2044d Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Tue, 26 Jul 2016 17:19:49 +0200 Subject: Prettier str() for some math types --- core/math/math_2d.cpp | 2 +- core/math/math_2d.h | 8 ++++---- core/math/matrix3.cpp | 13 ++++++++++--- core/math/quat.cpp | 2 +- core/math/vector3.cpp | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) (limited to 'core') diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 0e2060008..cf01e972a 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -658,5 +658,5 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons Matrix32::operator String() const { - return String(String()+elements[0]+", "+elements[1]+", "+elements[2]); + return "("+String(String()+elements[0]+", "+elements[1]+", "+elements[2])+")"; } diff --git a/core/math/math_2d.h b/core/math/math_2d.h index ad4655b8f..5f511c933 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -157,7 +157,7 @@ struct Vector2 { float get_aspect() const { return width/height; } - operator String() const { return String::num(x)+","+String::num(y); } + operator String() const { return "("+String::num(x)+", "+String::num(y)+")"; } _FORCE_INLINE_ Vector2(float p_x,float p_y) { x=p_x; y=p_y; } _FORCE_INLINE_ Vector2() { x=0; y=0; } @@ -356,7 +356,7 @@ struct Rect2 { } - operator String() const { return String(pos)+","+String(size); } + operator String() const { return "("+String(pos)+", "+String(size)+")"; } Rect2() {} Rect2( float p_x, float p_y, float p_width, float p_height) { pos=Point2(p_x,p_y); size=Size2( p_width, p_height ); } @@ -409,7 +409,7 @@ struct Point2i { float get_aspect() const { return width/(float)height; } - operator String() const { return String::num(x)+","+String::num(y); } + operator String() const { return "("+String::num(x)+", "+String::num(y)+")"; } operator Vector2() const { return Vector2(x,y); } inline Point2i(const Vector2& p_vec2) { x=(int)p_vec2.x; y=(int)p_vec2.y; } @@ -540,7 +540,7 @@ struct Rect2i { } - operator String() const { return String(pos)+","+String(size); } + operator String() const { return "("+String(pos)+", "+String(size)+")"; } operator Rect2() const { return Rect2(pos,size); } Rect2i(const Rect2& p_r2) { pos=p_r2.pos; size=p_r2.size; } diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index 71e6b6221..7b811c245 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -233,19 +233,26 @@ bool Matrix3::operator!=(const Matrix3& p_matrix) const { Matrix3::operator String() const { - String mtx; + String mtx("("); for (int i=0;i<3;i++) { + if (i!=0) + mtx+=", "; + + mtx+="("; + for (int j=0;j<3;j++) { - if (i!=0 || j!=0) + if (j!=0) mtx+=", "; mtx+=rtos( elements[i][j] ); } + + mtx+=")"; } - return mtx; + return mtx+")"; } Matrix3::operator Quat() const { diff --git a/core/math/quat.cpp b/core/math/quat.cpp index c6c12129b..5457638ad 100644 --- a/core/math/quat.cpp +++ b/core/math/quat.cpp @@ -252,7 +252,7 @@ Quat Quat::cubic_slerp(const Quat& q, const Quat& prep, const Quat& postq,const Quat::operator String() const { - return String::num(x)+","+String::num(y)+","+ String::num(z)+","+ String::num(w); + return "("+String::num(x)+", "+String::num(y)+", "+ String::num(z)+", "+ String::num(w)+")"; } Quat::Quat(const Vector3& axis, const real_t& angle) { diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index 8afd73f48..8a0a6e963 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -182,5 +182,5 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co # endif Vector3::operator String() const { - return (rtos(x)+", "+rtos(y)+", "+rtos(z)); + return "("+(rtos(x)+", "+rtos(y)+", "+rtos(z))+")"; } -- cgit v1.2.3-70-g09d2 From 2d4c4b6ea9947607227e55682d195ebd05d383c6 Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Thu, 28 Jul 2016 14:41:15 +0200 Subject: Fix regression with str() improvements for math types --- core/math/math_2d.cpp | 2 +- core/math/math_2d.h | 8 ++++---- core/math/matrix3.cpp | 13 +++---------- core/math/quat.cpp | 2 +- core/math/vector3.cpp | 2 +- core/variant.cpp | 40 ++++++++++++++++++++++++++++++++++------ 6 files changed, 44 insertions(+), 23 deletions(-) (limited to 'core') diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index cf01e972a..0e2060008 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -658,5 +658,5 @@ Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) cons Matrix32::operator String() const { - return "("+String(String()+elements[0]+", "+elements[1]+", "+elements[2])+")"; + return String(String()+elements[0]+", "+elements[1]+", "+elements[2]); } diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 5f511c933..fbf700fb9 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -157,7 +157,7 @@ struct Vector2 { float get_aspect() const { return width/height; } - operator String() const { return "("+String::num(x)+", "+String::num(y)+")"; } + operator String() const { return String::num(x)+", "+String::num(y); } _FORCE_INLINE_ Vector2(float p_x,float p_y) { x=p_x; y=p_y; } _FORCE_INLINE_ Vector2() { x=0; y=0; } @@ -356,7 +356,7 @@ struct Rect2 { } - operator String() const { return "("+String(pos)+", "+String(size)+")"; } + operator String() const { return String(pos)+", "+String(size); } Rect2() {} Rect2( float p_x, float p_y, float p_width, float p_height) { pos=Point2(p_x,p_y); size=Size2( p_width, p_height ); } @@ -409,7 +409,7 @@ struct Point2i { float get_aspect() const { return width/(float)height; } - operator String() const { return "("+String::num(x)+", "+String::num(y)+")"; } + operator String() const { return String::num(x)+", "+String::num(y); } operator Vector2() const { return Vector2(x,y); } inline Point2i(const Vector2& p_vec2) { x=(int)p_vec2.x; y=(int)p_vec2.y; } @@ -540,7 +540,7 @@ struct Rect2i { } - operator String() const { return "("+String(pos)+", "+String(size)+")"; } + operator String() const { return String(pos)+", "+String(size); } operator Rect2() const { return Rect2(pos,size); } Rect2i(const Rect2& p_r2) { pos=p_r2.pos; size=p_r2.size; } diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index 7b811c245..71e6b6221 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -233,26 +233,19 @@ bool Matrix3::operator!=(const Matrix3& p_matrix) const { Matrix3::operator String() const { - String mtx("("); + String mtx; for (int i=0;i<3;i++) { - if (i!=0) - mtx+=", "; - - mtx+="("; - for (int j=0;j<3;j++) { - if (j!=0) + if (i!=0 || j!=0) mtx+=", "; mtx+=rtos( elements[i][j] ); } - - mtx+=")"; } - return mtx+")"; + return mtx; } Matrix3::operator Quat() const { diff --git a/core/math/quat.cpp b/core/math/quat.cpp index 5457638ad..73124e5e8 100644 --- a/core/math/quat.cpp +++ b/core/math/quat.cpp @@ -252,7 +252,7 @@ Quat Quat::cubic_slerp(const Quat& q, const Quat& prep, const Quat& postq,const Quat::operator String() const { - return "("+String::num(x)+", "+String::num(y)+", "+ String::num(z)+", "+ String::num(w)+")"; + return String::num(x)+", "+String::num(y)+", "+ String::num(z)+", "+ String::num(w); } Quat::Quat(const Vector3& axis, const real_t& angle) { diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index 8a0a6e963..8afd73f48 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -182,5 +182,5 @@ Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, co # endif Vector3::operator String() const { - return "("+(rtos(x)+", "+rtos(y)+", "+rtos(z))+")"; + return (rtos(x)+", "+rtos(y)+", "+rtos(z)); } diff --git a/core/variant.cpp b/core/variant.cpp index 31321dc0f..a78c07d81 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1515,15 +1515,43 @@ Variant::operator String() const { case INT: return String::num(_data._int); case REAL: return String::num(_data._real); case STRING: return *reinterpret_cast(_data._mem); - case VECTOR2: return operator Vector2(); - case RECT2: return operator Rect2(); - case MATRIX32: return operator Matrix32(); - case VECTOR3: return operator Vector3(); + case VECTOR2: return "("+operator Vector2()+")"; + case RECT2: return "("+operator Rect2()+")"; + case MATRIX32: { + + Matrix32 mat32 = operator Matrix32(); + return "("+Variant(mat32.elements[0]).operator String()+", "+Variant(mat32.elements[1]).operator String()+", "+Variant(mat32.elements[2]).operator String()+")"; + } break; + case VECTOR3: return "("+operator Vector3()+")"; case PLANE: return operator Plane(); //case QUAT: case _AABB: return operator AABB(); - case QUAT: return operator Quat(); - case MATRIX3: return operator Matrix3(); + case QUAT: return "("+operator Quat()+")"; + case MATRIX3: { + + Matrix3 mat3 = operator Matrix3(); + + String mtx("("); + for (int i=0;i<3;i++) { + + if (i!=0) + mtx+=", "; + + mtx+="("; + + for (int j=0;j<3;j++) { + + if (j!=0) + mtx+=", "; + + mtx+=Variant( mat3.elements[i][j] ).operator String(); + } + + mtx+=")"; + } + + return mtx+")"; + } break; case TRANSFORM: return operator Transform(); case NODE_PATH: return operator NodePath(); case INPUT_EVENT: return operator InputEvent(); -- cgit v1.2.3-70-g09d2 From 09c4d65b64892f945aeb98a4abcedab42126c248 Mon Sep 17 00:00:00 2001 From: allkhor Date: Sun, 31 Jul 2016 00:18:30 +0600 Subject: Fix String::is_valid_integer() for single symbols + and - --- core/ustring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/ustring.cpp b/core/ustring.cpp index 6788ada1b..0d887210c 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3491,7 +3491,7 @@ bool String::is_valid_integer() const { return false; int from=0; - if (operator[](0)=='+' || operator[](0)=='-') + if (len!=1 && (operator[](0)=='+' || operator[](0)=='-')) from++; for(int i=from;i - Stop the function execution and return the current state. Call resume on the state to resume execution. This makes the state invalid. + Stop the function execution and return the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state. Returns anything that was passed to the resume function call. If passed an object and a signal, the execution is resumed when the object's signal is emmited. @@ -13042,8 +13042,11 @@ + Reference to a function in an object. + In GDScript, functions are not [i]first-class objects[/i]. This means it is impossible to store them directly as variables, return them from another function, or pass them as arguments. + However, by creating a [FuncRef] using the [method @GDScript.funcref] function, a reference to a function in a given object can be created, passed around and called. @@ -13068,18 +13071,21 @@ + Call the referenced function with the given arguments. The argument count must correspond to the required number of arguments in the function. Returns the return value of the function call. + Set the name of the function to call on the object, without parentheses or any parameters. + Set the object on which to call the referenced function. This object must be of a type actually inheriting from [Object], not a built-in type such as [int], [Vector2] or [Dictionary]. @@ -13088,15 +13094,17 @@ + State of a function call after yielding. + Calling [method @GDScript.yield] within a function will cause that function to yield and return its current state as an object of this type. The yielded function call can then be resumed later by calling [method resume] on this state object. - Should put children to the top left corner instead of center of the container. + Check whether the function call may be resumed. This is not the case if the function state was already resumed. @@ -13105,6 +13113,9 @@ + Resume execution of the yielded function call. + If handed an argument, return the argument from the [method @GDScript.yield] call in the yielded function call. You can pass e.g. an [Array] to hand multiple arguments. + This function returns what the resumed function call returns, possibly another function state if yielded again. @@ -17235,20 +17246,25 @@ + Placeholder for the root [Node] of a [PackedScene]. + Turning on the option [b]Load As Placeholder[/b] for an instanced scene in the editor causes it to be replaced by an InstacePlaceholder when running the game. This makes it possible to delay actually loading the scene until calling [method replace_by_instance]. This is useful to avoid loading large scenes all at once by loading parts of it selectively. + The InstancePlaceholder does not have a transform. This causes any child nodes to be positioned relatively to the Viewport from point (0,0), rather than their parent as displayed in the editor. Replacing the placeholder with a scene with a transform will transform children relatively to their parent again. + Retrieve the path to the [PackedScene] resource file that is loaded by default when calling [method replace_by_instance]. + Replace this placeholder by the scene handed as an argument, or the original scene if no argument is given. As for all resources, the scene is loaded only if it's not loaded already. By manually loading the scene beforehand, delays caused by this function can be avoided. @@ -30280,8 +30296,10 @@ + Handle for a [Resource]'s unique ID. + The RID type is used to access the unique integer ID of a resource. They are opaque, so they do not grant access to the associated resource by themselves. They are used by and with the low-level Server classes such as [VisualServer]. @@ -30290,12 +30308,14 @@ + Create a new RID instance with the ID of a given resource. When not handed a valid resource, silently stores the unused ID 0. + Retrieve the ID of the referenced resource. @@ -46584,24 +46604,28 @@ + Retrieve the [RID] of this world's canvas resource. Used by the [VisualServer] for 2D drawing. + Retrieve the state of this world's physics space. This allows arbitrary querying for collision. + Retrieve the [RID] of this world's sound space resource. Used by the [SpatialSound2DServer] for 2D spatial audio. + Retrieve the [RID] of this world's physics space resource. Used by the [Physics2DServer] for 2D physics, treating it as both a space and an area. diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 520a8b18d..b02e55cf9 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -297,7 +297,7 @@ void GDScriptLanguage::get_public_functions(List *p_functions) const } { MethodInfo mi; - mi.name="yield"; + mi.name="yield:GDFunctionState"; mi.arguments.push_back(PropertyInfo(Variant::OBJECT,"object")); mi.arguments.push_back(PropertyInfo(Variant::STRING,"signal")); mi.default_arguments.push_back(Variant::NIL); -- cgit v1.2.3-70-g09d2