diff options
-rw-r--r-- | core/pool_vector.h | 6 | ||||
-rw-r--r-- | doc/classes/Area.xml | 15 | ||||
-rw-r--r-- | doc/classes/Area2D.xml | 23 | ||||
-rw-r--r-- | doc/classes/OS.xml | 2 | ||||
-rw-r--r-- | doc/classes/Object.xml | 1 | ||||
-rw-r--r-- | editor/editor_help.cpp | 12 | ||||
-rw-r--r-- | editor/editor_layouts_dialog.cpp | 2 | ||||
-rw-r--r-- | modules/bullet/collision_object_bullet.cpp | 2 | ||||
-rw-r--r-- | scene/2d/area_2d.cpp | 8 | ||||
-rw-r--r-- | scene/3d/vehicle_body.cpp | 2 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 32 | ||||
-rw-r--r-- | scene/gui/line_edit.h | 3 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 31 | ||||
-rw-r--r-- | scene/gui/rich_text_label.h | 1 |
14 files changed, 102 insertions, 38 deletions
diff --git a/core/pool_vector.h b/core/pool_vector.h index 102a620f17..338de966f6 100644 --- a/core/pool_vector.h +++ b/core/pool_vector.h @@ -411,8 +411,8 @@ public: p_to = size() + p_to; } - CRASH_BAD_INDEX(p_from, size()); - CRASH_BAD_INDEX(p_to, size()); + ERR_FAIL_INDEX_V(p_from, size(), PoolVector<T>()); + ERR_FAIL_INDEX_V(p_to, size(), PoolVector<T>()); PoolVector<T> slice; int span = 1 + p_to - p_from; @@ -511,6 +511,8 @@ const T PoolVector<T>::operator[](int p_index) const { template <class T> Error PoolVector<T>::resize(int p_size) { + ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER); + if (alloc == NULL) { if (p_size == 0) diff --git a/doc/classes/Area.xml b/doc/classes/Area.xml index c39c570be9..d40376414f 100644 --- a/doc/classes/Area.xml +++ b/doc/classes/Area.xml @@ -56,7 +56,8 @@ <argument index="0" name="body" type="Node"> </argument> <description> - If [code]true[/code], the given body overlaps the Area. Note that the result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. + If [code]true[/code], the given physics body overlaps the Area. Note that the result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. + The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </method> <method name="set_collision_layer_bit"> @@ -183,14 +184,16 @@ <argument index="0" name="body" type="Node"> </argument> <description> - Emitted when a [PhysicsBody] object enters. + Emitted when a physics body enters. + The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_exited"> <argument index="0" name="body" type="Node"> </argument> <description> - Emitted when a [PhysicsBody] object exits. + Emitted when a physics body exits. + The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_shape_entered"> @@ -203,7 +206,8 @@ <argument index="3" name="area_shape" type="int"> </argument> <description> - Emitted when a [PhysicsBody] object enters, reporting which shapes overlapped. + Emitted when a physics body enters, reporting which shapes overlapped. + The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_shape_exited"> @@ -216,7 +220,8 @@ <argument index="3" name="area_shape" type="int"> </argument> <description> - Emitted when a [PhysicsBody] object exits, reporting which shapes were overlapping. + Emitted when a physics body exits, reporting which shapes were overlapping. + The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> </signals> diff --git a/doc/classes/Area2D.xml b/doc/classes/Area2D.xml index 8d28ddc889..4771a976b5 100644 --- a/doc/classes/Area2D.xml +++ b/doc/classes/Area2D.xml @@ -56,7 +56,8 @@ <argument index="0" name="body" type="Node"> </argument> <description> - If [code]true[/code], the given body overlaps the Area2D. Note that the result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. + If [code]true[/code], the given physics body overlaps the Area2D. Note that the result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. + The [code]body[/code] argument can either be a [PhysicsBody2D] or a [TileMap] instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </method> <method name="set_collision_layer_bit"> @@ -168,43 +169,47 @@ </description> </signal> <signal name="body_entered"> - <argument index="0" name="body" type="PhysicsBody2D"> + <argument index="0" name="body" type="Node"> </argument> <description> - Emitted when a [PhysicsBody2D] object enters. + Emitted when a physics body enters. + The [code]body[/code] argument can either be a [PhysicsBody2D] or a [TileMap] instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_exited"> - <argument index="0" name="body" type="PhysicsBody2D"> + <argument index="0" name="body" type="Node"> </argument> <description> - Emitted when a [PhysicsBody2D] object exits. + Emitted when a physics body exits. + The [code]body[/code] argument can either be a [PhysicsBody2D] or a [TileMap] instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_shape_entered"> <argument index="0" name="body_id" type="int"> </argument> - <argument index="1" name="body" type="PhysicsBody2D"> + <argument index="1" name="body" type="Node"> </argument> <argument index="2" name="body_shape" type="int"> </argument> <argument index="3" name="area_shape" type="int"> </argument> <description> - Emitted when a [PhysicsBody2D] object enters, reporting which shapes overlapped. + Emitted when a physics body enters, reporting which shapes overlapped. + The [code]body[/code] argument can either be a [PhysicsBody2D] or a [TileMap] instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> <signal name="body_shape_exited"> <argument index="0" name="body_id" type="int"> </argument> - <argument index="1" name="body" type="PhysicsBody2D"> + <argument index="1" name="body" type="Node"> </argument> <argument index="2" name="body_shape" type="int"> </argument> <argument index="3" name="area_shape" type="int"> </argument> <description> - Emitted when a [PhysicsBody2D] object exits, reporting which shapes were overlapping. + Emitted when a physics body exits, reporting which shapes were overlapping. + The [code]body[/code] argument can either be a [PhysicsBody2D] or a [TileMap] instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body). </description> </signal> </signals> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 7b50021284..3292438851 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -4,7 +4,7 @@ Operating System functions. </brief_description> <description> - Operating System functions. OS Wraps the most common functionality to communicate with the host Operating System, such as: mouse grabbing, mouse cursors, clipboard, video mode, date and time, timers, environment variables, execution of binaries, command line, etc. + Operating System functions. OS Wraps the most common functionality to communicate with the host Operating System, such as: clipboard, video mode, date and time, timers, environment variables, execution of binaries, command line, etc. </description> <tutorials> </tutorials> diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index c9910360ed..548a0c18bb 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -374,6 +374,7 @@ <argument index="1" name="value" type="Variant"> </argument> <description> + Set property into the object, after the current frame's physics step. This is equivalent to calling [method set] via [method call_deferred], i.e. [code]call_deferred("set", [property, value])[/code]. </description> </method> <method name="set_indexed"> diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 26d793cf65..4bfb967351 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -416,6 +416,7 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->add_newline(); + class_desc->add_newline(); class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); @@ -441,6 +442,7 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->pop(); + class_desc->add_newline(); class_desc->push_indent(1); class_desc->push_table(2); class_desc->set_table_column_expand(1, 1); @@ -479,14 +481,15 @@ void EditorHelp::_update_doc() { class_desc->push_color(headline_color); _add_text(cd.properties[i].name); + class_desc->pop(); + class_desc->pop(); + if (describe) { class_desc->pop(); property_descr = true; } class_desc->pop(); - class_desc->pop(); - class_desc->pop(); } class_desc->pop(); //table @@ -519,6 +522,7 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->pop(); + class_desc->add_newline(); class_desc->push_font(doc_code_font); class_desc->push_indent(1); class_desc->push_table(2); @@ -876,6 +880,7 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->add_newline(); + class_desc->add_newline(); class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); @@ -1000,6 +1005,7 @@ void EditorHelp::_update_doc() { class_desc->pop(); // table class_desc->add_newline(); + class_desc->add_newline(); class_desc->push_color(text_color); class_desc->push_font(doc_font); @@ -1042,6 +1048,8 @@ void EditorHelp::_update_doc() { class_desc->pop(); class_desc->add_newline(); + class_desc->add_newline(); + class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); diff --git a/editor/editor_layouts_dialog.cpp b/editor/editor_layouts_dialog.cpp index 01e4762196..36f7b30016 100644 --- a/editor/editor_layouts_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -120,7 +120,7 @@ EditorLayoutsDialog::EditorLayoutsDialog() { layout_names->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5); layout_names->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5); layout_names->set_v_size_flags(Control::SIZE_EXPAND_FILL); - layout_names->set_select_mode(ItemList::SelectMode::SELECT_MULTI); + layout_names->set_select_mode(ItemList::SELECT_MULTI); layout_names->set_allow_rmb_select(true); name = memnew(LineEdit); diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index 166d7e6158..e1800fd3eb 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -305,7 +305,7 @@ void RigidCollisionObjectBullet::set_shape_transform(int p_index, const Transfor ERR_FAIL_INDEX(p_index, get_shape_count()); shapes.write[p_index].set_transform(p_transform); - reload_shapes(); + shape_changed(p_index); } const btTransform &RigidCollisionObjectBullet::get_bt_shape_transform(int p_index) const { diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index b322cfe8f1..b701e84a9c 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -657,10 +657,10 @@ void Area2D::_bind_methods() { ClassDB::bind_method(D_METHOD("_body_inout"), &Area2D::_body_inout); ClassDB::bind_method(D_METHOD("_area_inout"), &Area2D::_area_inout); - ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape"))); - ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape"))); - ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D"))); - ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsBody2D"))); + ADD_SIGNAL(MethodInfo("body_shape_entered", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape"))); + ADD_SIGNAL(MethodInfo("body_shape_exited", PropertyInfo(Variant::INT, "body_id"), PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::INT, "body_shape"), PropertyInfo(Variant::INT, "area_shape"))); + ADD_SIGNAL(MethodInfo("body_entered", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); + ADD_SIGNAL(MethodInfo("body_exited", PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "Node"))); ADD_SIGNAL(MethodInfo("area_shape_entered", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape"))); ADD_SIGNAL(MethodInfo("area_shape_exited", PropertyInfo(Variant::INT, "area_id"), PropertyInfo(Variant::OBJECT, "area", PROPERTY_HINT_RESOURCE_TYPE, "Area2D"), PropertyInfo(Variant::INT, "area_shape"), PropertyInfo(Variant::INT, "self_shape"))); diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index 32b8219ee0..55bb7eabd9 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -585,7 +585,7 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec if (p_rollInfluence > 0.0) { // !BAS! But seeing we apply this frame by frame, makes more sense to me to make this time based // keeping in mind our anti roll factor if it is set - contactDamping = s->get_step() / p_rollInfluence; + contactDamping = MIN(contactDamping, s->get_step() / p_rollInfluence); } #define ONLY_USE_LINEAR_MASS diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index da6bff8ab8..a0429fe8d1 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -650,6 +650,11 @@ void LineEdit::_notification(int p_what) { set_cursor_position(get_cursor_position()); } break; + case NOTIFICATION_TRANSLATION_CHANGED: { + placeholder_translated = tr(placeholder); + update_placeholder_width(); + update(); + } break; case MainLoop::NOTIFICATION_WM_FOCUS_IN: { window_has_focus = true; draw_caret = true; @@ -728,7 +733,7 @@ void LineEdit::_notification(int p_what) { Color font_color_selected = get_color("font_color_selected"); Color cursor_color = get_color("cursor_color"); - const String &t = using_placeholder ? placeholder : text; + const String &t = using_placeholder ? placeholder_translated : text; // draw placeholder color if (using_placeholder) font_color.a *= placeholder_alpha; @@ -1148,16 +1153,9 @@ String LineEdit::get_text() const { void LineEdit::set_placeholder(String p_text) { - placeholder = tr(p_text); - if ((max_length <= 0) || (placeholder.length() <= max_length)) { - Ref<Font> font = get_font("font"); - cached_placeholder_width = 0; - if (font != NULL) { - for (int i = 0; i < placeholder.length(); i++) { - cached_placeholder_width += font->get_char_size(placeholder[i]).width; - } - } - } + placeholder = p_text; + placeholder_translated = tr(placeholder); + update_placeholder_width(); update(); } @@ -1546,6 +1544,18 @@ void LineEdit::_emit_text_change() { text_changed_dirty = false; } +void LineEdit::update_placeholder_width() { + if ((max_length <= 0) || (placeholder_translated.length() <= max_length)) { + Ref<Font> font = get_font("font"); + cached_placeholder_width = 0; + if (font != NULL) { + for (int i = 0; i < placeholder_translated.length(); i++) { + cached_placeholder_width += font->get_char_size(placeholder_translated[i]).width; + } + } + } +} + void LineEdit::_clear_redo() { _create_undo_state(); if (undo_stack_pos == NULL) { diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 3b29780dc0..3002f6f637 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -72,6 +72,7 @@ private: String undo_text; String text; String placeholder; + String placeholder_translated; String secret_character; float placeholder_alpha; String ime_text; @@ -126,6 +127,8 @@ private: void _emit_text_change(); bool expand_to_text_length; + void update_placeholder_width(); + bool caret_blink_enabled; bool draw_caret; bool window_has_focus; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 8891f679ee..3a9a0ae21a 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -314,6 +314,18 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int & align = align_it->align; } break; + case ITEM_INDENT: { + + if (it != l.from) { + ItemIndent *indent_it = static_cast<ItemIndent *>(it); + + int indent = indent_it->level * tab_size * cfont->get_char_size(' ').width; + margin += indent; + begin += indent; + wofs += indent; + } + + } break; case ITEM_TEXT: { ItemText *text = static_cast<ItemText *>(it); @@ -1301,6 +1313,23 @@ bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item) return false; } +bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) { + + if (from && from != to) { + if (from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH) + return true; + + for (List<Item *>::Element *E = from->subitems.front(); E; E = E->next()) { + bool layout = _find_layout_subitem(E->get(), to); + + if (layout) + return true; + } + } + + return false; +} + void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) { if (p_frame->first_invalid_line == p_frame->lines.size()) @@ -1421,7 +1450,7 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) if (p_ensure_newline) { Item *from = current_frame->lines[current_frame->lines.size() - 1].from; // only create a new line for Item types that generate content/layout, ignore those that represent formatting/styling - if (from && from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH) { + if (_find_layout_subitem(from, p_item)) { _invalidate_current_line(current_frame); current_frame->lines.resize(current_frame->lines.size() + 1); } diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 114c6103e2..21d099c37a 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -286,6 +286,7 @@ private: bool _find_underline(Item *p_item); bool _find_strikethrough(Item *p_item); bool _find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item = NULL); + bool _find_layout_subitem(Item *from, Item *to); void _update_scroll(); void _scroll_changed(double); |