godot/editor/editor_export.h

429 lines
14 KiB
C++
Raw Normal View History

2014-02-10 01:10:30 +00:00
/*************************************************************************/
2017-09-01 14:07:55 +00:00
/* editor_export.h */
2014-02-10 01:10:30 +00:00
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
2014-02-10 01:10:30 +00:00
/*************************************************************************/
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
2014-02-10 01:10:30 +00: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. */
/*************************************************************************/
#ifndef EDITOR_EXPORT_H
#define EDITOR_EXPORT_H
2014-02-10 01:10:30 +00:00
#include "core/os/dir_access.h"
#include "core/resource.h"
2014-02-10 01:10:30 +00:00
#include "scene/main/node.h"
#include "scene/main/timer.h"
#include "scene/resources/texture.h"
2014-02-10 01:10:30 +00:00
class FileAccess;
class EditorExportPlatform;
class EditorFileSystemDirectory;
Fix mismatched class/struct definition warnings [-Wmismatched-tags] Fixes the following Clang 7 warnings: ``` core/object.cpp:44:1: warning: '_ObjectDebugLock' defined as a struct here but previously declared as a class [-Wmismatched-tags] core/variant_call.cpp:43:1: warning: '_VariantCall' defined as a struct here but previously declared as a class [-Wmismatched-tags] drivers/gles3/rasterizer_storage_gles3.h:765:2: warning: 'MultiMesh' defined as a struct here but previously declared as a class [-Wmismatched-tags] editor/editor_node.h:794:1: warning: 'EditorProgress' defined as a struct here but previously declared as a class [-Wmismatched-tags] modules/bullet/rigid_body_bullet.h:230:17: warning: class 'KinematicUtilities' was previously declared as a struct [-Wmismatched-tags] modules/bullet/space_bullet.h:60:1: warning: class 'btSoftBodyWorldInfo' was previously declared as a struct [-Wmismatched-tags] scene/resources/world_2d.cpp:40:1: warning: 'SpatialIndexer2D' defined as a struct here but previously declared as a class [-Wmismatched-tags] scene/resources/world.cpp:39:1: warning: 'SpatialIndexer' defined as a struct here but previously declared as a class [-Wmismatched-tags] servers/audio/reverb_sw.cpp:60:1: warning: 'ReverbParamsSW' defined as a struct here but previously declared as a class [-Wmismatched-tags] thirdparty/bullet/BulletSoftBody/btSoftBody.h:43:1: warning: 'btSoftBodyWorldInfo' defined as a struct here but previously declared as a class [-Wmismatched-tags] ```
2018-10-01 14:46:50 +00:00
struct EditorProgress;
class EditorExportPreset : public Reference {
GDCLASS(EditorExportPreset, Reference)
2014-02-10 01:10:30 +00:00
public:
enum ExportFilter {
EXPORT_ALL_RESOURCES,
EXPORT_SELECTED_SCENES,
EXPORT_SELECTED_RESOURCES,
};
2014-02-10 01:10:30 +00:00
private:
Ref<EditorExportPlatform> platform;
ExportFilter export_filter;
String include_filter;
String exclude_filter;
2018-10-27 13:53:05 +00:00
String export_path;
String exporter;
Set<String> selected_files;
bool runnable;
Vector<String> patches;
2014-02-10 01:10:30 +00:00
friend class EditorExport;
friend class EditorExportPlatform;
2014-02-24 12:53:33 +00:00
List<PropertyInfo> properties;
Map<StringName, Variant> values;
2014-02-24 12:53:33 +00:00
String name;
String custom_features;
2014-02-24 12:53:33 +00:00
protected:
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 12:53:33 +00:00
public:
Ref<EditorExportPlatform> get_platform() const;
bool has(const StringName &p_property) const { return values.has(p_property); }
Vector<String> get_files_to_export() const;
void add_export_file(const String &p_path);
void remove_export_file(const String &p_path);
bool has_export_file(const String &p_path);
void set_name(const String &p_name);
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;
void set_include_filter(const String &p_include);
String get_include_filter() const;
void set_exclude_filter(const String &p_exclude);
String get_exclude_filter() const;
void add_patch(const String &p_path, int p_at_pos = -1);
void set_patch(int p_index, const String &p_path);
String get_patch(int p_index);
void remove_patch(int p_idx);
Vector<String> get_patches() const;
void set_custom_features(const String &p_custom_features);
String get_custom_features() const;
2018-10-27 13:53:05 +00:00
void set_export_path(const String &p_path);
String get_export_path() const;
const List<PropertyInfo> &get_properties() const { return properties; }
2014-02-24 12:53:33 +00:00
EditorExportPreset();
2014-02-24 12:53:33 +00:00
};
struct SharedObject {
String path;
Vector<String> tags;
SharedObject(const String &p_path, const Vector<String> &p_tags) :
path(p_path),
tags(p_tags) {
}
SharedObject() {}
};
2014-02-10 01:10:30 +00:00
class EditorExportPlatform : public Reference {
GDCLASS(EditorExportPlatform, Reference)
2014-02-10 01:10:30 +00:00
public:
typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
typedef Error (*EditorExportSaveSharedObject)(void *p_userdata, const SharedObject &p_so);
private:
struct SavedData {
2014-02-10 01:10:30 +00:00
uint64_t ofs;
uint64_t size;
Vector<uint8_t> md5;
CharString path_utf8;
bool operator<(const SavedData &p_data) const {
return path_utf8 < p_data.path_utf8;
}
2014-02-10 01:10:30 +00:00
};
struct PackData {
FileAccess *f;
Vector<SavedData> file_ofs;
2014-02-10 01:10:30 +00:00
EditorProgress *ep;
Vector<SharedObject> *so_files;
2014-02-10 01:10:30 +00:00
};
2015-12-13 04:08:36 +00:00
struct ZipData {
void *zip;
2015-12-13 04:08:36 +00:00
EditorProgress *ep;
};
struct FeatureContainers {
Set<String> features;
PoolVector<String> features_pv;
};
void _export_find_resources(EditorFileSystemDirectory *p_dir, Set<String> &p_paths);
void _export_find_dependencies(const String &p_path, Set<String> &p_paths);
void gen_debug_flags(Vector<String> &r_flags, int p_flags);
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 01:10:30 +00:00
void _edit_files_with_filter(DirAccess *da, const Vector<String> &p_filters, Set<String> &r_list, bool exclude);
void _edit_filter_list(Set<String> &r_list, const String &p_filter, bool exclude);
static Error _add_shared_object(void *p_userdata, const SharedObject &p_so);
protected:
struct ExportNotifier {
ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags);
~ExportNotifier();
};
FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset);
2017-04-21 23:15:42 +00:00
bool exists_export_template(String template_file_name, String *err) const;
String find_export_template(String template_file_name, String *err = NULL) const;
void gen_export_flags(Vector<String> &r_flags, int p_flags);
2014-02-10 01:10:30 +00:00
public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0;
struct ExportOption {
PropertyInfo option;
Variant default_value;
2014-02-10 01:10:30 +00:00
ExportOption(const PropertyInfo &p_info, const Variant &p_default) {
option = p_info;
default_value = p_default;
}
ExportOption() {}
};
2015-12-13 04:08:36 +00:00
virtual Ref<EditorExportPreset> create_preset();
virtual void get_export_options(List<ExportOption> *r_options) = 0;
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; }
virtual String get_os_name() const = 0;
virtual String get_name() const = 0;
virtual Ref<Texture> get_logo() const = 0;
2014-02-10 01:10:30 +00:00
Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = NULL);
2014-02-10 01:10:30 +00:00
Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path, Vector<SharedObject> *p_so_files = NULL);
Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path);
2014-02-10 01:10:30 +00: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 01:10:30 +00:00
enum DebugFlags {
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 01:10:30 +00:00
};
virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { return OK; }
virtual Ref<Texture> get_run_icon() const { return get_logo(); }
2014-02-10 01:10:30 +00:00
virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
2014-02-10 01:10:30 +00:00
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_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 void get_platform_features(List<String> *r_features) = 0;
2018-08-22 02:56:04 +00:00
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) = 0;
2014-02-10 01:10:30 +00:00
EditorExportPlatform();
2014-02-10 01:10:30 +00:00
};
class EditorExportPlugin : public Reference {
GDCLASS(EditorExportPlugin, Reference)
friend class EditorExportPlatform;
Vector<SharedObject> shared_objects;
struct ExtraFile {
String path;
Vector<uint8_t> data;
bool remap;
};
Vector<ExtraFile> extra_files;
bool skipped;
Vector<String> ios_frameworks;
String ios_plist_content;
String ios_linker_flags;
Vector<String> ios_bundle_files;
String ios_cpp_code;
_FORCE_INLINE_ void _clear() {
shared_objects.clear();
extra_files.clear();
skipped = false;
}
_FORCE_INLINE_ void _export_end() {
ios_frameworks.clear();
ios_bundle_files.clear();
ios_plist_content = "";
ios_linker_flags = "";
ios_cpp_code = "";
}
void _export_file_script(const String &p_path, const String &p_type, const PoolVector<String> &p_features);
void _export_begin_script(const PoolVector<String> &p_features, bool p_debug, const String &p_path, int p_flags);
protected:
void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap);
void add_shared_object(const String &p_path, const Vector<String> &tags);
void add_ios_framework(const String &p_path);
void add_ios_plist_content(const String &p_plist_content);
void add_ios_linker_flags(const String &p_flags);
void add_ios_bundle_file(const String &p_path);
void add_ios_cpp_code(const String &p_code);
void skip();
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features);
virtual void _export_begin(const Set<String> &p_features, bool p_debug, const String &p_path, int p_flags);
static void _bind_methods();
public:
Vector<String> get_ios_frameworks() const;
String get_ios_plist_content() const;
String get_ios_linker_flags() const;
Vector<String> get_ios_bundle_files() const;
String get_ios_cpp_code() const;
EditorExportPlugin();
};
class EditorExport : public Node {
GDCLASS(EditorExport, Node);
2014-02-10 01:10:30 +00:00
Vector<Ref<EditorExportPlatform> > export_platforms;
Vector<Ref<EditorExportPreset> > export_presets;
Vector<Ref<EditorExportPlugin> > export_plugins;
2014-02-10 01:10:30 +00:00
Timer *save_timer;
bool block_save;
static EditorExport *singleton;
void _save();
2014-02-10 01:10:30 +00:00
protected:
friend class EditorExportPreset;
void save_presets();
void _notification(int p_what);
2014-02-10 01:10:30 +00:00
static void _bind_methods();
public:
static EditorExport *get_singleton() { return singleton; }
void add_export_platform(const Ref<EditorExportPlatform> &p_platform);
int get_export_platform_count();
Ref<EditorExportPlatform> get_export_platform(int p_idx);
2014-02-10 01:10:30 +00:00
void add_export_preset(const Ref<EditorExportPreset> &p_preset, int p_at_pos = -1);
int get_export_preset_count() const;
Ref<EditorExportPreset> get_export_preset(int p_idx);
void remove_export_preset(int p_idx);
void add_export_plugin(const Ref<EditorExportPlugin> &p_plugin);
void remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin);
Vector<Ref<EditorExportPlugin> > get_export_plugins();
2014-02-10 01:10:30 +00:00
void load_config();
bool poll_export_platforms();
EditorExport();
~EditorExport();
2014-02-10 01:10:30 +00:00
};
class EditorExportPlatformPC : public EditorExportPlatform {
GDCLASS(EditorExportPlatformPC, EditorExportPlatform)
Ref<ImageTexture> logo;
String name;
String os_name;
Map<String, String> extensions;
2017-02-22 00:30:20 +00:00
String release_file_32;
String release_file_64;
String debug_file_32;
String debug_file_64;
Set<String> extra_features;
int chmod_flags;
2017-04-21 23:15:42 +00:00
public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
virtual void get_export_options(List<ExportOption> *r_options);
virtual String get_name() const;
virtual String get_os_name() 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 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);
void set_extension(const String &p_extension, const String &p_feature_key = "default");
void set_name(const String &p_name);
void set_os_name(const String &p_name);
2017-08-12 16:52:50 +00:00
void set_logo(const Ref<Texture> &p_logo);
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 00:30:20 +00:00
void add_platform_feature(const String &p_feature);
virtual void get_platform_features(List<String> *r_features);
2018-08-22 02:56:04 +00:00
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features);
int get_chmod_flags() const;
void set_chmod_flags(int p_flags);
EditorExportPlatformPC();
};
class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin {
GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin)
public:
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features);
EditorExportTextSceneToBinaryPlugin();
};
2014-02-10 01:10:30 +00:00
#endif // EDITOR_IMPORT_EXPORT_H