From e501c128e3cdb0393168b3606a6f03f95bf13389 Mon Sep 17 00:00:00 2001 From: Allen Pestaluky Date: Thu, 3 Oct 2024 08:54:19 -0400 Subject: [PATCH] Exposed `EditorExport` through the `EditorInterface` singleton. Also exposed functions relating to feature tags of platforms and presets. --- doc/classes/EditorExport.xml | 52 ++++++++++++++++++++++++ doc/classes/EditorExportPlatform.xml | 14 +++++++ doc/classes/EditorExportPreset.xml | 6 +++ doc/classes/EditorInterface.xml | 6 +++ editor/editor_interface.cpp | 5 +++ editor/editor_interface.h | 2 + editor/export/editor_export.cpp | 13 ++++-- editor/export/editor_export.h | 2 +- editor/export/editor_export_platform.cpp | 23 +++++++++++ editor/export/editor_export_platform.h | 2 + editor/export/editor_export_preset.cpp | 2 + editor/register_editor_types.cpp | 2 + 12 files changed, 124 insertions(+), 5 deletions(-) create mode 100644 doc/classes/EditorExport.xml diff --git a/doc/classes/EditorExport.xml b/doc/classes/EditorExport.xml new file mode 100644 index 000000000000..7d48564a5bae --- /dev/null +++ b/doc/classes/EditorExport.xml @@ -0,0 +1,52 @@ + + + + Hosts data related to a project's export configuration. + + + Editor-only singleton that hosts a project's [EditorExportPlatform], [EditorExportPreset], and [EditorExportPlugin] objects. Use this class to retrieve information about a project's export configuration. + + + $DOCS_URL/tutorials/export/index.html + + + + + + + Returns the [EditorExportPlatform] at index [param idx]. [param idx] must be equal to or greater than [code]0[/code] and less than the result of [method get_export_platform_count]. + + + + + + Returns the number of unique platforms available for export. This includes platforms that do not have an export preset in the current project. + + + + + + + Returns the [EditorExportPreset] at index [param idx]. [param idx] must be equal to or greater than [code]0[/code] and less than the result of [method get_export_preset_count]. + + + + + + Returns the number of export presets in the project. + + + + + + + Emitted when the [code]runnable[/code] property of an [EditorExportPreset] has been updated or when an [EditorExportPreset] has been added to or removed from the project. + + + + + Emitted when the properties of an [EditorExportPreset] have been updated. + + + + diff --git a/doc/classes/EditorExportPlatform.xml b/doc/classes/EditorExportPlatform.xml index 8792bbedc34d..5c7572d832f6 100644 --- a/doc/classes/EditorExportPlatform.xml +++ b/doc/classes/EditorExportPlatform.xml @@ -158,6 +158,20 @@ Returns the name of the export operating system handled by this [EditorExportPlatform] class, as a friendly string. Possible return values are [code]Windows[/code], [code]Linux[/code], [code]macOS[/code], [code]Android[/code], [code]iOS[/code], and [code]Web[/code]. + + + + Returns feature tags that are specific to the export platform. Some feature tags that may be included in this list are [code]mobile[/code], [code]pc[/code], [code]web[/code], [code]android[/code], [code]ios[/code], [code]linux[/code], [code]macos[/code], and [code]windows[/code]. + + + + + + + Returns feature tags that are specific to [param preset], excluding custom features. Some feature tags that may be included in this list are texture formats ([code]etc2[/code], [code]bptc[/code], [code]s3tc[/code]), architectures ([code]x86_64[/code], [code]x86_32[/code], [code]arm64[/code], [code]arm32[/code], [code]rv64[/code], [code]riscv[/code], [code]ppc64[/code], [code]ppc[/code], [code]wasm32[/code], [code]wasm64[/code], [code]universal[/code]), and other features ([code]threads[/code], [code]nothreads[/code]). + Use [method EditorExportPreset.get_custom_features] to get the custom features of an export preset. + + diff --git a/doc/classes/EditorExportPreset.xml b/doc/classes/EditorExportPreset.xml index 314f74340aa3..d7ccd611e5ee 100644 --- a/doc/classes/EditorExportPreset.xml +++ b/doc/classes/EditorExportPreset.xml @@ -115,6 +115,12 @@ Returns the list of packs on which to base a patch export on. + + + + Returns the [EditorExportPlatform] for this export preset. + + diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 43059db8b2e2..91c32f72fbed 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -83,6 +83,12 @@ Returns the edited (current) scene's root [Node]. + + + + Returns the [EditorExport] singleton. + + diff --git a/editor/editor_interface.cpp b/editor/editor_interface.cpp index 264c80dcbf5e..34127a4482a9 100644 --- a/editor/editor_interface.cpp +++ b/editor/editor_interface.cpp @@ -93,6 +93,10 @@ EditorUndoRedoManager *EditorInterface::get_editor_undo_redo() const { return EditorUndoRedoManager::get_singleton(); } +EditorExport *EditorInterface::get_editor_export() const { + return EditorExport::get_singleton(); +} + TypedArray EditorInterface::_make_mesh_previews(const TypedArray &p_meshes, int p_preview_size) { Vector> meshes; @@ -557,6 +561,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection); ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings); ClassDB::bind_method(D_METHOD("get_editor_undo_redo"), &EditorInterface::get_editor_undo_redo); + ClassDB::bind_method(D_METHOD("get_editor_export"), &EditorInterface::get_editor_export); ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews); diff --git a/editor/editor_interface.h b/editor/editor_interface.h index 4877444dac4c..4a38b88c5b72 100644 --- a/editor/editor_interface.h +++ b/editor/editor_interface.h @@ -46,6 +46,7 @@ class EditorResourcePreview; class EditorSelection; class EditorSettings; class EditorUndoRedoManager; +class EditorExport; class FileSystemDock; class Mesh; class Node; @@ -103,6 +104,7 @@ class EditorInterface : public Object { EditorSelection *get_selection() const; Ref get_editor_settings() const; EditorUndoRedoManager *get_editor_undo_redo() const; + EditorExport *get_editor_export() const; Vector> make_mesh_previews(const Vector> &p_meshes, Vector *p_transforms, int p_preview_size); diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp index 6ca83c5e25cb..55056a0178a6 100644 --- a/editor/export/editor_export.cpp +++ b/editor/export/editor_export.cpp @@ -120,8 +120,16 @@ void EditorExport::emit_presets_runnable_changed() { } void EditorExport::_bind_methods() { + _export_presets_updated = StringName("export_presets_updated", true); + _export_presets_runnable_updated = StringName("export_presets_runnable_updated", true); + ADD_SIGNAL(MethodInfo(_export_presets_updated)); ADD_SIGNAL(MethodInfo(_export_presets_runnable_updated)); + + ClassDB::bind_method(D_METHOD("get_export_platform_count"), &EditorExport::get_export_platform_count); + ClassDB::bind_method(D_METHOD("get_export_platform", "idx"), &EditorExport::get_export_platform); + ClassDB::bind_method(D_METHOD("get_export_preset_count"), &EditorExport::get_export_preset_count); + ClassDB::bind_method(D_METHOD("get_export_preset", "idx"), &EditorExport::get_export_preset); } void EditorExport::add_export_platform(const Ref &p_platform) { @@ -139,7 +147,7 @@ void EditorExport::remove_export_platform(const Ref &p_pla should_reload_presets = true; } -int EditorExport::get_export_platform_count() { +int EditorExport::get_export_platform_count() const { return export_platforms.size(); } @@ -442,9 +450,6 @@ EditorExport::EditorExport() { save_timer->set_one_shot(true); save_timer->connect("timeout", callable_mp(this, &EditorExport::_save)); - _export_presets_updated = StringName("export_presets_updated", true); - _export_presets_runnable_updated = StringName("export_presets_runnable_updated", true); - singleton = this; set_process(true); } diff --git a/editor/export/editor_export.h b/editor/export/editor_export.h index ebb2038f534c..f97aaf232ef3 100644 --- a/editor/export/editor_export.h +++ b/editor/export/editor_export.h @@ -65,7 +65,7 @@ class EditorExport : public Node { static EditorExport *get_singleton() { return singleton; } void add_export_platform(const Ref &p_platform); - int get_export_platform_count(); + int get_export_platform_count() const; Ref get_export_platform(int p_idx); void remove_export_platform(const Ref &p_platform); diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 58737c53edbc..892b1a80b5a8 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -534,6 +534,26 @@ HashSet EditorExportPlatform::get_features(const Ref return result; } +TypedArray EditorExportPlatform::get_platform_features_as_array() const { + List feature_list; + get_platform_features(&feature_list); + TypedArray result; + for (const String &E : feature_list) { + result.push_back(E); + } + return result; +} + +TypedArray EditorExportPlatform::get_preset_features_as_array(const Ref &p_preset) const { + List feature_list; + get_preset_features(p_preset, &feature_list); + TypedArray result; + for (const String &E : feature_list) { + result.push_back(E); + } + return result; +} + EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_platform, const Ref &p_preset, bool p_debug, const String &p_path, BitField p_flags) { HashSet features = p_platform.get_features(p_preset, p_debug); Vector> export_plugins = EditorExport::get_singleton()->get_export_plugins(); @@ -2299,6 +2319,9 @@ void EditorExportPlatform::_bind_methods() { ClassDB::bind_method(D_METHOD("ssh_run_on_remote_no_wait", "host", "port", "ssh_args", "cmd_args", "port_fwd"), &EditorExportPlatform::_ssh_run_on_remote_no_wait, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("ssh_push_to_remote", "host", "port", "scp_args", "src_file", "dst_file"), &EditorExportPlatform::ssh_push_to_remote); + ClassDB::bind_method(D_METHOD("get_platform_features"), &EditorExportPlatform::get_platform_features_as_array); + ClassDB::bind_method(D_METHOD("get_preset_features", "preset"), &EditorExportPlatform::get_preset_features_as_array); + ClassDB::bind_static_method("EditorExportPlatform", D_METHOD("get_forced_export_files"), &EditorExportPlatform::get_forced_export_files); BIND_ENUM_CONSTANT(EXPORT_MESSAGE_NONE); diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index ef3274c5e4c2..27c0134e9bde 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -197,6 +197,8 @@ class EditorExportPlatform : public RefCounted { void _unload_patches(); public: + TypedArray get_platform_features_as_array() const; + TypedArray get_preset_features_as_array(const Ref &p_preset) const; virtual void get_preset_features(const Ref &p_preset, List *r_features) const = 0; struct ExportOption { diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index da7059b7777f..d0f152dc5956 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -65,6 +65,8 @@ void EditorExportPreset::_bind_methods() { ClassDB::bind_method(D_METHOD("has", "property"), &EditorExportPreset::has); + ClassDB::bind_method(D_METHOD("get_platform"), &EditorExportPreset::get_platform); + ClassDB::bind_method(D_METHOD("get_files_to_export"), &EditorExportPreset::get_files_to_export); ClassDB::bind_method(D_METHOD("get_customized_files"), &EditorExportPreset::get_customized_files); ClassDB::bind_method(D_METHOD("get_customized_files_count"), &EditorExportPreset::get_customized_files_count); diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp index c4ebca7308b1..3317904b1187 100644 --- a/editor/register_editor_types.cpp +++ b/editor/register_editor_types.cpp @@ -45,6 +45,7 @@ #include "editor/editor_string_names.h" #include "editor/editor_translation_parser.h" #include "editor/editor_undo_redo_manager.h" +#include "editor/export/editor_export.h" #include "editor/export/editor_export_platform.h" #include "editor/export/editor_export_platform_extension.h" #include "editor/export/editor_export_platform_pc.h" @@ -158,6 +159,7 @@ void register_editor_types() { GDREGISTER_ABSTRACT_CLASS(ScriptEditorBase); GDREGISTER_CLASS(EditorSyntaxHighlighter); GDREGISTER_ABSTRACT_CLASS(EditorInterface); + GDREGISTER_ABSTRACT_CLASS(EditorExport); GDREGISTER_CLASS(EditorExportPlugin); GDREGISTER_ABSTRACT_CLASS(EditorExportPlatform); GDREGISTER_ABSTRACT_CLASS(EditorExportPlatformPC);