2023-04-05 17:14:46 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/* editor_interface.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#ifndef EDITOR_INTERFACE_H
|
|
|
|
#define EDITOR_INTERFACE_H
|
|
|
|
|
|
|
|
#include "core/io/resource.h"
|
|
|
|
#include "core/object/class_db.h"
|
|
|
|
#include "core/object/object.h"
|
|
|
|
#include "core/object/script_language.h"
|
|
|
|
|
|
|
|
class Control;
|
|
|
|
class EditorCommandPalette;
|
|
|
|
class EditorFileSystem;
|
|
|
|
class EditorInspector;
|
|
|
|
class EditorPaths;
|
2023-05-11 23:46:53 +02:00
|
|
|
class EditorPlugin;
|
2023-04-05 17:14:46 +02:00
|
|
|
class EditorResourcePreview;
|
|
|
|
class EditorSelection;
|
|
|
|
class EditorSettings;
|
2024-04-02 13:33:12 +02:00
|
|
|
class EditorUndoRedoManager;
|
2023-04-05 17:14:46 +02:00
|
|
|
class FileSystemDock;
|
|
|
|
class Mesh;
|
|
|
|
class Node;
|
2023-09-13 22:03:13 +02:00
|
|
|
class PropertySelector;
|
|
|
|
class SceneTreeDialog;
|
2023-04-05 17:14:46 +02:00
|
|
|
class ScriptEditor;
|
2023-08-13 20:57:23 +02:00
|
|
|
class SubViewport;
|
2023-04-05 17:14:46 +02:00
|
|
|
class Texture2D;
|
2023-09-13 13:14:07 +02:00
|
|
|
class Theme;
|
2023-04-05 17:14:46 +02:00
|
|
|
class VBoxContainer;
|
2023-04-20 15:13:21 +02:00
|
|
|
class Window;
|
2023-04-05 17:14:46 +02:00
|
|
|
|
|
|
|
class EditorInterface : public Object {
|
|
|
|
GDCLASS(EditorInterface, Object);
|
|
|
|
|
|
|
|
static EditorInterface *singleton;
|
|
|
|
|
2023-09-13 22:03:13 +02:00
|
|
|
// Editor dialogs.
|
|
|
|
|
|
|
|
PropertySelector *property_selector = nullptr;
|
|
|
|
SceneTreeDialog *node_selector = nullptr;
|
|
|
|
|
|
|
|
void _node_selected(const NodePath &p_node_paths, const Callable &p_callback);
|
|
|
|
void _node_selection_canceled(const Callable &p_callback);
|
|
|
|
void _property_selected(const String &p_property_name, const Callable &p_callback);
|
|
|
|
void _property_selection_canceled(const Callable &p_callback);
|
|
|
|
void _call_dialog_callback(const Callable &p_callback, const Variant &p_selected, const String &p_context);
|
|
|
|
|
2023-04-05 17:14:46 +02:00
|
|
|
// Editor tools.
|
|
|
|
|
|
|
|
TypedArray<Texture2D> _make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static EditorInterface *get_singleton() { return singleton; }
|
|
|
|
|
|
|
|
void restart_editor(bool p_save = true);
|
|
|
|
|
|
|
|
// Editor tools.
|
|
|
|
|
|
|
|
EditorCommandPalette *get_command_palette() const;
|
|
|
|
EditorFileSystem *get_resource_file_system() const;
|
|
|
|
EditorPaths *get_editor_paths() const;
|
|
|
|
EditorResourcePreview *get_resource_previewer() const;
|
|
|
|
EditorSelection *get_selection() const;
|
|
|
|
Ref<EditorSettings> get_editor_settings() const;
|
2024-04-02 13:33:12 +02:00
|
|
|
EditorUndoRedoManager *get_editor_undo_redo() const;
|
2023-04-05 17:14:46 +02:00
|
|
|
|
|
|
|
Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size);
|
|
|
|
|
|
|
|
void set_plugin_enabled(const String &p_plugin, bool p_enabled);
|
|
|
|
bool is_plugin_enabled(const String &p_plugin) const;
|
|
|
|
|
|
|
|
// Editor GUI.
|
|
|
|
|
2023-09-13 13:14:07 +02:00
|
|
|
Ref<Theme> get_editor_theme() const;
|
|
|
|
|
2023-04-05 17:14:46 +02:00
|
|
|
Control *get_base_control() const;
|
|
|
|
VBoxContainer *get_editor_main_screen() const;
|
|
|
|
ScriptEditor *get_script_editor() const;
|
2023-08-13 20:57:23 +02:00
|
|
|
SubViewport *get_editor_viewport_2d() const;
|
|
|
|
SubViewport *get_editor_viewport_3d(int p_idx = 0) const;
|
2023-04-05 17:14:46 +02:00
|
|
|
|
|
|
|
void set_main_screen_editor(const String &p_name);
|
|
|
|
void set_distraction_free_mode(bool p_enter);
|
|
|
|
bool is_distraction_free_mode_enabled() const;
|
2023-11-06 12:41:08 +01:00
|
|
|
bool is_multi_window_enabled() const;
|
2023-04-05 17:14:46 +02:00
|
|
|
|
|
|
|
float get_editor_scale() const;
|
|
|
|
|
2023-04-20 15:13:21 +02:00
|
|
|
void popup_dialog(Window *p_dialog, const Rect2i &p_screen_rect = Rect2i());
|
|
|
|
void popup_dialog_centered(Window *p_dialog, const Size2i &p_minsize = Size2i());
|
|
|
|
void popup_dialog_centered_ratio(Window *p_dialog, float p_ratio = 0.8);
|
|
|
|
void popup_dialog_centered_clamped(Window *p_dialog, const Size2i &p_size = Size2i(), float p_fallback_ratio = 0.75);
|
|
|
|
|
2023-03-04 20:27:56 +01:00
|
|
|
String get_current_feature_profile() const;
|
|
|
|
void set_current_feature_profile(const String &p_profile_name);
|
|
|
|
|
2023-09-13 22:03:13 +02:00
|
|
|
// Editor dialogs.
|
|
|
|
|
|
|
|
void popup_node_selector(const Callable &p_callback, const TypedArray<StringName> &p_valid_types = TypedArray<StringName>());
|
|
|
|
// Must use Vector<int> because exposing Vector<Variant::Type> is not supported.
|
|
|
|
void popup_property_selector(Object *p_object, const Callable &p_callback, const PackedInt32Array &p_type_filter = PackedInt32Array());
|
|
|
|
|
2023-04-05 17:14:46 +02:00
|
|
|
// Editor docks.
|
|
|
|
|
|
|
|
FileSystemDock *get_file_system_dock() const;
|
|
|
|
void select_file(const String &p_file);
|
|
|
|
Vector<String> get_selected_paths() const;
|
|
|
|
String get_current_path() const;
|
|
|
|
String get_current_directory() const;
|
|
|
|
|
|
|
|
EditorInspector *get_inspector() const;
|
|
|
|
|
|
|
|
// Object/Resource/Node editing.
|
|
|
|
|
|
|
|
void inspect_object(Object *p_obj, const String &p_for_property = String(), bool p_inspector_only = false);
|
|
|
|
|
|
|
|
void edit_resource(const Ref<Resource> &p_resource);
|
|
|
|
void edit_node(Node *p_node);
|
|
|
|
void edit_script(const Ref<Script> &p_script, int p_line = -1, int p_col = 0, bool p_grab_focus = true);
|
|
|
|
void open_scene_from_path(const String &scene_path);
|
|
|
|
void reload_scene_from_path(const String &scene_path);
|
|
|
|
|
|
|
|
PackedStringArray get_open_scenes() const;
|
|
|
|
Node *get_edited_scene_root() const;
|
|
|
|
|
|
|
|
Error save_scene();
|
|
|
|
void save_scene_as(const String &p_scene, bool p_with_preview = true);
|
2023-06-07 13:44:37 +02:00
|
|
|
void mark_scene_as_unsaved();
|
2023-05-27 04:23:06 +02:00
|
|
|
void save_all_scenes();
|
2023-04-05 17:14:46 +02:00
|
|
|
|
|
|
|
// Scene playback.
|
|
|
|
|
|
|
|
void play_main_scene();
|
|
|
|
void play_current_scene();
|
|
|
|
void play_custom_scene(const String &scene_path);
|
|
|
|
void stop_playing_scene();
|
|
|
|
bool is_playing_scene() const;
|
|
|
|
String get_playing_scene() const;
|
|
|
|
|
|
|
|
void set_movie_maker_enabled(bool p_enabled);
|
|
|
|
bool is_movie_maker_enabled() const;
|
|
|
|
|
2024-01-03 12:10:11 +01:00
|
|
|
#ifdef TOOLS_ENABLED
|
2024-01-06 18:06:41 +01:00
|
|
|
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
2024-01-03 12:10:11 +01:00
|
|
|
#endif
|
2024-01-06 18:06:41 +01:00
|
|
|
|
2024-01-03 12:10:11 +01:00
|
|
|
// Base.
|
2023-04-05 17:14:46 +02:00
|
|
|
static void create();
|
|
|
|
static void free();
|
|
|
|
|
|
|
|
EditorInterface();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EDITOR_INTERFACE_H
|