mirror of
https://github.com/godotengine/godot.git
synced 2024-11-24 21:22:48 +00:00
Export working (for linux at least)
This commit is contained in:
parent
b5a06cecff
commit
c37fad650f
@ -315,17 +315,20 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat
|
||||
return OK;
|
||||
}
|
||||
|
||||
String EditorExportPlatform::find_export_template(String template_file_name, String *err) const {
|
||||
String EditorExportPlatform::find_export_template(String template_file_name) const {
|
||||
|
||||
String user_file = EditorSettings::get_singleton()->get_settings_path() + "/templates/" + itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "." + _MKSTR(VERSION_STATUS) + "/" + template_file_name;
|
||||
String base_name = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + _MKSTR(VERSION_STATUS) + "/" + template_file_name;
|
||||
String user_file = EditorSettings::get_singleton()->get_settings_path() + "/templates/" + base_name;
|
||||
String system_file = OS::get_singleton()->get_installed_templates_path();
|
||||
bool has_system_path = (system_file != "");
|
||||
system_file += template_file_name;
|
||||
system_file = system_file.plus_file(base_name);
|
||||
|
||||
print_line("test user file: " + user_file);
|
||||
// Prefer user file
|
||||
if (FileAccess::exists(user_file)) {
|
||||
return user_file;
|
||||
}
|
||||
print_line("test system file: " + system_file);
|
||||
|
||||
// Now check system file
|
||||
if (has_system_path) {
|
||||
@ -333,16 +336,9 @@ String EditorExportPlatform::find_export_template(String template_file_name, Str
|
||||
return system_file;
|
||||
}
|
||||
}
|
||||
print_line("none,sorry");
|
||||
|
||||
// Not found
|
||||
if (err) {
|
||||
*err += "No export template found at \"" + user_file + "\"";
|
||||
if (has_system_path)
|
||||
*err += "\n or \"" + system_file + "\".";
|
||||
else
|
||||
*err += ".";
|
||||
}
|
||||
return "";
|
||||
return String(); //not found
|
||||
}
|
||||
|
||||
Ref<EditorExportPreset> EditorExportPlatform::create_preset() {
|
||||
@ -880,7 +876,42 @@ String EditorExportPlatformPC::get_binary_extension() const {
|
||||
|
||||
Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
|
||||
|
||||
return OK;
|
||||
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 == String()) {
|
||||
|
||||
if (p_preset->get("binary_format/64_bits")) {
|
||||
if (p_debug) {
|
||||
template_path = find_export_template(debug_file_64);
|
||||
} else {
|
||||
template_path = find_export_template(release_file_64);
|
||||
}
|
||||
} else {
|
||||
if (p_debug) {
|
||||
template_path = find_export_template(debug_file_32);
|
||||
} else {
|
||||
template_path = find_export_template(release_file_32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (template_path != String() && !FileAccess::exists(template_path)) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Template file not found:\n") + template_path);
|
||||
return ERR_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
||||
da->copy(template_path, p_path);
|
||||
memdelete(da);
|
||||
|
||||
String pck_path = p_path.get_basename() + ".pck";
|
||||
|
||||
return save_pack(p_preset, pck_path);
|
||||
}
|
||||
|
||||
void EditorExportPlatformPC::set_extension(const String &p_extension) {
|
||||
|
@ -152,7 +152,7 @@ private:
|
||||
|
||||
protected:
|
||||
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0;
|
||||
String find_export_template(String template_file_name, String *err = NULL) const;
|
||||
String find_export_template(String template_file_name) const;
|
||||
|
||||
public:
|
||||
struct ExportOption {
|
||||
|
@ -229,9 +229,12 @@ void ProjectExportDialog::_edit_preset(int p_index) {
|
||||
if (needs_templates)
|
||||
export_templates_error->show();
|
||||
|
||||
get_ok()->set_disabled(true);
|
||||
|
||||
} else {
|
||||
export_error->show();
|
||||
export_templates_error->hide();
|
||||
get_ok()->set_disabled(false);
|
||||
}
|
||||
|
||||
updating = false;
|
||||
@ -642,6 +645,33 @@ void ProjectExportDialog::_open_export_template_manager() {
|
||||
hide();
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_export_project() {
|
||||
|
||||
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
Ref<EditorExportPlatform> platform = current->get_platform();
|
||||
ERR_FAIL_COND(platform.is_null());
|
||||
|
||||
export_project->set_access(FileDialog::ACCESS_FILESYSTEM);
|
||||
export_project->clear_filters();
|
||||
String extension = platform->get_binary_extension();
|
||||
if (extension != String()) {
|
||||
export_project->add_filter("*." + extension + " ; " + platform->get_name() + " Export");
|
||||
}
|
||||
|
||||
export_project->popup_centered_ratio();
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_export_project_to_path(const String &p_path) {
|
||||
|
||||
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
||||
ERR_FAIL_COND(current.is_null());
|
||||
Ref<EditorExportPlatform> platform = current->get_platform();
|
||||
ERR_FAIL_COND(platform.is_null());
|
||||
|
||||
Error err = platform->export_project(current, export_debug->is_pressed(), p_path, 0);
|
||||
}
|
||||
|
||||
void ProjectExportDialog::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_add_preset", &ProjectExportDialog::_add_preset);
|
||||
@ -663,6 +693,8 @@ void ProjectExportDialog::_bind_methods() {
|
||||
ClassDB::bind_method("_export_pck_zip", &ProjectExportDialog::_export_pck_zip);
|
||||
ClassDB::bind_method("_export_pck_zip_selected", &ProjectExportDialog::_export_pck_zip_selected);
|
||||
ClassDB::bind_method("_open_export_template_manager", &ProjectExportDialog::_open_export_template_manager);
|
||||
ClassDB::bind_method("_export_project", &ProjectExportDialog::_export_project);
|
||||
ClassDB::bind_method("_export_project_to_path", &ProjectExportDialog::_export_project_to_path);
|
||||
}
|
||||
ProjectExportDialog::ProjectExportDialog() {
|
||||
|
||||
@ -828,6 +860,17 @@ ProjectExportDialog::ProjectExportDialog() {
|
||||
export_templates_error->add_child(download_templates);
|
||||
download_templates->connect("pressed", this, "_open_export_template_manager");
|
||||
|
||||
export_project = memnew(FileDialog);
|
||||
export_project->set_access(FileDialog::ACCESS_FILESYSTEM);
|
||||
add_child(export_project);
|
||||
export_project->connect("file_selected", this, "_export_project_to_path");
|
||||
export_button->connect("pressed", this, "_export_project");
|
||||
|
||||
export_debug = memnew(CheckButton);
|
||||
export_debug->set_text(TTR("Export With Debug"));
|
||||
export_debug->set_pressed(true);
|
||||
export_project->get_vbox()->add_child(export_debug);
|
||||
|
||||
set_hide_on_ok(false);
|
||||
|
||||
editor_icons = "EditorIcons";
|
||||
|
@ -64,8 +64,8 @@ private:
|
||||
PropertyEditor *parameters;
|
||||
CheckButton *runnable;
|
||||
|
||||
EditorFileDialog *pck_export;
|
||||
EditorFileDialog *file_export;
|
||||
//EditorFileDialog *pck_export;
|
||||
//EditorFileDialog *file_export;
|
||||
|
||||
Button *button_export;
|
||||
bool updating;
|
||||
@ -119,12 +119,17 @@ private:
|
||||
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
||||
|
||||
FileDialog *export_pck_zip;
|
||||
FileDialog *export_project;
|
||||
CheckButton *export_debug;
|
||||
|
||||
void _open_export_template_manager();
|
||||
|
||||
void _export_pck_zip();
|
||||
void _export_pck_zip_selected(const String &p_path);
|
||||
|
||||
void _export_project();
|
||||
void _export_project_to_path(const String &p_path);
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
@ -42,7 +42,11 @@ void register_x11_exporter() {
|
||||
logo->create_from_image(img);
|
||||
platform->set_logo(logo);
|
||||
platform->set_name("Linux/X11");
|
||||
platform->set_extension("");
|
||||
platform->set_extension("bin");
|
||||
platform->set_release_32("linux_x11_32_release");
|
||||
platform->set_debug_32("linux_x11_32_debug");
|
||||
platform->set_release_64("linux_x11_64_release");
|
||||
platform->set_debug_64("linux_x11_64_debug");
|
||||
|
||||
EditorExport::get_singleton()->add_export_platform(platform);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user