diff options
38 files changed, 174 insertions, 145 deletions
diff --git a/core/error_macros.h b/core/error_macros.h index 60a0e8a7dc..3aa8ed4596 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -154,6 +154,20 @@ extern bool _err_error_exists; _err_error_exists = false; \ } while (0); // (*) +/** An index has failed if m_index >=m_size, the function exists. +* This function returns an error value, if returning Error, please select the most +* appropriate error condition from error_macros.h +*/ + +#define ERR_FAIL_UNSIGNED_INDEX_V(m_index, m_size, m_retval) \ + do { \ + if (unlikely((m_index) >= (m_size))) { \ + _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \ + return m_retval; \ + } else \ + _err_error_exists = false; \ + } while (0); // (*) + /** Use this one if there is no sensible fallback, that is, the error is unrecoverable. * We'll return a null reference and try to keep running. */ diff --git a/core/typedefs.h b/core/typedefs.h index 0005e5e6ee..e01e1c00b9 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -116,6 +116,8 @@ T *_nullptr() { #define ABS(m_v) (((m_v) < 0) ? (-(m_v)) : (m_v)) #endif +#define ABSDIFF(x, y) (((x) < (y)) ? ((y) - (x)) : ((x) - (y))) + #ifndef SGN #define SGN(m_v) (((m_v) < 0) ? (-1.0) : (+1.0)) #endif diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 00894b41d8..40ccd95758 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -63,43 +63,37 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) { _discard_redo(); // Check if the merge operation is valid - if (p_mode != MERGE_DISABLE && actions.size() && actions[actions.size() - 1].name == p_name && actions[actions.size() - 1].last_tick + 800 > ticks) { + if (p_mode == MERGE_ENDS && actions.size() && actions[actions.size() - 1].name == p_name && actions[actions.size() - 1].last_tick + 800 > ticks) { current_action = actions.size() - 2; - if (p_mode == MERGE_ENDS) { + // Clear all do ops from last action, and delete all object references + List<Operation>::Element *E = actions.write[current_action + 1].do_ops.front(); - // Clear all do ops from last action, and delete all object references - List<Operation>::Element *E = actions.write[current_action + 1].do_ops.front(); + while (E) { - while (E) { + if (E->get().type == Operation::TYPE_REFERENCE) { - if (E->get().type == Operation::TYPE_REFERENCE) { + Object *obj = ObjectDB::get_instance(E->get().object); - Object *obj = ObjectDB::get_instance(E->get().object); - - if (obj) - memdelete(obj); - } - - E = E->next(); - actions.write[current_action + 1].do_ops.pop_front(); + if (obj) + memdelete(obj); } + + E = E->next(); + actions.write[current_action + 1].do_ops.pop_front(); } actions.write[actions.size() - 1].last_tick = ticks; - - merge_mode = p_mode; - } else { Action new_action; new_action.name = p_name; new_action.last_tick = ticks; actions.push_back(new_action); - - merge_mode = MERGE_DISABLE; } + + merge_mode = p_mode; } action_level++; diff --git a/core/ustring.cpp b/core/ustring.cpp index 17b52035dd..b9914fb530 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2393,7 +2393,7 @@ int String::find(const char *p_str, int p_from) const { return -1; } -int String::find_char(CharType p_char, int p_from) const { +int String::find_char(const CharType &p_char, int p_from) const { return _cowdata.find(p_char, p_from); } diff --git a/core/ustring.h b/core/ustring.h index 5ec5c79e2d..cb3d87378a 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -85,8 +85,7 @@ public: _FORCE_INLINE_ int size() const { return _cowdata.size(); } Error resize(int p_size) { return _cowdata.resize(p_size); } - _FORCE_INLINE_ char get(int p_index) { return _cowdata.get(p_index); } - _FORCE_INLINE_ const char get(int p_index) const { return _cowdata.get(p_index); } + _FORCE_INLINE_ char get(int p_index) const { return _cowdata.get(p_index); } _FORCE_INLINE_ void set(int p_index, const char &p_elem) { _cowdata.set(p_index, p_elem); } _FORCE_INLINE_ const char &operator[](int p_index) const { if (unlikely(p_index == _cowdata.size())) @@ -143,8 +142,7 @@ public: _FORCE_INLINE_ void clear() { resize(0); } - _FORCE_INLINE_ CharType get(int p_index) { return _cowdata.get(p_index); } - _FORCE_INLINE_ const CharType get(int p_index) const { return _cowdata.get(p_index); } + _FORCE_INLINE_ CharType get(int p_index) const { return _cowdata.get(p_index); } _FORCE_INLINE_ void set(int p_index, const CharType &p_elem) { _cowdata.set(p_index, p_elem); } _FORCE_INLINE_ int size() const { return _cowdata.size(); } Error resize(int p_size) { return _cowdata.resize(p_size); } @@ -197,7 +195,7 @@ public: String substr(int p_from, int p_chars) const; int find(const String &p_str, int p_from = 0) const; ///< return <0 if failed int find(const char *p_str, int p_from = 0) const; ///< return <0 if failed - int find_char(CharType p_char, int p_from = 0) const; ///< return <0 if failed + int find_char(const CharType &p_char, int p_from = 0) const; ///< return <0 if failed int find_last(const String &p_str) const; ///< return <0 if failed int findn(const String &p_str, int p_from = 0) const; ///< return <0 if failed, case insensitive int rfind(const String &p_str, int p_from = -1) const; ///< return <0 if failed diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index 6f6f827d60..327fb65e8e 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -2057,7 +2057,6 @@ FRAGMENT_SHADER_CODE gl_FragColor.rgb *= (1.0 - fog_interp.a); #endif // BASE_PASS - #else //pixel based fog float fog_amount = 0.0; diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 565336701a..f6d4a2665c 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -758,7 +758,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { time += 0.001; } - undo_redo->create_action("Add Bezier Point"); + undo_redo->create_action(TTR("Add Bezier Point")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, time, new_point); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", track, time); undo_redo->commit_action(); @@ -823,7 +823,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (moving_handle != 0 && mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - undo_redo->create_action("Move Bezier Points"); + undo_redo->create_action(TTR("Move Bezier Points")); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_in_handle", track, moving_handle_key, moving_handle_left); undo_redo->add_do_method(animation.ptr(), "bezier_track_set_key_out_handle", track, moving_handle_key, moving_handle_right); undo_redo->add_undo_method(animation.ptr(), "bezier_track_set_key_in_handle", track, moving_handle_key, animation->bezier_track_get_key_in_handle(track, moving_handle_key)); @@ -839,7 +839,7 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (moving_selection) { //combit it - undo_redo->create_action("Move Bezier Points"); + undo_redo->create_action(TTR("Move Bezier Points")); List<AnimMoveRestore> to_restore; // 1-remove the keys @@ -1053,7 +1053,7 @@ void AnimationBezierTrackEdit::_menu_selected(int p_index) { time += 0.001; } - undo_redo->create_action("Add Bezier Point"); + undo_redo->create_action(TTR("Add Bezier Point")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", track, time, new_point); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", track, time); undo_redo->commit_action(); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index d92b745e26..6b45ca2cae 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -693,7 +693,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { editing = true; *block_animation_update_ptr = true; - undo_redo->create_action("Change animation length"); + undo_redo->create_action(TTR("Change Animation Length")); undo_redo->add_do_method(animation.ptr(), "set_length", p_new_len); undo_redo->add_undo_method(animation.ptr(), "set_length", animation->get_length()); undo_redo->commit_action(); @@ -707,7 +707,7 @@ void AnimationTimelineEdit::_anim_length_changed(double p_new_len) { void AnimationTimelineEdit::_anim_loop_pressed() { *block_animation_update_ptr = true; - undo_redo->create_action("Change animation loop"); + undo_redo->create_action(TTR("Change Animation Loop")); undo_redo->add_do_method(animation.ptr(), "set_loop", loop->is_pressed()); undo_redo->add_undo_method(animation.ptr(), "set_loop", animation->has_loop()); undo_redo->commit_action(); @@ -1694,7 +1694,7 @@ void AnimationTrackEdit::_zoom_changed() { } void AnimationTrackEdit::_path_entered(const String &p_text) { - undo_redo->create_action("Change Track Path"); + undo_redo->create_action(TTR("Change Track Path")); undo_redo->add_do_method(animation.ptr(), "track_set_path", track, p_text); undo_redo->add_undo_method(animation.ptr(), "track_set_path", track, animation->track_get_path(track)); undo_redo->commit_action(); @@ -1885,7 +1885,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { if (check_rect.has_point(pos)) { *block_animation_update_ptr = true; - undo_redo->create_action("Toggle track enabled"); + undo_redo->create_action(TTR("Toggle Track Enabled")); undo_redo->add_do_method(animation.ptr(), "track_set_enabled", track, !animation->track_is_enabled(track)); undo_redo->add_undo_method(animation.ptr(), "track_set_enabled", track, animation->track_is_enabled(track)); undo_redo->commit_action(); @@ -2187,7 +2187,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { Animation::UpdateMode update_mode = Animation::UpdateMode(p_index); *block_animation_update_ptr = true; - undo_redo->create_action("Change animation update mode"); + undo_redo->create_action(TTR("Change Animation Update Mode")); undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", track, update_mode); undo_redo->add_undo_method(animation.ptr(), "value_track_set_update_mode", track, animation->value_track_get_update_mode(track)); undo_redo->commit_action(); @@ -2201,7 +2201,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { Animation::InterpolationType interp_mode = Animation::InterpolationType(p_index - MENU_INTERPOLATION_NEAREST); *block_animation_update_ptr = true; - undo_redo->create_action("Change animation interpolation mode"); + undo_redo->create_action(TTR("Change Animation Interpolation Mode")); undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_type", track, interp_mode); undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_type", track, animation->track_get_interpolation_type(track)); undo_redo->commit_action(); @@ -2213,7 +2213,7 @@ void AnimationTrackEdit::_menu_selected(int p_index) { bool loop_wrap = p_index == MENU_LOOP_WRAP; *block_animation_update_ptr = true; - undo_redo->create_action("Change animation loop mode"); + undo_redo->create_action(TTR("Change Animation Loop Mode")); undo_redo->add_do_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, loop_wrap); undo_redo->add_undo_method(animation.ptr(), "track_set_interpolation_loop_wrap", track, animation->track_get_interpolation_loop_wrap(track)); undo_redo->commit_action(); @@ -3478,7 +3478,7 @@ void AnimationTrackEditor::_update_scroll(double) { void AnimationTrackEditor::_update_step(double p_new_step) { - undo_redo->create_action("Change animation step"); + undo_redo->create_action(TTR("Change Animation Step")); undo_redo->add_do_method(animation.ptr(), "set_step", p_new_step); undo_redo->add_undo_method(animation.ptr(), "set_step", animation->get_step()); step->set_block_signals(true); @@ -3501,7 +3501,7 @@ void AnimationTrackEditor::_dropped_track(int p_from_track, int p_to_track) { return; _clear_selection(); - undo_redo->create_action("Rearrange tracks"); + undo_redo->create_action(TTR("Rearrange Tracks")); undo_redo->add_do_method(animation.ptr(), "track_swap", p_from_track, p_to_track); undo_redo->add_undo_method(animation.ptr(), "track_swap", p_to_track, p_from_track); undo_redo->commit_action(); @@ -3528,7 +3528,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { case Animation::TYPE_TRANSFORM: case Animation::TYPE_METHOD: { - undo_redo->create_action("Add Track"); + undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path_to); undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count()); @@ -3557,7 +3557,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { return; } - undo_redo->create_action("Add Track"); + undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path_to); undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count()); @@ -3576,7 +3576,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) { return; } - undo_redo->create_action("Add Track"); + undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), path_to); undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count()); @@ -3628,7 +3628,7 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) { } } - undo_redo->create_action("Add Track"); + undo_redo->create_action(TTR("Add Track")); undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", animation->get_track_count(), full_path); undo_redo->add_do_method(animation.ptr(), "value_track_set_update_mode", animation->get_track_count(), update_mode); @@ -3651,7 +3651,7 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) { } } - undo_redo->create_action("Add Bezier Track"); + undo_redo->create_action(TTR("Add Bezier Track")); int base_track = animation->get_track_count(); for (int i = 0; i < subindices.size(); i++) { undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); @@ -3719,7 +3719,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { Vector3 scale = xf.basis.get_scale_local(); Quat rot = xf.basis; - undo_redo->create_action("Add Transform Track Key"); + undo_redo->create_action(TTR("Add Transform Track Key")); undo_redo->add_do_method(animation.ptr(), "transform_track_insert_key", p_track, p_ofs, loc, rot, scale); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); undo_redo->commit_action(); @@ -3731,7 +3731,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { Variant value; _find_hint_for_track(p_track, bp, &value); - undo_redo->create_action("Add Track Key"); + undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, value); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); undo_redo->commit_action(); @@ -3763,7 +3763,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { arr[3] = 0.25; arr[4] = 0; - undo_redo->create_action("Add Track Key"); + undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, arr); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); undo_redo->commit_action(); @@ -3776,7 +3776,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { ak["start_offset"] = 0; ak["end_offset"] = 0; - undo_redo->create_action("Add Track Key"); + undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, ak); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); undo_redo->commit_action(); @@ -3785,7 +3785,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { StringName anim = "[stop]"; - undo_redo->create_action("Add Track Key"); + undo_redo->create_action(TTR("Add Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, anim); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", p_track, p_ofs); undo_redo->commit_action(); @@ -3825,7 +3825,7 @@ void AnimationTrackEditor::_add_method_key(const String &p_method) { } d["args"] = params; - undo_redo->create_action("Add Method Track Key"); + undo_redo->create_action(TTR("Add Method Track Key")); undo_redo->add_do_method(animation.ptr(), "track_insert_key", insert_key_from_track_call_track, insert_key_from_track_call_ofs, d); undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_position", insert_key_from_track_call_track, insert_key_from_track_call_ofs); undo_redo->commit_action(); @@ -4408,7 +4408,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { } int base_track = animation->get_track_count(); - undo_redo->create_action("Paste Tracks"); + undo_redo->create_action(TTR("Paste Tracks")); for (int i = 0; i < track_clipboard.size(); i++) { undo_redo->add_do_method(animation.ptr(), "add_track", track_clipboard[i].track_type); Node *exists = NULL; diff --git a/editor/animation_track_editor_plugins.cpp b/editor/animation_track_editor_plugins.cpp index bb0bd1b458..399d561e28 100644 --- a/editor/animation_track_editor_plugins.cpp +++ b/editor/animation_track_editor_plugins.cpp @@ -1005,7 +1005,7 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant } *get_block_animation_update_ptr() = true; - get_undo_redo()->create_action("Add Audio Track Clip"); + get_undo_redo()->create_action(TTR("Add Audio Track Clip")); get_undo_redo()->add_do_method(get_animation().ptr(), "audio_track_insert_key", get_track(), ofs, stream); get_undo_redo()->add_undo_method(get_animation().ptr(), "track_remove_key_at_position", get_track(), ofs); get_undo_redo()->commit_action(); @@ -1099,7 +1099,7 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) { if (len_resizing_start) { float prev_ofs = get_animation()->audio_track_get_key_start_offset(get_track(), len_resizing_index); *get_block_animation_update_ptr() = true; - get_undo_redo()->create_action("Change Audio Track Clip Start Offset"); + get_undo_redo()->create_action(TTR("Change Audio Track Clip Start Offset")); get_undo_redo()->add_do_method(get_animation().ptr(), "audio_track_set_key_start_offset", get_track(), len_resizing_index, prev_ofs + ofs_local); get_undo_redo()->add_undo_method(get_animation().ptr(), "audio_track_set_key_start_offset", get_track(), len_resizing_index, prev_ofs); get_undo_redo()->commit_action(); @@ -1108,7 +1108,7 @@ void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) { } else { float prev_ofs = get_animation()->audio_track_get_key_end_offset(get_track(), len_resizing_index); *get_block_animation_update_ptr() = true; - get_undo_redo()->create_action("Change Audio Track Clip End Offset"); + get_undo_redo()->create_action(TTR("Change Audio Track Clip End Offset")); get_undo_redo()->add_do_method(get_animation().ptr(), "audio_track_set_key_end_offset", get_track(), len_resizing_index, prev_ofs + ofs_local); get_undo_redo()->add_undo_method(get_animation().ptr(), "audio_track_set_key_end_offset", get_track(), len_resizing_index, prev_ofs); get_undo_redo()->commit_action(); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index bc8aa7688a..29e9cd01c5 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -365,7 +365,7 @@ void EditorAudioBus::_send_selected(int p_which) { updating_bus = true; UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Select Audio Bus Send"); + ur->create_action(TTR("Select Audio Bus Send")); ur->add_do_method(AudioServer::get_singleton(), "set_bus_send", get_index(), send->get_item_text(p_which)); ur->add_undo_method(AudioServer::get_singleton(), "set_bus_send", get_index(), AudioServer::get_singleton()->get_bus_send(get_index())); ur->add_do_method(buses, "_update_bus", get_index()); diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 3029ad978a..2ae39d90de 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -142,7 +142,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven } updating = true; - undo_redo->create_action("Move Node Point"); + undo_redo->create_action(TTR("Move Node Point")); undo_redo->add_do_method(blend_space.ptr(), "set_blend_point_position", selected_point, point); undo_redo->add_undo_method(blend_space.ptr(), "set_blend_point_position", selected_point, blend_space->get_blend_point_position(selected_point)); undo_redo->add_do_method(this, "_update_space"); @@ -325,7 +325,7 @@ void AnimationNodeBlendSpace1DEditor::_config_changed(double) { return; updating = true; - undo_redo->create_action("Change BlendSpace1D Limits"); + undo_redo->create_action(TTR("Change BlendSpace1D Limits")); undo_redo->add_do_method(blend_space.ptr(), "set_max_space", max_value->get_value()); undo_redo->add_undo_method(blend_space.ptr(), "set_max_space", blend_space->get_max_space()); undo_redo->add_do_method(blend_space.ptr(), "set_min_space", min_value->get_value()); @@ -345,7 +345,7 @@ void AnimationNodeBlendSpace1DEditor::_labels_changed(String) { return; updating = true; - undo_redo->create_action("Change BlendSpace1D Labels", UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Change BlendSpace1D Labels"), UndoRedo::MERGE_ENDS); undo_redo->add_do_method(blend_space.ptr(), "set_value_label", label_value->get_text()); undo_redo->add_undo_method(blend_space.ptr(), "set_value_label", blend_space->get_value_label()); undo_redo->add_do_method(this, "_update_space"); @@ -401,7 +401,7 @@ void AnimationNodeBlendSpace1DEditor::_add_menu_type(int p_index) { } updating = true; - undo_redo->create_action("Add Node Point"); + undo_redo->create_action(TTR("Add Node Point")); undo_redo->add_do_method(blend_space.ptr(), "add_blend_point", node, add_point_pos); undo_redo->add_undo_method(blend_space.ptr(), "remove_blend_point", blend_space->get_blend_point_count()); undo_redo->add_do_method(this, "_update_space"); @@ -419,7 +419,7 @@ void AnimationNodeBlendSpace1DEditor::_add_animation_type(int p_index) { anim->set_animation(animations_to_add[p_index]); updating = true; - undo_redo->create_action("Add Animation Point"); + undo_redo->create_action(TTR("Add Animation Point")); undo_redo->add_do_method(blend_space.ptr(), "add_blend_point", anim, add_point_pos); undo_redo->add_undo_method(blend_space.ptr(), "remove_blend_point", blend_space->get_blend_point_count()); undo_redo->add_do_method(this, "_update_space"); @@ -489,7 +489,7 @@ void AnimationNodeBlendSpace1DEditor::_erase_selected() { if (selected_point != -1) { updating = true; - undo_redo->create_action("Remove BlendSpace1D Point"); + undo_redo->create_action(TTR("Remove BlendSpace1D Point")); undo_redo->add_do_method(blend_space.ptr(), "remove_blend_point", selected_point); undo_redo->add_undo_method(blend_space.ptr(), "add_blend_point", blend_space->get_blend_point_node(selected_point), blend_space->get_blend_point_position(selected_point), selected_point); undo_redo->add_do_method(this, "_update_space"); @@ -507,7 +507,7 @@ void AnimationNodeBlendSpace1DEditor::_edit_point_pos(double) { return; updating = true; - undo_redo->create_action("Move BlendSpace1D Node Point"); + undo_redo->create_action(TTR("Move BlendSpace1D Node Point")); undo_redo->add_do_method(blend_space.ptr(), "set_blend_point_position", selected_point, edit_value->get_value()); undo_redo->add_undo_method(blend_space.ptr(), "set_blend_point_position", selected_point, blend_space->get_blend_point_position(selected_point)); undo_redo->add_do_method(this, "_update_space"); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 038e2d0b3e..918f3a2149 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -200,7 +200,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } updating = true; - undo_redo->create_action("Add Triangle"); + undo_redo->create_action(TTR("Add Triangle")); undo_redo->add_do_method(blend_space.ptr(), "add_triangle", making_triangle[0], making_triangle[1], making_triangle[2]); undo_redo->add_undo_method(blend_space.ptr(), "remove_triangle", blend_space->get_triangle_count()); undo_redo->add_do_method(this, "_update_space"); @@ -225,7 +225,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven } updating = true; - undo_redo->create_action("Move Node Point"); + undo_redo->create_action(TTR("Move Node Point")); undo_redo->add_do_method(blend_space.ptr(), "set_blend_point_position", selected_point, point); undo_redo->add_undo_method(blend_space.ptr(), "set_blend_point_position", selected_point, blend_space->get_blend_point_position(selected_point)); undo_redo->add_do_method(this, "_update_space"); @@ -333,7 +333,7 @@ void AnimationNodeBlendSpace2DEditor::_add_menu_type(int p_index) { } updating = true; - undo_redo->create_action("Add Node Point"); + undo_redo->create_action(TTR("Add Node Point")); undo_redo->add_do_method(blend_space.ptr(), "add_blend_point", node, add_point_pos); undo_redo->add_undo_method(blend_space.ptr(), "remove_blend_point", blend_space->get_blend_point_count()); undo_redo->add_do_method(this, "_update_space"); @@ -352,7 +352,7 @@ void AnimationNodeBlendSpace2DEditor::_add_animation_type(int p_index) { anim->set_animation(animations_to_add[p_index]); updating = true; - undo_redo->create_action("Add Animation Point"); + undo_redo->create_action(TTR("Add Animation Point")); undo_redo->add_do_method(blend_space.ptr(), "add_blend_point", anim, add_point_pos); undo_redo->add_undo_method(blend_space.ptr(), "remove_blend_point", blend_space->get_blend_point_count()); undo_redo->add_do_method(this, "_update_space"); @@ -639,7 +639,7 @@ void AnimationNodeBlendSpace2DEditor::_config_changed(double) { return; updating = true; - undo_redo->create_action("Change BlendSpace2D Limits"); + undo_redo->create_action(TTR("Change BlendSpace2D Limits")); undo_redo->add_do_method(blend_space.ptr(), "set_max_space", Vector2(max_x_value->get_value(), max_y_value->get_value())); undo_redo->add_undo_method(blend_space.ptr(), "set_max_space", blend_space->get_max_space()); undo_redo->add_do_method(blend_space.ptr(), "set_min_space", Vector2(min_x_value->get_value(), min_y_value->get_value())); @@ -661,7 +661,7 @@ void AnimationNodeBlendSpace2DEditor::_labels_changed(String) { return; updating = true; - undo_redo->create_action("Change BlendSpace2D Labels", UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Change BlendSpace2D Labels"), UndoRedo::MERGE_ENDS); undo_redo->add_do_method(blend_space.ptr(), "set_x_label", label_x->get_text()); undo_redo->add_undo_method(blend_space.ptr(), "set_x_label", blend_space->get_x_label()); undo_redo->add_do_method(blend_space.ptr(), "set_y_label", label_y->get_text()); @@ -677,7 +677,7 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() { if (selected_point != -1) { updating = true; - undo_redo->create_action("Remove BlendSpace2D Point"); + undo_redo->create_action(TTR("Remove BlendSpace2D Point")); undo_redo->add_do_method(blend_space.ptr(), "remove_blend_point", selected_point); undo_redo->add_undo_method(blend_space.ptr(), "add_blend_point", blend_space->get_blend_point_node(selected_point), blend_space->get_blend_point_position(selected_point), selected_point); @@ -700,7 +700,7 @@ void AnimationNodeBlendSpace2DEditor::_erase_selected() { } else if (selected_triangle != -1) { updating = true; - undo_redo->create_action("Remove BlendSpace2D Triangle"); + undo_redo->create_action(TTR("Remove BlendSpace2D Triangle")); undo_redo->add_do_method(blend_space.ptr(), "remove_triangle", selected_triangle); undo_redo->add_undo_method(blend_space.ptr(), "add_triangle", blend_space->get_triangle_point(selected_triangle, 0), blend_space->get_triangle_point(selected_triangle, 1), blend_space->get_triangle_point(selected_triangle, 2), selected_triangle); @@ -737,7 +737,7 @@ void AnimationNodeBlendSpace2DEditor::_edit_point_pos(double) { if (updating) return; updating = true; - undo_redo->create_action("Move Node Point"); + undo_redo->create_action(TTR("Move Node Point")); undo_redo->add_do_method(blend_space.ptr(), "set_blend_point_position", selected_point, Vector2(edit_x->get_value(), edit_y->get_value())); undo_redo->add_undo_method(blend_space.ptr(), "set_blend_point_position", selected_point, blend_space->get_blend_point_position(selected_point)); undo_redo->add_do_method(this, "_update_space"); @@ -814,7 +814,7 @@ void AnimationNodeBlendSpace2DEditor::_removed_from_graph() { void AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled() { - undo_redo->create_action("Toggle Auto Triangles"); + undo_redo->create_action(TTR("Toggle Auto Triangles")); undo_redo->add_do_method(blend_space.ptr(), "set_auto_triangles", auto_triangles->is_pressed()); undo_redo->add_undo_method(blend_space.ptr(), "set_auto_triangles", blend_space->get_auto_triangles()); undo_redo->add_do_method(this, "_update_space"); diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index e615856195..eef3358260 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -91,7 +91,7 @@ void AnimationNodeBlendTreeEditor::_property_changed(const StringName &p_propert AnimationTree *tree = AnimationTreeEditor::get_singleton()->get_tree(); updating = true; - undo_redo->create_action("Parameter Changed: " + String(p_property), UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Parameter Changed") + ": " + String(p_property), UndoRedo::MERGE_ENDS); undo_redo->add_do_property(tree, p_property, p_value); undo_redo->add_undo_property(tree, p_property, tree->get(p_property)); undo_redo->add_do_method(this, "_update_graph"); @@ -325,7 +325,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { name = base_name + " " + itos(base); } - undo_redo->create_action("Add Node to BlendTree"); + undo_redo->create_action(TTR("Add Node to BlendTree")); undo_redo->add_do_method(blend_tree.ptr(), "add_node", name, anode, instance_pos / EDSCALE); undo_redo->add_undo_method(blend_tree.ptr(), "remove_node", name); undo_redo->add_do_method(this, "_update_graph"); @@ -336,7 +336,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { void AnimationNodeBlendTreeEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, const StringName &p_which) { updating = true; - undo_redo->create_action("Node Moved"); + undo_redo->create_action(TTR("Node Moved")); undo_redo->add_do_method(blend_tree.ptr(), "set_node_position", p_which, p_to / EDSCALE); undo_redo->add_undo_method(blend_tree.ptr(), "set_node_position", p_which, p_from / EDSCALE); undo_redo->add_do_method(this, "_update_graph"); @@ -354,7 +354,7 @@ void AnimationNodeBlendTreeEditor::_connection_request(const String &p_from, int return; } - undo_redo->create_action("Nodes Connected"); + undo_redo->create_action(TTR("Nodes Connected")); undo_redo->add_do_method(blend_tree.ptr(), "connect_node", p_to, p_to_index, p_from); undo_redo->add_undo_method(blend_tree.ptr(), "disconnect_node", p_to, p_to_index); undo_redo->add_do_method(this, "_update_graph"); @@ -367,7 +367,7 @@ void AnimationNodeBlendTreeEditor::_disconnection_request(const String &p_from, graph->disconnect_node(p_from, p_from_index, p_to, p_to_index); updating = true; - undo_redo->create_action("Nodes Disconnected"); + undo_redo->create_action(TTR("Nodes Disconnected")); undo_redo->add_do_method(blend_tree.ptr(), "disconnect_node", p_to, p_to_index); undo_redo->add_undo_method(blend_tree.ptr(), "connect_node", p_to, p_to_index, p_from); undo_redo->add_do_method(this, "_update_graph"); @@ -383,7 +383,7 @@ void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options, Ref<AnimationNodeAnimation> anim = blend_tree->get_node(p_node); ERR_FAIL_COND(!anim.is_valid()); - undo_redo->create_action("Set Animation"); + undo_redo->create_action(TTR("Set Animation")); undo_redo->add_do_method(anim.ptr(), "set_animation", option); undo_redo->add_undo_method(anim.ptr(), "set_animation", anim->get_animation()); undo_redo->add_do_method(this, "_update_graph"); @@ -393,7 +393,7 @@ void AnimationNodeBlendTreeEditor::_anim_selected(int p_index, Array p_options, void AnimationNodeBlendTreeEditor::_delete_request(const String &p_which) { - undo_redo->create_action("Delete Node"); + undo_redo->create_action(TTR("Delete Node")); undo_redo->add_do_method(blend_tree.ptr(), "remove_node", p_which); undo_redo->add_undo_method(blend_tree.ptr(), "add_node", p_which, blend_tree->get_node(p_which), blend_tree.ptr()->get_node_position(p_which)); @@ -434,7 +434,7 @@ void AnimationNodeBlendTreeEditor::_open_in_editor(const String &p_which) { void AnimationNodeBlendTreeEditor::_filter_toggled() { updating = true; - undo_redo->create_action("Toggle filter on/off"); + undo_redo->create_action(TTR("Toggle Filter On/Off")); undo_redo->add_do_method(_filter_edit.ptr(), "set_filter_enabled", filter_enabled->is_pressed()); undo_redo->add_undo_method(_filter_edit.ptr(), "set_filter_enabled", _filter_edit->is_filter_enabled()); undo_redo->add_do_method(this, "_update_filters", _filter_edit); @@ -452,7 +452,7 @@ void AnimationNodeBlendTreeEditor::_filter_edited() { bool filtered = edited->is_checked(0); updating = true; - undo_redo->create_action("Change filter"); + undo_redo->create_action(TTR("Change Filter")); undo_redo->add_do_method(_filter_edit.ptr(), "set_filter_path", edited_path, filtered); undo_redo->add_undo_method(_filter_edit.ptr(), "set_filter_path", edited_path, _filter_edit->is_path_filtered(edited_path)); undo_redo->add_do_method(this, "_update_filters", _filter_edit); @@ -769,7 +769,7 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima String base_path = AnimationTreeEditor::get_singleton()->get_base_path(); updating = true; - undo_redo->create_action("Node Renamed"); + undo_redo->create_action(TTR("Node Renamed")); undo_redo->add_do_method(blend_tree.ptr(), "rename_node", prev_name, name); undo_redo->add_undo_method(blend_tree.ptr(), "rename_node", name, prev_name); undo_redo->add_do_method(AnimationTreeEditor::get_singleton()->get_tree(), "rename_parameter", base_path + prev_name, base_path + name); diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp index e73c4ebd8a..cb3e5a8129 100644 --- a/editor/plugins/animation_state_machine_editor.cpp +++ b/editor/plugins/animation_state_machine_editor.cpp @@ -226,7 +226,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv Ref<AnimationNode> an = state_machine->get_node(selected_node); updating = true; - undo_redo->create_action("Move Node"); + undo_redo->create_action(TTR("Move Node")); undo_redo->add_do_method(state_machine.ptr(), "set_node_position", selected_node, state_machine->get_node_position(selected_node) + drag_ofs / EDSCALE); undo_redo->add_undo_method(state_machine.ptr(), "set_node_position", selected_node, state_machine->get_node_position(selected_node)); undo_redo->add_do_method(this, "_update_graph"); @@ -271,7 +271,7 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv tr->set_switch_mode(AnimationNodeStateMachineTransition::SwitchMode(transition_mode->get_selected())); updating = true; - undo_redo->create_action("Add Transition"); + undo_redo->create_action(TTR("Add Transition")); undo_redo->add_do_method(state_machine.ptr(), "add_transition", connecting_from, connecting_to_node, tr); undo_redo->add_undo_method(state_machine.ptr(), "remove_transition", connecting_from, connecting_to_node); undo_redo->add_do_method(this, "_update_graph"); @@ -463,7 +463,7 @@ void AnimationNodeStateMachineEditor::_add_menu_type(int p_index) { } updating = true; - undo_redo->create_action("Add Node"); + undo_redo->create_action(TTR("Add Node")); undo_redo->add_do_method(state_machine.ptr(), "add_node", name, node, add_node_pos); undo_redo->add_undo_method(state_machine.ptr(), "remove_node", name); undo_redo->add_do_method(this, "_update_graph"); @@ -490,7 +490,7 @@ void AnimationNodeStateMachineEditor::_add_animation_type(int p_index) { } updating = true; - undo_redo->create_action("Add Node"); + undo_redo->create_action(TTR("Add Node")); undo_redo->add_do_method(state_machine.ptr(), "add_node", name, anim, add_node_pos); undo_redo->add_undo_method(state_machine.ptr(), "remove_node", name); undo_redo->add_do_method(this, "_update_graph"); @@ -1088,7 +1088,7 @@ void AnimationNodeStateMachineEditor::_name_edited(const String &p_text) { } updating = true; - undo_redo->create_action("Node Renamed"); + undo_redo->create_action(TTR("Node Renamed")); undo_redo->add_do_method(state_machine.ptr(), "rename_node", prev_name, name); undo_redo->add_undo_method(state_machine.ptr(), "rename_node", name, prev_name); undo_redo->add_do_method(this, "_update_graph"); @@ -1119,7 +1119,7 @@ void AnimationNodeStateMachineEditor::_erase_selected() { if (selected_node != StringName() && state_machine->has_node(selected_node)) { updating = true; - undo_redo->create_action("Node Removed"); + undo_redo->create_action(TTR("Node Removed")); undo_redo->add_do_method(state_machine.ptr(), "remove_node", selected_node); undo_redo->add_undo_method(state_machine.ptr(), "add_node", selected_node, state_machine->get_node(selected_node), state_machine->get_node_position(selected_node)); for (int i = 0; i < state_machine->get_transition_count(); i++) { @@ -1143,7 +1143,7 @@ void AnimationNodeStateMachineEditor::_erase_selected() { Ref<AnimationNodeStateMachineTransition> tr = state_machine->get_transition(state_machine->find_transition(selected_transition_from, selected_transition_to)); updating = true; - undo_redo->create_action("Transition Removed"); + undo_redo->create_action(TTR("Transition Removed")); undo_redo->add_do_method(state_machine.ptr(), "remove_transition", selected_transition_from, selected_transition_to); undo_redo->add_undo_method(state_machine.ptr(), "add_transition", selected_transition_from, selected_transition_to, tr); undo_redo->add_do_method(this, "_update_graph"); @@ -1169,7 +1169,7 @@ void AnimationNodeStateMachineEditor::_autoplay_selected() { } updating = true; - undo_redo->create_action("Set Start Node (Autoplay)"); + undo_redo->create_action(TTR("Set Start Node (Autoplay)")); undo_redo->add_do_method(state_machine.ptr(), "set_start_node", new_start_node); undo_redo->add_undo_method(state_machine.ptr(), "set_start_node", state_machine->get_start_node()); undo_redo->add_do_method(this, "_update_graph"); @@ -1192,7 +1192,7 @@ void AnimationNodeStateMachineEditor::_end_selected() { } updating = true; - undo_redo->create_action("Set Start Node (Autoplay)"); + undo_redo->create_action(TTR("Set Start Node (Autoplay)")); undo_redo->add_do_method(state_machine.ptr(), "set_end_node", new_end_node); undo_redo->add_undo_method(state_machine.ptr(), "set_end_node", state_machine->get_end_node()); undo_redo->add_do_method(this, "_update_graph"); diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index 62a9ce719b..e85c475ad7 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -51,7 +51,7 @@ void GradientEditor::_ramp_changed() { editing = true; UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Gradient Edited"); + undo_redo->create_action(TTR("Gradient Edited")); undo_redo->add_do_method(gradient.ptr(), "set_offsets", get_offsets()); undo_redo->add_do_method(gradient.ptr(), "set_colors", get_colors()); undo_redo->add_undo_method(gradient.ptr(), "set_offsets", gradient->get_offsets()); diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp index 619d54b202..ef3e17279c 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/editor/plugins/skeleton_2d_editor_plugin.cpp @@ -63,7 +63,7 @@ void Skeleton2DEditor::_menu_option(int p_option) { return; } UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Create Rest Pose from Bones"); + ur->create_action(TTR("Create Rest Pose from Bones")); for (int i = 0; i < node->get_bone_count(); i++) { Bone2D *bone = node->get_bone(i); ur->add_do_method(bone, "set_rest", bone->get_transform()); @@ -79,7 +79,7 @@ void Skeleton2DEditor::_menu_option(int p_option) { return; } UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); - ur->create_action("Set Rest Pose to Bones"); + ur->create_action(TTR("Set Rest Pose to Bones")); for (int i = 0; i < node->get_bone_count(); i++) { Bone2D *bone = node->get_bone(i); ur->add_do_method(bone, "set_transform", bone->get_rest()); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index f578d5037d..1e9ff87fd3 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2546,7 +2546,7 @@ void SpatialEditorViewport::_menu_option(int p_option) { List<Node *> &selection = editor_selection->get_selected_node_list(); - undo_redo->create_action(TTR("Align with view")); + undo_redo->create_action(TTR("Align with View")); for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Spatial *sp = Object::cast_to<Spatial>(E->get()); @@ -5055,7 +5055,7 @@ void SpatialEditor::snap_selected_nodes_to_floor() { Array keys = snap_data.keys(); if (keys.size()) { - undo_redo->create_action("Snap Nodes To Floor"); + undo_redo->create_action(TTR("Snap Nodes To Floor")); for (int i = 0; i < keys.size(); i++) { Node *node = keys[i]; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 3670c78f1f..1a367b61dd 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -1157,7 +1157,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (points.size() == 0) return false; - undo_redo->create_action("Bucket Fill"); + undo_redo->create_action(TTR("Bucket Fill")); undo_redo->add_do_method(this, "_erase_points", points); undo_redo->add_undo_method(this, "_fill_points", points, pop); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 734cd505d2..7bd26de092 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -393,7 +393,7 @@ void VisualShaderEditor::_preview_select_port(int p_node, int p_port) { if (node->get_output_port_for_preview() == p_port) { p_port = -1; //toggle it } - undo_redo->create_action("Set Uniform Name"); + undo_redo->create_action(TTR("Set Uniform Name")); undo_redo->add_do_method(node.ptr(), "set_output_port_for_preview", p_port); undo_redo->add_undo_method(node.ptr(), "set_output_port_for_preview", node->get_output_port_for_preview()); undo_redo->add_do_method(this, "_update_graph"); @@ -411,7 +411,7 @@ void VisualShaderEditor::_line_edit_changed(const String &p_text, Object *line_e String validated_name = visual_shader->validate_uniform_name(p_text, node); updating = true; - undo_redo->create_action("Set Uniform Name"); + undo_redo->create_action(TTR("Set Uniform Name")); undo_redo->add_do_method(node.ptr(), "set_uniform_name", validated_name); undo_redo->add_undo_method(node.ptr(), "set_uniform_name", node->get_uniform_name()); undo_redo->add_do_method(this, "_update_graph"); @@ -436,7 +436,7 @@ void VisualShaderEditor::_port_edited() { Ref<VisualShaderNode> vsn = visual_shader->get_node(type, editing_node); ERR_FAIL_COND(!vsn.is_valid()); - undo_redo->create_action("Set Input Default Port"); + undo_redo->create_action(TTR("Set Input Default Port")); undo_redo->add_do_method(vsn.ptr(), "set_input_port_default_value", editing_port, value); undo_redo->add_undo_method(vsn.ptr(), "set_input_port_default_value", editing_port, vsn->get_input_port_default_value(editing_port)); undo_redo->add_do_method(this, "_update_graph"); @@ -487,7 +487,7 @@ void VisualShaderEditor::_add_node(int p_idx) { int id_to_use = visual_shader->get_valid_node_id(type); - undo_redo->create_action("Add Node to Visual Shader"); + undo_redo->create_action(TTR("Add Node to Visual Shader")); undo_redo->add_do_method(visual_shader.ptr(), "add_node", type, vsnode, position, id_to_use); undo_redo->add_undo_method(visual_shader.ptr(), "remove_node", type, id_to_use); undo_redo->add_do_method(this, "_update_graph"); @@ -500,7 +500,7 @@ void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_t VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); updating = true; - undo_redo->create_action("Node Moved"); + undo_redo->create_action(TTR("Node Moved")); undo_redo->add_do_method(visual_shader.ptr(), "set_node_position", type, p_node, p_to); undo_redo->add_undo_method(visual_shader.ptr(), "set_node_position", type, p_node, p_from); undo_redo->add_do_method(this, "_update_graph"); @@ -521,7 +521,7 @@ void VisualShaderEditor::_connection_request(const String &p_from, int p_from_in return; } - undo_redo->create_action("Nodes Connected"); + undo_redo->create_action(TTR("Nodes Connected")); List<VisualShader::Connection> conns; visual_shader->get_node_connections(type, &conns); @@ -550,7 +550,7 @@ void VisualShaderEditor::_disconnection_request(const String &p_from, int p_from int to = p_to.to_int(); //updating = true; seems graph edit can handle this, no need to protect - undo_redo->create_action("Nodes Disconnected"); + undo_redo->create_action(TTR("Nodes Disconnected")); undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, from, p_from_index, to, p_to_index); undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, from, p_from_index, to, p_to_index); undo_redo->add_do_method(this, "_update_graph"); @@ -566,7 +566,7 @@ void VisualShaderEditor::_delete_request(int which) { VisualShader::Type type = VisualShader::Type(edit_type->get_selected()); - undo_redo->create_action("Delete Node"); + undo_redo->create_action(TTR("Delete Node")); undo_redo->add_do_method(visual_shader.ptr(), "remove_node", type, which); undo_redo->add_undo_method(visual_shader.ptr(), "add_node", type, visual_shader->get_node(type, which), visual_shader->get_node_position(type, which), which); @@ -671,7 +671,7 @@ void VisualShaderEditor::_duplicate_nodes() { if (nodes.empty()) return; - undo_redo->create_action("Duplicate Nodes"); + undo_redo->create_action(TTR("Duplicate Nodes")); int base_id = visual_shader->get_valid_node_id(type); int id_from = base_id; @@ -732,7 +732,7 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> input, St bool type_changed = input->get_input_type_by_name(name) != input->get_input_type_by_name(prev_name); UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Visual Shader Input Type Changed"); + undo_redo->create_action(TTR("Visual Shader Input Type Changed")); undo_redo->add_do_method(input.ptr(), "set_input_name", name); undo_redo->add_undo_method(input.ptr(), "set_input_name", prev_name); @@ -972,7 +972,7 @@ public: UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); updating = true; - undo_redo->create_action("Edit Visual Property: " + prop, UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Edit Visual Property") + ": " + prop, UndoRedo::MERGE_ENDS); undo_redo->add_do_property(node.ptr(), prop, p_value); undo_redo->add_undo_property(node.ptr(), prop, node->get(prop)); undo_redo->commit_action(); @@ -1093,7 +1093,7 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { return; UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action("Visual Shader Mode Changed"); + undo_redo->create_action(TTR("Visual Shader Mode Changed")); //do is easy undo_redo->add_do_method(visual_shader.ptr(), "set_mode", p_which); undo_redo->add_undo_method(visual_shader.ptr(), "set_mode", visual_shader->get_mode()); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index c470ee1481..d931d5bb37 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -583,7 +583,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { return; } - editor_data->get_undo_redo().create_action("Make node as Root"); + editor_data->get_undo_redo().create_action(TTR("Make node as Root")); editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node); editor_data->get_undo_redo().add_do_method(root->get_parent(), "remove_child", root); editor_data->get_undo_redo().add_do_method(node, "add_child", root); @@ -849,7 +849,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } - editor_data->get_undo_redo().create_action("New Scene Root"); + editor_data->get_undo_redo().create_action(TTR("New Scene Root")); editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", new_node); editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); editor_data->get_undo_redo().add_do_reference(new_node); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index ecd35cb930..611067214d 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -282,7 +282,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column if (!sc.is_valid()) return; //pointless, there is nothing - undo_redo->create_action("Erase Shortcut"); + undo_redo->create_action(TTR("Erase Shortcut")); undo_redo->add_do_method(sc.ptr(), "set_shortcut", Ref<InputEvent>()); undo_redo->add_undo_method(sc.ptr(), "set_shortcut", sc->get_shortcut()); undo_redo->add_do_method(this, "_update_shortcuts"); @@ -296,7 +296,7 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column Ref<InputEvent> original = sc->get_meta("original"); - undo_redo->create_action("Restore Shortcut"); + undo_redo->create_action(TTR("Restore Shortcut")); undo_redo->add_do_method(sc.ptr(), "set_shortcut", original); undo_redo->add_undo_method(sc.ptr(), "set_shortcut", sc->get_shortcut()); undo_redo->add_do_method(this, "_update_shortcuts"); @@ -344,7 +344,7 @@ void EditorSettingsDialog::_press_a_key_confirm() { Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(shortcut_configured); - undo_redo->create_action("Change Shortcut '" + shortcut_configured + "'"); + undo_redo->create_action(TTR("Change Shortcut") + " '" + shortcut_configured + "'"); undo_redo->add_do_method(sc.ptr(), "set_shortcut", ie); undo_redo->add_undo_method(sc.ptr(), "set_shortcut", sc->get_shortcut()); undo_redo->add_do_method(this, "_update_shortcuts"); diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index 784e99ab86..1e1bea846a 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -167,7 +167,7 @@ public: KinematicShape() : shape(NULL) {} - const bool is_active() const { return shape; } + bool is_active() const { return shape; } }; struct KinematicUtilities { diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 871c33bb35..000917507a 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -433,7 +433,6 @@ bool NetworkedMultiplayerENet::is_server() const { void NetworkedMultiplayerENet::close_connection(uint32_t wait_usec) { ERR_FAIL_COND(!active); - ERR_FAIL_COND(wait_usec < 0); _pop_current_packet(); diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index 11509fc20a..9cd37ac950 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -223,7 +223,7 @@ void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_ Ref<ARVRInterfaceGDNative> new_interface; new_interface.instance(); - new_interface->set_interface((godot_arvr_interface_gdnative *const)p_interface); + new_interface->set_interface((const godot_arvr_interface_gdnative *)p_interface); ARVRServer::get_singleton()->add_interface(new_interface); } diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp index a18d221a7c..2c6c9e2de2 100644 --- a/modules/gdnative/gdnative/dictionary.cpp +++ b/modules/gdnative/gdnative/dictionary.cpp @@ -155,12 +155,26 @@ godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self) { return raw_dest; } +// GDNative core 1.1 + godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key) { Dictionary *self = (Dictionary *)p_self; const Variant *key = (const Variant *)p_key; return self->erase(*key); } +godot_variant GDAPI godot_dictionary_get_with_default(const godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_default) { + const Dictionary *self = (const Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + const Variant *def = (const Variant *)p_default; + + godot_variant raw_dest; + Variant *dest = (Variant *)&raw_dest; + memnew_placement(dest, Variant(self->get(*key, *def))); + + return raw_dest; +} + #ifdef __cplusplus } #endif diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 7680471409..bdcd51085f 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -107,6 +107,23 @@ ] }, { + "name": "godot_dictionary_get_with_default", + "return_type": "godot_variant", + "arguments": [ + ["const godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"], + ["const godot_variant *", "p_default"] + ] + }, + { + "name": "godot_dictionary_erase_with_return", + "return_type": "bool", + "arguments": [ + ["godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"] + ] + }, + { "name": "godot_node_path_get_as_property_path", "return_type": "godot_node_path", "arguments": [ @@ -234,14 +251,6 @@ ] }, { - "name": "godot_dictionary_erase_with_return", - "return_type": "bool", - "arguments": [ - ["godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { "name": "godot_is_instance_valid", "return_type": "bool", "arguments": [ diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h index 7703742899..14e35b4692 100644 --- a/modules/gdnative/include/gdnative/dictionary.h +++ b/modules/gdnative/include/gdnative/dictionary.h @@ -94,8 +94,12 @@ godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self); +// GDNative core 1.1 + godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key); +godot_variant GDAPI godot_dictionary_get_with_default(const godot_dictionary *p_self, const godot_variant *p_key, const godot_variant *p_default); + #ifdef __cplusplus } #endif diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index dc9f2db331..480bf0fa3c 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -1417,7 +1417,7 @@ StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const { ERR_FAIL_INDEX_V(offset, tokens.size(), StringName()); uint32_t identifier = tokens[offset] >> TOKEN_BITS; - ERR_FAIL_INDEX_V(identifier, (uint32_t)identifiers.size(), StringName()); + ERR_FAIL_UNSIGNED_INDEX_V(identifier, identifiers.size(), StringName()); return identifiers[identifier]; } @@ -1473,7 +1473,7 @@ const Variant &GDScriptTokenizerBuffer::get_token_constant(int p_offset) const { int offset = token + p_offset; ERR_FAIL_INDEX_V(offset, tokens.size(), nil); uint32_t constant = tokens[offset] >> TOKEN_BITS; - ERR_FAIL_INDEX_V(constant, (uint32_t)constants.size(), nil); + ERR_FAIL_UNSIGNED_INDEX_V(constant, constants.size(), nil); return constants[constant]; } String GDScriptTokenizerBuffer::get_token_error(int p_offset) const { diff --git a/modules/gdscript/gdscript_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h index 88e44c6e0f..7b977ff67c 100644 --- a/modules/gdscript/gdscript_tokenizer.h +++ b/modules/gdscript/gdscript_tokenizer.h @@ -173,7 +173,7 @@ public: #ifdef DEBUG_ENABLED virtual const Vector<Pair<int, String> > &get_warning_skips() const = 0; virtual const Set<String> &get_warning_global_skips() const = 0; - virtual const bool is_ignoring_warnings() const = 0; + virtual bool is_ignoring_warnings() const = 0; #endif // DEBUG_ENABLED virtual ~GDScriptTokenizer(){}; @@ -245,7 +245,7 @@ public: #ifdef DEBUG_ENABLED virtual const Vector<Pair<int, String> > &get_warning_skips() const { return warning_skips; } virtual const Set<String> &get_warning_global_skips() const { return warning_global_skips; } - virtual const bool is_ignoring_warnings() const { return ignore_warnings; } + virtual bool is_ignoring_warnings() const { return ignore_warnings; } #endif // DEBUG_ENABLED }; @@ -289,7 +289,7 @@ public: static Set<String> s; return s; } - virtual const bool is_ignoring_warnings() const { return true; } + virtual bool is_ignoring_warnings() const { return true; } #endif // DEBUG_ENABLED GDScriptTokenizerBuffer(); }; diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index fb98755444..bc7a576785 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -631,7 +631,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) { if (set_items.size()) { - undo_redo->create_action("GridMap Paint"); + undo_redo->create_action(TTR("GridMap Paint")); for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) { const SetItem &si = E->get(); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 040d61a31e..7e54891d97 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -3103,7 +3103,7 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_ graph->set_block_minimum_size_adjust(true); //faster resize - undo_redo->create_action("Resize Comment", UndoRedo::MERGE_ENDS); + undo_redo->create_action(TTR("Resize Comment"), UndoRedo::MERGE_ENDS); undo_redo->add_do_method(vsc.ptr(), "set_size", p_new_size / EDSCALE); undo_redo->add_undo_method(vsc.ptr(), "set_size", vsc->get_size()); undo_redo->commit_action(); diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp index 907c652ab4..7cf0a1ef1e 100644 --- a/platform/x11/joypad_linux.cpp +++ b/platform/x11/joypad_linux.cpp @@ -476,7 +476,7 @@ void JoypadLinux::process_joypads() { // ev may be tainted and out of MAX_KEY range, which will cause // joy->key_map[ev.code] to crash - if (ev.code < 0 || ev.code >= MAX_KEY) + if (ev.code >= MAX_KEY) return; switch (ev.type) { diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 8db4635d68..879642d8f9 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1743,7 +1743,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { // is correct, but the xorg developers are // not very helpful today. - ::Time tresh = ABS(peek_event.xkey.time - xkeyevent->time); + ::Time tresh = ABSDIFF(peek_event.xkey.time, xkeyevent->time); if (peek_event.type == KeyPress && tresh < 5) { KeySym rk; XLookupString((XKeyEvent *)&peek_event, str, 256, &rk, NULL); diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index 91b3ea6ca0..42c2318701 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -2208,7 +2208,7 @@ PoolVector<int> VoxelLightBaker::create_gi_probe_data() { } { - uint16_t alpha = CLAMP(uint32_t(bake_cells[i].alpha * 65535.0), 0, 65535); + uint16_t alpha = MAX(uint32_t(bake_cells[i].alpha * 65535.0), 65535); uint16_t level = bake_cells[i].level; w32[ofs++] = (uint32_t(level) << 16) | uint32_t(alpha); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 99a0a3dc82..9ef6b9b474 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1422,7 +1422,6 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, } else { _find_resources(v); } - } I = I->next(); diff --git a/servers/audio/reverb_sw.cpp b/servers/audio/reverb_sw.cpp index 8adc21b406..63bf1a7eaa 100644 --- a/servers/audio/reverb_sw.cpp +++ b/servers/audio/reverb_sw.cpp @@ -39,9 +39,6 @@ #define rangeloop(c, min, max) \ for ((c) = (min); (c) < (max); (c)++) -#define ABSDIFF(x, y) \ - (((x) < (y)) ? ((y) - (x)) : ((x) - (y))) - #define MULSHIFT_S32(Factor1, Factor2, Bits) \ ((int)(((int64_t)(Factor1) * (Factor2)) >> (Bits))) diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index 6e6b66dac2..5c14d5aaf9 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -130,7 +130,7 @@ public: _FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; } _FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; } _FORCE_INLINE_ const AABB &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } - _FORCE_INLINE_ const real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; } + _FORCE_INLINE_ real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; } _FORCE_INLINE_ Transform get_transform() const { return transform; } _FORCE_INLINE_ Transform get_inv_transform() const { return inv_transform; } diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index b561351374..01d00ccc21 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -2480,7 +2480,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { uint32_t a = uint32_t(alpha_block[x][y]) - min_alpha; //convert range to 3 bits a = int((a * 7.0 / (max_alpha - min_alpha)) + 0.5); - a = CLAMP(a, 0, 7); //just to be sure + a = MAX(a, 7); //just to be sure a = 7 - a; //because range is inverted in this mode if (a == 0) { //do none, remain @@ -2924,10 +2924,10 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { uint32_t mm_ofs = sizes[0] * sizes[1] * (local_data[idx].pos[2]) + sizes[0] * (local_data[idx].pos[1]) + (local_data[idx].pos[0]); mm_ofs *= 4; //for RGBA (4 bytes) - mipmapw[mm_ofs + 0] = uint8_t(CLAMP(r2, 0, 255)); - mipmapw[mm_ofs + 1] = uint8_t(CLAMP(g, 0, 255)); - mipmapw[mm_ofs + 2] = uint8_t(CLAMP(b, 0, 255)); - mipmapw[mm_ofs + 3] = uint8_t(CLAMP(a, 0, 255)); + mipmapw[mm_ofs + 0] = uint8_t(MAX(r2, 255)); + mipmapw[mm_ofs + 1] = uint8_t(MAX(g, 255)); + mipmapw[mm_ofs + 2] = uint8_t(MAX(b, 255)); + mipmapw[mm_ofs + 3] = uint8_t(MAX(a, 255)); } } } else if (probe_data->dynamic.compression == RasterizerStorage::GI_PROBE_S3TC) { |