summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/object.cpp8
-rw-r--r--core/object.h4
-rw-r--r--doc/base/classes.xml22
-rw-r--r--editor/connections_dialog.h3
-rw-r--r--editor/node_dock.cpp5
-rw-r--r--editor/node_dock.h2
-rw-r--r--editor/plugins/script_editor_plugin.cpp10
-rw-r--r--editor/plugins/script_editor_plugin.h1
-rw-r--r--editor/plugins/script_text_editor.cpp1
-rw-r--r--modules/visual_script/visual_script_editor.cpp13
-rw-r--r--scene/gui/button.cpp4
-rw-r--r--scene/gui/dialogs.cpp2
-rw-r--r--scene/gui/file_dialog.cpp2
-rw-r--r--scene/gui/label.cpp4
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/popup_menu.cpp18
-rw-r--r--scene/gui/tab_container.cpp4
17 files changed, 66 insertions, 39 deletions
diff --git a/core/object.cpp b/core/object.cpp
index 3cfd74a448..06c2603b74 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1560,7 +1560,7 @@ void Object::initialize_class() {
initialized = true;
}
-StringName Object::localize(const StringName &p_message) const {
+StringName Object::tr(const StringName &p_message) const {
if (!_can_translate || !TranslationServer::get_singleton())
return p_message;
@@ -1707,11 +1707,11 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_block_signals", "enable"), &Object::set_block_signals);
ClassDB::bind_method(D_METHOD("is_blocking_signals"), &Object::is_blocking_signals);
- ClassDB::bind_method(D_METHOD("set_message_localization", "enable"), &Object::set_message_localization);
- ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages);
ClassDB::bind_method(D_METHOD("property_list_changed_notify"), &Object::property_list_changed_notify);
- ClassDB::bind_method(D_METHOD("localize", "message"), &Object::localize);
+ ClassDB::bind_method(D_METHOD("set_message_translation", "enable"), &Object::set_message_translation);
+ ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages);
+ ClassDB::bind_method(D_METHOD("tr", "message"), &Object::tr);
ClassDB::bind_method(D_METHOD("is_queued_for_deletion"), &Object::is_queued_for_deletion);
diff --git a/core/object.h b/core/object.h
index b694876505..8a858b5b00 100644
--- a/core/object.h
+++ b/core/object.h
@@ -679,12 +679,12 @@ public:
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
- StringName localize(const StringName &p_message) const; //translate message (internationalization)
+ StringName tr(const StringName &p_message) const; // translate message (internationalization)
bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete()
bool is_queued_for_deletion() const;
- _FORCE_INLINE_ void set_message_localization(bool p_enable) { _can_translate = p_enable; }
+ _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate = p_enable; }
_FORCE_INLINE_ bool can_translate_messages() const { return _can_translate; }
#ifdef TOOLS_ENABLED
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index 418739aa3d..f21fa2c7c0 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -28259,15 +28259,6 @@
<description>
</description>
</method>
- <method name="localize" qualifiers="const">
- <return type="String">
- </return>
- <argument index="0" name="message" type="String">
- </argument>
- <description>
- Localize (translate) a message. Only works if message localization is enabled (which it is by default). See [method set_message_localization].
- </description>
- </method>
<method name="notification">
<argument index="0" name="what" type="int">
</argument>
@@ -28297,11 +28288,11 @@
If set to true, signal emission is blocked.
</description>
</method>
- <method name="set_message_localization">
+ <method name="set_message_translation">
<argument index="0" name="enable" type="bool">
</argument>
<description>
- Define whether this object can localize strings (with calls to [code]localize[/code]). Default is true.
+ Define whether this object can translate strings (with calls to [method tr]). Default is true.
</description>
</method>
<method name="set_meta">
@@ -28320,6 +28311,15 @@
Set a script into the object, scripts extend the object functionality.
</description>
</method>
+ <method name="tr" qualifiers="const">
+ <return type="String">
+ </return>
+ <argument index="0" name="message" type="String">
+ </argument>
+ <description>
+ Translate a message. Only works if message translation is enabled (which it is by default). See [method set_message_translation].
+ </description>
+ </method>
</methods>
<signals>
<signal name="script_changed">
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index bff85941cb..849bb880d4 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -103,8 +103,6 @@ class ConnectionsDock : public VBoxContainer {
ConfirmationDialog *remove_confirm;
ConnectDialog *connect_dialog;
- void update_tree();
-
void _close();
void _connect();
void _something_selected();
@@ -121,6 +119,7 @@ public:
void set_node(Node *p_node);
String get_selected_type();
+ void update_tree();
ConnectionsDock(EditorNode *p_editor = NULL);
~ConnectionsDock();
diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp
index 0f3f4b96f5..b1a538ed2e 100644
--- a/editor/node_dock.cpp
+++ b/editor/node_dock.cpp
@@ -63,6 +63,11 @@ void NodeDock::_notification(int p_what) {
NodeDock *NodeDock::singleton = NULL;
+void NodeDock::update_lists() {
+
+ connections->update_tree();
+}
+
void NodeDock::set_node(Node *p_node) {
connections->set_node(p_node);
diff --git a/editor/node_dock.h b/editor/node_dock.h
index 0af65719c9..29e5dc5169 100644
--- a/editor/node_dock.h
+++ b/editor/node_dock.h
@@ -59,6 +59,8 @@ public:
void show_groups();
void show_connections();
+ void update_lists();
+
NodeDock();
};
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 1873a3f58b..fc89a4b9b4 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -34,18 +34,19 @@
#include "editor/script_editor_debugger.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
+#include "node_dock.h"
#include "os/file_access.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "project_settings.h"
#include "scene/main/viewport.h"
-
/*** SCRIPT EDITOR ****/
void ScriptEditorBase::_bind_methods() {
ADD_SIGNAL(MethodInfo("name_changed"));
+ ADD_SIGNAL(MethodInfo("script_changed"));
ADD_SIGNAL(MethodInfo("request_help_search", PropertyInfo(Variant::STRING, "topic")));
ADD_SIGNAL(MethodInfo("request_help_index"));
ADD_SIGNAL(MethodInfo("request_open_script_at_line", PropertyInfo(Variant::OBJECT, "script"), PropertyInfo(Variant::INT, "line")));
@@ -1714,6 +1715,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
_update_script_names();
_save_layout();
se->connect("name_changed", this, "_update_script_names");
+ se->connect("script_changed", this, "_script_changed");
se->connect("request_help_search", this, "_help_search");
se->connect("request_open_script_at_line", this, "_goto_script_line");
se->connect("go_to_help", this, "_help_class_goto");
@@ -2200,6 +2202,11 @@ void ScriptEditor::register_create_script_editor_function(CreateScriptEditorFunc
script_editor_funcs[script_editor_func_count++] = p_func;
}
+void ScriptEditor::_script_changed() {
+
+ NodeDock::singleton->update_lists();
+}
+
void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_file_dialog_action", &ScriptEditor::_file_dialog_action);
@@ -2241,6 +2248,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_history_back", &ScriptEditor::_history_back);
ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
+ ClassDB::bind_method("_script_changed", &ScriptEditor::_script_changed);
ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script);
ClassDB::bind_method(D_METHOD("get_open_scripts"), &ScriptEditor::_get_open_scripts);
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 4614a41605..f87a20a1f0 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -318,6 +318,7 @@ class ScriptEditor : public PanelContainer {
void _update_script_colors();
void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script = Ref<Script>());
+ void _script_changed();
int file_dialog_option;
void _file_dialog_action(String p_file);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 422c656351..1aa9f04484 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -524,6 +524,7 @@ void ScriptTextEditor::_validate_script() {
}
emit_signal("name_changed");
+ emit_signal("script_changed");
}
static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) {
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 0f6b47c56d..a39491ef5b 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -886,6 +886,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
// _update_graph();
@@ -901,6 +903,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
@@ -914,6 +918,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(script.ptr(), "rename_custom_signal", new_name, name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
@@ -1051,7 +1057,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
-
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
_update_graph();
@@ -1070,6 +1077,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(script.ptr(), "remove_variable", name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
}
@@ -1084,6 +1093,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(script.ptr(), "remove_custom_signal", name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
}
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index e2c9f5ecb4..5036e4f7f6 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -59,7 +59,7 @@ void Button::_notification(int p_what) {
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- xl_text = localize(text);
+ xl_text = tr(text);
minimum_size_changed();
update();
}
@@ -172,7 +172,7 @@ void Button::set_text(const String &p_text) {
if (text == p_text)
return;
text = p_text;
- xl_text = localize(p_text);
+ xl_text = tr(p_text);
update();
_change_notify("text");
minimum_size_changed();
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index d5872d92ec..ef8b0adfa9 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -271,7 +271,7 @@ int WindowDialog::_drag_hit_test(const Point2 &pos) const {
void WindowDialog::set_title(const String &p_title) {
- title = localize(p_title);
+ title = tr(p_title);
update();
}
String WindowDialog::get_title() const {
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 197683b825..b3530c2971 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -464,7 +464,7 @@ void FileDialog::update_filters() {
String flt = filters[i].get_slice(";", 0).strip_edges();
String desc = filters[i].get_slice(";", 1).strip_edges();
if (desc.length())
- filter->add_item(String(localize(desc)) + " ( " + flt + " )");
+ filter->add_item(String(tr(desc)) + " ( " + flt + " )");
else
filter->add_item("( " + flt + " )");
}
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 758aafd115..b2afca8766 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -63,7 +63,7 @@ void Label::_notification(int p_what) {
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- String new_text = localize(text);
+ String new_text = tr(text);
if (new_text == xl_text)
return; //nothing new
xl_text = new_text;
@@ -526,7 +526,7 @@ void Label::set_text(const String &p_string) {
if (text == p_string)
return;
text = p_string;
- xl_text = localize(p_string);
+ xl_text = tr(p_string);
word_cache_dirty = true;
if (percent_visible < 1)
visible_chars = get_total_character_count() * percent_visible;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 2dc60b3dcb..e91f8add31 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -991,7 +991,7 @@ String LineEdit::get_text() const {
void LineEdit::set_placeholder(String p_text) {
- placeholder = localize(p_text);
+ placeholder = tr(p_text);
update();
}
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index a3c06a7b17..1ba936c4e9 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -96,7 +96,7 @@ Size2 PopupMenu::get_minimum_size() const {
size.width += check_w + hseparation;
}
- String text = items[i].shortcut.is_valid() ? String(localize(items[i].shortcut->get_name())) : items[i].xl_text;
+ String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].xl_text;
size.width += font->get_string_size(text).width;
if (i > 0)
size.height += vseparation;
@@ -395,7 +395,7 @@ void PopupMenu::_notification(int p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: {
for (int i = 0; i < items.size(); i++) {
- items[i].xl_text = localize(items[i].text);
+ items[i].xl_text = tr(items[i].text);
}
minimum_size_changed();
@@ -475,7 +475,7 @@ void PopupMenu::_notification(int p_what) {
}
item_ofs.y += font->get_ascent();
- String text = items[i].shortcut.is_valid() ? String(localize(items[i].shortcut->get_name())) : items[i].xl_text;
+ String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].xl_text;
if (!items[i].separator) {
font->draw(ci, item_ofs + Point2(0, Math::floor((h - font_h) / 2.0)), text, items[i].disabled ? font_color_disabled : (i == mouse_over ? font_color_hover : font_color));
@@ -513,7 +513,7 @@ void PopupMenu::add_icon_item(const Ref<Texture> &p_icon, const String &p_label,
Item item;
item.icon = p_icon;
item.text = p_label;
- item.xl_text = localize(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
items.push_back(item);
@@ -523,7 +523,7 @@ void PopupMenu::add_item(const String &p_label, int p_ID, uint32_t p_accel) {
Item item;
item.text = p_label;
- item.xl_text = localize(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
items.push_back(item);
@@ -534,7 +534,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu,
Item item;
item.text = p_label;
- item.xl_text = localize(p_label);
+ item.xl_text = tr(p_label);
item.ID = p_ID;
item.submenu = p_submenu;
items.push_back(item);
@@ -546,7 +546,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_
Item item;
item.icon = p_icon;
item.text = p_label;
- item.xl_text = localize(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
item.checkable = true;
@@ -557,7 +557,7 @@ void PopupMenu::add_check_item(const String &p_label, int p_ID, uint32_t p_accel
Item item;
item.text = p_label;
- item.xl_text = localize(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
item.checkable = true;
@@ -628,7 +628,7 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) {
ERR_FAIL_INDEX(p_idx, items.size());
items[p_idx].text = p_text;
- items[p_idx].xl_text = localize(p_text);
+ items[p_idx].xl_text = tr(p_text);
update();
}
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 520de951d5..d32b899de7 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -231,7 +231,7 @@ void TabContainer::_notification(int p_what) {
// Draw the tab contents.
Control *control = tabs[i + first_tab_cache]->cast_to<Control>();
- String text = control->has_meta("_tab_name") ? String(localize(String(control->get_meta("_tab_name")))) : String(control->get_name());
+ String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
int x_content = tab_rect.position.x + tab_style->get_margin(MARGIN_LEFT);
int top_margin = tab_style->get_margin(MARGIN_TOP);
@@ -299,7 +299,7 @@ int TabContainer::_get_tab_width(int p_index) const {
// Get the width of the text displayed on the tab.
Ref<Font> font = get_font("font");
- String text = control->has_meta("_tab_name") ? String(localize(String(control->get_meta("_tab_name")))) : String(control->get_name());
+ String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
int width = font->get_string_size(text).width;
// Add space for a tab icon.