summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/tests/test_math.cpp1
-rw-r--r--core/math/math_2d.cpp2
-rw-r--r--core/math/math_2d.h8
-rw-r--r--core/math/math_funcs.cpp36
-rw-r--r--core/math/math_funcs.h2
-rw-r--r--core/math/matrix3.cpp13
-rw-r--r--core/math/quat.cpp2
-rw-r--r--core/math/vector3.cpp2
-rw-r--r--core/variant_parser.cpp4
-rw-r--r--doc/base/classes.xml15
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp11
-rw-r--r--modules/gdscript/gd_functions.cpp2
-rw-r--r--platform/windows/godot_res.rc16
-rw-r--r--platform/windows/os_windows.cpp2
-rw-r--r--scene/gui/graph_edit.cpp5
-rw-r--r--scene/gui/graph_edit.h1
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/spin_box.cpp2
-rw-r--r--scene/gui/tree.cpp8
-rw-r--r--tools/editor/editor_node.cpp2
-rw-r--r--tools/editor/project_settings.cpp33
21 files changed, 106 insertions, 63 deletions
diff --git a/bin/tests/test_math.cpp b/bin/tests/test_math.cpp
index 8e08969fa4..4b686e8af8 100644
--- a/bin/tests/test_math.cpp
+++ b/bin/tests/test_math.cpp
@@ -113,6 +113,7 @@ uint32_t ihash3( uint32_t a)
MainLoop* test() {
+ print_line(itos(Math::step_decimals( 0.0001 )));
return NULL;
{
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index 0e2060008c..cf01e972a4 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 ad4655b8f7..5f511c933e 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/math_funcs.cpp b/core/math/math_funcs.cpp
index 0fbd031214..64615fe6b4 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -206,25 +206,29 @@ double Math::ceil(double p_x) {
return ::ceil(p_x);
}
-int Math::decimals(double p_step) {
-
- int max=4;
- double llimit = Math::pow(0.1,max);
- double ulimit = 1.0-llimit;
- int i=0;
- while( max) {
-
- float d = absf(p_step) - Math::floor(absf(p_step));
+int Math::step_decimals(double p_step) {
+
+ static const int maxn=9;
+ static const double sd[maxn]={
+ 0.9999, // somehow compensate for floating point error
+ 0.09999,
+ 0.009999,
+ 0.0009999,
+ 0.00009999,
+ 0.000009999,
+ 0.0000009999,
+ 0.00000009999,
+ 0.000000009999
+ };
- if (d<llimit || d>ulimit)
- break;
- p_step*=10.0;
- max--;
- i++;
+ double as=absf(p_step);
+ for(int i=0;i<maxn;i++) {
+ if (as>=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 2e1b9c989e..fc76d96b2e 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/core/math/matrix3.cpp b/core/math/matrix3.cpp
index 71e6b62212..7b811c245c 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 c6c12129b3..5457638ada 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 8afd73f482..8a0a6e963d 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_parser.cpp b/core/variant_parser.cpp
index dce873a306..023605a952 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;
}
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index d70b11b5ae..dc24231dd0 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -4546,6 +4546,15 @@
Searches the array in reverse order for a value and returns its index or -1 if not found.
</description>
</method>
+ <method name="has">
+ <return type="bool">
+ </return>
+ <argument index="0" name="value" type="var">
+ </argument>
+ <description>
+ Return true if the array contains given value. [code][ "inside", 7 ].has("inside") == true, [ "inside", 7 ].has("outside") == false, [ "inside", 7 ].has(7) == true, [ "inside", 7 ].has("7") == false[/code]
+ </description>
+ </method>
<method name="hash">
<return type="int">
</return>
@@ -12264,7 +12273,7 @@
file.open("user://save_game.dat", file.WRITE)
file.store_string(content)
file.close()
-
+
func load():
var file = File.new()
file.open("user://save_game.dat", file.READ)
@@ -15692,7 +15701,7 @@
</brief_description>
<description>
</description>
- ImmediateGeometry is a node used for displaying simple geometry created from code, very similar to how glBegin() and glEnd() worked in old versions of OpenGL (1.x).
+ ImmediateGeometry is a node used for displaying simple geometry created from code, very similar to how glBegin() and glEnd() worked in old versions of OpenGL (1.x).
Simply call [method begin()], and add vertices. For custom vertex colors, uvs, normal, etc. call one of the set_ functions below before adding each vertex. When done, call [method end]
Calls to begin/end are accumulative and all geometry is added together. To clear all the geometry, call [method clear].
If a material override is set, and this material contains a texture, it's possible to override the texture used in this material for every begin/end set of calls.
@@ -42401,7 +42410,7 @@
Because it is easy to get it wrong, here is a quick usage example:
[codeblock]
var tween = get_node("Tween")
- tween.interpolate_property(get_node("Node2D_to_move"), "transform/pos", Vector2(0,0), Vector2(100,100), Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
+ tween.interpolate_property(get_node("Node2D_to_move"), "transform/pos", Vector2(0,0), Vector2(100,100), 1, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
[/codeblock]
Some of the methods of this class require a property name. You can get the property name by hovering over the property in the inspector of the editor.
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 4cd97a7f6a..ba93a26a2d 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -10788,8 +10788,17 @@ void RasterizerGLES2::init() {
if (OS::get_singleton()->is_stdout_verbose()) {
print_line(String("GLES2: Using GLEW ") + (const char*) glewGetString(GLEW_VERSION));
}
-#endif
+ // Check for GL 2.1 compatibility, if not bail out
+ if (!glewIsSupported("GL_VERSION_2_1")) {
+ ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 2.1 / GLES 2.0, sorry :(\n"
+ "Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault.");
+ OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 2.1 / GLES 2.0, sorry :(\n"
+ "Godot Engine will self-destruct as soon as you acknowledge this error message.",
+ "Fatal error: Insufficient OpenGL / GLES drivers");
+ // TODO: If it's even possible, we should stop the execution without segfault and memory leaks :)
+ }
+#endif
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index b9815a5efd..a565e866d0 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/platform/windows/godot_res.rc b/platform/windows/godot_res.rc
index 5f1e951e0f..b86869d316 100644
--- a/platform/windows/godot_res.rc
+++ b/platform/windows/godot_res.rc
@@ -3,12 +3,18 @@
#define _STR(m_x) #m_x
#define _MKSTR(m_x) _STR(m_x)
#endif
+#ifndef VERSION_PATCH
+#define VERSION_PATCH 0
+#define PATCH_STRING
+#else
+#define PATCH_STRING "." _MKSTR(VERSION_PATCH)
+#endif
GODOT_ICON ICON platform/windows/godot.ico
1 VERSIONINFO
-FILEVERSION VERSION_MAJOR,VERSION_MINOR,0,0
-PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,0,0
+FILEVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_PATCH,0
+PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_PATCH,0
FILEOS 4
FILETYPE 1
BEGIN
@@ -17,13 +23,13 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Godot Engine"
- VALUE "FileDescription", _MKSTR(VERSION_NAME) " Editor (" _MKSTR(VERSION_STATUS) ")"
- VALUE "FileVersion", _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "."_MKSTR(VERSION_REVISION)
+ VALUE "FileDescription", _MKSTR(VERSION_NAME) " Editor"
+ VALUE "FileVersion", _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH)
VALUE "ProductName", _MKSTR(VERSION_NAME)
VALUE "Licence", "MIT"
VALUE "LegalCopyright", "Copyright (c) 2007-" _MKSTR(VERSION_YEAR) " Juan Linietsky, Ariel Manzur"
VALUE "Info", "http://www.godotengine.org"
- VALUE "ProductVersion", _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "."_MKSTR(VERSION_REVISION)
+ VALUE "ProductVersion", _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) PATCH_STRING "." _MKSTR(VERSION_REVISION)
END
END
BLOCK "VarFileInfo"
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index a3858fe641..571277f91e 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1343,7 +1343,7 @@ void OS_Windows::vprint(const char* p_format, va_list p_list, bool p_stderr) {
void OS_Windows::alert(const String& p_alert,const String& p_title) {
if (!is_no_window_mode_enabled())
- MessageBoxW(NULL,p_alert.c_str(),p_title.c_str(),MB_OK|MB_ICONEXCLAMATION);
+ MessageBoxW(NULL, p_alert.c_str(), p_title.c_str(), MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
else
print_line("ALERT: "+p_alert);
}
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 06b1c42690..9ad621b7aa 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -548,7 +548,9 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {
just_selected=true;
- drag_accum+=Vector2(p_ev.mouse_motion.relative_x,p_ev.mouse_motion.relative_y);
+ // TODO: Remove local mouse pos hack if/when InputEventMouseMotion is fixed to support floats
+ //drag_accum+=Vector2(p_ev.mouse_motion.relative_x,p_ev.mouse_motion.relative_y);
+ drag_accum = get_local_mouse_pos() - drag_origin;
for(int i=get_child_count()-1;i>=0;i--) {
GraphNode *gn=get_child(i)->cast_to<GraphNode>();
if (gn && gn->is_selected())
@@ -665,6 +667,7 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
dragging = true;
drag_accum = Vector2();
+ drag_origin = get_local_mouse_pos();
just_selected = !gn->is_selected();
if(!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
for (int i = 0; i < get_child_count(); i++) {
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index ac4e71ba49..ed6838ac1d 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -92,6 +92,7 @@ private:
bool dragging;
bool just_selected;
Vector2 drag_accum;
+ Point2 drag_origin; // Workaround for GH-5907
float zoom;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 89c235e101..fcea12fd6b 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -468,7 +468,7 @@ void LineEdit::_input_event(InputEvent p_event) {
if (handled) {
accept_event();
- } else {
+ } else if (!k.mod.alt && !k.mod.command) {
if (k.unicode>=32 && k.scancode!=KEY_DELETE) {
if (editable) {
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 2b64d36a81..98e1a32aef 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 82459ba0ab..487f62ed44 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<Texture> 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 ) {
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 2839708f8d..f27a753464 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -2842,7 +2842,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case SETTINGS_ABOUT: {
- about->popup_centered(Size2(500,130)*EDSCALE);
+ about->popup_centered_minsize(Size2(500,130)*EDSCALE);
} break;
case SOURCES_REIMPORT: {
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp
index 6be1abf52f..e8d22143ee 100644
--- a/tools/editor/project_settings.cpp
+++ b/tools/editor/project_settings.cpp
@@ -1375,34 +1375,35 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
input_base->set_area_as_parent_rect();;
tab_container->add_child(input_base);
+ VBoxContainer *vbc = memnew( VBoxContainer );
+ input_base->add_child(vbc);
+ vbc->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 5 );
+ vbc->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 5 );
+ vbc->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 5 );
+ vbc->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 5 );
+
l = memnew( Label );
- input_base->add_child(l);
+ vbc->add_child(l);
l->set_pos(Point2(6,5));
l->set_text(TTR("Action:"));
+ hbc = memnew( HBoxContainer );
+ vbc->add_child(hbc);
+
action_name = memnew( LineEdit );
- action_name->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
- action_name->set_begin( Point2(5,25) );
- action_name->set_end( Point2(0.85,26) );
- input_base->add_child(action_name);
+ action_name->set_h_size_flags(SIZE_EXPAND_FILL);
+ hbc->add_child(action_name);
action_name->connect("text_entered",this,"_action_adds");
add = memnew( Button );
- input_base->add_child(add);
- add->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
- add->set_begin( Point2(0.86,25) );
- add->set_anchor(MARGIN_RIGHT,ANCHOR_END);
- add->set_end( Point2(5,26) );
+ hbc->add_child(add);
+ add->set_custom_minimum_size(Size2(150, 0));
add->set_text(TTR("Add"));
add->connect("pressed",this,"_action_add");
input_editor = memnew( Tree );
- input_base->add_child(input_editor);
- input_editor->set_area_as_parent_rect();
- input_editor->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 55 );
- input_editor->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
- input_editor->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 5 );
- input_editor->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 5 );
+ vbc->add_child(input_editor);
+ input_editor->set_v_size_flags(SIZE_EXPAND_FILL);
input_editor->connect("item_edited",this,"_action_edited");
input_editor->connect("cell_selected",this,"_action_selected");
input_editor->connect("button_pressed",this,"_action_button_pressed");