diff options
Diffstat (limited to 'editor/export/editor_export_preset.cpp')
-rw-r--r-- | editor/export/editor_export_preset.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index dfc0c23afc..29a31c0470 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -30,6 +30,8 @@ #include "editor_export.h" +#include "core/config/project_settings.h" + bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value) { values[p_name] = p_value; EditorExport::singleton->save_presets(); @@ -332,4 +334,35 @@ Variant EditorExportPreset::get_or_env(const StringName &p_name, const String &p return get(p_name, r_valid); } +String EditorExportPreset::get_version(const StringName &p_preset_string, bool p_windows_version) const { + String result = get(p_preset_string); + if (result.is_empty()) { + result = GLOBAL_GET("application/config/version"); + + if (p_windows_version) { + // Modify version number to match Windows constraints (version numbers must have 4 components). + const PackedStringArray result_split = result.split("."); + String windows_version; + if (result_split.is_empty()) { + // Use a valid fallback if the version string is empty, as a version number must be specified. + result = "1.0.0.0"; + } else if (result_split.size() == 1) { + result = result + ".0.0.0"; + } else if (result_split.size() == 2) { + result = result + ".0.0"; + } else if (result_split.size() == 3) { + result = result + ".0"; + } else { + // 4 components or more in the version string. Trim to contain only the first 4 components. + result = vformat("%s.%s.%s.%s", result_split[0] + result_split[1] + result_split[2] + result_split[3]); + } + } else if (result.is_empty()) { + // Use a valid fallback if the version string is empty, as a version number must be specified. + result = "1.0.0"; + } + } + + return result; +} + EditorExportPreset::EditorExportPreset() {} |