2017-04-09 00:11:36 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_export_godot3.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:11:45 +00:00
|
|
|
/* https://godotengine.org */
|
2017-04-09 00:11:36 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
|
|
|
/* */
|
|
|
|
/* 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-13 01:52:02 +00:00
|
|
|
#ifndef EDITOR_EXPORT_GODOT3_H
|
|
|
|
#define EDITOR_EXPORT_GODOT3_H
|
|
|
|
|
2017-03-18 22:45:45 +00:00
|
|
|
#include "editor/editor_file_system.h"
|
2017-02-13 01:52:02 +00:00
|
|
|
#include "io/export_data.h"
|
2017-03-18 23:36:26 +00:00
|
|
|
#include "scene/main/node.h"
|
2017-02-13 01:52:02 +00:00
|
|
|
|
|
|
|
class EditorExportGodot3 {
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Map<String, int> pack_names;
|
|
|
|
HashMap<Variant, int, VariantHasher> pack_values;
|
2017-02-13 01:52:02 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
int _pack_name(const String &p_name) {
|
2017-02-13 01:52:02 +00:00
|
|
|
if (pack_names.has(p_name)) {
|
|
|
|
return pack_names[p_name];
|
|
|
|
}
|
|
|
|
|
|
|
|
int idx = pack_names.size();
|
2017-03-18 23:36:26 +00:00
|
|
|
pack_names[p_name] = idx;
|
2017-02-13 01:52:02 +00:00
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
int _pack_value(const Variant &p_value) {
|
2017-02-13 01:52:02 +00:00
|
|
|
if (pack_values.has(p_value)) {
|
|
|
|
return pack_values[p_value];
|
|
|
|
}
|
|
|
|
|
|
|
|
int idx = pack_values.size();
|
2017-03-18 23:36:26 +00:00
|
|
|
pack_values[p_value] = idx;
|
2017-02-13 01:52:02 +00:00
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2017-04-09 00:11:36 +00:00
|
|
|
Map<String, String> globals_rename_map;
|
2017-03-18 23:36:26 +00:00
|
|
|
Map<String, String> prop_rename_map;
|
|
|
|
Map<String, String> type_rename_map;
|
|
|
|
Map<String, String> signal_rename_map;
|
2017-02-13 01:52:02 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Map<String, String> resource_replace_map;
|
2017-02-13 01:52:02 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
String _replace_resource(const String &p_res) {
|
2017-02-13 01:52:02 +00:00
|
|
|
if (resource_replace_map.has(p_res))
|
|
|
|
return resource_replace_map[p_res];
|
|
|
|
else
|
|
|
|
return p_res;
|
|
|
|
}
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
Error _get_property_as_text(const Variant &p_variant, String &p_string);
|
2017-02-13 01:52:02 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void _save_text(const String &p_path, ExportData &resource);
|
2017-02-15 11:29:11 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void _save_binary_property(const Variant &p_property, FileAccess *f);
|
2017-02-15 11:29:11 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void _save_binary(const String &p_path, ExportData &resource);
|
2017-02-13 01:52:02 +00:00
|
|
|
void _save_config(const String &p_path);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void _rename_properties(const String &p_type, List<ExportData::PropertyData> *p_props);
|
2017-02-13 01:52:02 +00:00
|
|
|
void _convert_resources(ExportData &resource);
|
|
|
|
void _unpack_packed_scene(ExportData &resource);
|
|
|
|
void _pack_packed_scene(ExportData &resource);
|
|
|
|
|
2017-10-05 23:18:00 +00:00
|
|
|
Error _convert_script(const String &p_path, const String &p_target_path);
|
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
void _find_files(EditorFileSystemDirectory *p_dir, List<String> *r_files);
|
2017-02-13 01:52:02 +00:00
|
|
|
|
2017-03-18 23:36:26 +00:00
|
|
|
public:
|
2017-10-05 23:18:00 +00:00
|
|
|
Error export_godot3(const String &p_path, bool convert_scripts);
|
2017-02-13 01:52:02 +00:00
|
|
|
|
|
|
|
EditorExportGodot3();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EDITOR_EXPORT_GODOT3_H
|