summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/create_dialog.cpp2
-rw-r--r--tools/editor/editor_help.cpp353
-rw-r--r--tools/editor/editor_help.h43
-rw-r--r--tools/editor/editor_node.cpp38
-rw-r--r--tools/editor/editor_node.h4
-rw-r--r--tools/editor/editor_run_script.cpp72
-rw-r--r--tools/editor/editor_run_script.h27
-rw-r--r--tools/editor/plugins/script_editor_plugin.h1
8 files changed, 536 insertions, 4 deletions
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index 8d577909ef..3a6b856247 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -245,6 +245,7 @@ void CreateDialog::_notification(int p_what) {
void CreateDialog::set_base_type(const String& p_base) {
base_type=p_base;
+ set_title("Create New "+p_base);
_update_search();
}
@@ -295,6 +296,7 @@ CreateDialog::CreateDialog() {
search_options->connect("item_activated",this,"_confirmed");
// search_options->set_hide_root(true);
base_type="Object";
+
}
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp
index 1f281a0feb..75b902dc64 100644
--- a/tools/editor/editor_help.cpp
+++ b/tools/editor/editor_help.cpp
@@ -32,6 +32,288 @@
#include "os/keyboard.h"
#include "doc_data_compressed.h"
+
+
+#include "os/keyboard.h"
+
+
+void EditorHelpSearch::popup(const String& p_term) {
+
+ popup_centered_ratio(0.6);
+ if (p_term!="") {
+ search_box->set_text(p_term);
+ search_box->select_all();
+ } else
+ search_box->clear();
+ search_box->grab_focus();
+}
+
+
+void EditorHelpSearch::_text_changed(const String& p_newtext) {
+
+ _update_search();
+}
+
+void EditorHelpSearch::_sbox_input(const InputEvent& p_ie) {
+
+ if (p_ie.type==InputEvent::KEY && (
+ p_ie.key.scancode == KEY_UP ||
+ p_ie.key.scancode == KEY_DOWN ||
+ p_ie.key.scancode == KEY_PAGEUP ||
+ p_ie.key.scancode == KEY_PAGEDOWN ) ) {
+
+ search_options->call("_input_event",p_ie);
+ search_box->accept_event();
+ }
+
+}
+
+void EditorHelpSearch::_update_search() {
+
+
+ search_options->clear();
+ search_options->set_hide_root(true);
+
+ /*
+ TreeItem *root = search_options->create_item();
+ _parse_fs(EditorFileSystem::get_singleton()->get_filesystem());
+*/
+
+ List<String> type_list;
+ ObjectTypeDB::get_type_list(&type_list);
+
+ DocData *doc=EditorHelp::get_doc_data();
+ String term = search_box->get_text();
+ if (term.length()<3)
+ return;
+
+ TreeItem *root = search_options->create_item();
+
+
+
+ Ref<Texture> def_icon = get_icon("Node","EditorIcons");
+ //classes first
+ for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
+
+ if (E->key().findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_name:"+E->key());
+ item->set_text(0,E->key()+" (Class)");
+ if (has_icon(E->key(),"EditorIcons"))
+ item->set_icon(0,get_icon(E->key(),"EditorIcons"));
+ else
+ item->set_icon(0,def_icon);
+
+
+ }
+
+ }
+
+ //class methods, etc second
+ for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
+
+
+ DocData::ClassDoc & c = E->get();
+
+ Ref<Texture> cicon;
+ if (has_icon(E->key(),"EditorIcons"))
+ cicon=get_icon(E->key(),"EditorIcons");
+ else
+ cicon=def_icon;
+
+ for(int i=0;i<c.methods.size();i++) {
+
+ if (c.methods[i].name.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_method:"+E->key()+":"+c.methods[i].name);
+ item->set_text(0,E->key()+"."+c.methods[i].name+" (Method)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+ for(int i=0;i<c.signals.size();i++) {
+
+ if (c.signals[i].name.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_signal:"+E->key()+":"+c.signals[i].name);
+ item->set_text(0,E->key()+"."+c.signals[i].name+" (Signal)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+ for(int i=0;i<c.constants.size();i++) {
+
+ if (c.constants[i].name.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_constant:"+E->key()+":"+c.constants[i].name);
+ item->set_text(0,E->key()+"."+c.constants[i].name+" (Constant)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+ for(int i=0;i<c.properties.size();i++) {
+
+ if (c.properties[i].name.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_property:"+E->key()+":"+c.properties[i].name);
+ item->set_text(0,E->key()+"."+c.properties[i].name+" (Property)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+ }
+
+ //same but descriptions
+
+ for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) {
+
+
+ DocData::ClassDoc & c = E->get();
+
+ Ref<Texture> cicon;
+ if (has_icon(E->key(),"EditorIcons"))
+ cicon=get_icon(E->key(),"EditorIcons");
+ else
+ cicon=def_icon;
+
+ if (c.description.findn(term)!=-1) {
+
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_desc:"+E->key());
+ item->set_text(0,E->key()+" (Class Description)");
+ item->set_icon(0,cicon);
+
+ }
+
+ for(int i=0;i<c.methods.size();i++) {
+
+ if (c.methods[i].description.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_method_desc:"+E->key()+":"+c.methods[i].name);
+ item->set_text(0,E->key()+"."+c.methods[i].name+" (Method Description)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+ for(int i=0;i<c.signals.size();i++) {
+
+ if (c.signals[i].description.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_signal:"+E->key()+":"+c.signals[i].name);
+ item->set_text(0,E->key()+"."+c.signals[i].name+" (Signal Description)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+ for(int i=0;i<c.constants.size();i++) {
+
+ if (c.constants[i].description.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_constant:"+E->key()+":"+c.constants[i].name);
+ item->set_text(0,E->key()+"."+c.constants[i].name+" (Constant Description)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+ for(int i=0;i<c.properties.size();i++) {
+
+ if (c.properties[i].description.findn(term)!=-1) {
+
+ TreeItem *item = search_options->create_item(root);
+ item->set_metadata(0,"class_property_desc:"+E->key()+":"+c.properties[i].name);
+ item->set_text(0,E->key()+"."+c.properties[i].name+" (Property Description)");
+ item->set_icon(0,cicon);
+ }
+ }
+
+ }
+
+ get_ok()->set_disabled(root->get_children()==NULL);
+
+}
+
+void EditorHelpSearch::_confirmed() {
+
+ TreeItem *ti = search_options->get_selected();
+ if (!ti)
+ return;
+
+ String mdata=ti->get_metadata(0);
+ emit_signal("go_to_help",mdata);
+ // go to that
+ hide();
+}
+
+void EditorHelpSearch::_notification(int p_what) {
+
+ if (p_what==NOTIFICATION_ENTER_SCENE) {
+
+ connect("confirmed",this,"_confirmed");
+ _update_search();
+ }
+
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
+ if (is_visible()) {
+
+ search_box->call_deferred("grab_focus"); // still not visible
+ search_box->select_all();
+ }
+ }
+
+}
+
+
+void EditorHelpSearch::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("_text_changed"),&EditorHelpSearch::_text_changed);
+ ObjectTypeDB::bind_method(_MD("_confirmed"),&EditorHelpSearch::_confirmed);
+ ObjectTypeDB::bind_method(_MD("_sbox_input"),&EditorHelpSearch::_sbox_input);
+ ObjectTypeDB::bind_method(_MD("_update_search"),&EditorHelpSearch::_sbox_input);
+
+ ADD_SIGNAL(MethodInfo("go_to_help"));
+
+}
+
+
+EditorHelpSearch::EditorHelpSearch(EditorNode *p_editor) {
+
+ editor=p_editor;
+ VBoxContainer *vbc = memnew( VBoxContainer );
+ add_child(vbc);
+ set_child_rect(vbc);
+ HBoxContainer *sb_hb = memnew( HBoxContainer);
+ search_box = memnew( LineEdit );
+ sb_hb->add_child(search_box);
+ search_box->set_h_size_flags(SIZE_EXPAND_FILL);
+ Button *sb = memnew( Button("Search"));
+ sb->connect("pressed",this,"_update_search");
+ sb_hb->add_child(sb);
+ vbc->add_margin_child("Search:",sb_hb);
+ search_box->connect("text_changed",this,"_text_changed");
+ search_box->connect("input_event",this,"_sbox_input");
+ search_options = memnew( Tree );
+ vbc->add_margin_child("Matches:",search_options,true);
+ get_ok()->set_text("View");
+ get_ok()->set_disabled(true);
+ register_text_enter(search_box);
+ set_hide_on_ok(false);
+ search_options->connect("item_activated",this,"_confirmed");
+ set_title("Search Classes");
+// search_options->set_hide_root(true);
+
+}
+
+
DocData *EditorHelp::doc=NULL;
void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) {
@@ -98,8 +380,12 @@ void EditorHelp::_button_pressed(int p_idx) {
} else if (p_idx==PAGE_SEARCH) {
_search("");
+ } else if (p_idx==CLASS_SEARCH) {
+
+ class_search->popup();
}
+
}
@@ -181,6 +467,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
//tabs->set_current_tab(PAGE_CLASS_DESC);
edited_class->set_pressed(true);
class_list_button->set_pressed(false);
+ description_line=0;
if (p_class==edited_class->get_text())
return; //already there
@@ -203,7 +490,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
method_line.clear();
edited_class->set_text(p_class);
- edited_class->show();
+ //edited_class->show();
DocData::ClassDoc &cd=doc->class_list[p_class];
@@ -217,6 +504,16 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
h_color=Color(1,1,1,1);
+ class_desc->push_font(doc_title_font);
+ class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
+ class_desc->add_text("Class: ");
+ class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/base_type_color"));
+ class_desc->add_text(p_class);
+ class_desc->pop();
+ class_desc->pop();
+ class_desc->pop();
+ class_desc->add_newline();
+
if (cd.inherits!="") {
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
@@ -264,6 +561,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
for(int i=0;i<cd.methods.size();i++) {
+ method_line[cd.methods[i].name]=class_desc->get_line_count()-2; //gets overriden if description
class_desc->push_font(doc_code_font);
_add_type(cd.methods[i].return_type);
class_desc->add_text(" ");
@@ -332,6 +630,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
for(int i=0;i<cd.properties.size();i++) {
+ property_line[cd.properties[i].name]=class_desc->get_line_count()-2; //gets overriden if description
class_desc->push_font(doc_code_font);
_add_type(cd.properties[i].type);
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/text_color"));
@@ -374,6 +673,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
for(int i=0;i<cd.signals.size();i++) {
+ signal_line[cd.signals[i].name]=class_desc->get_line_count()-2; //gets overriden if description
class_desc->push_font(doc_code_font);
//_add_type("void");
//class_desc->add_text(" ");
@@ -435,6 +735,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
for(int i=0;i<cd.constants.size();i++) {
+ constant_line[cd.constants[i].name]=class_desc->get_line_count()-2;
class_desc->push_font(doc_code_font);
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/base_type_color"));
class_desc->add_text(cd.constants[i].name);
@@ -466,6 +767,7 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
if (cd.description!="") {
+ description_line=class_desc->get_line_count()-2;
class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color"));
class_desc->push_font(doc_title_font);
class_desc->add_text("Description:");
@@ -560,12 +862,46 @@ void EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vs
void EditorHelp::_request_help(const String& p_string) {
+ _goto_desc(p_string);
- _goto_desc(p_string);
+ //100 palabras
}
+void EditorHelp::_help_callback(const String& p_topic) {
+
+ String what = p_topic.get_slice(":",0);
+ String clss = p_topic.get_slice(":",1);
+ String name;
+ if (p_topic.get_slice_count(":")==3)
+ name=p_topic.get_slice(":",2);
+
+ _request_help(clss); //first go to class
+
+ int line=0;
+
+ if (what=="class_desc") {
+ line=description_line;
+ } else if (what=="class_signal") {
+ if (signal_line.has(name))
+ line=signal_line[name];
+ } else if (what=="class_method" || what=="class_method_desc") {
+ if (method_line.has(name))
+ line=method_line[name];
+ } else if (what=="class_property") {
+
+ if (property_line.has(name))
+ line=property_line[name];
+ } else if (what=="class_constant") {
+
+ if (constant_line.has(name))
+ line=constant_line[name];
+ }
+
+ class_desc->scroll_to_line(line);
+
+}
void EditorHelp::_add_text(const String& p_bbcode) {
@@ -903,6 +1239,7 @@ void EditorHelp::_bind_methods() {
ObjectTypeDB::bind_method("_unhandled_key_input",&EditorHelp::_unhandled_key_input);
ObjectTypeDB::bind_method("_search",&EditorHelp::_search);
ObjectTypeDB::bind_method("_tree_item_selected",&EditorHelp::_tree_item_selected);
+ ObjectTypeDB::bind_method("_help_callback",&EditorHelp::_help_callback);
}
@@ -933,6 +1270,10 @@ EditorHelp::EditorHelp(EditorNode *p_editor) {
b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_DESC));
edited_class->hide();
+ b = memnew( Button );
+ b->set_text("Search in Classes");
+ panel_hb->add_child(b);
+ b->connect("pressed",this,"_button_pressed",make_binds(CLASS_SEARCH));
Control *expand = memnew( Control );
expand->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -959,10 +1300,13 @@ EditorHelp::EditorHelp(EditorNode *p_editor) {
search->connect("text_entered",this,"_search");
b = memnew( Button );
- b->set_text("Search");
+ b->set_text("Find");
panel_hb->add_child(b);
b->connect("pressed",this,"_button_pressed",make_binds(PAGE_SEARCH));
+ hs = memnew( VSeparator );
+ panel_hb->add_child(hs);
+
h_split = memnew( HSplitContainer );
h_split->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -994,6 +1338,9 @@ EditorHelp::EditorHelp(EditorNode *p_editor) {
class_list->connect("cell_selected",this,"_tree_item_selected");
class_desc->hide();
+ class_search = memnew( EditorHelpSearch(editor) );
+ editor->get_gui_base()->add_child(class_search);
+ class_search->connect("go_to_help",this,"_help_callback");
// prev_search_page=-1;
}
diff --git a/tools/editor/editor_help.h b/tools/editor/editor_help.h
index d626304b4a..eac33e5e16 100644
--- a/tools/editor/editor_help.h
+++ b/tools/editor/editor_help.h
@@ -45,6 +45,36 @@
class EditorNode;
+class EditorHelpSearch : public ConfirmationDialog {
+
+ OBJ_TYPE(EditorHelpSearch,ConfirmationDialog )
+
+ EditorNode *editor;
+ LineEdit *search_box;
+ Tree *search_options;
+ String base_type;
+
+ void _update_search();
+
+ void _sbox_input(const InputEvent& p_ie);
+
+ void _confirmed();
+ void _text_changed(const String& p_newtext);
+
+
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void popup(const String& p_term="");
+
+ EditorHelpSearch(EditorNode *p_editor);
+};
+
+
+
class EditorHelp : public VBoxContainer {
OBJ_TYPE( EditorHelp, VBoxContainer );
@@ -56,6 +86,7 @@ class EditorHelp : public VBoxContainer {
PAGE_CLASS_PREV,
PAGE_CLASS_NEXT,
PAGE_SEARCH,
+ CLASS_SEARCH,
};
@@ -74,6 +105,10 @@ class EditorHelp : public VBoxContainer {
EditorNode *editor;
Map<String,int> method_line;
+ Map<String,int> signal_line;
+ Map<String,int> property_line;
+ Map<String,int> constant_line;
+ int description_line;
Tree *class_list;
@@ -91,6 +126,9 @@ class EditorHelp : public VBoxContainer {
HashMap<String,TreeItem*> tree_item_map;
+
+ void _help_callback(const String& p_topic);
+
void _add_text(const String& p_text);
bool scroll_locked;
@@ -112,6 +150,8 @@ class EditorHelp : public VBoxContainer {
void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root);
void _tree_item_selected();
+ EditorHelpSearch *class_search;
+
protected:
@@ -120,12 +160,14 @@ protected:
public:
static void generate_doc();
+ static DocData *get_doc_data() { return doc; }
EditorHelp(EditorNode *p_editor=NULL);
~EditorHelp();
};
+
class EditorHelpPlugin : public EditorPlugin {
OBJ_TYPE( EditorHelpPlugin, EditorPlugin );
@@ -156,4 +198,5 @@ public:
};
+
#endif // EDITOR_HELP_H
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp
index 35809e653e..ed932396db 100644
--- a/tools/editor/editor_node.cpp
+++ b/tools/editor/editor_node.cpp
@@ -938,7 +938,27 @@ void EditorNode::_dialog_action(String p_file) {
} break;
+ case FILE_RUN_SCRIPT: {
+ print_line("RUN: "+p_file);
+ Ref<Script> scr = ResourceLoader::load(p_file,"Script",true);
+ if (scr.is_null()) {
+ add_io_error("Script Failed to Load:\n"+p_file);
+ return;
+ }
+ if (!scr->is_tool()) {
+
+ add_io_error("Script is not tool, will not be able to run:\n"+p_file);
+ return;
+ }
+
+ Ref<EditorScript> es = memnew( EditorScript );
+ es->set_script(scr.get_ref_ptr());
+ es->set_editor(this);
+ es->_run();
+
+ get_undo_redo()->clear_history();
+ } break;
case FILE_DUMP_STRINGS: {
save_translatable_strings(p_file);
@@ -1633,7 +1653,10 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
quick_open->set_title("Quick Open Script..");
} break;
+ case FILE_RUN_SCRIPT: {
+ file_script->popup_centered_ratio();
+ } break;
case FILE_OPEN_PREV: {
if (previous_scenes.empty())
@@ -3028,6 +3051,7 @@ void EditorNode::register_editor_types() {
ObjectTypeDB::register_type<EditorPlugin>();
ObjectTypeDB::register_type<EditorImportPlugin>();
ObjectTypeDB::register_type<EditorScenePostImport>();
+ ObjectTypeDB::register_type<EditorScript>();
//ObjectTypeDB::register_type<EditorImporter>();
@@ -3424,6 +3448,8 @@ EditorNode::EditorNode() {
p->add_item("Undo",EDIT_UNDO,KEY_MASK_CMD+KEY_Z);
p->add_item("Redo",EDIT_REDO,KEY_MASK_CMD+KEY_MASK_SHIFT+KEY_Z);
p->add_separator();
+ p->add_item("Run Script",FILE_RUN_SCRIPT,KEY_MASK_CMD+KEY_R);
+ p->add_separator();
p->add_item("Project Settings",RUN_SETTINGS);
p->add_item("Project Manager",RUN_PROJECT_MANAGER);
p->add_separator();
@@ -3929,6 +3955,18 @@ EditorNode::EditorNode() {
file_export->get_vbox()->add_margin_child("Password:",file_export_password);
+ file_script = memnew( FileDialog );
+ file_script->set_title("Open & Run a Script");
+ file_script->set_access(FileDialog::ACCESS_FILESYSTEM);
+ file_script->set_mode(FileDialog::MODE_OPEN_FILE);
+ List<String> sexts;
+ ResourceLoader::get_recognized_extensions_for_type("Script",&sexts);
+ for (List<String>::Element*E=sexts.front();E;E=E->next()) {
+ file_script->add_filter("*."+E->get());
+ }
+ gui_base->add_child(file_script);
+ file_script->connect("file_selected",this,"_dialog_action");
+
reimport_dialog = memnew( EditorReImportDialog );
gui_base->add_child(reimport_dialog);
diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h
index 89b3917d7c..30504aa08e 100644
--- a/tools/editor/editor_node.h
+++ b/tools/editor/editor_node.h
@@ -65,6 +65,7 @@
#include "tools/editor/scene_tree_dock.h"
#include "tools/editor/resources_dock.h"
#include "tools/editor/optimized_save_dialog.h"
+#include "tools/editor/editor_run_script.h"
#include "tools/editor/editor_run_native.h"
#include "scene/gui/tabs.h"
@@ -115,6 +116,7 @@ class EditorNode : public Node {
FILE_OPEN_OLD_SCENE,
FILE_QUICK_OPEN_SCENE,
FILE_QUICK_OPEN_SCRIPT,
+ FILE_RUN_SCRIPT,
FILE_OPEN_PREV,
FILE_QUIT,
FILE_EXTERNAL_OPEN_SCENE,
@@ -231,6 +233,7 @@ class EditorNode : public Node {
FileDialog *file_templates;
FileDialog *file_export;
FileDialog *file_export_lib;
+ FileDialog *file_script;
CheckButton *file_export_check;
CheckButton *file_export_lib_merge;
LineEdit *file_export_password;
@@ -459,7 +462,6 @@ public:
Error export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password,bool p_quit_after=false);
-
static void register_editor_types();
Control *get_gui_base() { return gui_base; }
diff --git a/tools/editor/editor_run_script.cpp b/tools/editor/editor_run_script.cpp
new file mode 100644
index 0000000000..5f8598d052
--- /dev/null
+++ b/tools/editor/editor_run_script.cpp
@@ -0,0 +1,72 @@
+#include "editor_run_script.h"
+#include "editor_node.h"
+
+
+
+
+
+
+void EditorScript::add_root_node(Node *p_node) {
+
+ if (!editor) {
+ EditorNode::add_io_error("EditorScript::add_root_node : Write your logic in the _run() method.");
+ return;
+ }
+
+ if (editor->get_edited_scene()) {
+ EditorNode::add_io_error("EditorScript::add_root_node : There is an edited scene already.");
+ return;
+ }
+
+ editor->set_edited_scene(p_node);
+}
+
+Node *EditorScript::get_scene() {
+
+ if (!editor) {
+ EditorNode::add_io_error("EditorScript::get_scene : Write your logic in the _run() method.");
+ return NULL;
+ }
+
+ return editor->get_edited_scene();
+}
+
+void EditorScript::_run() {
+
+ Ref<Script> s = get_script();
+ ERR_FAIL_COND(!s.is_valid());
+ if (!get_script_instance()) {
+ EditorNode::add_io_error("Couldn't instance script:\n "+s->get_path()+"\nDid you forget the 'tool' keyword?");
+ return;
+
+ }
+
+ Variant::CallError ce;
+ ce.error=Variant::CallError::CALL_OK;
+ get_script_instance()->call("_run",NULL,0,ce);
+ if (ce.error!=Variant::CallError::CALL_OK) {
+
+ EditorNode::add_io_error("Couldn't run script:\n "+s->get_path()+"\nDid you forget the '_run' method?");
+ }
+}
+
+void EditorScript::set_editor(EditorNode *p_editor) {
+
+ editor=p_editor;
+}
+
+
+void EditorScript::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("add_root_node","node"),&EditorScript::add_root_node);
+ ObjectTypeDB::bind_method(_MD("get_scene"),&EditorScript::get_scene);
+ BIND_VMETHOD( MethodInfo("_run") );
+
+
+}
+
+EditorScript::EditorScript() {
+
+ editor=NULL;
+}
+
diff --git a/tools/editor/editor_run_script.h b/tools/editor/editor_run_script.h
new file mode 100644
index 0000000000..8dbefced7f
--- /dev/null
+++ b/tools/editor/editor_run_script.h
@@ -0,0 +1,27 @@
+#ifndef EDITOR_RUN_SCRIPT_H
+#define EDITOR_RUN_SCRIPT_H
+
+#include "reference.h"
+
+
+class EditorNode;
+class EditorScript : public Reference {
+
+ OBJ_TYPE( EditorScript, Reference );
+
+ EditorNode *editor;
+protected:
+
+ static void _bind_methods();
+public:
+
+ void add_root_node(Node *p_node);
+ Node *get_scene();
+
+ virtual void _run();
+
+ void set_editor(EditorNode *p_editor);
+ EditorScript();
+};
+
+#endif // EDITOR_RUN_SCRIPT_H
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 898ad1daff..e0cf3c1a49 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -79,6 +79,7 @@ class ScriptTextEditor : public CodeTextEditor {
Vector<String> functions;
+
protected: