2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_import_export.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:11:42 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2017-02-20 03:19:30 +01:00
|
|
|
#ifndef EDITOR_EXPORT_H
|
|
|
|
#define EDITOR_EXPORT_H
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
#include "resource.h"
|
|
|
|
#include "scene/main/node.h"
|
2017-02-20 03:19:30 +01:00
|
|
|
#include "scene/main/timer.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/resources/texture.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
class EditorProgress;
|
2014-02-10 02:10:30 +01:00
|
|
|
class FileAccess;
|
2017-02-20 03:19:30 +01:00
|
|
|
class EditorExportPlatform;
|
2017-02-21 04:05:15 +01:00
|
|
|
class EditorFileSystemDirectory;
|
2016-02-28 03:10:44 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
class EditorExportPreset : public Reference {
|
2016-02-28 03:10:44 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(EditorExportPreset, Reference)
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
2017-02-13 02:51:16 +01:00
|
|
|
enum ExportFilter {
|
2017-02-20 03:19:30 +01:00
|
|
|
EXPORT_ALL_RESOURCES,
|
|
|
|
EXPORT_SELECTED_SCENES,
|
|
|
|
EXPORT_SELECTED_RESOURCES,
|
2017-02-13 02:51:16 +01:00
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
private:
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPlatform> platform;
|
2017-02-13 02:51:16 +01:00
|
|
|
ExportFilter export_filter;
|
2017-02-20 03:19:30 +01:00
|
|
|
String include_filter;
|
|
|
|
String exclude_filter;
|
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
String exporter;
|
|
|
|
Set<String> selected_files;
|
2017-02-20 03:19:30 +01:00
|
|
|
bool runnable;
|
|
|
|
|
|
|
|
Vector<String> patches;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
friend class EditorExport;
|
|
|
|
friend class EditorExportPlatform;
|
2014-02-24 13:53:33 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
List<PropertyInfo> properties;
|
2017-03-05 16:44:50 +01:00
|
|
|
Map<StringName, Variant> values;
|
2014-02-24 13:53:33 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
String name;
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2014-02-24 13:53:33 +01:00
|
|
|
protected:
|
2017-03-05 16:44:50 +01:00
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
2014-02-24 13:53:33 +01:00
|
|
|
|
|
|
|
public:
|
2017-02-21 04:05:15 +01:00
|
|
|
Ref<EditorExportPlatform> get_platform() const;
|
2017-03-28 03:21:21 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool has(const StringName &p_property) const { return values.has(p_property); }
|
2017-02-20 03:19:30 +01:00
|
|
|
|
|
|
|
Vector<String> get_files_to_export() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void add_export_file(const String &p_path);
|
|
|
|
void remove_export_file(const String &p_path);
|
|
|
|
bool has_export_file(const String &p_path);
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_name(const String &p_name);
|
2017-02-20 03:19:30 +01:00
|
|
|
String get_name() const;
|
|
|
|
|
|
|
|
void set_runnable(bool p_enable);
|
|
|
|
bool is_runnable() const;
|
|
|
|
|
|
|
|
void set_export_filter(ExportFilter p_filter);
|
|
|
|
ExportFilter get_export_filter() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_include_filter(const String &p_include);
|
2017-02-20 03:19:30 +01:00
|
|
|
String get_include_filter() const;
|
2017-02-13 02:51:16 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_exclude_filter(const String &p_exclude);
|
2017-02-20 03:19:30 +01:00
|
|
|
String get_exclude_filter() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void add_patch(const String &p_path, int p_at_pos = -1);
|
|
|
|
void set_patch(int p_index, const String &p_path);
|
2017-02-20 03:19:30 +01:00
|
|
|
String get_patch(int p_index);
|
|
|
|
void remove_patch(int p_idx);
|
|
|
|
Vector<String> get_patches() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
const List<PropertyInfo> &get_properties() const { return properties; }
|
2014-02-24 13:53:33 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
EditorExportPreset();
|
2014-02-24 13:53:33 +01:00
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
class EditorExportPlatform : public Reference {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(EditorExportPlatform, Reference)
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
public:
|
2017-03-05 16:44:50 +01:00
|
|
|
typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
|
2016-04-28 02:39:52 +02:00
|
|
|
|
|
|
|
private:
|
2017-02-13 02:51:16 +01:00
|
|
|
struct SavedData {
|
2016-04-28 02:39:52 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
uint64_t ofs;
|
|
|
|
uint64_t size;
|
2017-02-21 04:05:15 +01:00
|
|
|
Vector<uint8_t> md5;
|
|
|
|
CharString path_utf8;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool operator<(const SavedData &p_data) const {
|
2017-02-21 04:05:15 +01:00
|
|
|
return path_utf8 < p_data.path_utf8;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PackData {
|
|
|
|
|
|
|
|
FileAccess *f;
|
2017-02-13 02:51:16 +01:00
|
|
|
Vector<SavedData> file_ofs;
|
2014-02-10 02:10:30 +01:00
|
|
|
EditorProgress *ep;
|
|
|
|
};
|
|
|
|
|
2015-12-13 05:08:36 +01:00
|
|
|
struct ZipData {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void *zip;
|
2015-12-13 05:08:36 +01:00
|
|
|
EditorProgress *ep;
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths);
|
|
|
|
void _export_find_dependencies(const String &p_path, Set<String> &p_paths);
|
2017-02-21 04:05:15 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
void gen_debug_flags(Vector<String> &r_flags, int p_flags);
|
2017-03-05 16:44:50 +01:00
|
|
|
static Error _save_pack_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
|
|
|
|
static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
protected:
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0;
|
2017-03-21 23:34:26 +01:00
|
|
|
String find_export_template(String template_file_name) const;
|
2017-03-24 00:14:12 +01:00
|
|
|
void gen_export_flags(Vector<String> &r_flags, int p_flags);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
public:
|
|
|
|
struct ExportOption {
|
|
|
|
PropertyInfo option;
|
|
|
|
Variant default_value;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ExportOption(const PropertyInfo &p_info, const Variant &p_default) {
|
|
|
|
option = p_info;
|
|
|
|
default_value = p_default;
|
|
|
|
}
|
2017-02-13 02:51:16 +01:00
|
|
|
ExportOption() {}
|
|
|
|
};
|
2015-12-13 05:08:36 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
virtual Ref<EditorExportPreset> create_preset();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void get_export_options(List<ExportOption> *r_options) = 0;
|
2017-03-28 03:21:21 +02:00
|
|
|
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; }
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual String get_name() const = 0;
|
|
|
|
virtual Ref<Texture> get_logo() const = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path);
|
|
|
|
Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
virtual bool poll_devices() { return false; }
|
|
|
|
virtual int get_device_count() const { return 0; }
|
|
|
|
virtual String get_device_name(int p_device) const { return ""; }
|
|
|
|
virtual String get_device_info(int p_device) const { return ""; }
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
enum DebugFlags {
|
2017-03-05 16:44:50 +01:00
|
|
|
DEBUG_FLAG_DUMB_CLIENT = 1,
|
|
|
|
DEBUG_FLAG_REMOTE_DEBUG = 2,
|
|
|
|
DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST = 4,
|
|
|
|
DEBUG_FLAG_VIEW_COLLISONS = 8,
|
|
|
|
DEBUG_FLAG_VIEW_NAVIGATION = 16,
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2017-03-24 00:14:12 +01:00
|
|
|
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; }
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual String get_binary_extension() const = 0;
|
|
|
|
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
EditorExportPlatform();
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
class EditorExport : public Node {
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(EditorExport, Node);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
Vector<Ref<EditorExportPlatform> > export_platforms;
|
|
|
|
Vector<Ref<EditorExportPreset> > export_presets;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Timer *save_timer;
|
|
|
|
bool block_save;
|
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
static EditorExport *singleton;
|
2015-11-09 04:49:18 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void _save();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
protected:
|
|
|
|
friend class EditorExportPreset;
|
2017-02-20 03:19:30 +01:00
|
|
|
void save_presets();
|
2016-02-27 04:32:00 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void _notification(int p_what);
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
|
|
|
static EditorExport *get_singleton() { return singleton; }
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void add_export_platform(const Ref<EditorExportPlatform> &p_platform);
|
2017-02-13 02:51:16 +01:00
|
|
|
int get_export_platform_count();
|
|
|
|
Ref<EditorExportPlatform> get_export_platform(int p_idx);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos = -1);
|
2017-02-13 02:51:16 +01:00
|
|
|
int get_export_preset_count() const;
|
|
|
|
Ref<EditorExportPreset> get_export_preset(int p_idx);
|
|
|
|
void remove_export_preset(int p_idx);
|
2015-12-04 14:18:28 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void load_config();
|
|
|
|
|
2017-03-24 00:14:12 +01:00
|
|
|
bool poll_export_platforms();
|
|
|
|
|
2017-02-13 02:51:16 +01:00
|
|
|
EditorExport();
|
|
|
|
~EditorExport();
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
class EditorExportPlatformPC : public EditorExportPlatform {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(EditorExportPlatformPC, EditorExportPlatform)
|
2017-02-20 03:19:30 +01:00
|
|
|
|
|
|
|
Ref<ImageTexture> logo;
|
|
|
|
String name;
|
|
|
|
String extension;
|
|
|
|
|
2017-02-22 01:30:20 +01:00
|
|
|
String release_file_32;
|
|
|
|
String release_file_64;
|
|
|
|
String debug_file_32;
|
|
|
|
String debug_file_64;
|
2017-02-20 03:19:30 +01:00
|
|
|
|
|
|
|
public:
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
|
2017-02-20 03:19:30 +01:00
|
|
|
|
|
|
|
virtual void get_export_options(List<ExportOption> *r_options);
|
|
|
|
|
|
|
|
virtual String get_name() const;
|
|
|
|
virtual Ref<Texture> get_logo() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
|
2017-02-20 03:19:30 +01:00
|
|
|
virtual String get_binary_extension() const;
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_extension(const String &p_extension);
|
|
|
|
void set_name(const String &p_name);
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_logo(const Ref<Texture> &p_loco);
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_release_64(const String &p_file);
|
|
|
|
void set_release_32(const String &p_file);
|
|
|
|
void set_debug_64(const String &p_file);
|
|
|
|
void set_debug_32(const String &p_file);
|
2017-02-22 01:30:20 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
EditorExportPlatformPC();
|
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#endif // EDITOR_IMPORT_EXPORT_H
|