mirror of
https://github.com/godotengine/godot.git
synced 2025-02-16 15:50:45 +00:00
Make available more informations about editor for Tool Plugins
This commit is contained in:
parent
0ee47fefbe
commit
708d825001
@ -353,6 +353,7 @@ void EditorData::notify_edited_scene_changed() {
|
|||||||
for (int i = 0; i < editor_plugins.size(); i++) {
|
for (int i = 0; i < editor_plugins.size(); i++) {
|
||||||
|
|
||||||
editor_plugins[i]->edited_scene_changed();
|
editor_plugins[i]->edited_scene_changed();
|
||||||
|
editor_plugins[i]->notify_scene_changed(get_edited_scene_root());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,8 +489,14 @@ void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) {
|
|||||||
}
|
}
|
||||||
void EditorData::remove_scene(int p_idx) {
|
void EditorData::remove_scene(int p_idx) {
|
||||||
ERR_FAIL_INDEX(p_idx, edited_scene.size());
|
ERR_FAIL_INDEX(p_idx, edited_scene.size());
|
||||||
if (edited_scene[p_idx].root)
|
if (edited_scene[p_idx].root) {
|
||||||
|
|
||||||
|
for (int i = 0; i < editor_plugins.size(); i++) {
|
||||||
|
editor_plugins[i]->notify_scene_closed(edited_scene[p_idx].root->get_filename());
|
||||||
|
}
|
||||||
|
|
||||||
memdelete(edited_scene[p_idx].root);
|
memdelete(edited_scene[p_idx].root);
|
||||||
|
}
|
||||||
|
|
||||||
if (current_edited_scene > p_idx)
|
if (current_edited_scene > p_idx)
|
||||||
current_edited_scene--;
|
current_edited_scene--;
|
||||||
@ -615,6 +622,17 @@ int EditorData::get_edited_scene_count() const {
|
|||||||
return edited_scene.size();
|
return edited_scene.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector<EditorData::EditedScene> EditorData::get_edited_scenes() const {
|
||||||
|
|
||||||
|
Vector<EditedScene> out_edited_scenes_list = Vector<EditedScene>();
|
||||||
|
|
||||||
|
for (int i = 0; i < edited_scene.size(); i++) {
|
||||||
|
out_edited_scenes_list.push_back(edited_scene[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return out_edited_scenes_list;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorData::set_edited_scene_version(uint64_t version, int scene_idx) {
|
void EditorData::set_edited_scene_version(uint64_t version, int scene_idx) {
|
||||||
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
|
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
|
||||||
if (scene_idx < 0) {
|
if (scene_idx < 0) {
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#define EDITOR_DATA_H
|
#define EDITOR_DATA_H
|
||||||
|
|
||||||
#include "editor/editor_plugin.h"
|
#include "editor/editor_plugin.h"
|
||||||
|
#include "editor/plugins/script_editor_plugin.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "pair.h"
|
#include "pair.h"
|
||||||
#include "scene/resources/texture.h"
|
#include "scene/resources/texture.h"
|
||||||
@ -109,6 +110,17 @@ public:
|
|||||||
Ref<Texture> icon;
|
Ref<Texture> icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct EditedScene {
|
||||||
|
Node *root;
|
||||||
|
Dictionary editor_states;
|
||||||
|
List<Node *> selection;
|
||||||
|
Vector<EditorHistory::History> history_stored;
|
||||||
|
int history_current;
|
||||||
|
Dictionary custom_state;
|
||||||
|
uint64_t version;
|
||||||
|
NodePath live_edit_root;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<EditorPlugin *> editor_plugins;
|
Vector<EditorPlugin *> editor_plugins;
|
||||||
|
|
||||||
@ -124,17 +136,6 @@ private:
|
|||||||
|
|
||||||
void _cleanup_history();
|
void _cleanup_history();
|
||||||
|
|
||||||
struct EditedScene {
|
|
||||||
Node *root;
|
|
||||||
Dictionary editor_states;
|
|
||||||
List<Node *> selection;
|
|
||||||
Vector<EditorHistory::History> history_stored;
|
|
||||||
int history_current;
|
|
||||||
Dictionary custom_state;
|
|
||||||
uint64_t version;
|
|
||||||
NodePath live_edit_root;
|
|
||||||
};
|
|
||||||
|
|
||||||
Vector<EditedScene> edited_scene;
|
Vector<EditedScene> edited_scene;
|
||||||
int current_edited_scene;
|
int current_edited_scene;
|
||||||
|
|
||||||
@ -180,6 +181,7 @@ public:
|
|||||||
int get_edited_scene() const;
|
int get_edited_scene() const;
|
||||||
Node *get_edited_scene_root(int p_idx = -1);
|
Node *get_edited_scene_root(int p_idx = -1);
|
||||||
int get_edited_scene_count() const;
|
int get_edited_scene_count() const;
|
||||||
|
Vector<EditedScene> get_edited_scenes() const;
|
||||||
String get_scene_title(int p_idx) const;
|
String get_scene_title(int p_idx) const;
|
||||||
String get_scene_path(int p_idx) const;
|
String get_scene_path(int p_idx) const;
|
||||||
String get_scene_type(int p_idx) const;
|
String get_scene_type(int p_idx) const;
|
||||||
|
@ -1575,6 +1575,11 @@ void EditorNode::_edit_current() {
|
|||||||
|
|
||||||
editor_plugin_screen->make_visible(true);
|
editor_plugin_screen->make_visible(true);
|
||||||
|
|
||||||
|
int plugin_count = editor_data.get_editor_plugin_count();
|
||||||
|
for (int i = 0; i < plugin_count; i++) {
|
||||||
|
editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name());
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < editor_table.size(); i++) {
|
for (int i = 0; i < editor_table.size(); i++) {
|
||||||
|
|
||||||
main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin);
|
main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin);
|
||||||
@ -2865,6 +2870,11 @@ void EditorNode::_editor_select(int p_which) {
|
|||||||
editor_plugin_screen->make_visible(true);
|
editor_plugin_screen->make_visible(true);
|
||||||
editor_plugin_screen->selected_notify();
|
editor_plugin_screen->selected_notify();
|
||||||
|
|
||||||
|
int plugin_count = editor_data.get_editor_plugin_count();
|
||||||
|
for (int i = 0; i < plugin_count; i++) {
|
||||||
|
editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name());
|
||||||
|
}
|
||||||
|
|
||||||
if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) {
|
if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) {
|
||||||
if (p_which == EDITOR_SCRIPT) {
|
if (p_which == EDITOR_SCRIPT) {
|
||||||
set_distraction_free_mode(script_distraction);
|
set_distraction_free_mode(script_distraction);
|
||||||
@ -3756,6 +3766,7 @@ void EditorNode::register_editor_types() {
|
|||||||
ClassDB::register_class<EditorResourcePreviewGenerator>();
|
ClassDB::register_class<EditorResourcePreviewGenerator>();
|
||||||
ClassDB::register_class<EditorFileSystem>();
|
ClassDB::register_class<EditorFileSystem>();
|
||||||
ClassDB::register_class<EditorFileSystemDirectory>();
|
ClassDB::register_class<EditorFileSystemDirectory>();
|
||||||
|
ClassDB::register_virtual_class<ScriptEditor>();
|
||||||
|
|
||||||
//ClassDB::register_type<EditorImporter>();
|
//ClassDB::register_type<EditorImporter>();
|
||||||
//ClassDB::register_type<EditorPostImport>();
|
//ClassDB::register_type<EditorPostImport>();
|
||||||
|
@ -171,6 +171,46 @@ void EditorPlugin::set_input_event_forwarding_always_enabled() {
|
|||||||
always_input_forwarding_list->add_plugin(this);
|
always_input_forwarding_list->add_plugin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node *EditorPlugin::get_edited_scene_root() {
|
||||||
|
return EditorNode::get_singleton()->get_edited_scene();
|
||||||
|
}
|
||||||
|
|
||||||
|
Array EditorPlugin::get_opened_scenes_list() const {
|
||||||
|
|
||||||
|
Array ret;
|
||||||
|
Vector<EditorData::EditedScene> scenes = EditorNode::get_singleton()->get_editor_data().get_edited_scenes();
|
||||||
|
|
||||||
|
int scns_amount = scenes.size();
|
||||||
|
for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
|
||||||
|
if (scenes[idx_scn].root == NULL)
|
||||||
|
continue;
|
||||||
|
ret.push_back(scenes[idx_scn].root->get_filename());
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptEditor *EditorPlugin::get_script_editor() {
|
||||||
|
return ScriptEditor::get_singleton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorPlugin::notify_scene_changed(const Node *scn_root) {
|
||||||
|
if (scn_root == NULL) return;
|
||||||
|
emit_signal("scene_changed", scn_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorPlugin::notify_main_screen_changed(const String &screen_name) {
|
||||||
|
|
||||||
|
if (screen_name == last_main_screen_name)
|
||||||
|
return;
|
||||||
|
|
||||||
|
emit_signal("main_screen_changed", screen_name);
|
||||||
|
last_main_screen_name = screen_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorPlugin::notify_scene_closed(const String &scene_filepath) {
|
||||||
|
emit_signal("scene_closed", scene_filepath);
|
||||||
|
}
|
||||||
|
|
||||||
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
|
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
|
||||||
//??
|
//??
|
||||||
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
|
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
|
||||||
@ -392,6 +432,7 @@ void EditorPlugin::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("get_undo_redo:UndoRedo"), &EditorPlugin::_get_undo_redo);
|
ClassDB::bind_method(D_METHOD("get_undo_redo:UndoRedo"), &EditorPlugin::_get_undo_redo);
|
||||||
ClassDB::bind_method(D_METHOD("get_selection:EditorSelection"), &EditorPlugin::get_selection);
|
ClassDB::bind_method(D_METHOD("get_selection:EditorSelection"), &EditorPlugin::get_selection);
|
||||||
ClassDB::bind_method(D_METHOD("get_editor_settings:EditorSettings"), &EditorPlugin::get_editor_settings);
|
ClassDB::bind_method(D_METHOD("get_editor_settings:EditorSettings"), &EditorPlugin::get_editor_settings);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_script_editor:ScriptEditor"), &EditorPlugin::get_script_editor);
|
||||||
ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
|
ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
|
||||||
ClassDB::bind_method(D_METHOD("edit_resource"), &EditorPlugin::edit_resource);
|
ClassDB::bind_method(D_METHOD("edit_resource"), &EditorPlugin::edit_resource);
|
||||||
ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorPlugin::open_scene_from_path);
|
ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorPlugin::open_scene_from_path);
|
||||||
@ -399,6 +440,9 @@ void EditorPlugin::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("add_import_plugin"), &EditorPlugin::add_import_plugin);
|
ClassDB::bind_method(D_METHOD("add_import_plugin"), &EditorPlugin::add_import_plugin);
|
||||||
ClassDB::bind_method(D_METHOD("remove_import_plugin"), &EditorPlugin::remove_import_plugin);
|
ClassDB::bind_method(D_METHOD("remove_import_plugin"), &EditorPlugin::remove_import_plugin);
|
||||||
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
|
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_opened_scenes_list"), &EditorPlugin::get_opened_scenes_list);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_edited_scene_root:Node"), &EditorPlugin::get_edited_scene_root);
|
||||||
|
|
||||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
||||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control")));
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control")));
|
||||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
||||||
@ -420,6 +464,10 @@ void EditorPlugin::_bind_methods() {
|
|||||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
|
||||||
ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
|
ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
|
||||||
|
|
||||||
|
ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root:Node")));
|
||||||
|
ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath:String")));
|
||||||
|
ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name:String")));
|
||||||
|
|
||||||
BIND_CONSTANT(CONTAINER_TOOLBAR);
|
BIND_CONSTANT(CONTAINER_TOOLBAR);
|
||||||
BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
|
BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
|
||||||
BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE);
|
BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE);
|
||||||
@ -442,6 +490,7 @@ void EditorPlugin::_bind_methods() {
|
|||||||
EditorPlugin::EditorPlugin() {
|
EditorPlugin::EditorPlugin() {
|
||||||
undo_redo = NULL;
|
undo_redo = NULL;
|
||||||
input_event_forwarding_always_enabled = false;
|
input_event_forwarding_always_enabled = false;
|
||||||
|
last_main_screen_name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorPlugin::~EditorPlugin() {
|
EditorPlugin::~EditorPlugin() {
|
||||||
|
@ -52,6 +52,8 @@ class EditorImportPlugin;
|
|||||||
class EditorExportPlugin;
|
class EditorExportPlugin;
|
||||||
class EditorResourcePreview;
|
class EditorResourcePreview;
|
||||||
class EditorFileSystem;
|
class EditorFileSystem;
|
||||||
|
class EditorToolAddons;
|
||||||
|
class ScriptEditor;
|
||||||
|
|
||||||
class EditorPlugin : public Node {
|
class EditorPlugin : public Node {
|
||||||
|
|
||||||
@ -63,6 +65,8 @@ class EditorPlugin : public Node {
|
|||||||
|
|
||||||
bool input_event_forwarding_always_enabled;
|
bool input_event_forwarding_always_enabled;
|
||||||
|
|
||||||
|
String last_main_screen_name;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
UndoRedo &get_undo_redo() { return *undo_redo; }
|
UndoRedo &get_undo_redo() { return *undo_redo; }
|
||||||
@ -113,6 +117,14 @@ public:
|
|||||||
void set_input_event_forwarding_always_enabled();
|
void set_input_event_forwarding_always_enabled();
|
||||||
bool is_input_event_forwarding_always_enabled() { return input_event_forwarding_always_enabled; }
|
bool is_input_event_forwarding_always_enabled() { return input_event_forwarding_always_enabled; }
|
||||||
|
|
||||||
|
Node *get_edited_scene_root();
|
||||||
|
Array get_opened_scenes_list() const;
|
||||||
|
ScriptEditor *get_script_editor();
|
||||||
|
|
||||||
|
void notify_main_screen_changed(const String &screen_name);
|
||||||
|
void notify_scene_changed(const Node *scn_root);
|
||||||
|
void notify_scene_closed(const String &scene_filepath);
|
||||||
|
|
||||||
virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
|
virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
|
||||||
virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event);
|
virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event);
|
||||||
virtual void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas);
|
virtual void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas);
|
||||||
|
@ -405,6 +405,8 @@ void ScriptEditor::_go_to_tab(int p_idx) {
|
|||||||
script_icon->set_texture(c->cast_to<ScriptEditorBase>()->get_icon());
|
script_icon->set_texture(c->cast_to<ScriptEditorBase>()->get_icon());
|
||||||
if (is_visible_in_tree())
|
if (is_visible_in_tree())
|
||||||
c->cast_to<ScriptEditorBase>()->ensure_focus();
|
c->cast_to<ScriptEditorBase>()->ensure_focus();
|
||||||
|
|
||||||
|
notify_script_changed(c->cast_to<ScriptEditorBase>()->get_edited_script());
|
||||||
}
|
}
|
||||||
if (c->cast_to<EditorHelp>()) {
|
if (c->cast_to<EditorHelp>()) {
|
||||||
|
|
||||||
@ -510,7 +512,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) {
|
|||||||
apply_scripts();
|
apply_scripts();
|
||||||
}
|
}
|
||||||
current->clear_edit_menu();
|
current->clear_edit_menu();
|
||||||
|
notify_script_close(current->get_edited_script());
|
||||||
} else {
|
} else {
|
||||||
EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>();
|
EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>();
|
||||||
_add_recent_script(help->get_class());
|
_add_recent_script(help->get_class());
|
||||||
@ -777,6 +779,31 @@ void ScriptEditor::_file_dialog_action(String p_file) {
|
|||||||
file_dialog_option = -1;
|
file_dialog_option = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<Script> ScriptEditor::_get_current_script() {
|
||||||
|
|
||||||
|
int selected = tab_container->get_current_tab();
|
||||||
|
if (selected < 0 || selected >= tab_container->get_child_count())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>();
|
||||||
|
if (current) {
|
||||||
|
return current->get_edited_script();
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Array ScriptEditor::_get_opened_script_list() const {
|
||||||
|
|
||||||
|
Array ret;
|
||||||
|
Vector<Ref<Script> > scripts = get_opened_scripts();
|
||||||
|
int scrits_amount = scripts.size();
|
||||||
|
for (int idx_script = 0; idx_script < scrits_amount; idx_script++) {
|
||||||
|
ret.push_back(scripts[idx_script]);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptEditor::_menu_option(int p_option) {
|
void ScriptEditor::_menu_option(int p_option) {
|
||||||
|
|
||||||
switch (p_option) {
|
switch (p_option) {
|
||||||
@ -1127,6 +1154,14 @@ void ScriptEditor::edited_scene_changed() {
|
|||||||
_update_modified_scripts_for_external_editor();
|
_update_modified_scripts_for_external_editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptEditor::notify_script_close(const Ref<Script> &p_script) {
|
||||||
|
emit_signal("script_close", p_script);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) {
|
||||||
|
emit_signal("script_changed", p_script);
|
||||||
|
}
|
||||||
|
|
||||||
static const Node *_find_node_with_script(const Node *p_node, const RefPtr &p_script) {
|
static const Node *_find_node_with_script(const Node *p_node, const RefPtr &p_script) {
|
||||||
|
|
||||||
if (p_node->get_script() == p_script)
|
if (p_node->get_script() == p_script)
|
||||||
@ -1662,6 +1697,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
|
|||||||
if (p_line >= 0)
|
if (p_line >= 0)
|
||||||
se->goto_line(p_line - 1);
|
se->goto_line(p_line - 1);
|
||||||
|
|
||||||
|
notify_script_changed(p_script);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2038,6 +2074,8 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
|
|||||||
|
|
||||||
n->cast_to<ScriptEditorBase>()->set_edit_state(history[history_pos].state);
|
n->cast_to<ScriptEditorBase>()->set_edit_state(history[history_pos].state);
|
||||||
n->cast_to<ScriptEditorBase>()->ensure_focus();
|
n->cast_to<ScriptEditorBase>()->ensure_focus();
|
||||||
|
|
||||||
|
notify_script_changed(n->cast_to<ScriptEditorBase>()->get_edited_script());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n->cast_to<EditorHelp>()) {
|
if (n->cast_to<EditorHelp>()) {
|
||||||
@ -2065,6 +2103,21 @@ void ScriptEditor::_history_back() {
|
|||||||
_update_history_pos(history_pos - 1);
|
_update_history_pos(history_pos - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector<Ref<Script> > ScriptEditor::get_opened_scripts() const {
|
||||||
|
|
||||||
|
Vector<Ref<Script> > out_scripts = Vector<Ref<Script> >();
|
||||||
|
|
||||||
|
for (int i = 0; i < tab_container->get_child_count(); i++) {
|
||||||
|
ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>();
|
||||||
|
if (!se)
|
||||||
|
continue;
|
||||||
|
out_scripts.push_back(se->get_edited_script());
|
||||||
|
}
|
||||||
|
|
||||||
|
return out_scripts;
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
|
void ScriptEditor::set_scene_root_script(Ref<Script> p_script) {
|
||||||
|
|
||||||
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
|
bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change");
|
||||||
@ -2158,6 +2211,12 @@ void ScriptEditor::_bind_methods() {
|
|||||||
ClassDB::bind_method("_history_back", &ScriptEditor::_history_back);
|
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("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
|
||||||
ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
|
ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_opened_scripts_list"), &ScriptEditor::_get_opened_script_list);
|
||||||
|
|
||||||
|
ADD_SIGNAL(MethodInfo("script_changed", PropertyInfo(Variant::OBJECT, "script:Script")));
|
||||||
|
ADD_SIGNAL(MethodInfo("script_close", PropertyInfo(Variant::STRING, "script:String")));
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
||||||
|
@ -321,6 +321,9 @@ class ScriptEditor : public VBoxContainer {
|
|||||||
int file_dialog_option;
|
int file_dialog_option;
|
||||||
void _file_dialog_action(String p_file);
|
void _file_dialog_action(String p_file);
|
||||||
|
|
||||||
|
Ref<Script> _get_current_script();
|
||||||
|
Array _get_opened_script_list() const;
|
||||||
|
|
||||||
static void _open_script_request(const String &p_path);
|
static void _open_script_request(const String &p_path);
|
||||||
|
|
||||||
static ScriptEditor *script_editor;
|
static ScriptEditor *script_editor;
|
||||||
@ -354,11 +357,15 @@ public:
|
|||||||
void get_window_layout(Ref<ConfigFile> p_layout);
|
void get_window_layout(Ref<ConfigFile> p_layout);
|
||||||
|
|
||||||
void set_scene_root_script(Ref<Script> p_script);
|
void set_scene_root_script(Ref<Script> p_script);
|
||||||
|
Vector<Ref<Script> > get_opened_scripts() const;
|
||||||
|
|
||||||
bool script_goto_method(Ref<Script> p_script, const String &p_method);
|
bool script_goto_method(Ref<Script> p_script, const String &p_method);
|
||||||
|
|
||||||
virtual void edited_scene_changed();
|
virtual void edited_scene_changed();
|
||||||
|
|
||||||
|
void notify_script_close(const Ref<Script> &p_script);
|
||||||
|
void notify_script_changed(const Ref<Script> &p_script);
|
||||||
|
|
||||||
void close_builtin_scripts_from_scene(const String &p_scene);
|
void close_builtin_scripts_from_scene(const String &p_scene);
|
||||||
|
|
||||||
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
|
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
|
||||||
|
Loading…
Reference in New Issue
Block a user