summaryrefslogtreecommitdiff
path: root/editor/editor_export.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_export.cpp')
-rw-r--r--editor/editor_export.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 87ca499413..716ead9afc 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -1162,6 +1162,7 @@ void EditorExport::save_presets() {
}
void EditorExport::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("export_presets_updated"));
}
void EditorExport::add_export_platform(const Ref<EditorExportPlatform> &p_platform) {
@@ -1229,8 +1230,13 @@ Vector<Ref<EditorExportPlugin>> EditorExport::get_export_plugins() {
}
void EditorExport::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- load_config();
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ load_config();
+ } break;
+ case NOTIFICATION_PROCESS: {
+ update_export_presets();
+ } break;
}
}
@@ -1332,6 +1338,49 @@ void EditorExport::load_config() {
block_save = false;
}
+void EditorExport::update_export_presets() {
+ Map<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
+ Map<StringName, Variant> previous_values = preset->values;
+
+ // Clear the preset properties and values prior to reloading
+ preset->properties.clear();
+ preset->values.clear();
+
+ for (List<EditorExportPlatform::ExportOption>::Element *E = options.front(); E; E = E->next()) {
+ preset->properties.push_back(E->get().option);
+
+ StringName option_name = E->get().option.name;
+ preset->values[option_name] = previous_values.has(option_name) ? previous_values[option_name] : E->get().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++) {
@@ -1351,7 +1400,10 @@ EditorExport::EditorExport() {
save_timer->connect("timeout", callable_mp(this, &EditorExport::_save));
block_save = false;
+ _export_presets_updated = "export_presets_updated";
+
singleton = this;
+ set_process(true);
}
EditorExport::~EditorExport() {