summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp27
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/plugins/script_editor_plugin.cpp28
-rw-r--r--editor/plugins/script_editor_plugin.h1
4 files changed, 30 insertions, 27 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index f724cba3ef..c376efca34 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -56,7 +56,6 @@
#include "editor/editor_help.h"
#include "editor/editor_initialize_ssl.h"
#include "editor/editor_settings.h"
-#include "editor/editor_settings.h"
#include "editor/editor_themes.h"
#include "editor/import/editor_import_collada.h"
#include "editor/import/editor_scene_importer_gltf.h"
@@ -972,26 +971,6 @@ void EditorNode::_dialog_action(String p_file) {
//would be nice to show the project manager opened with the highlighted field..
_run(false, ""); // automatically run the project
} break;
- case FILE_RUN_SCRIPT: {
-
- 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_CLOSE:
case FILE_CLOSE_ALL_AND_QUIT:
case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER:
@@ -1652,10 +1631,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
quick_open->set_title(TTR("Quick Open Script.."));
} break;
- case FILE_RUN_SCRIPT: {
-
- file_script->popup_centered_ratio();
- } break;
case FILE_OPEN_PREV: {
if (previous_scenes.empty())
@@ -4806,7 +4781,7 @@ EditorNode::EditorNode() {
p->add_item(TTR("Project Settings"), RUN_SETTINGS);
p->add_separator();
p->connect("id_pressed", this, "_menu_option");
- p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R);
+ //p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R);
p->add_item(TTR("Export"), FILE_EXPORT_PROJECT);
PopupMenu *tool_menu = memnew(PopupMenu);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 985f5cd894..08c7e11c85 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -129,7 +129,6 @@ private:
FILE_OPEN_OLD_SCENE,
FILE_QUICK_OPEN_SCENE,
FILE_QUICK_OPEN_SCRIPT,
- FILE_RUN_SCRIPT,
FILE_OPEN_PREV,
FILE_CLOSE,
FILE_CLOSE_ALL_AND_QUIT,
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 316c76e4b2..6f35ca1b0c 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -965,7 +965,33 @@ void ScriptEditor::_menu_option(int p_option) {
current->reload(p_option == FILE_TOOL_RELOAD_SOFT);
} break;
+ case FILE_RUN: {
+ Ref<Script> scr = current->get_edited_script();
+ if (scr.is_null()) {
+ EditorNode::get_singleton()->show_warning("Can't obtain the script for running");
+ break;
+ }
+ if (!scr->is_tool()) {
+
+ EditorNode::get_singleton()->show_warning("Script is not in tool mode, will not be able to run");
+ return;
+ }
+
+ if (!ClassDB::is_parent_class(scr->get_instance_base_type(), "EditorScript")) {
+
+ EditorNode::get_singleton()->show_warning("To run this script, it must inherit EditorScript and be set to tool mode");
+ return;
+ }
+
+ Ref<EditorScript> es = memnew(EditorScript);
+ es->set_script(scr.get_ref_ptr());
+ es->set_editor(EditorNode::get_singleton());
+
+ es->_run();
+
+ EditorNode::get_undo_redo()->clear_history();
+ } break;
case FILE_CLOSE: {
if (current->is_unsaved()) {
_ask_close_current_unsaved_tab(current);
@@ -2220,6 +2246,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL);
file_menu->get_popup()->add_separator();
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/run_file", TTR("Run"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_X), FILE_RUN);
+ file_menu->get_popup()->add_separator();
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KEY_MASK_CMD | KEY_BACKSLASH), TOGGLE_SCRIPTS_PANEL);
file_menu->get_popup()->connect("id_pressed", this, "_menu_option");
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 17209de681..d2677c6a4a 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -131,6 +131,7 @@ class ScriptEditor : public PanelContainer {
FILE_RELOAD_THEME,
FILE_SAVE_THEME,
FILE_SAVE_THEME_AS,
+ FILE_RUN,
FILE_CLOSE,
CLOSE_DOCS,
CLOSE_ALL,