diff options
Diffstat (limited to 'editor')
125 files changed, 2416 insertions, 1733 deletions
diff --git a/editor/SCsub b/editor/SCsub index a596c7d364..59508f3025 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -113,6 +113,7 @@ if env["tools"]: env.add_source_files(env.editor_sources, "register_exporters.gen.cpp") SConscript("debugger/SCsub") + SConscript("export/SCsub") SConscript("fileserver/SCsub") SConscript("icons/SCsub") SConscript("import/SCsub") diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h index d8c40a97a7..1ca3c5bac0 100644 --- a/editor/action_map_editor.h +++ b/editor/action_map_editor.h @@ -209,4 +209,4 @@ public: ActionMapEditor(); }; -#endif +#endif // ACTION_MAP_EDITOR_H diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 703cfaee3d..234bfb944c 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -6113,7 +6113,8 @@ float AnimationTrackEditor::snap_time(float p_value, bool p_relative) { void AnimationTrackEditor::_show_imported_anim_warning() { // It looks terrible on a single line but the TTR extractor doesn't support line breaks yet. - EditorNode::get_singleton()->show_warning(TTR("This animation belongs to an imported scene, so changes to imported tracks will not be saved.\n\nTo enable the ability to add custom tracks, navigate to the scene's import settings and set\n\"Animation > Storage\" to \"Files\", enable \"Animation > Keep Custom Tracks\", then re-import.\nAlternatively, use an import preset that imports animations to separate files."), + EditorNode::get_singleton()->show_warning( + TTR("This animation belongs to an imported scene, so changes to imported tracks will not be saved.\n\nTo modify this animation, navigate to the scene's Advanced Import settings and select the animation.\nSome options, including looping, are available here. To add custom tracks, enable \"Save To File\" and\n\"Keep Custom Tracks\"."), TTR("Warning: Editing imported animation")); } @@ -6299,6 +6300,7 @@ AnimationTrackEditor::AnimationTrackEditor() { imported_anim_warning = memnew(Button); imported_anim_warning->hide(); + imported_anim_warning->set_text(TTR("Imported Scene")); imported_anim_warning->set_tooltip(TTR("Warning: Editing imported animation")); imported_anim_warning->connect("pressed", callable_mp(this, &AnimationTrackEditor::_show_imported_anim_warning)); bottom_hb->add_child(imported_anim_warning); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index fd331503ca..99ca82b311 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -824,12 +824,15 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) { if (k->is_pressed()) { if (ED_IS_SHORTCUT("script_editor/zoom_in", p_event)) { _zoom_in(); + accept_event(); } if (ED_IS_SHORTCUT("script_editor/zoom_out", p_event)) { _zoom_out(); + accept_event(); } if (ED_IS_SHORTCUT("script_editor/reset_zoom", p_event)) { _reset_zoom(); + accept_event(); } } } diff --git a/editor/create_dialog.h b/editor/create_dialog.h index dc8618a1c0..04094108ad 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -125,4 +125,4 @@ public: CreateDialog(); }; -#endif +#endif // CREATE_DIALOG_H diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index 0caeb90108..3c3e4faa6f 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -34,6 +34,7 @@ #include "editor/debugger/script_editor_debugger.h" #include "editor/editor_node.h" #include "editor/editor_run_native.h" +#include "editor/export/editor_export_platform.h" #include "editor/plugins/script_editor_plugin.h" void DebugAdapterParser::_bind_methods() { diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.h b/editor/debugger/debug_adapter/debug_adapter_parser.h index f458151e17..ee32306146 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.h +++ b/editor/debugger/debug_adapter/debug_adapter_parser.h @@ -93,4 +93,4 @@ public: Dictionary ev_breakpoint(const DAP::Breakpoint &p_breakpoint, const bool &p_enabled) const; }; -#endif +#endif // DEBUG_ADAPTER_PARSER_H diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.h b/editor/debugger/debug_adapter/debug_adapter_protocol.h index a17e550dfc..29f577ef97 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.h +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.h @@ -152,4 +152,4 @@ public: ~DebugAdapterProtocol(); }; -#endif +#endif // DEBUG_ADAPTER_PROTOCOL_H diff --git a/editor/debugger/debug_adapter/debug_adapter_server.h b/editor/debugger/debug_adapter/debug_adapter_server.h index a2b01f92c6..633739eaae 100644 --- a/editor/debugger/debug_adapter/debug_adapter_server.h +++ b/editor/debugger/debug_adapter/debug_adapter_server.h @@ -54,4 +54,4 @@ public: void stop(); }; -#endif +#endif // DEBUG_ADAPTER_SERVER_H diff --git a/editor/debugger/debug_adapter/debug_adapter_types.h b/editor/debugger/debug_adapter/debug_adapter_types.h index fd66905f9b..eb10184ab3 100644 --- a/editor/debugger/debug_adapter/debug_adapter_types.h +++ b/editor/debugger/debug_adapter/debug_adapter_types.h @@ -278,4 +278,4 @@ struct Variable { } // namespace DAP -#endif +#endif // DEBUG_ADAPTER_TYPES_H diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 0e3d424a4b..58206efc20 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -126,25 +126,25 @@ void EditorDebuggerInspector::_object_selected(ObjectID p_object) { } ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { - EditorDebuggerRemoteObject *debugObj = nullptr; + EditorDebuggerRemoteObject *debug_obj = nullptr; SceneDebuggerObject obj; obj.deserialize(p_arr); ERR_FAIL_COND_V(obj.id.is_null(), ObjectID()); if (remote_objects.has(obj.id)) { - debugObj = remote_objects[obj.id]; + debug_obj = remote_objects[obj.id]; } else { - debugObj = memnew(EditorDebuggerRemoteObject); - debugObj->remote_object_id = obj.id; - debugObj->type_name = obj.class_name; - remote_objects[obj.id] = debugObj; - debugObj->connect("value_edited", callable_mp(this, &EditorDebuggerInspector::_object_edited)); + debug_obj = memnew(EditorDebuggerRemoteObject); + debug_obj->remote_object_id = obj.id; + debug_obj->type_name = obj.class_name; + remote_objects[obj.id] = debug_obj; + debug_obj->connect("value_edited", callable_mp(this, &EditorDebuggerInspector::_object_edited)); } - int old_prop_size = debugObj->prop_list.size(); + int old_prop_size = debug_obj->prop_list.size(); - debugObj->prop_list.clear(); + debug_obj->prop_list.clear(); int new_props_added = 0; HashSet<String> changed; for (int i = 0; i < obj.properties.size(); i++) { @@ -165,12 +165,14 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { var = ResourceLoader::load(path); if (pinfo.hint_string == "Script") { - if (debugObj->get_script() != var) { - debugObj->set_script(Ref<RefCounted>()); + if (debug_obj->get_script() != var) { + debug_obj->set_script(Ref<RefCounted>()); Ref<Script> script(var); if (!script.is_null()) { - ScriptInstance *script_instance = script->placeholder_instance_create(debugObj); - debugObj->set_script_and_instance(var, script_instance); + ScriptInstance *script_instance = script->placeholder_instance_create(debug_obj); + if (script_instance) { + debug_obj->set_script_and_instance(var, script_instance); + } } } } @@ -178,27 +180,27 @@ ObjectID EditorDebuggerInspector::add_object(const Array &p_arr) { } //always add the property, since props may have been added or removed - debugObj->prop_list.push_back(pinfo); + debug_obj->prop_list.push_back(pinfo); - if (!debugObj->prop_values.has(pinfo.name)) { + if (!debug_obj->prop_values.has(pinfo.name)) { new_props_added++; - debugObj->prop_values[pinfo.name] = var; + debug_obj->prop_values[pinfo.name] = var; } else { - if (bool(Variant::evaluate(Variant::OP_NOT_EQUAL, debugObj->prop_values[pinfo.name], var))) { - debugObj->prop_values[pinfo.name] = var; + if (bool(Variant::evaluate(Variant::OP_NOT_EQUAL, debug_obj->prop_values[pinfo.name], var))) { + debug_obj->prop_values[pinfo.name] = var; changed.insert(pinfo.name); } } } - if (old_prop_size == debugObj->prop_list.size() && new_props_added == 0) { + if (old_prop_size == debug_obj->prop_list.size() && new_props_added == 0) { //only some may have changed, if so, then update those, if exist for (const String &E : changed) { - emit_signal(SNAME("object_property_updated"), debugObj->remote_object_id, E); + emit_signal(SNAME("object_property_updated"), debug_obj->remote_object_id, E); } } else { //full update, because props were added or removed - debugObj->update(); + debug_obj->update(); } return obj.id; } diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h index 0e73928558..5aac4dbf11 100644 --- a/editor/debugger/editor_debugger_inspector.h +++ b/editor/debugger/editor_debugger_inspector.h @@ -30,6 +30,7 @@ #ifndef EDITOR_DEBUGGER_INSPECTOR_H #define EDITOR_DEBUGGER_INSPECTOR_H + #include "editor/editor_inspector.h" class EditorDebuggerRemoteObject : public Object { diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index d50cbec291..4c9ad49ac4 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -205,4 +205,5 @@ public: void add_debugger_plugin(const Ref<Script> &p_script); void remove_debugger_plugin(const Ref<Script> &p_script); }; + #endif // EDITOR_DEBUGGER_NODE_H diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h index adf9a27c71..f3805f54d8 100644 --- a/editor/debugger/editor_debugger_server.h +++ b/editor/debugger/editor_debugger_server.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITOR_DEBUGGER_CONNECTION_H -#define EDITOR_DEBUGGER_CONNECTION_H +#ifndef EDITOR_DEBUGGER_SERVER_H +#define EDITOR_DEBUGGER_SERVER_H #include "core/debugger/remote_debugger_peer.h" #include "core/object/ref_counted.h" @@ -57,4 +57,4 @@ public: virtual Ref<RemoteDebuggerPeer> take_connection() = 0; }; -#endif // EDITOR_DEBUGGER_CONNECTION_H +#endif // EDITOR_DEBUGGER_SERVER_H diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h index bba524039e..9d163fd548 100644 --- a/editor/debugger/editor_debugger_tree.h +++ b/editor/debugger/editor_debugger_tree.h @@ -71,4 +71,5 @@ public: void update_scene_tree(const SceneDebuggerTree *p_tree, int p_debugger); EditorDebuggerTree(); }; + #endif // EDITOR_DEBUGGER_TREE_H diff --git a/editor/debugger/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h index d2e70a083d..aea7ce3eec 100644 --- a/editor/debugger/editor_network_profiler.h +++ b/editor/debugger/editor_network_profiler.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITORNETWORKPROFILER_H -#define EDITORNETWORKPROFILER_H +#ifndef EDITOR_NETWORK_PROFILER_H +#define EDITOR_NETWORK_PROFILER_H #include "scene/debugger/scene_debugger.h" #include "scene/gui/box_container.h" @@ -69,4 +69,4 @@ public: EditorNetworkProfiler(); }; -#endif //EDITORNETWORKPROFILER_H +#endif // EDITOR_NETWORK_PROFILER_H diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h index cb01a1819f..df92125258 100644 --- a/editor/debugger/editor_profiler.h +++ b/editor/debugger/editor_profiler.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITORPROFILER_H -#define EDITORPROFILER_H +#ifndef EDITOR_PROFILER_H +#define EDITOR_PROFILER_H #include "scene/gui/box_container.h" #include "scene/gui/button.h" @@ -165,4 +165,4 @@ public: EditorProfiler(); }; -#endif // EDITORPROFILER_H +#endif // EDITOR_PROFILER_H diff --git a/editor/debugger/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h index 4e5169da9e..8aa9e7b308 100644 --- a/editor/debugger/editor_visual_profiler.h +++ b/editor/debugger/editor_visual_profiler.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITOR_FRAME_PROFILER_H -#define EDITOR_FRAME_PROFILER_H +#ifndef EDITOR_VISUAL_PROFILER_H +#define EDITOR_VISUAL_PROFILER_H #include "scene/gui/box_container.h" #include "scene/gui/button.h" @@ -144,4 +144,4 @@ public: EditorVisualProfiler(); }; -#endif // EDITOR_FRAME_PROFILER_H +#endif // EDITOR_VISUAL_PROFILER_H diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index aa03b7e252..4f89e1b2d1 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -58,6 +58,9 @@ void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button, M search->set_title(TTR("Search Replacement For:") + " " + replacing.get_file()); + // Set directory to closest existing directory. + search->set_current_dir(replacing.get_base_dir()); + search->clear_filters(); List<String> ext; ResourceLoader::get_recognized_extensions_for_type(ti->get_metadata(0), &ext); diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index a6c7970264..773fcc5017 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -498,53 +498,7 @@ void DocTools::generate(bool p_basic_types) { } DocData::MethodDoc method; - - method.name = E.name; - - if (E.flags & METHOD_FLAG_VIRTUAL) { - method.qualifiers = "virtual"; - } - - if (E.flags & METHOD_FLAG_CONST) { - if (!method.qualifiers.is_empty()) { - method.qualifiers += " "; - } - method.qualifiers += "const"; - } - - if (E.flags & METHOD_FLAG_VARARG) { - if (!method.qualifiers.is_empty()) { - method.qualifiers += " "; - } - method.qualifiers += "vararg"; - } - - if (E.flags & METHOD_FLAG_STATIC) { - if (!method.qualifiers.is_empty()) { - method.qualifiers += " "; - } - method.qualifiers += "static"; - } - - for (int i = -1; i < E.arguments.size(); i++) { - if (i == -1) { -#ifdef DEBUG_METHODS_ENABLED - DocData::return_doc_from_retinfo(method, E.return_val); -#endif - } else { - const PropertyInfo &arginfo = E.arguments[i]; - DocData::ArgumentDoc argument; - DocData::argument_doc_from_arginfo(argument, arginfo); - - int darg_idx = i - (E.arguments.size() - E.default_arguments.size()); - if (darg_idx >= 0) { - Variant default_arg = E.default_arguments[darg_idx]; - argument.default_value = default_arg.get_construct_string().replace("\n", " "); - } - - method.arguments.push_back(argument); - } - } + DocData::method_doc_from_methodinfo(method, E, ""); Vector<Error> errs = ClassDB::get_method_error_return_values(name, E.name); if (errs.size()) { diff --git a/editor/doc_tools.h b/editor/doc_tools.h index 843cdf87a6..b3e45c6472 100644 --- a/editor/doc_tools.h +++ b/editor/doc_tools.h @@ -53,4 +53,4 @@ public: Error load_compressed(const uint8_t *p_data, int p_compressed_size, int p_uncompressed_size); }; -#endif // DOC_DATA_H +#endif // DOC_TOOLS_H diff --git a/editor/editor_about.h b/editor/editor_about.h index 6f05700582..971843f6d2 100644 --- a/editor/editor_about.h +++ b/editor/editor_about.h @@ -75,4 +75,4 @@ public: ~EditorAbout(); }; -#endif +#endif // EDITOR_ABOUT_H diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h index c44f4c5d22..9c88116336 100644 --- a/editor/editor_asset_installer.h +++ b/editor/editor_asset_installer.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITORASSETINSTALLER_H -#define EDITORASSETINSTALLER_H +#ifndef EDITOR_ASSET_INSTALLER_H +#define EDITOR_ASSET_INSTALLER_H #include "scene/gui/dialogs.h" #include "scene/gui/tree.h" @@ -59,4 +59,4 @@ public: EditorAssetInstaller(); }; -#endif // EDITORASSETINSTALLER_H +#endif // EDITOR_ASSET_INSTALLER_H diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h index e1e0bb0a64..0eda7016d3 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -112,4 +112,4 @@ public: ~EditorAutoloadSettings(); }; -#endif +#endif // EDITOR_AUTOLOAD_SETTINGS_H diff --git a/editor/editor_command_palette.h b/editor/editor_command_palette.h index 124703cca4..b3e84771d0 100644 --- a/editor/editor_command_palette.h +++ b/editor/editor_command_palette.h @@ -101,4 +101,4 @@ public: Ref<Shortcut> ED_SHORTCUT_AND_COMMAND(const String &p_path, const String &p_name, Key p_keycode = Key::NONE, String p_command = ""); -#endif //EDITOR_COMMAND_PALETTE_H +#endif // EDITOR_COMMAND_PALETTE_H diff --git a/editor/editor_export.h b/editor/editor_export.h deleted file mode 100644 index 9179a3e2b0..0000000000 --- a/editor/editor_export.h +++ /dev/null @@ -1,532 +0,0 @@ -/*************************************************************************/ -/* editor_export.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. */ -/*************************************************************************/ - -#ifndef EDITOR_EXPORT_H -#define EDITOR_EXPORT_H - -#include "core/io/dir_access.h" -#include "core/io/resource.h" -#include "scene/gui/rich_text_label.h" -#include "scene/main/node.h" -#include "scene/main/timer.h" -#include "scene/resources/texture.h" - -class FileAccess; -class EditorExportPlatform; -class EditorFileSystemDirectory; -struct EditorProgress; - -class EditorExportPreset : public RefCounted { - GDCLASS(EditorExportPreset, RefCounted); - -public: - enum ExportFilter { - EXPORT_ALL_RESOURCES, - EXPORT_SELECTED_SCENES, - EXPORT_SELECTED_RESOURCES, - EXCLUDE_SELECTED_RESOURCES, - }; - - enum ScriptExportMode { - MODE_SCRIPT_TEXT, - MODE_SCRIPT_COMPILED, - }; - -private: - Ref<EditorExportPlatform> platform; - ExportFilter export_filter = EXPORT_ALL_RESOURCES; - String include_filter; - String exclude_filter; - String export_path; - - String exporter; - HashSet<String> selected_files; - bool runnable = false; - - friend class EditorExport; - friend class EditorExportPlatform; - - List<PropertyInfo> properties; - HashMap<StringName, Variant> values; - - String name; - - String custom_features; - - String enc_in_filters; - String enc_ex_filters; - bool enc_pck = false; - bool enc_directory = false; - - int script_mode = MODE_SCRIPT_COMPILED; - String script_key; - -protected: - bool _set(const StringName &p_name, const Variant &p_value); - bool _get(const StringName &p_name, Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - -public: - Ref<EditorExportPlatform> get_platform() const; - - bool has(const StringName &p_property) const { return values.has(p_property); } - - void update_files_to_export(); - - Vector<String> get_files_to_export() const; - - void add_export_file(const String &p_path); - void remove_export_file(const String &p_path); - bool has_export_file(const String &p_path); - - void set_name(const String &p_name); - String get_name() const; - - void set_runnable(bool p_enable); - bool is_runnable() const; - - void set_export_filter(ExportFilter p_filter); - ExportFilter get_export_filter() const; - - void set_include_filter(const String &p_include); - String get_include_filter() const; - - void set_exclude_filter(const String &p_exclude); - String get_exclude_filter() const; - - void set_custom_features(const String &p_custom_features); - String get_custom_features() const; - - void set_export_path(const String &p_path); - String get_export_path() const; - - void set_enc_in_filter(const String &p_filter); - String get_enc_in_filter() const; - - void set_enc_ex_filter(const String &p_filter); - String get_enc_ex_filter() const; - - void set_enc_pck(bool p_enabled); - bool get_enc_pck() const; - - void set_enc_directory(bool p_enabled); - bool get_enc_directory() const; - - void set_script_export_mode(int p_mode); - int get_script_export_mode() const; - - void set_script_encryption_key(const String &p_key); - String get_script_encryption_key() const; - - const List<PropertyInfo> &get_properties() const { return properties; } - - EditorExportPreset() {} -}; - -struct SharedObject { - String path; - Vector<String> tags; - String target; - - SharedObject(const String &p_path, const Vector<String> &p_tags, const String &p_target) : - path(p_path), - tags(p_tags), - target(p_target) { - } - - SharedObject() {} -}; - -class EditorExportPlatform : public RefCounted { - GDCLASS(EditorExportPlatform, RefCounted); - -public: - typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); - typedef Error (*EditorExportSaveSharedObject)(void *p_userdata, const SharedObject &p_so); - - enum ExportMessageType { - EXPORT_MESSAGE_NONE, - EXPORT_MESSAGE_INFO, - EXPORT_MESSAGE_WARNING, - EXPORT_MESSAGE_ERROR, - }; - - struct ExportMessage { - ExportMessageType msg_type; - String category; - String text; - }; - -private: - struct SavedData { - uint64_t ofs = 0; - uint64_t size = 0; - bool encrypted = false; - Vector<uint8_t> md5; - CharString path_utf8; - - bool operator<(const SavedData &p_data) const { - return path_utf8 < p_data.path_utf8; - } - }; - - struct PackData { - Ref<FileAccess> f; - Vector<SavedData> file_ofs; - EditorProgress *ep = nullptr; - Vector<SharedObject> *so_files = nullptr; - }; - - struct ZipData { - void *zip = nullptr; - EditorProgress *ep = nullptr; - }; - - struct FeatureContainers { - HashSet<String> features; - Vector<String> features_pv; - }; - - Vector<ExportMessage> messages; - - void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths); - void _export_find_dependencies(const String &p_path, HashSet<String> &p_paths); - - void gen_debug_flags(Vector<String> &r_flags, int p_flags); - static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); - static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); - - void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<String> &r_list, bool exclude); - void _edit_filter_list(HashSet<String> &r_list, const String &p_filter, bool exclude); - - static Error _add_shared_object(void *p_userdata, const SharedObject &p_so); - -protected: - struct ExportNotifier { - ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags); - ~ExportNotifier(); - }; - - FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug); - - bool exists_export_template(String template_file_name, String *err) const; - String find_export_template(String template_file_name, String *err = nullptr) const; - void gen_export_flags(Vector<String> &r_flags, int p_flags); - -public: - virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0; - - struct ExportOption { - PropertyInfo option; - Variant default_value; - - ExportOption(const PropertyInfo &p_info, const Variant &p_default) : - option(p_info), - default_value(p_default) { - } - ExportOption() {} - }; - - virtual Ref<EditorExportPreset> create_preset(); - - virtual void clear_messages() { messages.clear(); } - virtual void add_message(ExportMessageType p_type, const String &p_category, const String &p_message) { - ExportMessage msg; - msg.category = p_category; - msg.text = p_message; - msg.msg_type = p_type; - messages.push_back(msg); - switch (p_type) { - case EXPORT_MESSAGE_INFO: { - print_line(vformat("%s: %s\n", msg.category, msg.text)); - } break; - case EXPORT_MESSAGE_WARNING: { - WARN_PRINT(vformat("%s: %s\n", msg.category, msg.text)); - } break; - case EXPORT_MESSAGE_ERROR: { - ERR_PRINT(vformat("%s: %s\n", msg.category, msg.text)); - } break; - default: - break; - } - } - - virtual int get_message_count() const { - return messages.size(); - } - - virtual ExportMessage get_message(int p_index) const { - ERR_FAIL_INDEX_V(p_index, messages.size(), ExportMessage()); - return messages[p_index]; - } - - virtual ExportMessageType get_worst_message_type() const { - ExportMessageType worst_type = EXPORT_MESSAGE_NONE; - for (int i = 0; i < messages.size(); i++) { - worst_type = MAX(worst_type, messages[i].msg_type); - } - return worst_type; - } - - virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err); - - virtual void get_export_options(List<ExportOption> *r_options) = 0; - virtual bool should_update_export_options() { return false; } - virtual bool get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } - - virtual String get_os_name() const = 0; - virtual String get_name() const = 0; - virtual Ref<Texture2D> get_logo() const = 0; - - Error export_project_files(const Ref<EditorExportPreset> &p_preset, bool p_debug, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = nullptr); - - Error save_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, Vector<SharedObject> *p_so_files = nullptr, bool p_embed = false, int64_t *r_embedded_start = nullptr, int64_t *r_embedded_size = nullptr); - Error save_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path); - - virtual bool poll_export() { return false; } - virtual int get_options_count() const { return 0; } - virtual String get_options_tooltip() const { return ""; } - virtual Ref<ImageTexture> get_option_icon(int p_index) const; - virtual String get_option_label(int p_device) const { return ""; } - virtual String get_option_tooltip(int p_device) const { return ""; } - - enum DebugFlags { - DEBUG_FLAG_DUMB_CLIENT = 1, - DEBUG_FLAG_REMOTE_DEBUG = 2, - DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST = 4, - DEBUG_FLAG_VIEW_COLLISONS = 8, - DEBUG_FLAG_VIEW_NAVIGATION = 16, - }; - - virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; } - virtual Ref<Texture2D> get_run_icon() const { return get_logo(); } - - String test_etc2() const; - virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0; - - virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const = 0; - virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0; - virtual Error export_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); - virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); - virtual void get_platform_features(List<String> *r_features) = 0; - virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) = 0; - virtual String get_debug_protocol() const { return "tcp://"; } - - EditorExportPlatform(); -}; - -class EditorExportPlugin : public RefCounted { - GDCLASS(EditorExportPlugin, RefCounted); - - friend class EditorExportPlatform; - - Ref<EditorExportPreset> export_preset; - - Vector<SharedObject> shared_objects; - struct ExtraFile { - String path; - Vector<uint8_t> data; - bool remap = false; - }; - Vector<ExtraFile> extra_files; - bool skipped = false; - - Vector<String> ios_frameworks; - Vector<String> ios_embedded_frameworks; - Vector<String> ios_project_static_libs; - String ios_plist_content; - String ios_linker_flags; - Vector<String> ios_bundle_files; - String ios_cpp_code; - - Vector<String> macos_plugin_files; - - _FORCE_INLINE_ void _clear() { - shared_objects.clear(); - extra_files.clear(); - skipped = false; - } - - _FORCE_INLINE_ void _export_end() { - ios_frameworks.clear(); - ios_embedded_frameworks.clear(); - ios_bundle_files.clear(); - ios_plist_content = ""; - ios_linker_flags = ""; - ios_cpp_code = ""; - macos_plugin_files.clear(); - } - - void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features); - void _export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags); - void _export_end_script(); - -protected: - void set_export_preset(const Ref<EditorExportPreset> &p_preset); - Ref<EditorExportPreset> get_export_preset() const; - - void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap); - void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String()); - - void add_ios_framework(const String &p_path); - void add_ios_embedded_framework(const String &p_path); - void add_ios_project_static_lib(const String &p_path); - void add_ios_plist_content(const String &p_plist_content); - void add_ios_linker_flags(const String &p_flags); - void add_ios_bundle_file(const String &p_path); - void add_ios_cpp_code(const String &p_code); - void add_macos_plugin_file(const String &p_path); - - void skip(); - - virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features); - virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags); - - static void _bind_methods(); - - GDVIRTUAL3(_export_file, String, String, Vector<String>) - GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t) - GDVIRTUAL0(_export_end) - -public: - Vector<String> get_ios_frameworks() const; - Vector<String> get_ios_embedded_frameworks() const; - Vector<String> get_ios_project_static_libs() const; - String get_ios_plist_content() const; - String get_ios_linker_flags() const; - Vector<String> get_ios_bundle_files() const; - String get_ios_cpp_code() const; - const Vector<String> &get_macos_plugin_files() const; - - EditorExportPlugin(); -}; - -class EditorExport : public Node { - GDCLASS(EditorExport, Node); - - Vector<Ref<EditorExportPlatform>> export_platforms; - Vector<Ref<EditorExportPreset>> export_presets; - Vector<Ref<EditorExportPlugin>> export_plugins; - - StringName _export_presets_updated; - - Timer *save_timer = nullptr; - bool block_save = false; - - static EditorExport *singleton; - - void _save(); - -protected: - friend class EditorExportPreset; - void save_presets(); - - void _notification(int p_what); - static void _bind_methods(); - -public: - static EditorExport *get_singleton() { return singleton; } - - void add_export_platform(const Ref<EditorExportPlatform> &p_platform); - int get_export_platform_count(); - Ref<EditorExportPlatform> get_export_platform(int p_idx); - - void add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos = -1); - int get_export_preset_count() const; - Ref<EditorExportPreset> get_export_preset(int p_idx); - void remove_export_preset(int p_idx); - - void add_export_plugin(const Ref<EditorExportPlugin> &p_plugin); - void remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin); - Vector<Ref<EditorExportPlugin>> get_export_plugins(); - - void load_config(); - void update_export_presets(); - bool poll_export_platforms(); - - EditorExport(); - ~EditorExport(); -}; - -class EditorExportPlatformPC : public EditorExportPlatform { - GDCLASS(EditorExportPlatformPC, EditorExportPlatform); - -private: - Ref<ImageTexture> logo; - String name; - String os_name; - - int chmod_flags = -1; - -public: - virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override; - - virtual void get_export_options(List<ExportOption> *r_options) override; - - virtual String get_name() const override; - virtual String get_os_name() const override; - virtual Ref<Texture2D> get_logo() const override; - - virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override; - virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override; - virtual Error sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path); - virtual String get_template_file_name(const String &p_target, const String &p_arch) const = 0; - - virtual Error prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags); - virtual Error modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { return OK; }; - virtual Error export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags); - - void set_extension(const String &p_extension, const String &p_feature_key = "default"); - void set_name(const String &p_name); - void set_os_name(const String &p_name); - - void set_logo(const Ref<Texture2D> &p_logo); - - void add_platform_feature(const String &p_feature); - virtual void get_platform_features(List<String> *r_features) override; - virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override; - - int get_chmod_flags() const; - void set_chmod_flags(int p_flags); - - virtual Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) { - return Error::OK; - } -}; - -class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin { - GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin); - -public: - virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override; - EditorExportTextSceneToBinaryPlugin(); -}; - -#endif // EDITOR_IMPORT_EXPORT_H diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 2f106739a4..56046a07d7 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -36,6 +36,7 @@ #include "core/io/resource_importer.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" +#include "core/object/worker_thread_pool.h" #include "core/os/os.h" #include "core/variant/variant_parser.h" #include "editor/editor_node.h" @@ -2137,7 +2138,7 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { data.reimport_from = from; data.reimport_files = reimport_files.ptr(); - import_threads.begin_work(i - from + 1, this, &EditorFileSystem::_reimport_thread, &data); + WorkerThreadPool::GroupID group_task = WorkerThreadPool::get_singleton()->add_template_group_task(this, &EditorFileSystem::_reimport_thread, &data, i - from + 1, -1, false, vformat(TTR("Import resources of type: %s"), reimport_files[from].importer)); int current_index = from - 1; do { if (current_index < data.max_index) { @@ -2145,9 +2146,9 @@ void EditorFileSystem::reimport_files(const Vector<String> &p_files) { pr.step(reimport_files[current_index].path.get_file(), current_index); } OS::get_singleton()->delay_usec(1); - } while (!import_threads.is_done_dispatching()); + } while (!WorkerThreadPool::get_singleton()->is_group_task_completed(group_task)); - import_threads.end_work(); + WorkerThreadPool::get_singleton()->wait_for_group_task_completion(group_task); importer->import_threaded_end(); } @@ -2430,12 +2431,10 @@ EditorFileSystem::EditorFileSystem() { scan_total = 0; update_script_classes_queued.clear(); - import_threads.init(); ResourceUID::get_singleton()->clear(); //will be updated on scan ResourceSaver::set_get_resource_id_for_path(_resource_saver_get_resource_id_for_path); } EditorFileSystem::~EditorFileSystem() { - import_threads.finish(); ResourceSaver::set_get_resource_id_for_path(nullptr); } diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 07b1132046..f4e69b95e7 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -36,7 +36,6 @@ #include "core/os/thread_safe.h" #include "core/templates/hash_set.h" #include "core/templates/safe_refcount.h" -#include "core/templates/thread_work_pool.h" #include "scene/main/node.h" class FileAccess; @@ -275,8 +274,6 @@ class EditorFileSystem : public Node { HashSet<String> group_file_cache; - ThreadWorkPool import_threads; - struct ImportThreadData { const ImportFile *reimport_files; int reimport_from; diff --git a/editor/editor_fonts.h b/editor/editor_fonts.h index e450af00da..c8b60b0198 100644 --- a/editor/editor_fonts.h +++ b/editor/editor_fonts.h @@ -35,4 +35,4 @@ void editor_register_fonts(Ref<Theme> p_theme); -#endif +#endif // EDITOR_FONTS_H diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 1711b23547..b610e09545 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -3558,7 +3558,7 @@ void EditorInspector::_notification(int p_what) { if (refresh_countdown <= 0) { for (const KeyValue<StringName, List<EditorProperty *>> &F : editor_property_map) { for (EditorProperty *E : F.value) { - if (!E->is_cache_valid()) { + if (E && !E->is_cache_valid()) { E->update_property(); E->update_revert_and_pin_status(); E->update_cache(); diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 9542f102cb..4ec3513da5 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -602,4 +602,4 @@ public: EditorInspector(); }; -#endif // INSPECTOR_H +#endif // EDITOR_INSPECTOR_H diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ced63815b9..37329c92f3 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -78,7 +78,6 @@ #include "editor/editor_build_profile.h" #include "editor/editor_command_palette.h" #include "editor/editor_data.h" -#include "editor/editor_export.h" #include "editor/editor_feature_profile.h" #include "editor/editor_file_dialog.h" #include "editor/editor_file_system.h" @@ -91,6 +90,7 @@ #include "editor/editor_plugin.h" #include "editor/editor_properties.h" #include "editor/editor_property_name_processor.h" +#include "editor/editor_quick_open.h" #include "editor/editor_resource_picker.h" #include "editor/editor_resource_preview.h" #include "editor/editor_run.h" @@ -103,7 +103,9 @@ #include "editor/editor_themes.h" #include "editor/editor_toaster.h" #include "editor/editor_translation_parser.h" -#include "editor/export_template_manager.h" +#include "editor/export/editor_export.h" +#include "editor/export/export_template_manager.h" +#include "editor/export/project_export.h" #include "editor/filesystem_dock.h" #include "editor/import/audio_stream_import_settings.h" #include "editor/import/dynamic_font_import_settings.h" @@ -198,9 +200,7 @@ #include "editor/plugins/visual_shader_editor_plugin.h" #include "editor/plugins/voxel_gi_editor_plugin.h" #include "editor/progress_dialog.h" -#include "editor/project_export.h" #include "editor/project_settings_editor.h" -#include "editor/quick_open.h" #include "editor/register_exporters.h" #include "editor/scene_tree_dock.h" @@ -924,6 +924,7 @@ void EditorNode::_fs_changed() { // FIXME: Move this to a cleaner location, it's hacky to do this in _fs_changed. String export_error; + Error err = OK; if (!export_defer.preset.is_empty() && !EditorFileSystem::get_singleton()->is_scanning()) { String preset_name = export_defer.preset; // Ensures export_project does not loop infinitely, because notifications may @@ -941,6 +942,7 @@ void EditorNode::_fs_changed() { if (export_preset.is_null()) { Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (da->file_exists("res://export_presets.cfg")) { + err = FAILED; export_error = vformat( "Invalid export preset name: %s.\nThe following presets were detected in this project's `export_presets.cfg`:\n\n", preset_name); @@ -949,17 +951,19 @@ void EditorNode::_fs_changed() { export_error += vformat(" \"%s\"\n", EditorExport::get_singleton()->get_export_preset(i)->get_name()); } } else { + err = FAILED; export_error = "This project doesn't have an `export_presets.cfg` file at its root.\nCreate an export preset from the \"Project > Export\" dialog and try again."; } } else { Ref<EditorExportPlatform> platform = export_preset->get_platform(); const String export_path = export_defer.path.is_empty() ? export_preset->get_export_path() : export_defer.path; if (export_path.is_empty()) { + err = FAILED; export_error = vformat("Export preset \"%s\" doesn't have a default export path, and none was specified.", preset_name); } else if (platform.is_null()) { + err = FAILED; export_error = vformat("Export preset \"%s\" doesn't have a matching platform.", preset_name); } else { - Error err = OK; if (export_defer.pack_only) { // Only export .pck or .zip data pack. if (export_path.ends_with(".zip")) { err = platform->export_zip(export_preset, export_defer.debug, export_path); @@ -980,17 +984,18 @@ void EditorNode::_fs_changed() { if (err != OK) { export_error = vformat("Project export for preset \"%s\" failed.", preset_name); } else if (platform->get_worst_message_type() >= EditorExportPlatform::EXPORT_MESSAGE_WARNING) { - export_error = vformat("Project export for preset \"%s\" completed with errors.", preset_name); + export_error = vformat("Project export for preset \"%s\" completed with warnings.", preset_name); } } } - if (!export_error.is_empty()) { + if (err != OK) { ERR_PRINT(export_error); _exit_editor(EXIT_FAILURE); - } else { - _exit_editor(EXIT_SUCCESS); + } else if (!export_error.is_empty()) { + WARN_PRINT(export_error); } + _exit_editor(EXIT_SUCCESS); } } @@ -1795,9 +1800,16 @@ void EditorNode::restart_editor() { _exit_editor(EXIT_SUCCESS); List<String> args; + args.push_back("--path"); args.push_back(ProjectSettings::get_singleton()->get_resource_path()); + args.push_back("-e"); + + if (OS::get_singleton()->is_disable_crash_handler()) { + args.push_back("--disable-crash-handler"); + } + if (!to_reopen.is_empty()) { args.push_back(to_reopen); } @@ -2176,6 +2188,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { Object *prev_inspected_object = InspectorDock::get_inspector_singleton()->get_edited_object(); bool disable_folding = bool(EDITOR_GET("interface/inspector/disable_folding")); + bool stay_in_script_editor_on_node_selected = bool(EDITOR_GET("text_editor/behavior/navigation/stay_in_script_editor_on_node_selected")); bool is_resource = current_obj->is_class("Resource"); bool is_node = current_obj->is_class("Node"); @@ -2214,6 +2227,9 @@ void EditorNode::_edit_current(bool p_skip_foreign) { NodeDock::get_singleton()->set_node(current_node); SceneTreeDock::get_singleton()->set_selected(current_node); InspectorDock::get_singleton()->update(current_node); + if (!inspector_only) { + inspector_only = stay_in_script_editor_on_node_selected && ScriptEditor::get_singleton()->is_visible_in_tree(); + } } else { NodeDock::get_singleton()->set_node(nullptr); SceneTreeDock::get_singleton()->set_selected(nullptr); diff --git a/editor/editor_node.h b/editor/editor_node.h index 53c2312022..c521c0fb04 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -32,10 +32,10 @@ #define EDITOR_NODE_H #include "core/templates/safe_refcount.h" -#include "editor/editor_export.h" #include "editor/editor_folding.h" #include "editor/editor_native_shader_source_visualizer.h" #include "editor/editor_run.h" +#include "editor/export/editor_export.h" #include "editor/inspector_dock.h" #include "editor/property_editor.h" diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index d9c2a42114..566c22f5a9 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -31,11 +31,11 @@ #include "editor_plugin.h" #include "editor/editor_command_palette.h" -#include "editor/editor_export.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_resource_preview.h" #include "editor/editor_settings.h" +#include "editor/export/editor_export.h" #include "editor/filesystem_dock.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/node_3d_editor_plugin.h" diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index c666b4639d..84c63d1021 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -346,4 +346,4 @@ public: } }; -#endif +#endif // EDITOR_PLUGIN_H diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h index 4903a02c4d..7c6d93e6f4 100644 --- a/editor/editor_plugin_settings.h +++ b/editor/editor_plugin_settings.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITORPLUGINSETTINGS_H -#define EDITORPLUGINSETTINGS_H +#ifndef EDITOR_PLUGIN_SETTINGS_H +#define EDITOR_PLUGIN_SETTINGS_H #include "core/object/undo_redo.h" #include "editor/editor_data.h" @@ -65,4 +65,4 @@ public: EditorPluginSettings(); }; -#endif // EDITORPLUGINSETTINGS_H +#endif // EDITOR_PLUGIN_SETTINGS_H diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index e9354927c8..d145a1e820 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2623,6 +2623,186 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() { set_label_reference(spin[0]); //show text and buttons around this } } +///////////////////// VECTOR4 ///////////////////////// + +void EditorPropertyVector4::_set_read_only(bool p_read_only) { + for (int i = 0; i < 4; i++) { + spin[i]->set_read_only(p_read_only); + } +}; + +void EditorPropertyVector4::_value_changed(double val, const String &p_name) { + if (setting) { + return; + } + + Vector4 p; + p.x = spin[0]->get_value(); + p.y = spin[1]->get_value(); + p.z = spin[2]->get_value(); + p.w = spin[3]->get_value(); + emit_changed(get_edited_property(), p, p_name); +} + +void EditorPropertyVector4::update_property() { + Vector4 val = get_edited_object()->get(get_edited_property()); + setting = true; + spin[0]->set_value(val.x); + spin[1]->set_value(val.y); + spin[2]->set_value(val.z); + spin[3]->set_value(val.w); + setting = false; +} + +void EditorPropertyVector4::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + const Color *colors = _get_property_colors(); + for (int i = 0; i < 4; i++) { + spin[i]->add_theme_color_override("label_color", colors[i]); + } + } break; + } +} + +void EditorPropertyVector4::_bind_methods() { +} + +void EditorPropertyVector4::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) { + for (int i = 0; i < 4; i++) { + spin[i]->set_min(p_min); + spin[i]->set_max(p_max); + spin[i]->set_step(p_step); + spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); + // Vector4 is inherently unitless, however someone may want to use it as + // a generic way to store 4 values, so we'll still respect the suffix. + spin[i]->set_suffix(p_suffix); + } +} + +EditorPropertyVector4::EditorPropertyVector4() { + bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing"); + + BoxContainer *bc; + + if (horizontal) { + bc = memnew(HBoxContainer); + add_child(bc); + set_bottom_editor(bc); + } else { + bc = memnew(VBoxContainer); + add_child(bc); + } + + static const char *desc[4] = { "x", "y", "z", "w" }; + for (int i = 0; i < 4; i++) { + spin[i] = memnew(EditorSpinSlider); + spin[i]->set_flat(true); + spin[i]->set_label(desc[i]); + bc->add_child(spin[i]); + add_focusable(spin[i]); + spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector4::_value_changed), varray(desc[i])); + if (horizontal) { + spin[i]->set_h_size_flags(SIZE_EXPAND_FILL); + } + } + + if (!horizontal) { + set_label_reference(spin[0]); //show text and buttons around this + } +} + +///////////////////// VECTOR4I ///////////////////////// + +void EditorPropertyVector4i::_set_read_only(bool p_read_only) { + for (int i = 0; i < 4; i++) { + spin[i]->set_read_only(p_read_only); + } +}; + +void EditorPropertyVector4i::_value_changed(double val, const String &p_name) { + if (setting) { + return; + } + + Vector4i p; + p.x = spin[0]->get_value(); + p.y = spin[1]->get_value(); + p.z = spin[2]->get_value(); + p.w = spin[3]->get_value(); + emit_changed(get_edited_property(), p, p_name); +} + +void EditorPropertyVector4i::update_property() { + Vector4i val = get_edited_object()->get(get_edited_property()); + setting = true; + spin[0]->set_value(val.x); + spin[1]->set_value(val.y); + spin[2]->set_value(val.z); + spin[3]->set_value(val.w); + setting = false; +} + +void EditorPropertyVector4i::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + const Color *colors = _get_property_colors(); + for (int i = 0; i < 4; i++) { + spin[i]->add_theme_color_override("label_color", colors[i]); + } + } break; + } +} + +void EditorPropertyVector4i::_bind_methods() { +} + +void EditorPropertyVector4i::setup(double p_min, double p_max, bool p_no_slider, const String &p_suffix) { + for (int i = 0; i < 4; i++) { + spin[i]->set_min(p_min); + spin[i]->set_max(p_max); + spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); + spin[i]->set_suffix(p_suffix); + } +} + +EditorPropertyVector4i::EditorPropertyVector4i() { + bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing"); + + BoxContainer *bc; + + if (horizontal) { + bc = memnew(HBoxContainer); + add_child(bc); + set_bottom_editor(bc); + } else { + bc = memnew(VBoxContainer); + add_child(bc); + } + + static const char *desc[4] = { "x", "y", "z", "w" }; + for (int i = 0; i < 4; i++) { + spin[i] = memnew(EditorSpinSlider); + spin[i]->set_flat(true); + spin[i]->set_label(desc[i]); + bc->add_child(spin[i]); + add_focusable(spin[i]); + spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector4i::_value_changed), varray(desc[i])); + if (horizontal) { + spin[i]->set_h_size_flags(SIZE_EXPAND_FILL); + } + } + + if (!horizontal) { + set_label_reference(spin[0]); //show text and buttons around this + } +} ///////////////////// AABB ///////////////////////// @@ -2986,6 +3166,111 @@ EditorPropertyTransform3D::EditorPropertyTransform3D() { set_bottom_editor(g); } +///////////////////// PROJECTION ///////////////////////// + +void EditorPropertyProjection::_set_read_only(bool p_read_only) { + for (int i = 0; i < 12; i++) { + spin[i]->set_read_only(p_read_only); + } +}; + +void EditorPropertyProjection::_value_changed(double val, const String &p_name) { + if (setting) { + return; + } + + Projection p; + p.matrix[0][0] = spin[0]->get_value(); + p.matrix[0][1] = spin[1]->get_value(); + p.matrix[0][2] = spin[2]->get_value(); + p.matrix[0][3] = spin[3]->get_value(); + p.matrix[1][0] = spin[4]->get_value(); + p.matrix[1][1] = spin[5]->get_value(); + p.matrix[1][2] = spin[6]->get_value(); + p.matrix[1][3] = spin[7]->get_value(); + p.matrix[2][0] = spin[8]->get_value(); + p.matrix[2][1] = spin[9]->get_value(); + p.matrix[2][2] = spin[10]->get_value(); + p.matrix[2][3] = spin[11]->get_value(); + p.matrix[3][0] = spin[12]->get_value(); + p.matrix[3][1] = spin[13]->get_value(); + p.matrix[3][2] = spin[14]->get_value(); + p.matrix[3][3] = spin[15]->get_value(); + + emit_changed(get_edited_property(), p, p_name); +} + +void EditorPropertyProjection::update_property() { + update_using_transform(get_edited_object()->get(get_edited_property())); +} + +void EditorPropertyProjection::update_using_transform(Projection p_transform) { + setting = true; + spin[0]->set_value(p_transform.matrix[0][0]); + spin[1]->set_value(p_transform.matrix[0][1]); + spin[2]->set_value(p_transform.matrix[0][2]); + spin[3]->set_value(p_transform.matrix[0][3]); + spin[4]->set_value(p_transform.matrix[1][0]); + spin[5]->set_value(p_transform.matrix[1][1]); + spin[6]->set_value(p_transform.matrix[1][2]); + spin[7]->set_value(p_transform.matrix[1][3]); + spin[8]->set_value(p_transform.matrix[2][0]); + spin[9]->set_value(p_transform.matrix[2][1]); + spin[10]->set_value(p_transform.matrix[2][2]); + spin[11]->set_value(p_transform.matrix[2][3]); + spin[12]->set_value(p_transform.matrix[3][0]); + spin[13]->set_value(p_transform.matrix[3][1]); + spin[14]->set_value(p_transform.matrix[3][2]); + spin[15]->set_value(p_transform.matrix[3][3]); + setting = false; +} + +void EditorPropertyProjection::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + const Color *colors = _get_property_colors(); + for (int i = 0; i < 16; i++) { + spin[i]->add_theme_color_override("label_color", colors[i % 4]); + } + } break; + } +} + +void EditorPropertyProjection::_bind_methods() { +} + +void EditorPropertyProjection::setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix) { + for (int i = 0; i < 16; i++) { + spin[i]->set_min(p_min); + spin[i]->set_max(p_max); + spin[i]->set_step(p_step); + spin[i]->set_hide_slider(p_no_slider); + spin[i]->set_allow_greater(true); + spin[i]->set_allow_lesser(true); + if (i % 4 == 3) { + spin[i]->set_suffix(p_suffix); + } + } +} + +EditorPropertyProjection::EditorPropertyProjection() { + GridContainer *g = memnew(GridContainer); + g->set_columns(4); + add_child(g); + + static const char *desc[16] = { "xx", "xy", "xz", "xw", "yx", "yy", "yz", "yw", "zx", "zy", "zz", "zw", "wx", "wy", "wz", "ww" }; + for (int i = 0; i < 16; i++) { + spin[i] = memnew(EditorSpinSlider); + spin[i]->set_label(desc[i]); + spin[i]->set_flat(true); + g->add_child(spin[i]); + spin[i]->set_h_size_flags(SIZE_EXPAND_FILL); + add_focusable(spin[i]); + spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyProjection::_value_changed), varray(desc[i])); + } + set_bottom_editor(g); +} ////////////// COLOR PICKER ////////////////////// void EditorPropertyColor::_set_read_only(bool p_read_only) { @@ -3954,6 +4239,20 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ return editor; } break; + case Variant::VECTOR4: { + EditorPropertyVector4 *editor = memnew(EditorPropertyVector4); + EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); + editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + return editor; + + } break; + case Variant::VECTOR4I: { + EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i); + EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1); + editor->setup(hint.min, hint.max, hint.hide_slider, hint.suffix); + return editor; + + } break; case Variant::TRANSFORM2D: { EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D); EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); @@ -3991,6 +4290,13 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ return editor; } break; + case Variant::PROJECTION: { + EditorPropertyProjection *editor = memnew(EditorPropertyProjection); + EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step); + editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix); + return editor; + + } break; // misc types case Variant::COLOR: { diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 7bec2d0013..b3aac6e8ca 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -636,6 +636,40 @@ public: EditorPropertyQuaternion(); }; +class EditorPropertyVector4 : public EditorProperty { + GDCLASS(EditorPropertyVector4, EditorProperty); + EditorSpinSlider *spin[4]; + bool setting = false; + void _value_changed(double p_val, const String &p_name); + +protected: + virtual void _set_read_only(bool p_read_only) override; + void _notification(int p_what); + static void _bind_methods(); + +public: + virtual void update_property() override; + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); + EditorPropertyVector4(); +}; + +class EditorPropertyVector4i : public EditorProperty { + GDCLASS(EditorPropertyVector4i, EditorProperty); + EditorSpinSlider *spin[4]; + bool setting = false; + void _value_changed(double p_val, const String &p_name); + +protected: + virtual void _set_read_only(bool p_read_only) override; + void _notification(int p_what); + static void _bind_methods(); + +public: + virtual void update_property() override; + void setup(double p_min, double p_max, bool p_no_slider, const String &p_suffix = String()); + EditorPropertyVector4i(); +}; + class EditorPropertyAABB : public EditorProperty { GDCLASS(EditorPropertyAABB, EditorProperty); EditorSpinSlider *spin[6]; @@ -705,6 +739,24 @@ public: EditorPropertyTransform3D(); }; +class EditorPropertyProjection : public EditorProperty { + GDCLASS(EditorPropertyProjection, EditorProperty); + EditorSpinSlider *spin[16]; + bool setting = false; + void _value_changed(double p_val, const String &p_name); + +protected: + virtual void _set_read_only(bool p_read_only) override; + void _notification(int p_what); + static void _bind_methods(); + +public: + virtual void update_property() override; + virtual void update_using_transform(Projection p_transform); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); + EditorPropertyProjection(); +}; + class EditorPropertyColor : public EditorProperty { GDCLASS(EditorPropertyColor, EditorProperty); ColorPickerButton *picker = nullptr; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 0b9004bbc4..e83b070f6b 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -949,6 +949,18 @@ void EditorPropertyDictionary::update_property() { prop = editor; } break; + case Variant::VECTOR4: { + EditorPropertyVector4 *editor = memnew(EditorPropertyVector4); + editor->setup(-100000, 100000, default_float_step, true); + prop = editor; + + } break; + case Variant::VECTOR4I: { + EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i); + editor->setup(-100000, 100000, true); + prop = editor; + + } break; case Variant::TRANSFORM2D: { EditorPropertyTransform2D *editor = memnew(EditorPropertyTransform2D); editor->setup(-100000, 100000, default_float_step, true); @@ -985,6 +997,12 @@ void EditorPropertyDictionary::update_property() { prop = editor; } break; + case Variant::PROJECTION: { + EditorPropertyProjection *editor = memnew(EditorPropertyProjection); + editor->setup(-100000, 100000, default_float_step, true); + prop = editor; + + } break; // Miscellaneous types. case Variant::COLOR: { diff --git a/editor/quick_open.cpp b/editor/editor_quick_open.cpp index 4f7f9fc78c..539cb7cd8a 100644 --- a/editor/quick_open.cpp +++ b/editor/editor_quick_open.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* quick_open.cpp */ +/* editor_quick_open.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "quick_open.h" +#include "editor_quick_open.h" #include "core/os/keyboard.h" diff --git a/editor/quick_open.h b/editor/editor_quick_open.h index 843ef47711..e41a8c7e75 100644 --- a/editor/quick_open.h +++ b/editor/editor_quick_open.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* quick_open.h */ +/* editor_quick_open.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index da5ab08d49..e0903ea5ce 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -33,12 +33,12 @@ #include "editor/audio_stream_preview.h" #include "editor/editor_file_dialog.h" #include "editor/editor_node.h" +#include "editor/editor_quick_open.h" #include "editor/editor_resource_preview.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/filesystem_dock.h" #include "editor/plugins/script_editor_plugin.h" -#include "editor/quick_open.h" #include "editor/scene_tree_dock.h" HashMap<StringName, List<StringName>> EditorResourcePicker::allowed_types_cache; diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 820e22bdc8..0413477d88 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITORRESOURCEPREVIEW_H -#define EDITORRESOURCEPREVIEW_H +#ifndef EDITOR_RESOURCE_PREVIEW_H +#define EDITOR_RESOURCE_PREVIEW_H #include "core/os/semaphore.h" #include "core/os/thread.h" @@ -124,4 +124,4 @@ public: ~EditorResourcePreview(); }; -#endif // EDITORRESOURCEPREVIEW_H +#endif // EDITOR_RESOURCE_PREVIEW_H diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 854885c707..efd6c67d7a 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -30,9 +30,9 @@ #include "editor_run_native.h" -#include "editor/editor_export.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" +#include "editor/export/editor_export_platform.h" void EditorRunNative::_notification(int p_what) { switch (p_what) { diff --git a/editor/editor_scale.h b/editor/editor_scale.h index 918fde15fb..02e9b997f6 100644 --- a/editor/editor_scale.h +++ b/editor/editor_scale.h @@ -35,4 +35,5 @@ void editor_set_scale(float p_scale); float editor_get_scale(); #define EDSCALE (editor_get_scale()) + #endif // EDITOR_SCALE_H diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h index babd11eb69..758efae31e 100644 --- a/editor/editor_sectioned_inspector.h +++ b/editor/editor_sectioned_inspector.h @@ -76,4 +76,5 @@ public: SectionedInspector(); ~SectionedInspector(); }; + #endif // EDITOR_SECTIONED_INSPECTOR_H diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 40ca058406..c73caa78f3 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -544,6 +544,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/behavior/navigation/smooth_scrolling", true); EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "text_editor/behavior/navigation/v_scroll_speed", 80, "1,10000,1") _initial_set("text_editor/behavior/navigation/drag_and_drop_selection", true); + _initial_set("text_editor/behavior/navigation/stay_in_script_editor_on_node_selected", true); // Behavior: Indent EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "text_editor/behavior/indent/type", 0, "Tabs,Spaces") diff --git a/editor/editor_themes.h b/editor/editor_themes.h index 642558d774..95184b9d4a 100644 --- a/editor/editor_themes.h +++ b/editor/editor_themes.h @@ -40,4 +40,4 @@ Ref<Theme> create_custom_theme(Ref<Theme> p_theme = nullptr); Ref<ImageTexture> create_unscaled_default_project_icon(); -#endif +#endif // EDITOR_THEMES_H diff --git a/editor/editor_vcs_interface.h b/editor/editor_vcs_interface.h index 487625e84c..6a6fca7eba 100644 --- a/editor/editor_vcs_interface.h +++ b/editor/editor_vcs_interface.h @@ -85,4 +85,4 @@ public: virtual ~EditorVCSInterface(); }; -#endif // !EDITOR_VCS_INTERFACE_H +#endif // EDITOR_VCS_INTERFACE_H diff --git a/editor/export/SCsub b/editor/export/SCsub new file mode 100644 index 0000000000..359d04e5df --- /dev/null +++ b/editor/export/SCsub @@ -0,0 +1,5 @@ +#!/usr/bin/env python + +Import("env") + +env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp new file mode 100644 index 0000000000..31f408eedb --- /dev/null +++ b/editor/export/editor_export.cpp @@ -0,0 +1,355 @@ +/*************************************************************************/ +/* editor_export.cpp */ +/*************************************************************************/ +/* 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 "editor_export.h" + +#include "core/config/project_settings.h" +#include "core/io/config_file.h" + +EditorExport *EditorExport::singleton = nullptr; + +void EditorExport::_save() { + Ref<ConfigFile> config; + config.instantiate(); + for (int i = 0; i < export_presets.size(); i++) { + Ref<EditorExportPreset> preset = export_presets[i]; + String section = "preset." + itos(i); + + config->set_value(section, "name", preset->get_name()); + config->set_value(section, "platform", preset->get_platform()->get_name()); + config->set_value(section, "runnable", preset->is_runnable()); + config->set_value(section, "custom_features", preset->get_custom_features()); + + bool save_files = false; + switch (preset->get_export_filter()) { + case EditorExportPreset::EXPORT_ALL_RESOURCES: { + config->set_value(section, "export_filter", "all_resources"); + } break; + case EditorExportPreset::EXPORT_SELECTED_SCENES: { + config->set_value(section, "export_filter", "scenes"); + save_files = true; + } break; + case EditorExportPreset::EXPORT_SELECTED_RESOURCES: { + config->set_value(section, "export_filter", "resources"); + save_files = true; + } break; + case EditorExportPreset::EXCLUDE_SELECTED_RESOURCES: { + config->set_value(section, "export_filter", "exclude"); + save_files = true; + } break; + } + + if (save_files) { + Vector<String> export_files = preset->get_files_to_export(); + config->set_value(section, "export_files", export_files); + } + config->set_value(section, "include_filter", preset->get_include_filter()); + config->set_value(section, "exclude_filter", preset->get_exclude_filter()); + config->set_value(section, "export_path", preset->get_export_path()); + config->set_value(section, "encryption_include_filters", preset->get_enc_in_filter()); + config->set_value(section, "encryption_exclude_filters", preset->get_enc_ex_filter()); + config->set_value(section, "encrypt_pck", preset->get_enc_pck()); + config->set_value(section, "encrypt_directory", preset->get_enc_directory()); + config->set_value(section, "script_export_mode", preset->get_script_export_mode()); + config->set_value(section, "script_encryption_key", preset->get_script_encryption_key()); + + String option_section = "preset." + itos(i) + ".options"; + + for (const PropertyInfo &E : preset->get_properties()) { + config->set_value(option_section, E.name, preset->get(E.name)); + } + } + + config->save("res://export_presets.cfg"); +} + +void EditorExport::save_presets() { + if (block_save) { + return; + } + save_timer->start(); +} + +void EditorExport::_bind_methods() { + ADD_SIGNAL(MethodInfo("export_presets_updated")); +} + +void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) { + export_platforms.push_back(p_platform); +} + +int EditorExport::get_export_platform_count() { + return export_platforms.size(); +} + +Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) { + ERR_FAIL_INDEX_V(p_idx, export_platforms.size(), Ref<EditorExportPlatform>()); + + return export_platforms[p_idx]; +} + +void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) { + if (p_at_pos < 0) { + export_presets.push_back(p_preset); + } else { + export_presets.insert(p_at_pos, p_preset); + } +} + +String EditorExportPlatform::test_etc2() const { + const bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2"); + + if (!etc2_supported) { + return TTR("Target platform requires 'ETC2' texture compression. Enable 'Import Etc 2' in Project Settings."); + } + + return String(); +} + +int EditorExport::get_export_preset_count() const { + return export_presets.size(); +} + +Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) { + ERR_FAIL_INDEX_V(p_idx, export_presets.size(), Ref<EditorExportPreset>()); + return export_presets[p_idx]; +} + +void EditorExport::remove_export_preset(int p_idx) { + export_presets.remove_at(p_idx); + save_presets(); +} + +void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { + if (!export_plugins.has(p_plugin)) { + export_plugins.push_back(p_plugin); + } +} + +void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { + export_plugins.erase(p_plugin); +} + +Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() { + return export_plugins; +} + +void EditorExport::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + load_config(); + } break; + + case NOTIFICATION_PROCESS: { + update_export_presets(); + } break; + } +} + +void EditorExport::load_config() { + Ref<ConfigFile> config; + config.instantiate(); + Error err = config->load("res://export_presets.cfg"); + if (err != OK) { + return; + } + + block_save = true; + + int index = 0; + while (true) { + String section = "preset." + itos(index); + if (!config->has_section(section)) { + break; + } + + String platform = config->get_value(section, "platform"); + + Ref<EditorExportPreset> preset; + + for (int i = 0; i < export_platforms.size(); i++) { + if (export_platforms[i]->get_name() == platform) { + preset = export_platforms.write[i]->create_preset(); + break; + } + } + + if (!preset.is_valid()) { + index++; + ERR_CONTINUE(!preset.is_valid()); + } + + preset->set_name(config->get_value(section, "name")); + preset->set_runnable(config->get_value(section, "runnable")); + + if (config->has_section_key(section, "custom_features")) { + preset->set_custom_features(config->get_value(section, "custom_features")); + } + + String export_filter = config->get_value(section, "export_filter"); + + bool get_files = false; + + if (export_filter == "all_resources") { + preset->set_export_filter(EditorExportPreset::EXPORT_ALL_RESOURCES); + } else if (export_filter == "scenes") { + preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_SCENES); + get_files = true; + } else if (export_filter == "resources") { + preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES); + get_files = true; + } else if (export_filter == "exclude") { + preset->set_export_filter(EditorExportPreset::EXCLUDE_SELECTED_RESOURCES); + get_files = true; + } + + if (get_files) { + Vector<String> files = config->get_value(section, "export_files"); + + for (int i = 0; i < files.size(); i++) { + if (!FileAccess::exists(files[i])) { + preset->remove_export_file(files[i]); + } else { + preset->add_export_file(files[i]); + } + } + } + + preset->set_include_filter(config->get_value(section, "include_filter")); + preset->set_exclude_filter(config->get_value(section, "exclude_filter")); + preset->set_export_path(config->get_value(section, "export_path", "")); + + if (config->has_section_key(section, "encrypt_pck")) { + preset->set_enc_pck(config->get_value(section, "encrypt_pck")); + } + if (config->has_section_key(section, "encrypt_directory")) { + preset->set_enc_directory(config->get_value(section, "encrypt_directory")); + } + if (config->has_section_key(section, "encryption_include_filters")) { + preset->set_enc_in_filter(config->get_value(section, "encryption_include_filters")); + } + if (config->has_section_key(section, "encryption_exclude_filters")) { + preset->set_enc_ex_filter(config->get_value(section, "encryption_exclude_filters")); + } + if (config->has_section_key(section, "script_export_mode")) { + preset->set_script_export_mode(config->get_value(section, "script_export_mode")); + } + if (config->has_section_key(section, "script_encryption_key")) { + preset->set_script_encryption_key(config->get_value(section, "script_encryption_key")); + } + + String option_section = "preset." + itos(index) + ".options"; + + List<String> options; + + config->get_section_keys(option_section, &options); + + for (const String &E : options) { + Variant value = config->get_value(option_section, E); + + preset->set(E, value); + } + + add_export_preset(preset); + index++; + } + + block_save = false; +} + +void EditorExport::update_export_presets() { + HashMap<StringName, List<EditorExportPlatform::ExportOption>> platform_options; + + for (int i = 0; i < export_platforms.size(); i++) { + Ref<EditorExportPlatform> platform = export_platforms[i]; + + if (platform->should_update_export_options()) { + List<EditorExportPlatform::ExportOption> options; + platform->get_export_options(&options); + + platform_options[platform->get_name()] = options; + } + } + + bool export_presets_updated = false; + for (int i = 0; i < export_presets.size(); i++) { + Ref<EditorExportPreset> preset = export_presets[i]; + if (platform_options.has(preset->get_platform()->get_name())) { + export_presets_updated = true; + + List<EditorExportPlatform::ExportOption> options = platform_options[preset->get_platform()->get_name()]; + + // Copy the previous preset values + HashMap<StringName, Variant> previous_values = preset->values; + + // Clear the preset properties and values prior to reloading + preset->properties.clear(); + preset->values.clear(); + + for (const EditorExportPlatform::ExportOption &E : options) { + preset->properties.push_back(E.option); + + StringName option_name = E.option.name; + preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E.default_value; + } + } + } + + if (export_presets_updated) { + emit_signal(_export_presets_updated); + } +} + +bool EditorExport::poll_export_platforms() { + bool changed = false; + for (int i = 0; i < export_platforms.size(); i++) { + if (export_platforms.write[i]->poll_export()) { + changed = true; + } + } + + return changed; +} + +EditorExport::EditorExport() { + save_timer = memnew(Timer); + add_child(save_timer); + save_timer->set_wait_time(0.8); + save_timer->set_one_shot(true); + save_timer->connect("timeout", callable_mp(this, &EditorExport::_save)); + + _export_presets_updated = "export_presets_updated"; + + singleton = this; + set_process(true); +} + +EditorExport::~EditorExport() { +} diff --git a/editor/export/editor_export.h b/editor/export/editor_export.h new file mode 100644 index 0000000000..13c3c34cea --- /dev/null +++ b/editor/export/editor_export.h @@ -0,0 +1,84 @@ +/*************************************************************************/ +/* editor_export.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. */ +/*************************************************************************/ + +#ifndef EDITOR_EXPORT_H +#define EDITOR_EXPORT_H + +#include "editor_export_platform.h" +#include "editor_export_plugin.h" + +class EditorExport : public Node { + GDCLASS(EditorExport, Node); + + Vector<Ref<EditorExportPlatform>> export_platforms; + Vector<Ref<EditorExportPreset>> export_presets; + Vector<Ref<EditorExportPlugin>> export_plugins; + + StringName _export_presets_updated; + + Timer *save_timer = nullptr; + bool block_save = false; + + static EditorExport *singleton; + + void _save(); + +protected: + friend class EditorExportPreset; + void save_presets(); + + void _notification(int p_what); + static void _bind_methods(); + +public: + static EditorExport *get_singleton() { return singleton; } + + void add_export_platform(const Ref<EditorExportPlatform> &p_platform); + int get_export_platform_count(); + Ref<EditorExportPlatform> get_export_platform(int p_idx); + + void add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos = -1); + int get_export_preset_count() const; + Ref<EditorExportPreset> get_export_preset(int p_idx); + void remove_export_preset(int p_idx); + + void add_export_plugin(const Ref<EditorExportPlugin> &p_plugin); + void remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin); + Vector<Ref<EditorExportPlugin>> get_export_plugins(); + + void load_config(); + void update_export_presets(); + bool poll_export_platforms(); + + EditorExport(); + ~EditorExport(); +}; + +#endif // EDITOR_EXPORT_H diff --git a/editor/editor_export.cpp b/editor/export/editor_export_platform.cpp index 46907bdf8a..9f64b241c6 100644 --- a/editor/editor_export.cpp +++ b/editor/export/editor_export_platform.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* editor_export.cpp */ +/* editor_export_platform.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,28 +28,21 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "editor_export.h" +#include "editor_export_platform.h" #include "core/config/project_settings.h" #include "core/crypto/crypto_core.h" #include "core/extension/native_extension.h" -#include "core/io/config_file.h" -#include "core/io/dir_access.h" -#include "core/io/file_access.h" #include "core/io/file_access_encrypted.h" #include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" #include "core/io/zip_io.h" -#include "core/object/script_language.h" #include "core/version.h" #include "editor/editor_file_system.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" -#include "editor/editor_settings.h" #include "editor/plugins/script_editor_plugin.h" -#include "scene/resources/resource_format_text.h" +#include "editor_export_plugin.h" static int _get_pad(int p_alignment, int p_n) { int rest = p_n % p_alignment; @@ -63,196 +56,6 @@ static int _get_pad(int p_alignment, int p_n) { #define PCK_PADDING 16 -bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) { - if (values.has(p_name)) { - values[p_name] = p_value; - EditorExport::singleton->save_presets(); - return true; - } - - return false; -} - -bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { - if (values.has(p_name)) { - r_ret = values[p_name]; - return true; - } - - return false; -} - -void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const { - for (const PropertyInfo &E : properties) { - if (platform->get_export_option_visibility(E.name, values)) { - p_list->push_back(E); - } - } -} - -Ref<EditorExportPlatform> EditorExportPreset::get_platform() const { - return platform; -} - -void EditorExportPreset::update_files_to_export() { - Vector<String> to_remove; - for (const String &E : selected_files) { - if (!FileAccess::exists(E)) { - to_remove.push_back(E); - } - } - for (int i = 0; i < to_remove.size(); ++i) { - selected_files.erase(to_remove[i]); - } -} - -Vector<String> EditorExportPreset::get_files_to_export() const { - Vector<String> files; - for (const String &E : selected_files) { - files.push_back(E); - } - return files; -} - -void EditorExportPreset::set_name(const String &p_name) { - name = p_name; - EditorExport::singleton->save_presets(); -} - -String EditorExportPreset::get_name() const { - return name; -} - -void EditorExportPreset::set_runnable(bool p_enable) { - runnable = p_enable; - EditorExport::singleton->save_presets(); -} - -bool EditorExportPreset::is_runnable() const { - return runnable; -} - -void EditorExportPreset::set_export_filter(ExportFilter p_filter) { - export_filter = p_filter; - EditorExport::singleton->save_presets(); -} - -EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const { - return export_filter; -} - -void EditorExportPreset::set_include_filter(const String &p_include) { - include_filter = p_include; - EditorExport::singleton->save_presets(); -} - -String EditorExportPreset::get_include_filter() const { - return include_filter; -} - -void EditorExportPreset::set_export_path(const String &p_path) { - export_path = p_path; - /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path, - * this should be removed. */ - if (export_path.is_absolute_path()) { - String res_path = OS::get_singleton()->get_resource_dir(); - export_path = res_path.path_to_file(export_path); - } - EditorExport::singleton->save_presets(); -} - -String EditorExportPreset::get_export_path() const { - return export_path; -} - -void EditorExportPreset::set_exclude_filter(const String &p_exclude) { - exclude_filter = p_exclude; - EditorExport::singleton->save_presets(); -} - -String EditorExportPreset::get_exclude_filter() const { - return exclude_filter; -} - -void EditorExportPreset::add_export_file(const String &p_path) { - selected_files.insert(p_path); - EditorExport::singleton->save_presets(); -} - -void EditorExportPreset::remove_export_file(const String &p_path) { - selected_files.erase(p_path); - EditorExport::singleton->save_presets(); -} - -bool EditorExportPreset::has_export_file(const String &p_path) { - return selected_files.has(p_path); -} - -void EditorExportPreset::set_custom_features(const String &p_custom_features) { - custom_features = p_custom_features; - EditorExport::singleton->save_presets(); -} - -String EditorExportPreset::get_custom_features() const { - return custom_features; -} - -void EditorExportPreset::set_enc_in_filter(const String &p_filter) { - enc_in_filters = p_filter; - EditorExport::singleton->save_presets(); -} - -String EditorExportPreset::get_enc_in_filter() const { - return enc_in_filters; -} - -void EditorExportPreset::set_enc_ex_filter(const String &p_filter) { - enc_ex_filters = p_filter; - EditorExport::singleton->save_presets(); -} - -String EditorExportPreset::get_enc_ex_filter() const { - return enc_ex_filters; -} - -void EditorExportPreset::set_enc_pck(bool p_enabled) { - enc_pck = p_enabled; - EditorExport::singleton->save_presets(); -} - -bool EditorExportPreset::get_enc_pck() const { - return enc_pck; -} - -void EditorExportPreset::set_enc_directory(bool p_enabled) { - enc_directory = p_enabled; - EditorExport::singleton->save_presets(); -} - -bool EditorExportPreset::get_enc_directory() const { - return enc_directory; -} - -void EditorExportPreset::set_script_export_mode(int p_mode) { - script_mode = p_mode; - EditorExport::singleton->save_presets(); -} - -int EditorExportPreset::get_script_export_mode() const { - return script_mode; -} - -void EditorExportPreset::set_script_encryption_key(const String &p_key) { - script_key = p_key; - EditorExport::singleton->save_presets(); -} - -String EditorExportPreset::get_script_encryption_key() const { - return script_key; -} - -/////////////////////////////////// - bool EditorExportPlatform::fill_log_messages(RichTextLabel *p_log, Error p_err) { bool has_messages = false; @@ -272,7 +75,7 @@ bool EditorExportPlatform::fill_log_messages(RichTextLabel *p_log, Error p_err) } else { p_log->add_image(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("StatusSuccess"), SNAME("EditorIcons")), 16 * EDSCALE, 16 * EDSCALE, Color(1.0, 1.0, 1.0), INLINE_ALIGNMENT_CENTER); p_log->add_text(" "); - p_log->add_text(TTR("Completed successfully.")); + p_log->add_text(TTR("Completed sucessfully.")); if (msg_count > 0) { has_messages = true; } @@ -625,138 +428,6 @@ void EditorExportPlatform::_edit_filter_list(HashSet<String> &r_list, const Stri _edit_files_with_filter(da, filters, r_list, exclude); } -void EditorExportPlugin::set_export_preset(const Ref<EditorExportPreset> &p_preset) { - if (p_preset.is_valid()) { - export_preset = p_preset; - } -} - -Ref<EditorExportPreset> EditorExportPlugin::get_export_preset() const { - return export_preset; -} - -void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap) { - ExtraFile ef; - ef.data = p_file; - ef.path = p_path; - ef.remap = p_remap; - extra_files.push_back(ef); -} - -void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &p_tags, const String &p_target) { - shared_objects.push_back(SharedObject(p_path, p_tags, p_target)); -} - -void EditorExportPlugin::add_ios_framework(const String &p_path) { - ios_frameworks.push_back(p_path); -} - -void EditorExportPlugin::add_ios_embedded_framework(const String &p_path) { - ios_embedded_frameworks.push_back(p_path); -} - -Vector<String> EditorExportPlugin::get_ios_frameworks() const { - return ios_frameworks; -} - -Vector<String> EditorExportPlugin::get_ios_embedded_frameworks() const { - return ios_embedded_frameworks; -} - -void EditorExportPlugin::add_ios_plist_content(const String &p_plist_content) { - ios_plist_content += p_plist_content + "\n"; -} - -String EditorExportPlugin::get_ios_plist_content() const { - return ios_plist_content; -} - -void EditorExportPlugin::add_ios_linker_flags(const String &p_flags) { - if (ios_linker_flags.length() > 0) { - ios_linker_flags += ' '; - } - ios_linker_flags += p_flags; -} - -String EditorExportPlugin::get_ios_linker_flags() const { - return ios_linker_flags; -} - -void EditorExportPlugin::add_ios_bundle_file(const String &p_path) { - ios_bundle_files.push_back(p_path); -} - -Vector<String> EditorExportPlugin::get_ios_bundle_files() const { - return ios_bundle_files; -} - -void EditorExportPlugin::add_ios_cpp_code(const String &p_code) { - ios_cpp_code += p_code; -} - -String EditorExportPlugin::get_ios_cpp_code() const { - return ios_cpp_code; -} - -void EditorExportPlugin::add_macos_plugin_file(const String &p_path) { - macos_plugin_files.push_back(p_path); -} - -const Vector<String> &EditorExportPlugin::get_macos_plugin_files() const { - return macos_plugin_files; -} - -void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) { - ios_project_static_libs.push_back(p_path); -} - -Vector<String> EditorExportPlugin::get_ios_project_static_libs() const { - return ios_project_static_libs; -} - -void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) { - GDVIRTUAL_CALL(_export_file, p_path, p_type, p_features); -} - -void EditorExportPlugin::_export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags) { - GDVIRTUAL_CALL(_export_begin, p_features, p_debug, p_path, p_flags); -} - -void EditorExportPlugin::_export_end_script() { - GDVIRTUAL_CALL(_export_end); -} - -void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) { -} - -void EditorExportPlugin::_export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags) { -} - -void EditorExportPlugin::skip() { - skipped = true; -} - -void EditorExportPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags", "target"), &EditorExportPlugin::add_shared_object); - ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib); - ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file); - ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework); - ClassDB::bind_method(D_METHOD("add_ios_embedded_framework", "path"), &EditorExportPlugin::add_ios_embedded_framework); - ClassDB::bind_method(D_METHOD("add_ios_plist_content", "plist_content"), &EditorExportPlugin::add_ios_plist_content); - ClassDB::bind_method(D_METHOD("add_ios_linker_flags", "flags"), &EditorExportPlugin::add_ios_linker_flags); - ClassDB::bind_method(D_METHOD("add_ios_bundle_file", "path"), &EditorExportPlugin::add_ios_bundle_file); - ClassDB::bind_method(D_METHOD("add_ios_cpp_code", "code"), &EditorExportPlugin::add_ios_cpp_code); - ClassDB::bind_method(D_METHOD("add_macos_plugin_file", "path"), &EditorExportPlugin::add_macos_plugin_file); - ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip); - - GDVIRTUAL_BIND(_export_file, "path", "type", "features"); - GDVIRTUAL_BIND(_export_begin, "features", "is_debug", "path", "flags"); - GDVIRTUAL_BIND(_export_end); -} - -EditorExportPlugin::EditorExportPlugin() { -} - EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) { Ref<EditorExportPlatform> platform = p_preset->get_platform(); List<String> feature_list; @@ -1504,573 +1175,3 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags EditorExportPlatform::EditorExportPlatform() { } - -//// - -EditorExport *EditorExport::singleton = nullptr; - -void EditorExport::_save() { - Ref<ConfigFile> config; - config.instantiate(); - for (int i = 0; i < export_presets.size(); i++) { - Ref<EditorExportPreset> preset = export_presets[i]; - String section = "preset." + itos(i); - - config->set_value(section, "name", preset->get_name()); - config->set_value(section, "platform", preset->get_platform()->get_name()); - config->set_value(section, "runnable", preset->is_runnable()); - config->set_value(section, "custom_features", preset->get_custom_features()); - - bool save_files = false; - switch (preset->get_export_filter()) { - case EditorExportPreset::EXPORT_ALL_RESOURCES: { - config->set_value(section, "export_filter", "all_resources"); - } break; - case EditorExportPreset::EXPORT_SELECTED_SCENES: { - config->set_value(section, "export_filter", "scenes"); - save_files = true; - } break; - case EditorExportPreset::EXPORT_SELECTED_RESOURCES: { - config->set_value(section, "export_filter", "resources"); - save_files = true; - } break; - case EditorExportPreset::EXCLUDE_SELECTED_RESOURCES: { - config->set_value(section, "export_filter", "exclude"); - save_files = true; - } break; - } - - if (save_files) { - Vector<String> export_files = preset->get_files_to_export(); - config->set_value(section, "export_files", export_files); - } - config->set_value(section, "include_filter", preset->get_include_filter()); - config->set_value(section, "exclude_filter", preset->get_exclude_filter()); - config->set_value(section, "export_path", preset->get_export_path()); - config->set_value(section, "encryption_include_filters", preset->get_enc_in_filter()); - config->set_value(section, "encryption_exclude_filters", preset->get_enc_ex_filter()); - config->set_value(section, "encrypt_pck", preset->get_enc_pck()); - config->set_value(section, "encrypt_directory", preset->get_enc_directory()); - config->set_value(section, "script_export_mode", preset->get_script_export_mode()); - config->set_value(section, "script_encryption_key", preset->get_script_encryption_key()); - - String option_section = "preset." + itos(i) + ".options"; - - for (const PropertyInfo &E : preset->get_properties()) { - config->set_value(option_section, E.name, preset->get(E.name)); - } - } - - config->save("res://export_presets.cfg"); -} - -void EditorExport::save_presets() { - if (block_save) { - return; - } - save_timer->start(); -} - -void EditorExport::_bind_methods() { - ADD_SIGNAL(MethodInfo("export_presets_updated")); -} - -void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) { - export_platforms.push_back(p_platform); -} - -int EditorExport::get_export_platform_count() { - return export_platforms.size(); -} - -Ref<EditorExportPlatform> EditorExport::get_export_platform(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, export_platforms.size(), Ref<EditorExportPlatform>()); - - return export_platforms[p_idx]; -} - -void EditorExport::add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos) { - if (p_at_pos < 0) { - export_presets.push_back(p_preset); - } else { - export_presets.insert(p_at_pos, p_preset); - } -} - -String EditorExportPlatform::test_etc2() const { - const bool etc2_supported = ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2"); - - if (!etc2_supported) { - return TTR("Target platform requires 'ETC2' texture compression. Enable 'Import Etc 2' in Project Settings."); - } - - return String(); -} - -int EditorExport::get_export_preset_count() const { - return export_presets.size(); -} - -Ref<EditorExportPreset> EditorExport::get_export_preset(int p_idx) { - ERR_FAIL_INDEX_V(p_idx, export_presets.size(), Ref<EditorExportPreset>()); - return export_presets[p_idx]; -} - -void EditorExport::remove_export_preset(int p_idx) { - export_presets.remove_at(p_idx); - save_presets(); -} - -void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { - if (!export_plugins.has(p_plugin)) { - export_plugins.push_back(p_plugin); - } -} - -void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { - export_plugins.erase(p_plugin); -} - -Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() { - return export_plugins; -} - -void EditorExport::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - load_config(); - } break; - - case NOTIFICATION_PROCESS: { - update_export_presets(); - } break; - } -} - -void EditorExport::load_config() { - Ref<ConfigFile> config; - config.instantiate(); - Error err = config->load("res://export_presets.cfg"); - if (err != OK) { - return; - } - - block_save = true; - - int index = 0; - while (true) { - String section = "preset." + itos(index); - if (!config->has_section(section)) { - break; - } - - String platform = config->get_value(section, "platform"); - - Ref<EditorExportPreset> preset; - - for (int i = 0; i < export_platforms.size(); i++) { - if (export_platforms[i]->get_name() == platform) { - preset = export_platforms.write[i]->create_preset(); - break; - } - } - - if (!preset.is_valid()) { - index++; - ERR_CONTINUE(!preset.is_valid()); - } - - preset->set_name(config->get_value(section, "name")); - preset->set_runnable(config->get_value(section, "runnable")); - - if (config->has_section_key(section, "custom_features")) { - preset->set_custom_features(config->get_value(section, "custom_features")); - } - - String export_filter = config->get_value(section, "export_filter"); - - bool get_files = false; - - if (export_filter == "all_resources") { - preset->set_export_filter(EditorExportPreset::EXPORT_ALL_RESOURCES); - } else if (export_filter == "scenes") { - preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_SCENES); - get_files = true; - } else if (export_filter == "resources") { - preset->set_export_filter(EditorExportPreset::EXPORT_SELECTED_RESOURCES); - get_files = true; - } else if (export_filter == "exclude") { - preset->set_export_filter(EditorExportPreset::EXCLUDE_SELECTED_RESOURCES); - get_files = true; - } - - if (get_files) { - Vector<String> files = config->get_value(section, "export_files"); - - for (int i = 0; i < files.size(); i++) { - if (!FileAccess::exists(files[i])) { - preset->remove_export_file(files[i]); - } else { - preset->add_export_file(files[i]); - } - } - } - - preset->set_include_filter(config->get_value(section, "include_filter")); - preset->set_exclude_filter(config->get_value(section, "exclude_filter")); - preset->set_export_path(config->get_value(section, "export_path", "")); - - if (config->has_section_key(section, "encrypt_pck")) { - preset->set_enc_pck(config->get_value(section, "encrypt_pck")); - } - if (config->has_section_key(section, "encrypt_directory")) { - preset->set_enc_directory(config->get_value(section, "encrypt_directory")); - } - if (config->has_section_key(section, "encryption_include_filters")) { - preset->set_enc_in_filter(config->get_value(section, "encryption_include_filters")); - } - if (config->has_section_key(section, "encryption_exclude_filters")) { - preset->set_enc_ex_filter(config->get_value(section, "encryption_exclude_filters")); - } - if (config->has_section_key(section, "script_export_mode")) { - preset->set_script_export_mode(config->get_value(section, "script_export_mode")); - } - if (config->has_section_key(section, "script_encryption_key")) { - preset->set_script_encryption_key(config->get_value(section, "script_encryption_key")); - } - - String option_section = "preset." + itos(index) + ".options"; - - List<String> options; - - config->get_section_keys(option_section, &options); - - for (const String &E : options) { - Variant value = config->get_value(option_section, E); - - preset->set(E, value); - } - - add_export_preset(preset); - index++; - } - - block_save = false; -} - -void EditorExport::update_export_presets() { - HashMap<StringName, List<EditorExportPlatform::ExportOption>> platform_options; - - for (int i = 0; i < export_platforms.size(); i++) { - Ref<EditorExportPlatform> platform = export_platforms[i]; - - if (platform->should_update_export_options()) { - List<EditorExportPlatform::ExportOption> options; - platform->get_export_options(&options); - - platform_options[platform->get_name()] = options; - } - } - - bool export_presets_updated = false; - for (int i = 0; i < export_presets.size(); i++) { - Ref<EditorExportPreset> preset = export_presets[i]; - if (platform_options.has(preset->get_platform()->get_name())) { - export_presets_updated = true; - - List<EditorExportPlatform::ExportOption> options = platform_options[preset->get_platform()->get_name()]; - - // Copy the previous preset values - HashMap<StringName, Variant> previous_values = preset->values; - - // Clear the preset properties and values prior to reloading - preset->properties.clear(); - preset->values.clear(); - - for (const EditorExportPlatform::ExportOption &E : options) { - preset->properties.push_back(E.option); - - StringName option_name = E.option.name; - preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E.default_value; - } - } - } - - if (export_presets_updated) { - emit_signal(_export_presets_updated); - } -} - -bool EditorExport::poll_export_platforms() { - bool changed = false; - for (int i = 0; i < export_platforms.size(); i++) { - if (export_platforms.write[i]->poll_export()) { - changed = true; - } - } - - return changed; -} - -EditorExport::EditorExport() { - save_timer = memnew(Timer); - add_child(save_timer); - save_timer->set_wait_time(0.8); - save_timer->set_one_shot(true); - save_timer->connect("timeout", callable_mp(this, &EditorExport::_save)); - - _export_presets_updated = "export_presets_updated"; - - singleton = this; - set_process(true); -} - -EditorExport::~EditorExport() { -} - -////////// - -void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) { - if (p_preset->get("texture_format/s3tc")) { - r_features->push_back("s3tc"); - } - if (p_preset->get("texture_format/etc")) { - r_features->push_back("etc"); - } - if (p_preset->get("texture_format/etc2")) { - r_features->push_back("etc2"); - } - - if (p_preset->get("binary_format/64_bits")) { - r_features->push_back("64"); - } else { - r_features->push_back("32"); - } -} - -void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { - String ext_filter = (get_os_name() == "Windows") ? "*.exe" : ""; - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, ext_filter), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, ext_filter), "")); - - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_script", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1)); - - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/64_bits"), true)); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/embed_pck"), false)); - - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true)); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/no_bptc_fallbacks"), true)); -} - -String EditorExportPlatformPC::get_name() const { - return name; -} - -String EditorExportPlatformPC::get_os_name() const { - return os_name; -} - -Ref<Texture2D> EditorExportPlatformPC::get_logo() const { - return logo; -} - -bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { - String err; - bool valid = false; - - // Look for export templates (first official, and if defined custom templates). - - bool use64 = p_preset->get("binary_format/64_bits"); - bool dvalid = exists_export_template(get_template_file_name("debug", use64 ? "64" : "32"), &err); - bool rvalid = exists_export_template(get_template_file_name("release", use64 ? "64" : "32"), &err); - - if (p_preset->get("custom_template/debug") != "") { - dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); - if (!dvalid) { - err += TTR("Custom debug template not found.") + "\n"; - } - } - if (p_preset->get("custom_template/release") != "") { - rvalid = FileAccess::exists(p_preset->get("custom_template/release")); - if (!rvalid) { - err += TTR("Custom release template not found.") + "\n"; - } - } - - valid = dvalid || rvalid; - r_missing_templates = !valid; - - if (!err.is_empty()) { - r_error = err; - } - return valid; -} - -Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { - ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); - - Error err = prepare_template(p_preset, p_debug, p_path, p_flags); - if (err == OK) { - err = modify_template(p_preset, p_debug, p_path, p_flags); - } - if (err == OK) { - err = export_project_data(p_preset, p_debug, p_path, p_flags); - } - - return err; -} - -Error EditorExportPlatformPC::prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { - if (!DirAccess::exists(p_path.get_base_dir())) { - add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("The given export path doesn't exist.")); - return ERR_FILE_BAD_PATH; - } - - String custom_debug = p_preset->get("custom_template/debug"); - String custom_release = p_preset->get("custom_template/release"); - - String template_path = p_debug ? custom_debug : custom_release; - - template_path = template_path.strip_edges(); - - if (template_path.is_empty()) { - template_path = find_export_template(get_template_file_name(p_debug ? "debug" : "release", p_preset->get("binary_format/64_bits") ? "64" : "32")); - } - - if (!template_path.is_empty() && !FileAccess::exists(template_path)) { - add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), vformat(TTR("Template file not found: \"%s\"."), template_path)); - return ERR_FILE_NOT_FOUND; - } - - Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - da->make_dir_recursive(p_path.get_base_dir()); - Error err = da->copy(template_path, p_path, get_chmod_flags()); - if (err != OK) { - add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("Failed to copy export template.")); - } - - return err; -} - -Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { - String pck_path; - if (p_preset->get("binary_format/embed_pck")) { - pck_path = p_path; - } else { - pck_path = p_path.get_basename() + ".pck"; - } - - Vector<SharedObject> so_files; - - int64_t embedded_pos; - int64_t embedded_size; - Error err = save_pack(p_preset, p_debug, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size); - if (err == OK && p_preset->get("binary_format/embed_pck")) { - if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) { - add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB.")); - return ERR_INVALID_PARAMETER; - } - - err = fixup_embedded_pck(p_path, embedded_pos, embedded_size); - } - - if (err == OK && !so_files.is_empty()) { - // If shared object files, copy them. - Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - for (int i = 0; i < so_files.size() && err == OK; i++) { - String src_path = ProjectSettings::get_singleton()->globalize_path(so_files[i].path); - String target_path; - if (so_files[i].target.is_empty()) { - target_path = p_path.get_base_dir().plus_file(src_path.get_file()); - } else { - target_path = p_path.get_base_dir().plus_file(so_files[i].target).plus_file(src_path.get_file()); - } - - if (da->dir_exists(src_path)) { - err = da->make_dir_recursive(target_path); - if (err == OK) { - err = da->copy_dir(src_path, target_path, -1, true); - } - } else { - err = da->copy(src_path, target_path); - if (err == OK) { - err = sign_shared_object(p_preset, p_debug, target_path); - } - } - } - } - - return err; -} - -Error EditorExportPlatformPC::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) { - return OK; -} - -void EditorExportPlatformPC::set_name(const String &p_name) { - name = p_name; -} - -void EditorExportPlatformPC::set_os_name(const String &p_name) { - os_name = p_name; -} - -void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) { - logo = p_logo; -} - -void EditorExportPlatformPC::get_platform_features(List<String> *r_features) { - r_features->push_back("pc"); //all pcs support "pc" - r_features->push_back("s3tc"); //all pcs support "s3tc" compression - r_features->push_back(get_os_name().to_lower()); //OS name is a feature -} - -void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) { - if (p_features.has("bptc")) { - if (p_preset->has("texture_format/no_bptc_fallbacks")) { - p_features.erase("s3tc"); - } - } -} - -int EditorExportPlatformPC::get_chmod_flags() const { - return chmod_flags; -} - -void EditorExportPlatformPC::set_chmod_flags(int p_flags) { - chmod_flags = p_flags; -} - -/////////////////////// - -void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) { - String extension = p_path.get_extension().to_lower(); - if (extension != "tres" && extension != "tscn") { - return; - } - - bool convert = GLOBAL_GET("editor/export/convert_text_resources_to_binary"); - if (!convert) { - return; - } - String tmp_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpfile.res"); - Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path); - if (err != OK) { - DirAccess::remove_file_or_error(tmp_path); - ERR_FAIL(); - } - Vector<uint8_t> data = FileAccess::get_file_as_array(tmp_path); - if (data.size() == 0) { - DirAccess::remove_file_or_error(tmp_path); - ERR_FAIL(); - } - DirAccess::remove_file_or_error(tmp_path); - add_file(p_path + ".converted.res", data, true); -} - -EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() { - GLOBAL_DEF("editor/export/convert_text_resources_to_binary", false); -} diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h new file mode 100644 index 0000000000..2778a217b0 --- /dev/null +++ b/editor/export/editor_export_platform.h @@ -0,0 +1,221 @@ +/*************************************************************************/ +/* editor_export_platform.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. */ +/*************************************************************************/ + +#ifndef EDITOR_EXPORT_PLATFORM_H +#define EDITOR_EXPORT_PLATFORM_H + +class EditorFileSystemDirectory; +struct EditorProgress; + +#include "core/io/dir_access.h" +#include "editor_export_preset.h" +#include "editor_export_shared_object.h" +#include "scene/gui/rich_text_label.h" +#include "scene/main/node.h" + +class EditorExportPlatform : public RefCounted { + GDCLASS(EditorExportPlatform, RefCounted); + +public: + typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + typedef Error (*EditorExportSaveSharedObject)(void *p_userdata, const SharedObject &p_so); + + enum ExportMessageType { + EXPORT_MESSAGE_NONE, + EXPORT_MESSAGE_INFO, + EXPORT_MESSAGE_WARNING, + EXPORT_MESSAGE_ERROR, + }; + + struct ExportMessage { + ExportMessageType msg_type; + String category; + String text; + }; + +private: + struct SavedData { + uint64_t ofs = 0; + uint64_t size = 0; + bool encrypted = false; + Vector<uint8_t> md5; + CharString path_utf8; + + bool operator<(const SavedData &p_data) const { + return path_utf8 < p_data.path_utf8; + } + }; + + struct PackData { + Ref<FileAccess> f; + Vector<SavedData> file_ofs; + EditorProgress *ep = nullptr; + Vector<SharedObject> *so_files = nullptr; + }; + + struct ZipData { + void *zip = nullptr; + EditorProgress *ep = nullptr; + }; + + struct FeatureContainers { + HashSet<String> features; + Vector<String> features_pv; + }; + + Vector<ExportMessage> messages; + + void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths); + void _export_find_dependencies(const String &p_path, HashSet<String> &p_paths); + + void gen_debug_flags(Vector<String> &r_flags, int p_flags); + static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); + + void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<String> &r_list, bool exclude); + void _edit_filter_list(HashSet<String> &r_list, const String &p_filter, bool exclude); + + static Error _add_shared_object(void *p_userdata, const SharedObject &p_so); + +protected: + struct ExportNotifier { + ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags); + ~ExportNotifier(); + }; + + FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug); + + bool exists_export_template(String template_file_name, String *err) const; + String find_export_template(String template_file_name, String *err = nullptr) const; + void gen_export_flags(Vector<String> &r_flags, int p_flags); + +public: + virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0; + + struct ExportOption { + PropertyInfo option; + Variant default_value; + + ExportOption(const PropertyInfo &p_info, const Variant &p_default) : + option(p_info), + default_value(p_default) { + } + ExportOption() {} + }; + + virtual Ref<EditorExportPreset> create_preset(); + + virtual void clear_messages() { messages.clear(); } + virtual void add_message(ExportMessageType p_type, const String &p_category, const String &p_message) { + ExportMessage msg; + msg.category = p_category; + msg.text = p_message; + msg.msg_type = p_type; + messages.push_back(msg); + switch (p_type) { + case EXPORT_MESSAGE_INFO: { + print_line(vformat("%s: %s\n", msg.category, msg.text)); + } break; + case EXPORT_MESSAGE_WARNING: { + WARN_PRINT(vformat("%s: %s\n", msg.category, msg.text)); + } break; + case EXPORT_MESSAGE_ERROR: { + ERR_PRINT(vformat("%s: %s\n", msg.category, msg.text)); + } break; + default: + break; + } + } + + virtual int get_message_count() const { + return messages.size(); + } + + virtual ExportMessage get_message(int p_index) const { + ERR_FAIL_INDEX_V(p_index, messages.size(), ExportMessage()); + return messages[p_index]; + } + + virtual ExportMessageType get_worst_message_type() const { + ExportMessageType worst_type = EXPORT_MESSAGE_NONE; + for (int i = 0; i < messages.size(); i++) { + worst_type = MAX(worst_type, messages[i].msg_type); + } + return worst_type; + } + + virtual bool fill_log_messages(RichTextLabel *p_log, Error p_err); + + virtual void get_export_options(List<ExportOption> *r_options) = 0; + virtual bool should_update_export_options() { return false; } + virtual bool get_export_option_visibility(const String &p_option, const HashMap<StringName, Variant> &p_options) const { return true; } + + virtual String get_os_name() const = 0; + virtual String get_name() const = 0; + virtual Ref<Texture2D> get_logo() const = 0; + + Error export_project_files(const Ref<EditorExportPreset> &p_preset, bool p_debug, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = nullptr); + + Error save_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, Vector<SharedObject> *p_so_files = nullptr, bool p_embed = false, int64_t *r_embedded_start = nullptr, int64_t *r_embedded_size = nullptr); + Error save_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path); + + virtual bool poll_export() { return false; } + virtual int get_options_count() const { return 0; } + virtual String get_options_tooltip() const { return ""; } + virtual Ref<ImageTexture> get_option_icon(int p_index) const; + virtual String get_option_label(int p_device) const { return ""; } + virtual String get_option_tooltip(int p_device) const { return ""; } + + enum DebugFlags { + DEBUG_FLAG_DUMB_CLIENT = 1, + DEBUG_FLAG_REMOTE_DEBUG = 2, + DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST = 4, + DEBUG_FLAG_VIEW_COLLISONS = 8, + DEBUG_FLAG_VIEW_NAVIGATION = 16, + }; + + virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; } + virtual Ref<Texture2D> get_run_icon() const { return get_logo(); } + + String test_etc2() const; + virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0; + + virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const = 0; + virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0; + virtual Error export_pack(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); + virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); + virtual void get_platform_features(List<String> *r_features) = 0; + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) = 0; + virtual String get_debug_protocol() const { return "tcp://"; } + + EditorExportPlatform(); +}; + +#endif // EDITOR_EXPORT_PLATFORM_H diff --git a/editor/export/editor_export_platform_pc.cpp b/editor/export/editor_export_platform_pc.cpp new file mode 100644 index 0000000000..b60fba13ed --- /dev/null +++ b/editor/export/editor_export_platform_pc.cpp @@ -0,0 +1,247 @@ +/*************************************************************************/ +/* editor_export_platform_pc.cpp */ +/*************************************************************************/ +/* 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 "editor_export_platform_pc.h" + +#include "core/config/project_settings.h" + +void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) { + if (p_preset->get("texture_format/s3tc")) { + r_features->push_back("s3tc"); + } + if (p_preset->get("texture_format/etc")) { + r_features->push_back("etc"); + } + if (p_preset->get("texture_format/etc2")) { + r_features->push_back("etc2"); + } + + if (p_preset->get("binary_format/64_bits")) { + r_features->push_back("64"); + } else { + r_features->push_back("32"); + } +} + +void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { + String ext_filter = (get_os_name() == "Windows") ? "*.exe" : ""; + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, ext_filter), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, ext_filter), "")); + + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "debug/export_console_script", PROPERTY_HINT_ENUM, "No,Debug Only,Debug and Release"), 1)); + + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/64_bits"), true)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "binary_format/embed_pck"), false)); + + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/bptc"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), true)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/no_bptc_fallbacks"), true)); +} + +String EditorExportPlatformPC::get_name() const { + return name; +} + +String EditorExportPlatformPC::get_os_name() const { + return os_name; +} + +Ref<Texture2D> EditorExportPlatformPC::get_logo() const { + return logo; +} + +bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { + String err; + bool valid = false; + + // Look for export templates (first official, and if defined custom templates). + + bool use64 = p_preset->get("binary_format/64_bits"); + bool dvalid = exists_export_template(get_template_file_name("debug", use64 ? "x86_64" : "x86_32"), &err); + bool rvalid = exists_export_template(get_template_file_name("release", use64 ? "x86_64" : "x86_32"), &err); + + if (p_preset->get("custom_template/debug") != "") { + dvalid = FileAccess::exists(p_preset->get("custom_template/debug")); + if (!dvalid) { + err += TTR("Custom debug template not found.") + "\n"; + } + } + if (p_preset->get("custom_template/release") != "") { + rvalid = FileAccess::exists(p_preset->get("custom_template/release")); + if (!rvalid) { + err += TTR("Custom release template not found.") + "\n"; + } + } + + valid = dvalid || rvalid; + r_missing_templates = !valid; + + if (!err.is_empty()) { + r_error = err; + } + return valid; +} + +Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { + ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); + + Error err = prepare_template(p_preset, p_debug, p_path, p_flags); + if (err == OK) { + err = modify_template(p_preset, p_debug, p_path, p_flags); + } + if (err == OK) { + err = export_project_data(p_preset, p_debug, p_path, p_flags); + } + + return err; +} + +Error EditorExportPlatformPC::prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { + if (!DirAccess::exists(p_path.get_base_dir())) { + add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("The given export path doesn't exist.")); + return ERR_FILE_BAD_PATH; + } + + String custom_debug = p_preset->get("custom_template/debug"); + String custom_release = p_preset->get("custom_template/release"); + + String template_path = p_debug ? custom_debug : custom_release; + + template_path = template_path.strip_edges(); + + if (template_path.is_empty()) { + template_path = find_export_template(get_template_file_name(p_debug ? "debug" : "release", p_preset->get("binary_format/64_bits") ? "64" : "32")); + } + + if (!template_path.is_empty() && !FileAccess::exists(template_path)) { + add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), vformat(TTR("Template file not found: \"%s\"."), template_path)); + return ERR_FILE_NOT_FOUND; + } + + Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + da->make_dir_recursive(p_path.get_base_dir()); + Error err = da->copy(template_path, p_path, get_chmod_flags()); + if (err != OK) { + add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("Failed to copy export template.")); + } + + return err; +} + +Error EditorExportPlatformPC::export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { + String pck_path; + if (p_preset->get("binary_format/embed_pck")) { + pck_path = p_path; + } else { + pck_path = p_path.get_basename() + ".pck"; + } + + Vector<SharedObject> so_files; + + int64_t embedded_pos; + int64_t embedded_size; + Error err = save_pack(p_preset, p_debug, pck_path, &so_files, p_preset->get("binary_format/embed_pck"), &embedded_pos, &embedded_size); + if (err == OK && p_preset->get("binary_format/embed_pck")) { + if (embedded_size >= 0x100000000 && !p_preset->get("binary_format/64_bits")) { + add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("On 32-bit exports the embedded PCK cannot be bigger than 4 GiB.")); + return ERR_INVALID_PARAMETER; + } + + err = fixup_embedded_pck(p_path, embedded_pos, embedded_size); + } + + if (err == OK && !so_files.is_empty()) { + // If shared object files, copy them. + Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + for (int i = 0; i < so_files.size() && err == OK; i++) { + String src_path = ProjectSettings::get_singleton()->globalize_path(so_files[i].path); + String target_path; + if (so_files[i].target.is_empty()) { + target_path = p_path.get_base_dir().plus_file(src_path.get_file()); + } else { + target_path = p_path.get_base_dir().plus_file(so_files[i].target).plus_file(src_path.get_file()); + } + + if (da->dir_exists(src_path)) { + err = da->make_dir_recursive(target_path); + if (err == OK) { + err = da->copy_dir(src_path, target_path, -1, true); + } + } else { + err = da->copy(src_path, target_path); + if (err == OK) { + err = sign_shared_object(p_preset, p_debug, target_path); + } + } + } + } + + return err; +} + +Error EditorExportPlatformPC::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) { + return OK; +} + +void EditorExportPlatformPC::set_name(const String &p_name) { + name = p_name; +} + +void EditorExportPlatformPC::set_os_name(const String &p_name) { + os_name = p_name; +} + +void EditorExportPlatformPC::set_logo(const Ref<Texture2D> &p_logo) { + logo = p_logo; +} + +void EditorExportPlatformPC::get_platform_features(List<String> *r_features) { + r_features->push_back("pc"); //all pcs support "pc" + r_features->push_back("s3tc"); //all pcs support "s3tc" compression + r_features->push_back(get_os_name().to_lower()); //OS name is a feature +} + +void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) { + if (p_features.has("bptc")) { + if (p_preset->has("texture_format/no_bptc_fallbacks")) { + p_features.erase("s3tc"); + } + } +} + +int EditorExportPlatformPC::get_chmod_flags() const { + return chmod_flags; +} + +void EditorExportPlatformPC::set_chmod_flags(int p_flags) { + chmod_flags = p_flags; +} diff --git a/editor/export/editor_export_platform_pc.h b/editor/export/editor_export_platform_pc.h new file mode 100644 index 0000000000..ae7d6f1082 --- /dev/null +++ b/editor/export/editor_export_platform_pc.h @@ -0,0 +1,82 @@ +/*************************************************************************/ +/* editor_export_platform_pc.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. */ +/*************************************************************************/ + +#ifndef EDITOR_EXPORT_PLATFORM_PC_H +#define EDITOR_EXPORT_PLATFORM_PC_H + +#include "editor_export_platform.h" + +class EditorExportPlatformPC : public EditorExportPlatform { + GDCLASS(EditorExportPlatformPC, EditorExportPlatform); + +private: + Ref<ImageTexture> logo; + String name; + String os_name; + + int chmod_flags = -1; + +public: + virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) override; + + virtual void get_export_options(List<ExportOption> *r_options) override; + + virtual String get_name() const override; + virtual String get_os_name() const override; + virtual Ref<Texture2D> get_logo() const override; + + virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override; + virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override; + virtual Error sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path); + virtual String get_template_file_name(const String &p_target, const String &p_arch) const = 0; + + virtual Error prepare_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags); + virtual Error modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { return OK; }; + virtual Error export_project_data(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags); + + void set_extension(const String &p_extension, const String &p_feature_key = "default"); + void set_name(const String &p_name); + void set_os_name(const String &p_name); + + void set_logo(const Ref<Texture2D> &p_logo); + + void add_platform_feature(const String &p_feature); + virtual void get_platform_features(List<String> *r_features) override; + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override; + + int get_chmod_flags() const; + void set_chmod_flags(int p_flags); + + virtual Error fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) { + return Error::OK; + } +}; + +#endif // EDITOR_EXPORT_PLATFORM_PC_H diff --git a/editor/export/editor_export_plugin.cpp b/editor/export/editor_export_plugin.cpp new file mode 100644 index 0000000000..cf3a9b0810 --- /dev/null +++ b/editor/export/editor_export_plugin.cpp @@ -0,0 +1,201 @@ +/*************************************************************************/ +/* editor_export_plugin.cpp */ +/*************************************************************************/ +/* 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 "editor_export_plugin.h" + +#include "core/config/project_settings.h" +#include "core/io/dir_access.h" +#include "core/io/file_access.h" +#include "editor/editor_paths.h" +#include "editor/export/editor_export_platform.h" +#include "scene/resources/resource_format_text.h" + +void EditorExportPlugin::set_export_preset(const Ref<EditorExportPreset> &p_preset) { + if (p_preset.is_valid()) { + export_preset = p_preset; + } +} + +Ref<EditorExportPreset> EditorExportPlugin::get_export_preset() const { + return export_preset; +} + +void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap) { + ExtraFile ef; + ef.data = p_file; + ef.path = p_path; + ef.remap = p_remap; + extra_files.push_back(ef); +} + +void EditorExportPlugin::add_shared_object(const String &p_path, const Vector<String> &p_tags, const String &p_target) { + shared_objects.push_back(SharedObject(p_path, p_tags, p_target)); +} + +void EditorExportPlugin::add_ios_framework(const String &p_path) { + ios_frameworks.push_back(p_path); +} + +void EditorExportPlugin::add_ios_embedded_framework(const String &p_path) { + ios_embedded_frameworks.push_back(p_path); +} + +Vector<String> EditorExportPlugin::get_ios_frameworks() const { + return ios_frameworks; +} + +Vector<String> EditorExportPlugin::get_ios_embedded_frameworks() const { + return ios_embedded_frameworks; +} + +void EditorExportPlugin::add_ios_plist_content(const String &p_plist_content) { + ios_plist_content += p_plist_content + "\n"; +} + +String EditorExportPlugin::get_ios_plist_content() const { + return ios_plist_content; +} + +void EditorExportPlugin::add_ios_linker_flags(const String &p_flags) { + if (ios_linker_flags.length() > 0) { + ios_linker_flags += ' '; + } + ios_linker_flags += p_flags; +} + +String EditorExportPlugin::get_ios_linker_flags() const { + return ios_linker_flags; +} + +void EditorExportPlugin::add_ios_bundle_file(const String &p_path) { + ios_bundle_files.push_back(p_path); +} + +Vector<String> EditorExportPlugin::get_ios_bundle_files() const { + return ios_bundle_files; +} + +void EditorExportPlugin::add_ios_cpp_code(const String &p_code) { + ios_cpp_code += p_code; +} + +String EditorExportPlugin::get_ios_cpp_code() const { + return ios_cpp_code; +} + +void EditorExportPlugin::add_macos_plugin_file(const String &p_path) { + macos_plugin_files.push_back(p_path); +} + +const Vector<String> &EditorExportPlugin::get_macos_plugin_files() const { + return macos_plugin_files; +} + +void EditorExportPlugin::add_ios_project_static_lib(const String &p_path) { + ios_project_static_libs.push_back(p_path); +} + +Vector<String> EditorExportPlugin::get_ios_project_static_libs() const { + return ios_project_static_libs; +} + +void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) { + GDVIRTUAL_CALL(_export_file, p_path, p_type, p_features); +} + +void EditorExportPlugin::_export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags) { + GDVIRTUAL_CALL(_export_begin, p_features, p_debug, p_path, p_flags); +} + +void EditorExportPlugin::_export_end_script() { + GDVIRTUAL_CALL(_export_end); +} + +void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) { +} + +void EditorExportPlugin::_export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags) { +} + +void EditorExportPlugin::skip() { + skipped = true; +} + +void EditorExportPlugin::_bind_methods() { + ClassDB::bind_method(D_METHOD("add_shared_object", "path", "tags", "target"), &EditorExportPlugin::add_shared_object); + ClassDB::bind_method(D_METHOD("add_ios_project_static_lib", "path"), &EditorExportPlugin::add_ios_project_static_lib); + ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file); + ClassDB::bind_method(D_METHOD("add_ios_framework", "path"), &EditorExportPlugin::add_ios_framework); + ClassDB::bind_method(D_METHOD("add_ios_embedded_framework", "path"), &EditorExportPlugin::add_ios_embedded_framework); + ClassDB::bind_method(D_METHOD("add_ios_plist_content", "plist_content"), &EditorExportPlugin::add_ios_plist_content); + ClassDB::bind_method(D_METHOD("add_ios_linker_flags", "flags"), &EditorExportPlugin::add_ios_linker_flags); + ClassDB::bind_method(D_METHOD("add_ios_bundle_file", "path"), &EditorExportPlugin::add_ios_bundle_file); + ClassDB::bind_method(D_METHOD("add_ios_cpp_code", "code"), &EditorExportPlugin::add_ios_cpp_code); + ClassDB::bind_method(D_METHOD("add_macos_plugin_file", "path"), &EditorExportPlugin::add_macos_plugin_file); + ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip); + + GDVIRTUAL_BIND(_export_file, "path", "type", "features"); + GDVIRTUAL_BIND(_export_begin, "features", "is_debug", "path", "flags"); + GDVIRTUAL_BIND(_export_end); +} + +EditorExportPlugin::EditorExportPlugin() { +} + +/////////////////////// + +void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) { + String extension = p_path.get_extension().to_lower(); + if (extension != "tres" && extension != "tscn") { + return; + } + + bool convert = GLOBAL_GET("editor/export/convert_text_resources_to_binary"); + if (!convert) { + return; + } + String tmp_path = EditorPaths::get_singleton()->get_cache_dir().plus_file("tmpfile.res"); + Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path); + if (err != OK) { + DirAccess::remove_file_or_error(tmp_path); + ERR_FAIL(); + } + Vector<uint8_t> data = FileAccess::get_file_as_array(tmp_path); + if (data.size() == 0) { + DirAccess::remove_file_or_error(tmp_path); + ERR_FAIL(); + } + DirAccess::remove_file_or_error(tmp_path); + add_file(p_path + ".converted.res", data, true); +} + +EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() { + GLOBAL_DEF("editor/export/convert_text_resources_to_binary", false); +} diff --git a/editor/export/editor_export_plugin.h b/editor/export/editor_export_plugin.h new file mode 100644 index 0000000000..04ebc1dfed --- /dev/null +++ b/editor/export/editor_export_plugin.h @@ -0,0 +1,132 @@ +/*************************************************************************/ +/* editor_export_plugin.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. */ +/*************************************************************************/ + +#ifndef EDITOR_EXPORT_PLUGIN_H +#define EDITOR_EXPORT_PLUGIN_H + +#include "core/extension/native_extension.h" +#include "editor_export_preset.h" +#include "editor_export_shared_object.h" + +class EditorExportPlugin : public RefCounted { + GDCLASS(EditorExportPlugin, RefCounted); + + friend class EditorExportPlatform; + + Ref<EditorExportPreset> export_preset; + + Vector<SharedObject> shared_objects; + struct ExtraFile { + String path; + Vector<uint8_t> data; + bool remap = false; + }; + Vector<ExtraFile> extra_files; + bool skipped = false; + + Vector<String> ios_frameworks; + Vector<String> ios_embedded_frameworks; + Vector<String> ios_project_static_libs; + String ios_plist_content; + String ios_linker_flags; + Vector<String> ios_bundle_files; + String ios_cpp_code; + + Vector<String> macos_plugin_files; + + _FORCE_INLINE_ void _clear() { + shared_objects.clear(); + extra_files.clear(); + skipped = false; + } + + _FORCE_INLINE_ void _export_end() { + ios_frameworks.clear(); + ios_embedded_frameworks.clear(); + ios_bundle_files.clear(); + ios_plist_content = ""; + ios_linker_flags = ""; + ios_cpp_code = ""; + macos_plugin_files.clear(); + } + + void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features); + void _export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags); + void _export_end_script(); + +protected: + void set_export_preset(const Ref<EditorExportPreset> &p_preset); + Ref<EditorExportPreset> get_export_preset() const; + + void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap); + void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String()); + + void add_ios_framework(const String &p_path); + void add_ios_embedded_framework(const String &p_path); + void add_ios_project_static_lib(const String &p_path); + void add_ios_plist_content(const String &p_plist_content); + void add_ios_linker_flags(const String &p_flags); + void add_ios_bundle_file(const String &p_path); + void add_ios_cpp_code(const String &p_code); + void add_macos_plugin_file(const String &p_path); + + void skip(); + + virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features); + virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags); + + static void _bind_methods(); + + GDVIRTUAL3(_export_file, String, String, Vector<String>) + GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t) + GDVIRTUAL0(_export_end) + +public: + Vector<String> get_ios_frameworks() const; + Vector<String> get_ios_embedded_frameworks() const; + Vector<String> get_ios_project_static_libs() const; + String get_ios_plist_content() const; + String get_ios_linker_flags() const; + Vector<String> get_ios_bundle_files() const; + String get_ios_cpp_code() const; + const Vector<String> &get_macos_plugin_files() const; + + EditorExportPlugin(); +}; + +class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin { + GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin); + +public: + virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override; + EditorExportTextSceneToBinaryPlugin(); +}; + +#endif // EDITOR_EXPORT_PLUGIN_H diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp new file mode 100644 index 0000000000..cdf69e727d --- /dev/null +++ b/editor/export/editor_export_preset.cpp @@ -0,0 +1,221 @@ +/*************************************************************************/ +/* editor_export_preset.cpp */ +/*************************************************************************/ +/* 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 "editor_export.h" + +bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) { + if (values.has(p_name)) { + values[p_name] = p_value; + EditorExport::singleton->save_presets(); + return true; + } + + return false; +} + +bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const { + if (values.has(p_name)) { + r_ret = values[p_name]; + return true; + } + + return false; +} + +void EditorExportPreset::_get_property_list(List<PropertyInfo> *p_list) const { + for (const PropertyInfo &E : properties) { + if (platform->get_export_option_visibility(E.name, values)) { + p_list->push_back(E); + } + } +} + +Ref<EditorExportPlatform> EditorExportPreset::get_platform() const { + return platform; +} + +void EditorExportPreset::update_files_to_export() { + Vector<String> to_remove; + for (const String &E : selected_files) { + if (!FileAccess::exists(E)) { + to_remove.push_back(E); + } + } + for (int i = 0; i < to_remove.size(); ++i) { + selected_files.erase(to_remove[i]); + } +} + +Vector<String> EditorExportPreset::get_files_to_export() const { + Vector<String> files; + for (const String &E : selected_files) { + files.push_back(E); + } + return files; +} + +void EditorExportPreset::set_name(const String &p_name) { + name = p_name; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_name() const { + return name; +} + +void EditorExportPreset::set_runnable(bool p_enable) { + runnable = p_enable; + EditorExport::singleton->save_presets(); +} + +bool EditorExportPreset::is_runnable() const { + return runnable; +} + +void EditorExportPreset::set_export_filter(ExportFilter p_filter) { + export_filter = p_filter; + EditorExport::singleton->save_presets(); +} + +EditorExportPreset::ExportFilter EditorExportPreset::get_export_filter() const { + return export_filter; +} + +void EditorExportPreset::set_include_filter(const String &p_include) { + include_filter = p_include; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_include_filter() const { + return include_filter; +} + +void EditorExportPreset::set_export_path(const String &p_path) { + export_path = p_path; + /* NOTE(SonerSound): if there is a need to implement a PropertyHint that specifically indicates a relative path, + * this should be removed. */ + if (export_path.is_absolute_path()) { + String res_path = OS::get_singleton()->get_resource_dir(); + export_path = res_path.path_to_file(export_path); + } + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_export_path() const { + return export_path; +} + +void EditorExportPreset::set_exclude_filter(const String &p_exclude) { + exclude_filter = p_exclude; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_exclude_filter() const { + return exclude_filter; +} + +void EditorExportPreset::add_export_file(const String &p_path) { + selected_files.insert(p_path); + EditorExport::singleton->save_presets(); +} + +void EditorExportPreset::remove_export_file(const String &p_path) { + selected_files.erase(p_path); + EditorExport::singleton->save_presets(); +} + +bool EditorExportPreset::has_export_file(const String &p_path) { + return selected_files.has(p_path); +} + +void EditorExportPreset::set_custom_features(const String &p_custom_features) { + custom_features = p_custom_features; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_custom_features() const { + return custom_features; +} + +void EditorExportPreset::set_enc_in_filter(const String &p_filter) { + enc_in_filters = p_filter; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_enc_in_filter() const { + return enc_in_filters; +} + +void EditorExportPreset::set_enc_ex_filter(const String &p_filter) { + enc_ex_filters = p_filter; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_enc_ex_filter() const { + return enc_ex_filters; +} + +void EditorExportPreset::set_enc_pck(bool p_enabled) { + enc_pck = p_enabled; + EditorExport::singleton->save_presets(); +} + +bool EditorExportPreset::get_enc_pck() const { + return enc_pck; +} + +void EditorExportPreset::set_enc_directory(bool p_enabled) { + enc_directory = p_enabled; + EditorExport::singleton->save_presets(); +} + +bool EditorExportPreset::get_enc_directory() const { + return enc_directory; +} + +void EditorExportPreset::set_script_export_mode(int p_mode) { + script_mode = p_mode; + EditorExport::singleton->save_presets(); +} + +int EditorExportPreset::get_script_export_mode() const { + return script_mode; +} + +void EditorExportPreset::set_script_encryption_key(const String &p_key) { + script_key = p_key; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_script_encryption_key() const { + return script_key; +} + +EditorExportPreset::EditorExportPreset() {} diff --git a/editor/export/editor_export_preset.h b/editor/export/editor_export_preset.h new file mode 100644 index 0000000000..00109396b0 --- /dev/null +++ b/editor/export/editor_export_preset.h @@ -0,0 +1,145 @@ +/*************************************************************************/ +/* editor_export_preset.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. */ +/*************************************************************************/ + +#ifndef EDITOR_EXPORT_PRESET_H +#define EDITOR_EXPORT_PRESET_H + +class EditorExportPlatform; + +#include "core/object/ref_counted.h" + +class EditorExportPreset : public RefCounted { + GDCLASS(EditorExportPreset, RefCounted); + +public: + enum ExportFilter { + EXPORT_ALL_RESOURCES, + EXPORT_SELECTED_SCENES, + EXPORT_SELECTED_RESOURCES, + EXCLUDE_SELECTED_RESOURCES, + }; + + enum ScriptExportMode { + MODE_SCRIPT_TEXT, + MODE_SCRIPT_COMPILED, + }; + +private: + Ref<EditorExportPlatform> platform; + ExportFilter export_filter = EXPORT_ALL_RESOURCES; + String include_filter; + String exclude_filter; + String export_path; + + String exporter; + HashSet<String> selected_files; + bool runnable = false; + + friend class EditorExport; + friend class EditorExportPlatform; + + List<PropertyInfo> properties; + HashMap<StringName, Variant> values; + + String name; + + String custom_features; + + String enc_in_filters; + String enc_ex_filters; + bool enc_pck = false; + bool enc_directory = false; + + int script_mode = MODE_SCRIPT_COMPILED; + String script_key; + +protected: + bool _set(const StringName &p_name, const Variant &p_value); + bool _get(const StringName &p_name, Variant &r_ret) const; + void _get_property_list(List<PropertyInfo> *p_list) const; + +public: + Ref<EditorExportPlatform> get_platform() const; + + bool has(const StringName &p_property) const { return values.has(p_property); } + + void update_files_to_export(); + + Vector<String> get_files_to_export() const; + + void add_export_file(const String &p_path); + void remove_export_file(const String &p_path); + bool has_export_file(const String &p_path); + + void set_name(const String &p_name); + String get_name() const; + + void set_runnable(bool p_enable); + bool is_runnable() const; + + void set_export_filter(ExportFilter p_filter); + ExportFilter get_export_filter() const; + + void set_include_filter(const String &p_include); + String get_include_filter() const; + + void set_exclude_filter(const String &p_exclude); + String get_exclude_filter() const; + + void set_custom_features(const String &p_custom_features); + String get_custom_features() const; + + void set_export_path(const String &p_path); + String get_export_path() const; + + void set_enc_in_filter(const String &p_filter); + String get_enc_in_filter() const; + + void set_enc_ex_filter(const String &p_filter); + String get_enc_ex_filter() const; + + void set_enc_pck(bool p_enabled); + bool get_enc_pck() const; + + void set_enc_directory(bool p_enabled); + bool get_enc_directory() const; + + void set_script_export_mode(int p_mode); + int get_script_export_mode() const; + + void set_script_encryption_key(const String &p_key); + String get_script_encryption_key() const; + + const List<PropertyInfo> &get_properties() const { return properties; } + + EditorExportPreset(); +}; + +#endif // EDITOR_EXPORT_PRESET_H diff --git a/editor/export/editor_export_shared_object.h b/editor/export/editor_export_shared_object.h new file mode 100644 index 0000000000..558f403ca1 --- /dev/null +++ b/editor/export/editor_export_shared_object.h @@ -0,0 +1,51 @@ +/*************************************************************************/ +/* editor_export_shared_object.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. */ +/*************************************************************************/ + +#ifndef EDITOR_EXPORT_SHARED_OBJECT_H +#define EDITOR_EXPORT_SHARED_OBJECT_H + +#include "core/string/ustring.h" +#include "core/templates/vector.h" + +struct SharedObject { + String path; + Vector<String> tags; + String target; + + SharedObject(const String &p_path, const Vector<String> &p_tags, const String &p_target) : + path(p_path), + tags(p_tags), + target(p_target) { + } + + SharedObject() {} +}; + +#endif // EDITOR_EXPORT_SHARED_OBJECT_H diff --git a/editor/export_template_manager.cpp b/editor/export/export_template_manager.cpp index 9f9b8374ce..e02066e956 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export/export_template_manager.cpp @@ -30,18 +30,17 @@ #include "export_template_manager.h" -#include "core/input/input.h" #include "core/io/dir_access.h" #include "core/io/json.h" #include "core/io/zip_io.h" -#include "core/os/keyboard.h" -#include "core/templates/rb_set.h" #include "core/version.h" #include "editor/editor_node.h" #include "editor/editor_paths.h" #include "editor/editor_scale.h" -#include "progress_dialog.h" -#include "scene/gui/link_button.h" +#include "editor/progress_dialog.h" +#include "scene/gui/file_dialog.h" +#include "scene/gui/tree.h" +#include "scene/main/http_request.h" void ExportTemplateManager::_update_template_status() { // Fetch installed templates from the file system. diff --git a/editor/export_template_manager.h b/editor/export/export_template_manager.h index 3494e11d5e..f01da15832 100644 --- a/editor/export_template_manager.h +++ b/editor/export/export_template_manager.h @@ -31,15 +31,15 @@ #ifndef EXPORT_TEMPLATE_MANAGER_H #define EXPORT_TEMPLATE_MANAGER_H -#include "editor/editor_settings.h" #include "scene/gui/dialogs.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/menu_button.h" -#include "scene/gui/progress_bar.h" -#include "scene/gui/scroll_container.h" -#include "scene/main/http_request.h" class ExportTemplateVersion; +class FileDialog; +class HTTPRequest; +class MenuButton; +class OptionButton; +class ProgressBar; +class Tree; class ExportTemplateManager : public AcceptDialog { GDCLASS(ExportTemplateManager, AcceptDialog); diff --git a/editor/project_export.cpp b/editor/export/project_export.cpp index 209c997d58..a20f19efc8 100644 --- a/editor/project_export.cpp +++ b/editor/export/project_export.cpp @@ -31,23 +31,15 @@ #include "project_export.h" #include "core/config/project_settings.h" -#include "core/io/dir_access.h" -#include "core/io/file_access.h" -#include "core/io/image_loader.h" -#include "core/io/resource_loader.h" -#include "core/io/resource_saver.h" -#include "core/os/os.h" -#include "core/string/optimized_translation.h" -#include "core/version_generated.gen.h" +#include "core/version.h" #include "editor/editor_file_dialog.h" +#include "editor/editor_file_system.h" #include "editor/editor_node.h" +#include "editor/editor_properties.h" #include "editor/editor_scale.h" -#include "editor/editor_settings.h" -#include "scene/gui/box_container.h" -#include "scene/gui/margin_container.h" -#include "scene/gui/scroll_container.h" -#include "scene/gui/tab_container.h" -#include "servers/display_server.h" +#include "editor/export/editor_export.h" +#include "scene/gui/link_button.h" +#include "scene/gui/tree.h" void ProjectExportDialog::_theme_changed() { duplicate_preset->set_icon(presets->get_theme_icon(SNAME("Duplicate"), SNAME("EditorIcons"))); diff --git a/editor/project_export.h b/editor/export/project_export.h index 6b10642495..96dd765a2c 100644 --- a/editor/project_export.h +++ b/editor/export/project_export.h @@ -28,31 +28,25 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PROJECT_EXPORT_SETTINGS_H -#define PROJECT_EXPORT_SETTINGS_H - -#include "core/io/dir_access.h" -#include "core/os/thread.h" -#include "editor/editor_export.h" -#include "editor/editor_file_system.h" -#include "editor/editor_inspector.h" -#include "editor/editor_properties.h" -#include "scene/gui/button.h" -#include "scene/gui/check_button.h" -#include "scene/gui/control.h" +#ifndef PROJECT_EXPORT_H +#define PROJECT_EXPORT_H + #include "scene/gui/dialogs.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/label.h" -#include "scene/gui/link_button.h" -#include "scene/gui/menu_button.h" -#include "scene/gui/option_button.h" -#include "scene/gui/rich_text_label.h" -#include "scene/gui/slider.h" -#include "scene/gui/tab_container.h" -#include "scene/gui/tree.h" -#include "scene/main/timer.h" +class CheckBox; +class CheckButton; +class EditorExportPreset; class EditorFileDialog; +class EditorFileSystemDirectory; +class EditorInspector; +class EditorPropertyPath; +class ItemList; +class MenuButton; +class OptionButton; +class RichTextLabel; +class TabContainer; +class Tree; +class TreeItem; class ProjectExportDialog : public ConfirmationDialog { GDCLASS(ProjectExportDialog, ConfirmationDialog); @@ -183,4 +177,4 @@ public: ~ProjectExportDialog(); }; -#endif // PROJECT_EXPORT_SETTINGS_H +#endif // PROJECT_EXPORT_H diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index f73e076ac0..c38b3f8a47 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -342,4 +342,4 @@ public: ~FileSystemDock(); }; -#endif // SCENES_DOCK_H +#endif // FILESYSTEM_DOCK_H diff --git a/editor/groups_editor.h b/editor/groups_editor.h index 75cbfd01a4..fec8913e31 100644 --- a/editor/groups_editor.h +++ b/editor/groups_editor.h @@ -144,4 +144,4 @@ public: ~GroupsEditor(); }; -#endif +#endif // GROUPS_EDITOR_H diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index ee13a1a9c1..043681aa87 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -971,6 +971,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) { base_path = p_path; inspector_vars->edit(nullptr); + inspector_text->edit(nullptr); inspector_general->edit(nullptr); text_settings_data.instantiate(); diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index e45db47440..a75b0a903f 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -44,4 +44,4 @@ public: EditorSceneFormatImporterCollada(); }; -#endif +#endif // EDITOR_IMPORT_COLLADA_H diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index 44fbd41962..4548513b6f 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -68,4 +68,4 @@ public: virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata = nullptr) override; }; -#endif //EDITOR_IMPORT_PLUGIN_H +#endif // EDITOR_IMPORT_PLUGIN_H diff --git a/editor/import/resource_importer_bitmask.h b/editor/import/resource_importer_bitmask.h index 8682ab80a3..e791788d50 100644 --- a/editor/import/resource_importer_bitmask.h +++ b/editor/import/resource_importer_bitmask.h @@ -53,4 +53,5 @@ public: ResourceImporterBitMap(); ~ResourceImporterBitMap(); }; + #endif // RESOURCE_IMPORTER_BITMASK_H diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h index 306aafa843..2ed121c5e8 100644 --- a/editor/import/resource_importer_csv_translation.h +++ b/editor/import/resource_importer_csv_translation.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RESOURCEIMPORTERCSVTRANSLATION_H -#define RESOURCEIMPORTERCSVTRANSLATION_H +#ifndef RESOURCE_IMPORTER_CSV_TRANSLATION_H +#define RESOURCE_IMPORTER_CSV_TRANSLATION_H #include "core/io/resource_importer.h" @@ -54,4 +54,4 @@ public: ResourceImporterCSVTranslation(); }; -#endif // RESOURCEIMPORTERCSVTRANSLATION_H +#endif // RESOURCE_IMPORTER_CSV_TRANSLATION_H diff --git a/editor/import/resource_importer_imagefont.h b/editor/import/resource_importer_imagefont.h index f46bc8c19b..e163f873da 100644 --- a/editor/import/resource_importer_imagefont.h +++ b/editor/import/resource_importer_imagefont.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RESOURCE_IMPORTER_IMAGE_FONT_H -#define RESOURCE_IMPORTER_IMAGE_FONT_H +#ifndef RESOURCE_IMPORTER_IMAGEFONT_H +#define RESOURCE_IMPORTER_IMAGEFONT_H #include "core/io/resource_importer.h" #include "scene/resources/font.h" @@ -55,4 +55,4 @@ public: ResourceImporterImageFont(); }; -#endif // RESOURCE_IMPORTER_IMAGE_FONT_H +#endif // RESOURCE_IMPORTER_IMAGEFONT_H diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index 3da9f02adb..4dfac90fa1 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RESOURCEIMPORTEROBJ_H -#define RESOURCEIMPORTEROBJ_H +#ifndef RESOURCE_IMPORTER_OBJ_H +#define RESOURCE_IMPORTER_OBJ_H #include "resource_importer_scene.h" @@ -69,4 +69,4 @@ public: ResourceImporterOBJ(); }; -#endif // RESOURCEIMPORTEROBJ_H +#endif // RESOURCE_IMPORTER_OBJ_H diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index b77c1dccb4..db6ca0cdcf 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RESOURCEIMPORTERSCENE_H -#define RESOURCEIMPORTERSCENE_H +#ifndef RESOURCE_IMPORTER_SCENE_H +#define RESOURCE_IMPORTER_SCENE_H #include "core/error/error_macros.h" #include "core/io/resource_importer.h" @@ -479,4 +479,4 @@ Transform3D ResourceImporterScene::get_collision_shapes_transform(const M &p_opt return transform; } -#endif // RESOURCEIMPORTERSCENE_H +#endif // RESOURCE_IMPORTER_SCENE_H diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index 7def2d4f77..496ad3bf70 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef RESOURCEIMPORTTEXTURE_H -#define RESOURCEIMPORTTEXTURE_H +#ifndef RESOURCE_IMPORTER_TEXTURE_H +#define RESOURCE_IMPORTER_TEXTURE_H #include "core/io/file_access.h" #include "core/io/image.h" @@ -109,4 +109,4 @@ public: ~ResourceImporterTexture(); }; -#endif // RESOURCEIMPORTTEXTURE_H +#endif // RESOURCE_IMPORTER_TEXTURE_H diff --git a/editor/import_dock.h b/editor/import_dock.h index 7f4aa1ddb3..3098c6e815 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef IMPORTDOCK_H -#define IMPORTDOCK_H +#ifndef IMPORT_DOCK_H +#define IMPORT_DOCK_H #include "core/io/config_file.h" #include "core/io/resource_importer.h" @@ -105,4 +105,4 @@ public: ~ImportDock(); }; -#endif // IMPORTDOCK_H +#endif // IMPORT_DOCK_H diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 1f2d8afb7d..536852c0f2 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -153,4 +153,4 @@ public: ~InspectorDock(); }; -#endif +#endif // INSPECTOR_DOCK_H diff --git a/editor/plugins/animation_library_editor.h b/editor/plugins/animation_library_editor.h index bf89508321..6e214860b8 100644 --- a/editor/plugins/animation_library_editor.h +++ b/editor/plugins/animation_library_editor.h @@ -116,4 +116,4 @@ public: AnimationLibraryEditor(); }; -#endif // ANIMATIONPLAYERLIBRARYEDITOR_H +#endif // ANIMATION_LIBRARY_EDITOR_H diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index e02662b8db..070d25e29f 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -338,4 +338,4 @@ public: ~AssetLibraryEditorPlugin(); }; -#endif // EDITORASSETLIBRARY_H +#endif // ASSET_LIBRARY_EDITOR_PLUGIN_H diff --git a/editor/plugins/bit_map_editor_plugin.h b/editor/plugins/bit_map_editor_plugin.h index c883e5542f..b045f8c751 100644 --- a/editor/plugins/bit_map_editor_plugin.h +++ b/editor/plugins/bit_map_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef BIT_MAP_PREVIEW_EDITOR_PLUGIN_H -#define BIT_MAP_PREVIEW_EDITOR_PLUGIN_H +#ifndef BIT_MAP_EDITOR_PLUGIN_H +#define BIT_MAP_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/resources/bit_map.h" @@ -61,4 +61,4 @@ public: BitMapEditorPlugin(); }; -#endif // BIT_MAP_PREVIEW_EDITOR_PLUGIN_H +#endif // BIT_MAP_EDITOR_PLUGIN_H diff --git a/editor/plugins/bone_map_editor_plugin.h b/editor/plugins/bone_map_editor_plugin.h index e1ea6b4060..79fb47505b 100644 --- a/editor/plugins/bone_map_editor_plugin.h +++ b/editor/plugins/bone_map_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef BONE_MAP_EDITOR_H -#define BONE_MAP_EDITOR_H +#ifndef BONE_MAP_EDITOR_PLUGIN_H +#define BONE_MAP_EDITOR_PLUGIN_H #include "editor/editor_node.h" #include "editor/editor_plugin.h" @@ -176,4 +176,4 @@ public: BoneMapEditorPlugin(); }; -#endif // BONE_MAP_EDITOR_H +#endif // BONE_MAP_EDITOR_PLUGIN_H diff --git a/editor/plugins/camera_3d_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h index a8164f9b85..a969b31976 100644 --- a/editor/plugins/camera_3d_editor_plugin.h +++ b/editor/plugins/camera_3d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef CAMERA_EDITOR_PLUGIN_H -#define CAMERA_EDITOR_PLUGIN_H +#ifndef CAMERA_3D_EDITOR_PLUGIN_H +#define CAMERA_3D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/3d/camera_3d.h" @@ -68,4 +68,4 @@ public: ~Camera3DEditorPlugin(); }; -#endif // CAMERA_EDITOR_PLUGIN_H +#endif // CAMERA_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 18c898521d..5b368de3cc 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -630,4 +630,4 @@ public: ~CanvasItemEditorViewport(); }; -#endif //CANVAS_ITEM_EDITOR_PLUGIN_H +#endif // CANVAS_ITEM_EDITOR_PLUGIN_H diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index da9e9f339f..f7de05ddd1 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -112,4 +112,4 @@ public: ~CollisionShape2DEditorPlugin(); }; -#endif //COLLISION_SHAPE_2D_EDITOR_PLUGIN_H +#endif // COLLISION_SHAPE_2D_EDITOR_PLUGIN_H diff --git a/editor/plugins/control_editor_plugin.h b/editor/plugins/control_editor_plugin.h index d3f1d3acbb..11389bc095 100644 --- a/editor/plugins/control_editor_plugin.h +++ b/editor/plugins/control_editor_plugin.h @@ -247,4 +247,4 @@ public: ControlEditorPlugin(); }; -#endif //CONTROL_EDITOR_PLUGIN_H +#endif // CONTROL_EDITOR_PLUGIN_H diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h index 70f2da4b2d..f38349985c 100644 --- a/editor/plugins/cpu_particles_3d_editor_plugin.h +++ b/editor/plugins/cpu_particles_3d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef CPU_PARTICLES_EDITOR_PLUGIN_H -#define CPU_PARTICLES_EDITOR_PLUGIN_H +#ifndef CPU_PARTICLES_3D_EDITOR_PLUGIN_H +#define CPU_PARTICLES_3D_EDITOR_PLUGIN_H #include "editor/plugins/gpu_particles_3d_editor_plugin.h" #include "scene/3d/cpu_particles_3d.h" @@ -78,4 +78,4 @@ public: ~CPUParticles3DEditorPlugin(); }; -#endif // CPU_PARTICLES_EDITOR_PLUGIN_H +#endif // CPU_PARTICLES_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index f548683b70..163cfe79f9 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITORPREVIEWPLUGINS_H -#define EDITORPREVIEWPLUGINS_H +#ifndef EDITOR_PREVIEW_PLUGINS_H +#define EDITOR_PREVIEW_PLUGINS_H #include "core/templates/safe_refcount.h" #include "editor/editor_resource_preview.h" @@ -193,4 +193,5 @@ public: EditorGradientPreviewPlugin(); }; -#endif // EDITORPREVIEWPLUGINS_H + +#endif // EDITOR_PREVIEW_PLUGINS_H diff --git a/editor/plugins/font_config_plugin.h b/editor/plugins/font_config_plugin.h index 9b7ee55870..67c16bfe60 100644 --- a/editor/plugins/font_config_plugin.h +++ b/editor/plugins/font_config_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef OT_FEATURES_PLUGIN_H -#define OT_FEATURES_PLUGIN_H +#ifndef FONT_CONFIG_PLUGIN_H +#define FONT_CONFIG_PLUGIN_H #include "core/io/marshalls.h" #include "editor/editor_plugin.h" @@ -258,4 +258,4 @@ public: virtual String get_name() const override { return "Font"; } }; -#endif // OT_FEATURES_PLUGIN_H +#endif // FONT_CONFIG_PLUGIN_H diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h index b91a17d9e5..b5eca46ad3 100644 --- a/editor/plugins/gdextension_export_plugin.h +++ b/editor/plugins/gdextension_export_plugin.h @@ -31,7 +31,7 @@ #ifndef GDEXTENSION_EXPORT_PLUGIN_H #define GDEXTENSION_EXPORT_PLUGIN_H -#include "editor/editor_export.h" +#include "editor/export/editor_export.h" class GDExtensionExportPlugin : public EditorExportPlugin { protected: diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h index 75f68617d1..bf49a82166 100644 --- a/editor/plugins/gpu_particles_2d_editor_plugin.h +++ b/editor/plugins/gpu_particles_2d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PARTICLES_2D_EDITOR_PLUGIN_H -#define PARTICLES_2D_EDITOR_PLUGIN_H +#ifndef GPU_PARTICLES_2D_EDITOR_PLUGIN_H +#define GPU_PARTICLES_2D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/2d/collision_polygon_2d.h" @@ -97,4 +97,4 @@ public: ~GPUParticles2DEditorPlugin(); }; -#endif // PARTICLES_2D_EDITOR_PLUGIN_H +#endif // GPU_PARTICLES_2D_EDITOR_PLUGIN_H diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h index 6ba6d102ef..17bdfa6e3f 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.h +++ b/editor/plugins/gpu_particles_3d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PARTICLES_EDITOR_PLUGIN_H -#define PARTICLES_EDITOR_PLUGIN_H +#ifndef GPU_PARTICLES_3D_EDITOR_PLUGIN_H +#define GPU_PARTICLES_3D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/3d/gpu_particles_3d.h" @@ -114,4 +114,4 @@ public: ~GPUParticles3DEditorPlugin(); }; -#endif // PARTICLES_EDITOR_PLUGIN_H +#endif // GPU_PARTICLES_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.h b/editor/plugins/gradient_texture_2d_editor_plugin.h index 4ce64ce1dc..93c49b1e6f 100644 --- a/editor/plugins/gradient_texture_2d_editor_plugin.h +++ b/editor/plugins/gradient_texture_2d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GRADIENT_TEXTURE_2D_EDITOR -#define GRADIENT_TEXTURE_2D_EDITOR +#ifndef GRADIENT_TEXTURE_2D_EDITOR_PLUGIN_H +#define GRADIENT_TEXTURE_2D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "editor/editor_spin_slider.h" @@ -109,4 +109,4 @@ public: GradientTexture2DEditorPlugin(); }; -#endif +#endif // GRADIENT_TEXTURE_2D_EDITOR_PLUGIN_H diff --git a/editor/plugins/lightmap_gi_editor_plugin.h b/editor/plugins/lightmap_gi_editor_plugin.h index 1202efe8fc..a06f97fc94 100644 --- a/editor/plugins/lightmap_gi_editor_plugin.h +++ b/editor/plugins/lightmap_gi_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef BAKED_LIGHTMAP_EDITOR_PLUGIN_H -#define BAKED_LIGHTMAP_EDITOR_PLUGIN_H +#ifndef LIGHTMAP_GI_EDITOR_PLUGIN_H +#define LIGHTMAP_GI_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/3d/lightmap_gi.h" @@ -67,4 +67,4 @@ public: ~LightmapGIEditorPlugin(); }; -#endif +#endif // LIGHTMAP_GI_EDITOR_PLUGIN_H diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 34db75f118..e21cb7e76a 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -155,7 +155,9 @@ MaterialEditor::MaterialEditor() { camera = memnew(Camera3D); camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 3))); - camera->set_perspective(45, 0.1, 10); + // Use low field of view so the sphere/box is fully encompassed within the preview, + // without much distortion. + camera->set_perspective(20, 0.1, 10); camera->make_current(); viewport->add_child(camera); @@ -177,8 +179,8 @@ MaterialEditor::MaterialEditor() { Transform3D box_xform; box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0)); box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0)); - box_xform.basis.scale(Vector3(0.8, 0.8, 0.8)); - box_xform.origin.y = 0.2; + box_xform.basis.scale(Vector3(0.7, 0.7, 0.7)); + box_xform.origin.y = 0.05; box_instance->set_transform(box_xform); sphere_mesh.instantiate(); diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index 3554b3c1e9..fb61f03485 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -87,4 +87,4 @@ public: MeshEditorPlugin(); }; -#endif +#endif // MESH_EDITOR_PLUGIN_H diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h index 36d8eacd98..7968176744 100644 --- a/editor/plugins/mesh_instance_3d_editor_plugin.h +++ b/editor/plugins/mesh_instance_3d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef MESH_INSTANCE_EDITOR_PLUGIN_H -#define MESH_INSTANCE_EDITOR_PLUGIN_H +#ifndef MESH_INSTANCE_3D_EDITOR_PLUGIN_H +#define MESH_INSTANCE_3D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/3d/mesh_instance_3d.h" @@ -97,4 +97,4 @@ public: ~MeshInstance3DEditorPlugin(); }; -#endif // MESH_EDITOR_PLUGIN_H +#endif // MESH_INSTANCE_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h index 7550b75fa3..239da88ba2 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.h +++ b/editor/plugins/navigation_polygon_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef NAVIGATIONPOLYGONEDITORPLUGIN_H -#define NAVIGATIONPOLYGONEDITORPLUGIN_H +#ifndef NAVIGATION_POLYGON_EDITOR_PLUGIN_H +#define NAVIGATION_POLYGON_EDITOR_PLUGIN_H #include "editor/plugins/abstract_polygon_2d_editor.h" #include "scene/2d/navigation_region_2d.h" @@ -67,4 +67,4 @@ public: NavigationPolygonEditorPlugin(); }; -#endif // NAVIGATIONPOLYGONEDITORPLUGIN_H +#endif // NAVIGATION_POLYGON_EDITOR_PLUGIN_H diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index df17e2747f..44ab4e0a41 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -33,8 +33,8 @@ #include "core/config/project_settings.h" #include "core/input/input.h" #include "core/input/input_map.h" -#include "core/math/camera_matrix.h" #include "core/math/math_funcs.h" +#include "core/math/projection.h" #include "core/os/keyboard.h" #include "core/templates/sort_array.h" #include "editor/debugger/editor_debugger_node.h" @@ -642,7 +642,7 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, Vector<_RayRe } Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { - CameraMatrix cm; + Projection cm; if (orthogonal) { cm.set_orthogonal(camera->get_size(), get_size().aspect(), get_znear() + p_vector3.z, get_zfar()); } else { @@ -6639,7 +6639,7 @@ void Node3DEditor::_finish_grid() { } void Node3DEditor::update_grid() { - const Camera3D::Projection current_projection = viewports[0]->camera->get_projection(); + const Camera3D::ProjectionType current_projection = viewports[0]->camera->get_projection(); if (current_projection != grid_camera_last_update_perspective) { grid_init_draw = false; // redraw diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index c98022bcf7..244b461e16 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -560,7 +560,7 @@ private: bool grid_enable[3]; //should be always visible if true bool grid_enabled = false; bool grid_init_draw = false; - Camera3D::Projection grid_camera_last_update_perspective = Camera3D::PROJECTION_PERSPECTIVE; + Camera3D::ProjectionType grid_camera_last_update_perspective = Camera3D::PROJECTION_PERSPECTIVE; Vector3 grid_camera_last_update_position = Vector3(); Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[4], scale_gizmo[3], scale_plane_gizmo[3], axis_gizmo[3]; diff --git a/editor/plugins/occluder_instance_3d_editor_plugin.h b/editor/plugins/occluder_instance_3d_editor_plugin.h index 360b7297cf..e8d98927f4 100644 --- a/editor/plugins/occluder_instance_3d_editor_plugin.h +++ b/editor/plugins/occluder_instance_3d_editor_plugin.h @@ -63,4 +63,4 @@ public: ~OccluderInstance3DEditorPlugin(); }; -#endif +#endif // OCCLUDER_INSTANCE_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h index ee31fcf43d..53e4e2efa8 100644 --- a/editor/plugins/path_3d_editor_plugin.h +++ b/editor/plugins/path_3d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PATH_EDITOR_PLUGIN_H -#define PATH_EDITOR_PLUGIN_H +#ifndef PATH_3D_EDITOR_PLUGIN_H +#define PATH_3D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "editor/plugins/node_3d_editor_gizmos.h" @@ -118,4 +118,4 @@ public: ~Path3DEditorPlugin(); }; -#endif // PATH_EDITOR_PLUGIN_H +#endif // PATH_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/physical_bone_3d_editor_plugin.h b/editor/plugins/physical_bone_3d_editor_plugin.h index 93e722a432..f15eab7991 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.h +++ b/editor/plugins/physical_bone_3d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PHYSICAL_BONE_PLUGIN_H -#define PHYSICAL_BONE_PLUGIN_H +#ifndef PHYSICAL_BONE_3D_EDITOR_PLUGIN_H +#define PHYSICAL_BONE_3D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/3d/physics_body_3d.h" @@ -76,4 +76,4 @@ public: PhysicalBone3DEditorPlugin(); }; -#endif +#endif // PHYSICAL_BONE_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 303b52c495..bdf566e991 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -208,7 +208,30 @@ void ShaderTextEditor::_load_theme_settings() { // to distinguish from keywords at a quick glance. List<String> built_ins; - if (shader.is_valid()) { + + if (shader_inc.is_valid()) { + for (int i = 0; i < RenderingServer::SHADER_MAX; i++) { + for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(i))) { + for (const KeyValue<StringName, ShaderLanguage::BuiltInInfo> &F : E.value.built_ins) { + built_ins.push_back(F.key); + } + } + + const Vector<ShaderLanguage::ModeInfo> &modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(i)); + + for (int j = 0; j < modes.size(); j++) { + const ShaderLanguage::ModeInfo &info = modes[j]; + + if (!info.options.is_empty()) { + for (int k = 0; k < info.options.size(); k++) { + built_ins.push_back(String(info.name) + "_" + String(info.options[k])); + } + } else { + built_ins.push_back(String(info.name)); + } + } + } + } else if (shader.is_valid()) { for (const KeyValue<StringName, ShaderLanguage::FunctionInfo> &E : ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode()))) { for (const KeyValue<StringName, ShaderLanguage::BuiltInInfo> &F : E.value.built_ins) { built_ins.push_back(F.key); @@ -337,11 +360,10 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa ShaderLanguage::ShaderCompileInfo info; info.global_variable_type_func = _get_global_variable_type; - Ref<ShaderInclude> inc = shader_inc; if (shader.is_null()) { info.is_include = true; - sl.complete(p_code, info, r_options, calltip); + sl.complete(code, info, r_options, calltip); get_text_editor()->set_code_hint(calltip); return; } @@ -350,7 +372,7 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptLa info.render_modes = ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())); info.shader_types = ShaderTypes::get_singleton()->get_types(); - sl.complete(p_code, info, r_options, calltip); + sl.complete(code, info, r_options, calltip); get_text_editor()->set_code_hint(calltip); } diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 221822e8f2..907de6ea87 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -252,4 +252,4 @@ public: ~ShaderEditorPlugin(); }; -#endif +#endif // SHADER_EDITOR_PLUGIN_H diff --git a/editor/plugins/sprite_2d_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h index 8e3dc19c7e..b87f108bd2 100644 --- a/editor/plugins/sprite_2d_editor_plugin.h +++ b/editor/plugins/sprite_2d_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef SPRITE_EDITOR_PLUGIN_H -#define SPRITE_EDITOR_PLUGIN_H +#ifndef SPRITE_2D_EDITOR_PLUGIN_H +#define SPRITE_2D_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/2d/sprite_2d.h" @@ -111,4 +111,4 @@ public: ~Sprite2DEditorPlugin(); }; -#endif // SPRITE_EDITOR_PLUGIN_H +#endif // SPRITE_2D_EDITOR_PLUGIN_H diff --git a/editor/plugins/texture_3d_editor_plugin.h b/editor/plugins/texture_3d_editor_plugin.h index 2f7f6f83bb..357bdb0845 100644 --- a/editor/plugins/texture_3d_editor_plugin.h +++ b/editor/plugins/texture_3d_editor_plugin.h @@ -91,4 +91,4 @@ public: Texture3DEditorPlugin(); }; -#endif // TEXTURE_EDITOR_PLUGIN_H +#endif // TEXTURE_3D_EDITOR_PLUGIN_H diff --git a/editor/plugins/texture_layered_editor_plugin.h b/editor/plugins/texture_layered_editor_plugin.h index 830916e954..f49aa83eb2 100644 --- a/editor/plugins/texture_layered_editor_plugin.h +++ b/editor/plugins/texture_layered_editor_plugin.h @@ -93,4 +93,4 @@ public: TextureLayeredEditorPlugin(); }; -#endif // TEXTURE_EDITOR_PLUGIN_H +#endif // TEXTURE_LAYERED_EDITOR_PLUGIN_H diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h index ff46b7871f..196a642283 100644 --- a/editor/plugins/tiles/tile_atlas_view.h +++ b/editor/plugins/tiles/tile_atlas_view.h @@ -158,4 +158,4 @@ public: TileAtlasView(); }; -#endif // TILE_ATLAS_VIEW +#endif // TILE_ATLAS_VIEW_H diff --git a/editor/plugins/tiles/tile_map_editor.h b/editor/plugins/tiles/tile_map_editor.h index ff586ebbfe..605fbe4823 100644 --- a/editor/plugins/tiles/tile_map_editor.h +++ b/editor/plugins/tiles/tile_map_editor.h @@ -377,4 +377,4 @@ public: static Vector<Vector2i> get_line(TileMap *p_tile_map, Vector2i p_from_cell, Vector2i p_to_cell); }; -#endif // TILE_MAP_EDITOR_PLUGIN_H +#endif // TILE_MAP_EDITOR_H diff --git a/editor/plugins/tiles/tile_set_editor.h b/editor/plugins/tiles/tile_set_editor.h index e633de37b0..c45240043e 100644 --- a/editor/plugins/tiles/tile_set_editor.h +++ b/editor/plugins/tiles/tile_set_editor.h @@ -108,4 +108,4 @@ public: ~TileSetEditor(); }; -#endif // TILE_SET_EDITOR_PLUGIN_H +#endif // TILE_SET_EDITOR_H diff --git a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h index 657bfca032..77a583e522 100644 --- a/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h +++ b/editor/plugins/tiles/tile_set_scenes_collection_source_editor.h @@ -142,4 +142,4 @@ public: ~TileSetScenesCollectionSourceEditor(); }; -#endif +#endif // TILE_SET_SCENES_COLLECTION_SOURCE_EDITOR_H diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index 419d0ffcfc..97553578ba 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -226,14 +226,14 @@ void TilesEditorPlugin::synchronize_sources_list(Object *p_current_list, Object } if (item_list->is_visible_in_tree()) { + // Make sure the selection is not overwritten after sorting. + int atlas_sources_lists_current_mem = atlas_sources_lists_current; + item_list->emit_signal(SNAME("sort_request")); + atlas_sources_lists_current = atlas_sources_lists_current_mem; + if (atlas_sources_lists_current < 0 || atlas_sources_lists_current >= item_list->get_item_count()) { item_list->deselect_all(); } else { - // Make sure the selection is not overwritten after sorting. - int atlas_sources_lists_current_mem = atlas_sources_lists_current; - item_list->emit_signal(SNAME("sort_request")); - atlas_sources_lists_current = atlas_sources_lists_current_mem; - item_list->set_current(atlas_sources_lists_current); item_list->ensure_current_is_visible(); item_list->emit_signal(SNAME("item_selected"), atlas_sources_lists_current); diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h index 39a56de772..fa721268ba 100644 --- a/editor/plugins/version_control_editor_plugin.h +++ b/editor/plugins/version_control_editor_plugin.h @@ -148,4 +148,4 @@ public: VARIANT_ENUM_CAST(VersionControlEditorPlugin::ChangeType); -#endif // !VERSION_CONTROL_EDITOR_PLUGIN_H +#endif // VERSION_CONTROL_EDITOR_PLUGIN_H diff --git a/editor/plugins/voxel_gi_editor_plugin.h b/editor/plugins/voxel_gi_editor_plugin.h index 621e98beef..43d6f71e26 100644 --- a/editor/plugins/voxel_gi_editor_plugin.h +++ b/editor/plugins/voxel_gi_editor_plugin.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef VOXEL_GIEDITORPLUGIN_H -#define VOXEL_GIEDITORPLUGIN_H +#ifndef VOXEL_GI_EDITOR_PLUGIN_H +#define VOXEL_GI_EDITOR_PLUGIN_H #include "editor/editor_plugin.h" #include "scene/3d/voxel_gi.h" @@ -71,4 +71,4 @@ public: ~VoxelGIEditorPlugin(); }; -#endif // VOXEL_GIEDITORPLUGIN_H +#endif // VOXEL_GI_EDITOR_PLUGIN_H diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 49707355a0..077dfc60c0 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -31,7 +31,6 @@ #include "project_settings_editor.h" #include "core/config/project_settings.h" -#include "editor/editor_export.h" #include "editor/editor_log.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 488a084903..86b6e4c6a5 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -43,7 +43,6 @@ #include "editor/array_property_edit.h" #include "editor/create_dialog.h" #include "editor/dictionary_property_edit.h" -#include "editor/editor_export.h" #include "editor/editor_file_dialog.h" #include "editor/editor_file_system.h" #include "editor/editor_help.h" diff --git a/editor/property_editor.h b/editor/property_editor.h index 3230834d00..27d1cabc3d 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -181,4 +181,4 @@ public: CustomPropertyEditor(); }; -#endif +#endif // PROPERTY_EDITOR_H diff --git a/editor/property_selector.h b/editor/property_selector.h index f42f5daa3f..e2bf5c02b7 100644 --- a/editor/property_selector.h +++ b/editor/property_selector.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PROPERTYSELECTOR_H -#define PROPERTYSELECTOR_H +#ifndef PROPERTY_SELECTOR_H +#define PROPERTY_SELECTOR_H #include "editor/editor_help.h" #include "editor/property_editor.h" @@ -80,4 +80,4 @@ public: PropertySelector(); }; -#endif // PROPERTYSELECTOR_H +#endif // PROPERTY_SELECTOR_H diff --git a/editor/register_exporters.h b/editor/register_exporters.h index 09076af978..9aa98f509f 100644 --- a/editor/register_exporters.h +++ b/editor/register_exporters.h @@ -33,4 +33,4 @@ void register_exporters(); -#endif +#endif // REGISTER_EXPORTERS_H diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 8cf0f50db8..ca1771bedf 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1337,14 +1337,14 @@ void SceneTreeDock::_node_replace_owner(Node *p_base, Node *p_node, Node *p_root UndoRedo *undo_redo = &editor_data->get_undo_redo(); switch (p_mode) { case MODE_BIDI: { - bool is_unique = p_node->is_unique_name_in_owner() && p_base->get_node_or_null(UNIQUE_NODE_PREFIX + String(p_node->get_name())) != nullptr; - if (is_unique) { + bool disable_unique = p_node->is_unique_name_in_owner() && p_root->get_node_or_null(UNIQUE_NODE_PREFIX + String(p_node->get_name())) != nullptr; + if (disable_unique) { // Will create a unique name conflict. Disable before setting owner. undo_redo->add_do_method(p_node, "set_unique_name_in_owner", false); } undo_redo->add_do_method(p_node, "set_owner", p_root); undo_redo->add_undo_method(p_node, "set_owner", p_base); - if (is_unique) { + if (disable_unique) { // Will create a unique name conflict. Enable after setting owner. undo_redo->add_undo_method(p_node, "set_unique_name_in_owner", true); } diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index dc7f3476ee..e15865036b 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -33,8 +33,8 @@ #include "editor/create_dialog.h" #include "editor/editor_data.h" +#include "editor/editor_quick_open.h" #include "editor/groups_editor.h" -#include "editor/quick_open.h" #include "editor/reparent_dialog.h" #include "editor/script_create_dialog.h" #include "scene/animation/animation_player.h" diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index 31a14e4667..31772e55b5 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -192,4 +192,4 @@ public: ~SceneTreeDialog(); }; -#endif +#endif // SCENE_TREE_EDITOR_H diff --git a/editor/shader_create_dialog.h b/editor/shader_create_dialog.h index 44bd866fbd..bf031c3601 100644 --- a/editor/shader_create_dialog.h +++ b/editor/shader_create_dialog.h @@ -114,4 +114,4 @@ public: ShaderCreateDialog(); }; -#endif +#endif // SHADER_CREATE_DIALOG_H diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index bfabf269bf..26bd3a5979 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -156,7 +156,7 @@ protected: pinfo.type = Variant::VECTOR3I; } break; case RS::GLOBAL_VAR_TYPE_IVEC4: { - pinfo.type = Variant::PACKED_INT32_ARRAY; + pinfo.type = Variant::VECTOR4I; } break; case RS::GLOBAL_VAR_TYPE_RECT2I: { pinfo.type = Variant::RECT2I; @@ -171,7 +171,7 @@ protected: pinfo.type = Variant::VECTOR3I; } break; case RS::GLOBAL_VAR_TYPE_UVEC4: { - pinfo.type = Variant::PACKED_INT32_ARRAY; + pinfo.type = Variant::VECTOR4I; } break; case RS::GLOBAL_VAR_TYPE_FLOAT: { pinfo.type = Variant::FLOAT; @@ -183,7 +183,7 @@ protected: pinfo.type = Variant::VECTOR3; } break; case RS::GLOBAL_VAR_TYPE_VEC4: { - pinfo.type = Variant::QUATERNION; + pinfo.type = Variant::VECTOR4; } break; case RS::GLOBAL_VAR_TYPE_RECT2: { pinfo.type = Variant::RECT2; @@ -204,7 +204,7 @@ protected: pinfo.type = Variant::TRANSFORM3D; } break; case RS::GLOBAL_VAR_TYPE_MAT4: { - pinfo.type = Variant::PACKED_INT32_ARRAY; + pinfo.type = Variant::PROJECTION; } break; case RS::GLOBAL_VAR_TYPE_SAMPLER2D: { pinfo.type = Variant::OBJECT; |