diff options
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 78a5aac0eb..4a127e5d87 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -38,6 +38,7 @@ #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/version.h" +#include "editor/code_editor.h" #include "editor/debugger/editor_debugger_node.h" #include "editor/debugger/script_editor_debugger.h" #include "editor/editor_command_palette.h" @@ -1640,7 +1641,7 @@ void ScriptEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { EditorRunBar::get_singleton()->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); - _editor_settings_changed(); + _apply_editor_settings(); [[fallthrough]]; } @@ -2482,6 +2483,12 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col, se->connect("replace_in_files_requested", callable_mp(this, &ScriptEditor::_on_replace_in_files_requested)); se->connect("go_to_method", callable_mp(this, &ScriptEditor::script_goto_method)); + CodeTextEditor *cte = se->get_code_editor(); + if (cte) { + cte->set_zoom_factor(zoom_factor); + cte->connect("zoomed", callable_mp(this, &ScriptEditor::_set_zoom_factor)); + } + //test for modification, maybe the script was not edited but was loaded _test_script_times_on_disk(p_resource); @@ -2780,11 +2787,16 @@ void ScriptEditor::_save_layout() { } void ScriptEditor::_editor_settings_changed() { - if (!EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor") && + if (!EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor") && + !EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor") && !EditorSettings::get_singleton()->check_changed_settings_in_group("docks/filesystem")) { return; } + _apply_editor_settings(); +} + +void ScriptEditor::_apply_editor_settings() { textfile_extensions.clear(); const Vector<String> textfile_ext = ((String)(EDITOR_GET("docks/filesystem/textfile_extensions"))).split(",", false); for (const String &E : textfile_ext) { @@ -2809,6 +2821,11 @@ void ScriptEditor::_editor_settings_changed() { EditorSettings::get_singleton()->load_text_editor_theme(); } + _update_script_colors(); + _update_script_names(); + + ScriptServer::set_reload_scripts_on_save(EDITOR_GET("text_editor/behavior/files/auto_reload_and_parse_scripts_on_save")); + for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); if (!se) { @@ -2817,10 +2834,6 @@ void ScriptEditor::_editor_settings_changed() { se->update_settings(); } - _update_script_colors(); - _update_script_names(); - - ScriptServer::set_reload_scripts_on_save(EDITOR_GET("text_editor/behavior/files/auto_reload_and_parse_scripts_on_save")); } void ScriptEditor::_filesystem_changed() { @@ -3323,6 +3336,8 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { } } + _set_zoom_factor(p_layout->get_value("ScriptEditor", "zoom_factor", 1.0f)); + restoring_layout = false; _update_script_names(); @@ -3372,6 +3387,7 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { p_layout->set_value("ScriptEditor", "open_help", helps); p_layout->set_value("ScriptEditor", "script_split_offset", script_split->get_split_offset()); p_layout->set_value("ScriptEditor", "list_split_offset", list_split->get_split_offset()); + p_layout->set_value("ScriptEditor", "zoom_factor", zoom_factor); // Save the cache. script_editor_cache->save(EditorPaths::get_singleton()->get_project_settings_dir().path_join("script_editor_cache.cfg")); @@ -3807,6 +3823,24 @@ void ScriptEditor::_on_find_in_files_modified_files(PackedStringArray paths) { _update_modified_scripts_for_external_editor(); } +void ScriptEditor::_set_zoom_factor(float p_zoom_factor) { + if (zoom_factor == p_zoom_factor) { + return; + } + zoom_factor = p_zoom_factor; + for (int i = 0; i < tab_container->get_tab_count(); i++) { + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); + if (se) { + CodeTextEditor *cte = se->get_code_editor(); + if (cte) { + if (zoom_factor != cte->get_zoom_factor()) { + cte->set_zoom_factor(zoom_factor); + } + } + } + } +} + void ScriptEditor::_window_changed(bool p_visible) { make_floating->set_visible(!p_visible); is_floating = p_visible; @@ -3971,12 +4005,11 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new_textfile", TTR("New Text File..."), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::N), FILE_NEW_TEXTFILE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/open", TTR("Open...")), FILE_OPEN); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reopen_closed_script", TTR("Reopen Closed Script"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::T), FILE_REOPEN_CLOSED); - file_menu->get_popup()->add_submenu_item(TTR("Open Recent"), "RecentScripts", FILE_OPEN_RECENT); recent_scripts = memnew(PopupMenu); - recent_scripts->set_name("RecentScripts"); - file_menu->get_popup()->add_child(recent_scripts); + file_menu->get_popup()->add_submenu_node_item(TTR("Open Recent"), recent_scripts, FILE_OPEN_RECENT); recent_scripts->connect("id_pressed", callable_mp(this, &ScriptEditor::_open_recent_script)); + _update_recent_scripts(); file_menu->get_popup()->add_separator(); @@ -3994,14 +4027,11 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_next", TTR("History Next"), KeyModifierMask::ALT | Key::RIGHT), WINDOW_NEXT); file_menu->get_popup()->add_separator(); - file_menu->get_popup()->add_submenu_item(TTR("Theme"), "Theme", FILE_THEME); - theme_submenu = memnew(PopupMenu); - theme_submenu->set_name("Theme"); - file_menu->get_popup()->add_child(theme_submenu); - theme_submenu->connect("id_pressed", callable_mp(this, &ScriptEditor::_theme_option)); theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/import_theme", TTR("Import Theme...")), THEME_IMPORT); theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/reload_theme", TTR("Reload Theme")), THEME_RELOAD); + file_menu->get_popup()->add_submenu_node_item(TTR("Theme"), theme_submenu, FILE_THEME); + theme_submenu->connect("id_pressed", callable_mp(this, &ScriptEditor::_theme_option)); theme_submenu->add_separator(); theme_submenu->add_shortcut(ED_SHORTCUT("script_editor/save_theme", TTR("Save Theme")), THEME_SAVE); |