-Added new scene conversion to binary on export (disabled by default, please test)

-This method works by directly converting text to binary, so the scene does not need to be loaded and saved
This commit is contained in:
Juan Linietsky
2017-12-15 08:38:24 -03:00
parent 01c04d611f
commit 251433847f
7 changed files with 671 additions and 251 deletions

View File

@@ -39,10 +39,10 @@
#include "io/zip_io.h"
#include "os/file_access.h"
#include "project_settings.h"
#include "scene/resources/scene_format_text.h"
#include "script_language.h"
#include "version.h"
#include "thirdparty/misc/md5.h"
#include "version.h"
static int _get_pad(int p_alignment, int p_n) {
@@ -1399,3 +1399,30 @@ EditorExportPlatformPC::EditorExportPlatformPC() {
chmod_flags = -1;
}
///////////////////////
void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
String extension = p_path.get_extension().to_lower();
if (extension != "tres" && extension != "tscn") {
return;
}
print_line("exporting " + p_path);
bool convert = GLOBAL_GET("editor/convert_text_resources_to_binary_on_export");
if (!convert)
return;
String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("file.res");
Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path);
ERR_FAIL_COND(err != OK);
Vector<uint8_t> data = FileAccess::get_file_as_array(tmp_path);
ERR_FAIL_COND(data.size() == 0);
add_file(p_path + ".converted.res", data, true);
}
EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() {
GLOBAL_DEF("editor/convert_text_resources_to_binary_on_export", false);
}