Changed reload logic to auto-hard-reload scripts on save. It's simpler to use and also fixes #4756
This commit is contained in:
parent
910151a361
commit
45443a1651
5 changed files with 29 additions and 4 deletions
|
@ -32,7 +32,7 @@ ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES];
|
|||
int ScriptServer::_language_count=0;
|
||||
|
||||
bool ScriptServer::scripting_enabled=true;
|
||||
|
||||
bool ScriptServer::reload_scripts_on_save=false;
|
||||
|
||||
void Script::_notification( int p_what) {
|
||||
|
||||
|
@ -92,6 +92,16 @@ void ScriptServer::init_languages() {
|
|||
}
|
||||
}
|
||||
|
||||
void ScriptServer::set_reload_scripts_on_save(bool p_enable) {
|
||||
|
||||
reload_scripts_on_save=p_enable;
|
||||
}
|
||||
|
||||
bool ScriptServer::is_reload_scripts_on_save_enabled() {
|
||||
|
||||
return reload_scripts_on_save;
|
||||
}
|
||||
|
||||
void ScriptInstance::get_property_state(List<Pair<StringName, Variant> > &state) {
|
||||
|
||||
List<PropertyInfo> pinfo;
|
||||
|
|
|
@ -47,6 +47,7 @@ class ScriptServer {
|
|||
static ScriptLanguage *_languages[MAX_LANGUAGES];
|
||||
static int _language_count;
|
||||
static bool scripting_enabled;
|
||||
static bool reload_scripts_on_save;
|
||||
public:
|
||||
|
||||
static void set_scripting_enabled(bool p_enabled);
|
||||
|
@ -55,6 +56,9 @@ public:
|
|||
static ScriptLanguage *get_language(int p_idx);
|
||||
static void register_language(ScriptLanguage *p_language);
|
||||
|
||||
static void set_reload_scripts_on_save(bool p_enable);
|
||||
static bool is_reload_scripts_on_save_enabled();
|
||||
|
||||
static void init_languages();
|
||||
};
|
||||
|
||||
|
|
|
@ -1791,8 +1791,9 @@ Error VariantParser::parse(Stream *p_stream, Variant& r_ret, String &r_err_str,
|
|||
|
||||
static String rtosfix(double p_value) {
|
||||
|
||||
|
||||
if (p_value==0.0)
|
||||
return "0"; //avoid negative zero being written, which may annoy git, svn, etc. for changes when they don't exist.
|
||||
return "0"; //avoid negative zero (-0) being written, which may annoy git, svn, etc. for changes when they don't exist.
|
||||
else
|
||||
return rtoss(p_value);
|
||||
}
|
||||
|
|
|
@ -1898,6 +1898,11 @@ Error ResourceFormatSaverGDScript::save(const String &p_path,const RES& p_resour
|
|||
}
|
||||
file->close();
|
||||
memdelete(file);
|
||||
|
||||
if (ScriptServer::is_reload_scripts_on_save_enabled()) {
|
||||
GDScriptLanguage::get_singleton()->reload_tool_script(p_resource,false);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -2155,7 +2155,9 @@ void ScriptEditor::save_all_scripts() {
|
|||
|
||||
editor->save_resource(script);
|
||||
//ResourceSaver::save(script->get_path(),script);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2276,6 +2278,8 @@ void ScriptEditor::_editor_settings_changed() {
|
|||
ste->get_text_edit()->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter"));
|
||||
}
|
||||
|
||||
ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/auto_reload_and_parse_scripts_on_save",true));
|
||||
|
||||
}
|
||||
|
||||
void ScriptEditor::_autosave_scripts() {
|
||||
|
@ -2617,8 +2621,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
|||
edit_menu->get_popup()->add_item(TTR("Auto Indent"),EDIT_AUTO_INDENT,KEY_MASK_CMD|KEY_I);
|
||||
edit_menu->get_popup()->connect("item_pressed", this,"_menu_option");
|
||||
edit_menu->get_popup()->add_separator();
|
||||
edit_menu->get_popup()->add_item(TTR("Reload Tool Script"),FILE_TOOL_RELOAD,KEY_MASK_CMD|KEY_R);
|
||||
edit_menu->get_popup()->add_item(TTR("Reload Tool Script (Soft)"),FILE_TOOL_RELOAD_SOFT,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_R);
|
||||
edit_menu->get_popup()->add_item(TTR("Soft Reload Script"),FILE_TOOL_RELOAD_SOFT,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_R);
|
||||
|
||||
|
||||
search_menu = memnew( MenuButton );
|
||||
|
@ -2922,6 +2925,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
|
|||
script_editor->hide();
|
||||
|
||||
EDITOR_DEF("text_editor/auto_reload_scripts_on_external_change",true);
|
||||
ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/auto_reload_and_parse_scripts_on_save",true));
|
||||
EDITOR_DEF("text_editor/open_dominant_script_on_scene_change",true);
|
||||
EDITOR_DEF("external_editor/use_external_editor",false);
|
||||
EDITOR_DEF("external_editor/exec_path","");
|
||||
|
@ -2933,6 +2937,7 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
|
|||
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_GLOBAL_FILE));
|
||||
EDITOR_DEF("external_editor/exec_flags","");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue