diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/light.cpp | 2 | ||||
-rw-r--r-- | scene/animation/animation_player.cpp | 59 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 62 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 1 | ||||
-rw-r--r-- | scene/resources/curve.cpp | 1 |
5 files changed, 71 insertions, 54 deletions
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 16164cf3bf..762e090590 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -312,7 +312,7 @@ Light::Light(VisualServer::LightType p_type) { Light::Light() { type = VisualServer::LIGHT_DIRECTIONAL; - ERR_PRINT("Light shouldn't be instanced dircetly, use the subtypes."); + ERR_PRINT("Light should not be instanced directly; use the DirectionalLight, OmniLight or SpotLight subtypes instead."); } Light::~Light() { diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index d8db1973d2..460f62f092 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -263,43 +263,36 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { key.id = id; key.bone_idx = bone_idx; - if (node_cache_map.has(key)) { - - p_anim->node_cache.write[i] = &node_cache_map[key]; - } else { - + if (!node_cache_map.has(key)) node_cache_map[key] = TrackNodeCache(); - p_anim->node_cache.write[i] = &node_cache_map[key]; - p_anim->node_cache[i]->path = a->track_get_path(i); - p_anim->node_cache[i]->node = child; - p_anim->node_cache[i]->resource = resource; - p_anim->node_cache[i]->node_2d = Object::cast_to<Node2D>(child); - if (a->track_get_type(i) == Animation::TYPE_TRANSFORM) { - // special cases and caches for transform tracks - - // cache spatial - p_anim->node_cache[i]->spatial = Object::cast_to<Spatial>(child); - // cache skeleton - p_anim->node_cache[i]->skeleton = Object::cast_to<Skeleton>(child); - if (p_anim->node_cache[i]->skeleton) { - - if (a->track_get_path(i).get_subname_count() == 1) { - StringName bone_name = a->track_get_path(i).get_subname(0); - - p_anim->node_cache[i]->bone_idx = p_anim->node_cache[i]->skeleton->find_bone(bone_name); - if (p_anim->node_cache[i]->bone_idx < 0) { - // broken track (nonexistent bone) - p_anim->node_cache[i]->skeleton = NULL; - p_anim->node_cache[i]->spatial = NULL; - printf("bone is %ls\n", String(bone_name).c_str()); - ERR_CONTINUE(p_anim->node_cache[i]->bone_idx < 0); - } else { - } - } else { - // no property, just use spatialnode + p_anim->node_cache.write[i] = &node_cache_map[key]; + p_anim->node_cache[i]->path = a->track_get_path(i); + p_anim->node_cache[i]->node = child; + p_anim->node_cache[i]->resource = resource; + p_anim->node_cache[i]->node_2d = Object::cast_to<Node2D>(child); + if (a->track_get_type(i) == Animation::TYPE_TRANSFORM) { + // special cases and caches for transform tracks + + // cache spatial + p_anim->node_cache[i]->spatial = Object::cast_to<Spatial>(child); + // cache skeleton + p_anim->node_cache[i]->skeleton = Object::cast_to<Skeleton>(child); + if (p_anim->node_cache[i]->skeleton) { + if (a->track_get_path(i).get_subname_count() == 1) { + StringName bone_name = a->track_get_path(i).get_subname(0); + + p_anim->node_cache[i]->bone_idx = p_anim->node_cache[i]->skeleton->find_bone(bone_name); + if (p_anim->node_cache[i]->bone_idx < 0) { + // broken track (nonexistent bone) p_anim->node_cache[i]->skeleton = NULL; + p_anim->node_cache[i]->spatial = NULL; + printf("bone is %ls\n", String(bone_name).c_str()); + ERR_CONTINUE(p_anim->node_cache[i]->bone_idx < 0); } + } else { + // no property, just use spatialnode + p_anim->node_cache[i]->skeleton = NULL; } } } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index a32beecdd9..8f1971c1ee 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3119,16 +3119,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (selection.active) { int ini = selection.from_line; int end = selection.to_line; + for (int i = ini; i <= end; i++) { - if (get_line(i).begins_with("#")) - _remove_text(i, 0, i, 1); + _uncomment_line(i); } } else { - if (get_line(cursor.line).begins_with("#")) { - _remove_text(cursor.line, 0, cursor.line, 1); - if (cursor.column >= get_line(cursor.line).length()) { - cursor.column = MAX(0, get_line(cursor.line).length() - 1); - } + _uncomment_line(cursor.line); + if (cursor.column >= get_line(cursor.line).length()) { + cursor.column = MAX(0, get_line(cursor.line).length() - 1); } } update(); @@ -3208,6 +3206,24 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } } +void TextEdit::_uncomment_line(int p_line) { + String line_text = get_line(p_line); + for (int i = 0; i < line_text.length(); i++) { + if (line_text[i] == '#') { + _remove_text(p_line, i, p_line, i + 1); + if (p_line == selection.to_line && selection.to_column > line_text.length() - 1) { + selection.to_column -= 1; + if (selection.to_column >= selection.from_column) { + selection.active = false; + } + } + return; + } else if (line_text[i] != '\t' && line_text[i] != ' ') { + return; + } + } +} + void TextEdit::_scroll_up(real_t p_delta) { if (scrolling && smooth_scroll_enabled && SGN(target_v_scroll - v_scroll->get_value()) != SGN(-p_delta)) @@ -4822,28 +4838,27 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l pos = -1; - int pos_from = 0; + int pos_from = (p_search_flags & SEARCH_BACKWARDS) ? text_line.length() : 0; int last_pos = -1; while (true) { - while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) { - - if (p_search_flags & SEARCH_BACKWARDS) { - - if (last_pos > from_column) + if (p_search_flags & SEARCH_BACKWARDS) { + while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.rfind(p_key, pos_from) : text_line.rfindn(p_key, pos_from)) != -1) { + if (last_pos <= from_column) { + pos = last_pos; break; - pos = last_pos; - - } else { - + } + pos_from = last_pos - p_key.length(); + } + } else { + while ((last_pos = (p_search_flags & SEARCH_MATCH_CASE) ? text_line.find(p_key, pos_from) : text_line.findn(p_key, pos_from)) != -1) { if (last_pos >= from_column) { pos = last_pos; break; } + pos_from = last_pos + p_key.length(); } - - pos_from = last_pos + p_key.length(); } bool is_match = true; @@ -4856,11 +4871,15 @@ bool TextEdit::search(const String &p_key, uint32_t p_search_flags, int p_from_l is_match = false; } + if (pos_from == -1) { + pos = -1; + } + if (is_match || last_pos == -1 || pos == -1) { break; } - pos_from = pos + 1; + pos_from = (p_search_flags & SEARCH_BACKWARDS) ? pos - 1 : pos + 1; pos = -1; } @@ -5910,6 +5929,9 @@ void TextEdit::set_line(int line, String new_text) { if (cursor.line == line) { cursor.column = MIN(cursor.column, new_text.length()); } + if (is_selection_active() && line == selection.to_line && selection.to_column > text[line].length()) { + selection.to_column = text[line].length(); + } } void TextEdit::insert_at(const String &p_text, int at) { diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 19b5d574c6..697dc3a5e0 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -373,6 +373,7 @@ private: void _update_selection_mode_word(); void _update_selection_mode_line(); + void _uncomment_line(int p_line); void _scroll_up(real_t p_delta); void _scroll_down(real_t p_delta); diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index d8989bf062..66af816a28 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -491,6 +491,7 @@ void Curve::ensure_default_setup(float p_min, float p_max) { void Curve::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_point_count"), &Curve::get_point_count); ClassDB::bind_method(D_METHOD("add_point", "position", "left_tangent", "right_tangent", "left_mode", "right_mode"), &Curve::add_point, DEFVAL(0), DEFVAL(0), DEFVAL(TANGENT_FREE), DEFVAL(TANGENT_FREE)); ClassDB::bind_method(D_METHOD("remove_point", "index"), &Curve::remove_point); ClassDB::bind_method(D_METHOD("clear_points"), &Curve::clear_points); |