summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-05-17 15:09:09 +0200
committerGitHub <noreply@github.com>2022-05-17 15:09:09 +0200
commit5b02415fd0a603f76368212e829fc4f839200064 (patch)
tree393444fc8aed4535e969309a2ef0e48a2725e5c5
parent1d5e6627667f6963d9b29f85fa71c9d4240c07e7 (diff)
parentca4c63d654d3e31e8a7bfa7143b2d290de01c7e8 (diff)
Merge pull request #55134 from KoBeWi/script_pillow_or_something
Always soft-reload scripts
-rw-r--r--editor/plugins/script_editor_plugin.cpp26
-rw-r--r--editor/plugins/script_editor_plugin.h1
-rw-r--r--modules/gdscript/gdscript.cpp2
3 files changed, 18 insertions, 11 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 8e33afa3c6..115c6f43dd 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -966,7 +966,7 @@ void ScriptEditor::_reload_scripts() {
ERR_CONTINUE(!rel_script.is_valid());
script->set_source_code(rel_script->get_source_code());
script->set_last_modified_time(rel_script->get_last_modified_time());
- script->reload();
+ script->reload(true);
}
Ref<TextFile> text_file = edited_res;
@@ -1365,9 +1365,17 @@ void ScriptEditor::_menu_option(int p_option) {
}
} break;
- case FILE_TOOL_RELOAD:
case FILE_TOOL_RELOAD_SOFT: {
- current->reload(p_option == FILE_TOOL_RELOAD_SOFT);
+ Ref<Script> scr = current->get_edited_resource();
+ if (scr == nullptr || scr.is_null()) {
+ EditorNode::get_singleton()->show_warning(TTR("Can't obtain the script for reloading."));
+ break;
+ }
+ if (!scr->is_tool()) {
+ EditorNode::get_singleton()->show_warning(TTR("Reload only takes effect on tool scripts."));
+ return;
+ }
+ scr->reload(true);
} break;
case FILE_RUN: {
@@ -1376,6 +1384,10 @@ void ScriptEditor::_menu_option(int p_option) {
EditorNode::get_singleton()->show_warning(TTR("Can't obtain the script for running."));
break;
}
+ if (!scr->is_tool()) {
+ EditorNode::get_singleton()->show_warning(TTR("Script is not in tool mode, will not be able to run."));
+ return;
+ }
current->apply_code();
Error err = scr->reload(false); //hard reload script before running always
@@ -1384,10 +1396,6 @@ void ScriptEditor::_menu_option(int p_option) {
EditorNode::get_singleton()->show_warning(TTR("Script failed reloading, check console for errors."));
return;
}
- if (!scr->is_tool()) {
- EditorNode::get_singleton()->show_warning(TTR("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(TTR("To run this script, it must inherit EditorScript and be set to tool mode."));
@@ -3091,8 +3099,8 @@ void ScriptEditor::_make_script_list_context_menu() {
if (se) {
Ref<Script> scr = se->get_edited_resource();
if (scr != nullptr) {
- context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT);
if (!scr.is_null() && scr->is_tool()) {
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT);
context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/run_file"), FILE_RUN);
context_menu->add_separator();
}
@@ -3774,7 +3782,7 @@ ScriptEditor::ScriptEditor() {
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_as", TTR("Save As...")), FILE_SAVE_AS);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_all", TTR("Save All"), KeyModifierMask::SHIFT | KeyModifierMask::ALT | Key::S), FILE_SAVE_ALL);
file_menu->get_popup()->add_separator();
- file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_script_soft", TTR("Soft Reload Script"), KeyModifierMask::CMD | KeyModifierMask::ALT | Key::R), FILE_TOOL_RELOAD_SOFT);
+ file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_script_soft", TTR("Soft Reload Tool Script"), KeyModifierMask::CMD | KeyModifierMask::ALT | Key::R), FILE_TOOL_RELOAD_SOFT);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy_path", TTR("Copy Script Path")), FILE_COPY_PATH);
file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/show_in_file_system", TTR("Show in FileSystem")), SHOW_IN_FILE_SYSTEM);
file_menu->get_popup()->add_separator();
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 35cb24da70..ff71c8b484 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -206,7 +206,6 @@ class ScriptEditor : public PanelContainer {
TOGGLE_SCRIPTS_PANEL,
SHOW_IN_FILE_SYSTEM,
FILE_COPY_PATH,
- FILE_TOOL_RELOAD,
FILE_TOOL_RELOAD_SOFT,
SEARCH_IN_FILES,
REPLACE_IN_FILES,
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index e3c9101733..e400d0bf94 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -2372,7 +2372,7 @@ Error ResourceFormatSaverGDScript::save(const String &p_path, const Ref<Resource
}
if (ScriptServer::is_reload_scripts_on_save_enabled()) {
- GDScriptLanguage::get_singleton()->reload_tool_script(p_resource, false);
+ GDScriptLanguage::get_singleton()->reload_tool_script(p_resource, true);
}
return OK;