diff options
author | trollodel <33117082+trollodel@users.noreply.github.com> | 2022-01-27 10:36:51 +0100 |
---|---|---|
committer | trollodel <33117082+trollodel@users.noreply.github.com> | 2022-02-14 14:16:24 +0100 |
commit | 05b56f316ddc94c2bb55b62477ec3914fe81a220 (patch) | |
tree | 928404930fc4f99dfb45d64a6b510e66e2bcc357 /editor/plugins/script_editor_plugin.cpp | |
parent | f5a27ee4fe45925cebfda11ea7d53ca8f39e0a13 (diff) |
Remove most EditorNode constructor parameters and fields
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index bf3ab56a45..315879d4ac 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -416,7 +416,7 @@ void ScriptEditor::_breaked(bool p_breaked, bool p_can_debug) { } void ScriptEditor::_script_created(Ref<Script> p_script) { - editor->push_item(p_script.operator->()); + EditorNode::get_singleton()->push_item(p_script.operator->()); } void ScriptEditor::_goto_script_line2(int p_line) { @@ -430,7 +430,7 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) { Ref<Script> script = Object::cast_to<Script>(*p_script); if (script.is_valid() && (script->has_source_code() || script->get_path().is_resource_file())) { if (edit(p_script, p_line, 0)) { - editor->push_item(p_script.ptr()); + EditorNode::get_singleton()->push_item(p_script.ptr()); ScriptEditorBase *current = _get_current_editor(); if (ScriptTextEditor *script_text_editor = Object::cast_to<ScriptTextEditor>(current)) { @@ -930,7 +930,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) { _save_text_file(text_file, text_file->get_path()); break; } else { - editor->save_resource(script); + EditorNode::get_singleton()->save_resource(script); } se->tag_saved_version(); } @@ -1091,7 +1091,7 @@ void ScriptEditor::_file_dialog_action(String p_file) { Error err; FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err) { - editor->show_warning(TTR("Error writing TextFile:") + "\n" + p_file, TTR("Error!")); + EditorNode::get_singleton()->show_warning(TTR("Error writing TextFile:") + "\n" + p_file, TTR("Error!")); break; } file->close(); @@ -1120,7 +1120,7 @@ void ScriptEditor::_file_dialog_action(String p_file) { Error err = _save_text_file(resource, path); if (err != OK) { - editor->show_accept(TTR("Error saving file!"), TTR("OK")); + EditorNode::get_singleton()->show_accept(TTR("Error saving file!"), TTR("OK")); return; } @@ -1130,12 +1130,12 @@ void ScriptEditor::_file_dialog_action(String p_file) { } break; case THEME_SAVE_AS: { if (!EditorSettings::get_singleton()->save_text_editor_theme_as(p_file)) { - editor->show_warning(TTR("Error while saving theme."), TTR("Error Saving")); + EditorNode::get_singleton()->show_warning(TTR("Error while saving theme."), TTR("Error Saving")); } } break; case THEME_IMPORT: { if (!EditorSettings::get_singleton()->import_text_editor_theme(p_file)) { - editor->show_warning(TTR("Error importing theme."), TTR("Error Importing")); + EditorNode::get_singleton()->show_warning(TTR("Error importing theme."), TTR("Error Importing")); } } break; } @@ -1241,7 +1241,7 @@ void ScriptEditor::_menu_option(int p_option) { Ref<Script> scr = ResourceLoader::load(path); if (!scr.is_valid()) { - editor->show_warning(TTR("Could not load file at:") + "\n\n" + path, TTR("Error!")); + EditorNode::get_singleton()->show_warning(TTR("Could not load file at:") + "\n\n" + path, TTR("Error!")); file_dialog_option = -1; return; } @@ -1253,7 +1253,7 @@ void ScriptEditor::_menu_option(int p_option) { Error error; Ref<TextFile> text_file = _load_text_file(path, &error); if (error != OK) { - editor->show_warning(TTR("Could not load file at:") + "\n\n" + path, TTR("Error!")); + EditorNode::get_singleton()->show_warning(TTR("Could not load file at:") + "\n\n" + path, TTR("Error!")); } if (text_file.is_valid()) { @@ -1355,8 +1355,8 @@ void ScriptEditor::_menu_option(int p_option) { } } - editor->push_item(resource.ptr()); - editor->save_resource_as(resource); + EditorNode::get_singleton()->push_item(resource.ptr()); + EditorNode::get_singleton()->save_resource_as(resource); if (script != nullptr) { const Vector<DocData::ClassDoc> &documentations = script->get_documentation(); @@ -1522,7 +1522,7 @@ void ScriptEditor::_theme_option(int p_option) { if (EditorSettings::get_singleton()->is_default_text_editor_theme()) { ScriptEditor::_show_save_theme_as_dialog(); } else if (!EditorSettings::get_singleton()->save_text_editor_theme()) { - editor->show_warning(TTR("Error while saving theme"), TTR("Error saving")); + EditorNode::get_singleton()->show_warning(TTR("Error while saving theme"), TTR("Error saving")); } } break; case THEME_SAVE_AS: { @@ -1594,10 +1594,10 @@ void ScriptEditor::_tab_changed(int p_which) { void ScriptEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - editor->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); - editor->connect("script_add_function_request", callable_mp(this, &ScriptEditor::_add_callback)); - editor->connect("resource_saved", callable_mp(this, &ScriptEditor::_res_saved_callback)); - editor->connect("scene_saved", callable_mp(this, &ScriptEditor::_scene_saved_callback)); + EditorNode::get_singleton()->connect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); + EditorNode::get_singleton()->connect("script_add_function_request", callable_mp(this, &ScriptEditor::_add_callback)); + EditorNode::get_singleton()->connect("resource_saved", callable_mp(this, &ScriptEditor::_res_saved_callback)); + EditorNode::get_singleton()->connect("scene_saved", callable_mp(this, &ScriptEditor::_scene_saved_callback)); FileSystemDock::get_singleton()->connect("files_moved", callable_mp(this, &ScriptEditor::_files_moved)); FileSystemDock::get_singleton()->connect("file_removed", callable_mp(this, &ScriptEditor::_file_removed)); script_list->connect("item_selected", callable_mp(this, &ScriptEditor::_script_selected)); @@ -1631,7 +1631,7 @@ void ScriptEditor::_notification(int p_what) { filter_scripts->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); filter_methods->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - filename->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); + filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); recent_scripts->set_as_minsize(); @@ -1644,11 +1644,11 @@ void ScriptEditor::_notification(int p_what) { case NOTIFICATION_READY: { get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed)); InspectorDock::get_singleton()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open)); - editor->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search)); + EditorNode::get_singleton()->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search)); } break; case NOTIFICATION_EXIT_TREE: { - editor->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); + EditorNode::get_singleton()->disconnect("stop_pressed", callable_mp(this, &ScriptEditor::_editor_stop)); } break; case NOTIFICATION_WM_WINDOW_FOCUS_IN: { @@ -1661,7 +1661,7 @@ void ScriptEditor::_notification(int p_what) { find_in_files_button->show(); } else { if (find_in_files->is_visible_in_tree()) { - editor->hide_bottom_panel(); + EditorNode::get_singleton()->hide_bottom_panel(); } find_in_files_button->hide(); } @@ -2480,10 +2480,10 @@ void ScriptEditor::save_current_script() { if (!scene_path.is_empty()) { Vector<String> scene_to_save; scene_to_save.push_back(scene_path); - editor->save_scene_list(scene_to_save); + EditorNode::get_singleton()->save_scene_list(scene_to_save); } } else { - editor->save_resource(resource); + EditorNode::get_singleton()->save_resource(resource); } if (script != nullptr) { @@ -2547,7 +2547,7 @@ void ScriptEditor::save_all_scripts() { } } - editor->save_resource(edited_res); //external script, save it + EditorNode::get_singleton()->save_resource(edited_res); //external script, save it if (script != nullptr) { const Vector<DocData::ClassDoc> &documentations = script->get_documentation(); @@ -2567,7 +2567,7 @@ void ScriptEditor::save_all_scripts() { } if (!scenes_to_save.is_empty()) { - editor->save_scene_list(scenes_to_save); + EditorNode::get_singleton()->save_scene_list(scenes_to_save); } _update_script_names(); @@ -2602,7 +2602,7 @@ RES ScriptEditor::open_file(const String &p_file) { if (extensions.find(p_file.get_extension())) { Ref<Script> scr = ResourceLoader::load(p_file); if (!scr.is_valid()) { - editor->show_warning(TTR("Could not load file at:") + "\n\n" + p_file, TTR("Error!")); + EditorNode::get_singleton()->show_warning(TTR("Could not load file at:") + "\n\n" + p_file, TTR("Error!")); return RES(); } @@ -2613,7 +2613,7 @@ RES ScriptEditor::open_file(const String &p_file) { Error error; Ref<TextFile> text_file = _load_text_file(p_file, &error); if (error != OK) { - editor->show_warning(TTR("Could not load file at:") + "\n\n" + p_file, TTR("Error!")); + EditorNode::get_singleton()->show_warning(TTR("Could not load file at:") + "\n\n" + p_file, TTR("Error!")); return RES(); } @@ -2640,7 +2640,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const Ref<Script> script = p_obj->get_script(); ERR_FAIL_COND(!script.is_valid()); - editor->push_item(script.ptr()); + EditorNode::get_singleton()->push_item(script.ptr()); for (int i = 0; i < tab_container->get_child_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); @@ -2685,7 +2685,7 @@ void ScriptEditor::_save_layout() { return; } - editor->save_layout(); + EditorNode::get_singleton()->save_layout(); } void ScriptEditor::_editor_settings_changed() { @@ -3540,7 +3540,7 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb shader_editor->get_shader_editor()->goto_line_selection(line_number - 1, begin, end); return; } else if (fpath.get_extension() == "tscn") { - editor->load_scene(fpath); + EditorNode::get_singleton()->load_scene(fpath); return; } else { Ref<Script> script = res; @@ -3582,7 +3582,7 @@ void ScriptEditor::_start_find_in_files(bool with_replace) { find_in_files->set_replace_text(find_in_files_dialog->get_replace_text()); find_in_files->start_search(); - editor->make_bottom_panel_item_visible(find_in_files); + EditorNode::get_singleton()->make_bottom_panel_item_visible(find_in_files); } void ScriptEditor::_on_find_in_files_modified_files(PackedStringArray paths) { @@ -3630,7 +3630,7 @@ void ScriptEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("script_close", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script"))); } -ScriptEditor::ScriptEditor(EditorNode *p_editor) { +ScriptEditor::ScriptEditor() { current_theme = ""; script_editor_cache.instantiate(); @@ -3643,7 +3643,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { auto_reload_running_scripts = true; members_overview_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/show_members_overview"); help_overview_enabled = EditorSettings::get_singleton()->get("text_editor/help/show_help_index"); - editor = p_editor; VBoxContainer *main_container = memnew(VBoxContainer); add_child(main_container); @@ -3933,7 +3932,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_REPLACE_REQUESTED, callable_mp(this, &ScriptEditor::_start_find_in_files), varray(true)); add_child(find_in_files_dialog); find_in_files = memnew(FindInFilesPanel); - find_in_files_button = editor->add_bottom_panel_item(TTR("Search Results"), find_in_files); + find_in_files_button = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Search Results"), find_in_files); find_in_files->set_custom_minimum_size(Size2(0, 200) * EDSCALE); find_in_files->connect(FindInFilesPanel::SIGNAL_RESULT_SELECTED, callable_mp(this, &ScriptEditor::_on_find_in_files_result_selected)); find_in_files->connect(FindInFilesPanel::SIGNAL_FILES_MODIFIED, callable_mp(this, &ScriptEditor::_on_find_in_files_modified_files)); @@ -3949,8 +3948,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { ScriptServer::edit_request_func = _open_script_request; - add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); - tab_container->add_theme_style_override("panel", editor->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), SNAME("EditorStyles"))); + add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditorPanel"), SNAME("EditorStyles"))); + tab_container->add_theme_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("ScriptEditor"), SNAME("EditorStyles"))); } ScriptEditor::~ScriptEditor() { @@ -4034,10 +4033,9 @@ void ScriptEditorPlugin::edited_scene_changed() { script_editor->edited_scene_changed(); } -ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { - editor = p_node; - script_editor = memnew(ScriptEditor(p_node)); - editor->get_main_control()->add_child(script_editor); +ScriptEditorPlugin::ScriptEditorPlugin() { + script_editor = memnew(ScriptEditor); + EditorNode::get_singleton()->get_main_control()->add_child(script_editor); script_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); script_editor->hide(); |