mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Update script signals in real-time when script changes. Fixes #8980
This commit is contained in:
parent
2ed87f33cf
commit
b20952ebff
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
void show_groups();
|
||||
void show_connections();
|
||||
|
||||
void update_lists();
|
||||
|
||||
NodeDock();
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user