#ifndef EDITOR_NODE_H #define EDITOR_NODE_H /*************************************************************************/ /* editor_node.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "core/object/object.h" #include "scene/main/node.h" #include "editor/editor_folding.h" #include "editor/editor_run.h" #include "editor/inspector_dock.h" #include "editor/scene_tree_dock.h" #include "scene/gui/menu_button.h" #include "scene/gui/split_container.h" #include "core/containers/list.h" #include "core/containers/map.h" #include "core/containers/set.h" #include "core/containers/vector.h" #include "core/error/error_list.h" #include "core/math/rect2.h" #include "core/object/reference.h" #include "core/object/resource.h" #include "core/os/mutex.h" #include "core/os/os.h" #include "core/os/safe_refcount.h" #include "core/os/thread.h" #include "core/string/node_path.h" #include "core/string/print_string.h" #include "core/string/string_name.h" #include "core/string/ustring.h" #include "core/typedefs.h" #include "core/variant/dictionary.h" #include "core/variant/variant.h" #include "editor/editor_data.h" #include "scene/gui/control.h" #include "scene/resources/texture.h" #include "scene/resources/theme.h" class Button; class Camera; class CheckBox; class ConfigFile; class Container; class EditorFileDialog; class EditorInterface; class EditorResourceConversionPlugin; class FileDialog; class HBoxContainer; class InputEvent; class LinkButton; class OptionButton; class PopupMenu; class PopupPanel; class RichTextLabel; class Script; class TextureRect; class Timer; class Tree; class UndoRedo; class VBoxContainer; class Viewport; template class PoolVector; typedef void (*EditorNodeInitCallback)(); typedef void (*EditorPluginInitializeCallback)(); typedef bool (*EditorBuildCallback)(); class AcceptDialog; class AudioStreamPreviewGenerator; class BackgroundProgress; class CenterContainer; class ConfirmationDialog; class Control; class DependencyEditor; class DependencyErrorDialog; class EditorAbout; class EditorExport; class EditorFileServer; class EditorInspector; class EditorLayoutsDialog; class EditorLog; class EditorPlugin; class EditorPluginList; class EditorQuickOpen; class EditorResourcePreview; class EditorRunNative; class EditorSettingsDialog; class ExportTemplateManager; class FileSystemDock; class HSplitContainer; class ImportDock; class MenuButton; class NodeDock; class OrphanResourcesDialog; class PaneDrag; class Panel; class PanelContainer; class PluginConfigDialog; class ProgressDialog; class ProjectExportDialog; class ProjectSettingsEditor; class RunSettingsDialog; class ScriptCreateDialog; class TabContainer; class Tabs; class TextureProgress; class ToolButton; class VSplitContainer; class EditorNode : public Node { GDCLASS(EditorNode, Node); public: enum DockSlot { DOCK_SLOT_LEFT_UL, DOCK_SLOT_LEFT_BL, DOCK_SLOT_LEFT_UR, DOCK_SLOT_LEFT_BR, DOCK_SLOT_RIGHT_UL, DOCK_SLOT_RIGHT_BL, DOCK_SLOT_RIGHT_UR, DOCK_SLOT_RIGHT_BR, DOCK_SLOT_MAX }; struct ExecuteThreadArgs { String path; List args; String output; Thread execute_output_thread; Mutex execute_output_mutex; int exitcode; SafeFlag done; }; public: bool call_build(); static void add_plugin_init_callback(EditorPluginInitializeCallback p_callback); enum EditorTable { EDITOR_2D = 0, EDITOR_3D, EDITOR_SCRIPT }; void set_visible_editor(EditorTable p_table) { _editor_select(p_table); } static EditorNode *get_singleton() { return singleton; } EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; } EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; } EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; } EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; } EditorInspector *get_inspector() { return inspector_dock->get_inspector(); } Container *get_inspector_dock_addon_area() { return inspector_dock->get_addon_area(); } ScriptCreateDialog *get_script_create_dialog() { return scene_tree_dock->get_script_create_dialog(); } ProjectSettingsEditor *get_project_settings() { return project_settings; } static void add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false); static void remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false); static void disambiguate_filenames(const Vector p_full_paths, Vector &r_filenames); void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); } void set_docks_visible(bool p_show); bool get_docks_visible() const; void set_distraction_free_mode(bool p_enter); bool is_distraction_free_mode_enabled() const; void add_control_to_dock(DockSlot p_slot, Control *p_control); void remove_control_from_dock(Control *p_control); void set_addon_plugin_enabled(String p_addon, bool p_enabled, bool p_config_changed = false); bool is_addon_plugin_enabled(const String &p_addon) const; void edit_node(Node *p_node); void edit_resource(const Ref &p_resource) { inspector_dock->edit_resource(p_resource); }; void open_resource(const String &p_type) { inspector_dock->open_resource(p_type); }; void save_resource_in_path(const Ref &p_resource, const String &p_path); void save_resource(const Ref &p_resource); void save_resource_as(const Ref &p_resource, const String &p_at_path = String()); void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE, false); } void show_about() { _menu_option_confirm(HELP_ABOUT, false); } static bool has_unsaved_changes() { return singleton->unsaved_cache; } static HBoxContainer *get_menu_hb() { return singleton->menu_hb; } void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false); void edit_item(Object *p_object); void edit_item_resource(RES p_resource); bool item_has_editor(Object *p_object); void hide_top_editors(); void select_editor_by_name(const String &p_name); void editor_set_visible_by_name(const String &p_name, const bool p_visible); void open_request(const String &p_path); bool is_changing_scene() const; static EditorLog *get_log() { return singleton->log; } Control *get_viewport(); void set_edited_scene(Node *p_scene); Node *get_edited_scene() { return editor_data.get_edited_scene_root(); } Viewport *get_scene_root() { return scene_root; } //root of the scene being edited void fix_dependencies(const String &p_for_file); int new_scene(); Error load_scene(const String &p_scene, bool p_ignore_broken_deps = false, bool p_set_inherited = false, bool p_clear_errors = true, bool p_force_open_imported = false, bool p_silent_change_tab = false); Error load_resource(const String &p_resource, bool p_ignore_broken_deps = false); bool is_scene_open(const String &p_path); void set_current_version(uint64_t p_version); void set_current_scene(int p_idx); static EditorData &get_editor_data() { return singleton->editor_data; } static EditorFolding &get_editor_folding() { return singleton->editor_folding; } EditorHistory *get_editor_history() { return &editor_history; } static VSplitContainer *get_top_split() { return singleton->top_split; } void request_instance_scene(const String &p_path); void request_instance_scenes(const Vector &p_files); FileSystemDock *get_filesystem_dock(); ImportDock *get_import_dock(); SceneTreeDock *get_scene_tree_dock(); InspectorDock *get_inspector_dock(); static UndoRedo *get_undo_redo() { return &singleton->editor_data.get_undo_redo(); } EditorSelection *get_editor_selection() { return editor_selection; } void set_convert_old_scene(bool p_old) { convert_old = p_old; } void notify_child_process_exited(); OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); } void stop_child_process(); Ref get_editor_theme() const { return theme; } Ref