Merge pull request #23389 from marcelofg55/multiple_ext

Export for OS X on OS X now lets you select .dmg or .zip
This commit is contained in:
Rémi Verschelde 2018-11-02 11:07:18 +01:00 committed by GitHub
commit 5beaea9891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 22 deletions

View File

@ -1351,18 +1351,21 @@ bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset,
return valid; return valid;
} }
String EditorExportPlatformPC::get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { List<String> EditorExportPlatformPC::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
List<String> list;
for (Map<String, String>::Element *E = extensions.front(); E; E = E->next()) { for (Map<String, String>::Element *E = extensions.front(); E; E = E->next()) {
if (p_preset->get(E->key())) { if (p_preset->get(E->key())) {
return extensions[E->key()]; list.push_back(extensions[E->key()]);
return list;
} }
} }
if (extensions.has("default")) { if (extensions.has("default")) {
return extensions["default"]; list.push_back(extensions["default"]);
return list;
} }
return ""; return list;
} }
Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {

View File

@ -245,7 +245,7 @@ public:
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) 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_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_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 Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
@ -392,7 +392,7 @@ public:
virtual Ref<Texture> get_logo() const; virtual Ref<Texture> get_logo() const;
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const; virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
void set_extension(const String &p_extension, const String &p_feature_key = "default"); void set_extension(const String &p_extension, const String &p_feature_key = "default");

View File

@ -804,13 +804,16 @@ void ProjectExportDialog::_export_project() {
export_project->set_access(FileDialog::ACCESS_FILESYSTEM); export_project->set_access(FileDialog::ACCESS_FILESYSTEM);
export_project->clear_filters(); export_project->clear_filters();
List<String> extension_list = platform->get_binary_extensions(current);
for (int i = 0; i < extension_list.size(); i++) {
export_project->add_filter("*." + extension_list[i] + " ; " + platform->get_name() + " Export");
}
if (current->get_export_path() != "") { if (current->get_export_path() != "") {
export_project->set_current_path(current->get_export_path()); export_project->set_current_path(current->get_export_path());
} else { } else {
String extension = platform->get_binary_extension(current); if (extension_list.size() >= 1) {
if (extension != String()) { export_project->set_current_file(default_filename + "." + extension_list[0]);
export_project->add_filter("*." + extension + " ; " + platform->get_name() + " Export");
export_project->set_current_file(default_filename + "." + extension);
} else { } else {
export_project->set_current_file(default_filename); export_project->set_current_file(default_filename);
} }

View File

@ -1459,8 +1459,10 @@ public:
return valid; return valid;
} }
virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
return "apk"; List<String> list;
list.push_back("apk");
return list;
} }
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) { virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) {

View File

@ -108,7 +108,11 @@ public:
virtual String get_os_name() const { return "iOS"; } virtual String get_os_name() const { return "iOS"; }
virtual Ref<Texture> get_logo() const { return logo; } virtual Ref<Texture> get_logo() const { return logo; }
virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { return "ipa"; } virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
List<String> list;
list.push_back("ipa");
return list;
}
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;

View File

@ -58,7 +58,7 @@ public:
virtual Ref<Texture> get_logo() const; virtual Ref<Texture> get_logo() const;
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const; virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
virtual bool poll_devices(); virtual bool poll_devices();
@ -174,9 +174,11 @@ bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p
return valid; return valid;
} }
String EditorExportPlatformJavaScript::get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { List<String> EditorExportPlatformJavaScript::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
return "html"; List<String> list;
list.push_back("html");
return list;
} }
Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {

View File

@ -74,7 +74,14 @@ public:
virtual String get_os_name() const { return "OSX"; } virtual String get_os_name() const { return "OSX"; }
virtual Ref<Texture> get_logo() const { return logo; } virtual Ref<Texture> get_logo() const { return logo; }
virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { return use_dmg() ? "dmg" : "zip"; } virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
List<String> list;
if (use_dmg()) {
list.push_back("dmg");
}
list.push_back("zip");
return list;
}
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
@ -334,7 +341,8 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
io2.opaque = &dst_f; io2.opaque = &dst_f;
zipFile dst_pkg_zip = NULL; zipFile dst_pkg_zip = NULL;
if (use_dmg()) { String export_format = use_dmg() && p_path.ends_with("dmg") ? "dmg" : "zip";
if (export_format == "dmg") {
// We're on OSX so we can export to DMG, but first we create our application bundle // We're on OSX so we can export to DMG, but first we create our application bundle
tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app"); tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app");
print_line("Exporting to " + tmp_app_path_name); print_line("Exporting to " + tmp_app_path_name);
@ -429,7 +437,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
print_line("ADDING: " + file + " size: " + itos(data.size())); print_line("ADDING: " + file + " size: " + itos(data.size()));
total_size += data.size(); total_size += data.size();
if (use_dmg()) { if (export_format == "dmg") {
// write it into our application bundle // write it into our application bundle
file = tmp_app_path_name + "/" + file; file = tmp_app_path_name + "/" + file;
@ -491,7 +499,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
if (err == OK) { if (err == OK) {
ep.step("Making PKG", 1); ep.step("Making PKG", 1);
if (use_dmg()) { if (export_format == "dmg") {
String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck"; String pack_path = tmp_app_path_name + "/Contents/Resources/" + pkg_name + ".pck";
Vector<SharedObject> shared_objects; Vector<SharedObject> shared_objects;
err = save_pack(p_preset, pack_path, &shared_objects); err = save_pack(p_preset, pack_path, &shared_objects);

View File

@ -1021,8 +1021,10 @@ public:
return "UWP"; return "UWP";
} }
virtual String get_binary_extension(const Ref<EditorExportPreset> &p_preset) const { virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
return "appx"; List<String> list;
list.push_back("appx");
return list;
} }
virtual Ref<Texture> get_logo() const { virtual Ref<Texture> get_logo() const {