mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Remove old path remaps system
Unused in public repositories, deprecated for over 6 years, and the replacement system is well-tested by now.
This commit is contained in:
parent
1696ab0cb6
commit
a96e8ac62c
5 changed files with 44 additions and 84 deletions
|
@ -1274,44 +1274,39 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path_remaps.has(new_path)) {
|
// Usually, there's no remap file and FileAccess::exists() is faster than FileAccess::open().
|
||||||
new_path = path_remaps[new_path];
|
new_path = ResourceUID::ensure_path(new_path);
|
||||||
} else {
|
if (FileAccess::exists(new_path + ".remap")) {
|
||||||
// Try file remap.
|
Error err;
|
||||||
// Usually, there's no remap file and FileAccess::exists() is faster than FileAccess::open().
|
Ref<FileAccess> f = FileAccess::open(new_path + ".remap", FileAccess::READ, &err);
|
||||||
new_path = ResourceUID::ensure_path(new_path);
|
if (f.is_valid()) {
|
||||||
if (FileAccess::exists(new_path + ".remap")) {
|
VariantParser::StreamFile stream;
|
||||||
Error err;
|
stream.f = f;
|
||||||
Ref<FileAccess> f = FileAccess::open(new_path + ".remap", FileAccess::READ, &err);
|
|
||||||
if (f.is_valid()) {
|
|
||||||
VariantParser::StreamFile stream;
|
|
||||||
stream.f = f;
|
|
||||||
|
|
||||||
String assign;
|
String assign;
|
||||||
Variant value;
|
Variant value;
|
||||||
VariantParser::Tag next_tag;
|
VariantParser::Tag next_tag;
|
||||||
|
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
String error_text;
|
String error_text;
|
||||||
while (true) {
|
while (true) {
|
||||||
assign = Variant();
|
assign = Variant();
|
||||||
next_tag.fields.clear();
|
next_tag.fields.clear();
|
||||||
next_tag.name = String();
|
next_tag.name = String();
|
||||||
|
|
||||||
err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true);
|
err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true);
|
||||||
if (err == ERR_FILE_EOF) {
|
if (err == ERR_FILE_EOF) {
|
||||||
break;
|
break;
|
||||||
} else if (err != OK) {
|
} else if (err != OK) {
|
||||||
ERR_PRINT(vformat("Parse error: %s.remap:%d error: %s.", p_path, lines, error_text));
|
ERR_PRINT(vformat("Parse error: %s.remap:%d error: %s.", p_path, lines, error_text));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assign == "path") {
|
if (assign == "path") {
|
||||||
new_path = value;
|
new_path = value;
|
||||||
break;
|
break;
|
||||||
} else if (next_tag.name != "remap") {
|
} else if (next_tag.name != "remap") {
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1419,25 +1414,6 @@ void ResourceLoader::clear_thread_load_tasks() {
|
||||||
cleaning_tasks = false;
|
cleaning_tasks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceLoader::load_path_remaps() {
|
|
||||||
if (!ProjectSettings::get_singleton()->has_setting("path_remap/remapped_paths")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<String> remaps = GLOBAL_GET("path_remap/remapped_paths");
|
|
||||||
int rc = remaps.size();
|
|
||||||
ERR_FAIL_COND(rc & 1); //must be even
|
|
||||||
const String *r = remaps.ptr();
|
|
||||||
|
|
||||||
for (int i = 0; i < rc; i += 2) {
|
|
||||||
path_remaps[r[i]] = r[i + 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResourceLoader::clear_path_remaps() {
|
|
||||||
path_remaps.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResourceLoader::set_load_callback(ResourceLoadedCallback p_callback) {
|
void ResourceLoader::set_load_callback(ResourceLoadedCallback p_callback) {
|
||||||
_loaded_callback = p_callback;
|
_loaded_callback = p_callback;
|
||||||
}
|
}
|
||||||
|
@ -1602,6 +1578,5 @@ HashMap<String, ResourceLoader::LoadToken *> ResourceLoader::user_load_tokens;
|
||||||
|
|
||||||
SelfList<Resource>::List ResourceLoader::remapped_list;
|
SelfList<Resource>::List ResourceLoader::remapped_list;
|
||||||
HashMap<String, Vector<String>> ResourceLoader::translation_remaps;
|
HashMap<String, Vector<String>> ResourceLoader::translation_remaps;
|
||||||
HashMap<String, String> ResourceLoader::path_remaps;
|
|
||||||
|
|
||||||
ResourceLoaderImport ResourceLoader::import = nullptr;
|
ResourceLoaderImport ResourceLoader::import = nullptr;
|
||||||
|
|
|
@ -159,7 +159,6 @@ private:
|
||||||
static bool abort_on_missing_resource;
|
static bool abort_on_missing_resource;
|
||||||
static bool create_missing_resources_if_class_unavailable;
|
static bool create_missing_resources_if_class_unavailable;
|
||||||
static HashMap<String, Vector<String>> translation_remaps;
|
static HashMap<String, Vector<String>> translation_remaps;
|
||||||
static HashMap<String, String> path_remaps;
|
|
||||||
|
|
||||||
static String _path_remap(const String &p_path, bool *r_translation_remapped = nullptr);
|
static String _path_remap(const String &p_path, bool *r_translation_remapped = nullptr);
|
||||||
friend class Resource;
|
friend class Resource;
|
||||||
|
@ -289,9 +288,6 @@ public:
|
||||||
static String path_remap(const String &p_path);
|
static String path_remap(const String &p_path);
|
||||||
static String import_remap(const String &p_path);
|
static String import_remap(const String &p_path);
|
||||||
|
|
||||||
static void load_path_remaps();
|
|
||||||
static void clear_path_remaps();
|
|
||||||
|
|
||||||
static void reload_translation_remaps();
|
static void reload_translation_remaps();
|
||||||
static void load_translation_remaps();
|
static void load_translation_remaps();
|
||||||
static void clear_translation_remaps();
|
static void clear_translation_remaps();
|
||||||
|
|
|
@ -7142,7 +7142,6 @@ EditorNode::EditorNode() {
|
||||||
|
|
||||||
SceneState::set_disable_placeholders(true);
|
SceneState::set_disable_placeholders(true);
|
||||||
ResourceLoader::clear_translation_remaps(); // Using no remaps if in editor.
|
ResourceLoader::clear_translation_remaps(); // Using no remaps if in editor.
|
||||||
ResourceLoader::clear_path_remaps();
|
|
||||||
ResourceLoader::set_create_missing_resources_if_class_unavailable(true);
|
ResourceLoader::set_create_missing_resources_if_class_unavailable(true);
|
||||||
|
|
||||||
EditorPropertyNameProcessor *epnp = memnew(EditorPropertyNameProcessor);
|
EditorPropertyNameProcessor *epnp = memnew(EditorPropertyNameProcessor);
|
||||||
|
|
|
@ -1542,28 +1542,22 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
|
||||||
custom_list.append_array(export_plugins[i]->_get_export_features(Ref<EditorExportPlatform>(this), p_debug));
|
custom_list.append_array(export_plugins[i]->_get_export_features(Ref<EditorExportPlatform>(this), p_debug));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectSettings::CustomMap custom_map = get_custom_project_settings(p_preset);
|
|
||||||
if (path_remaps.size()) {
|
if (path_remaps.size()) {
|
||||||
if (true) { //new remap mode, use always as it's friendlier with multiple .pck exports
|
for (int i = 0; i < path_remaps.size(); i += 2) {
|
||||||
for (int i = 0; i < path_remaps.size(); i += 2) {
|
const String &from = path_remaps[i];
|
||||||
const String &from = path_remaps[i];
|
const String &to = path_remaps[i + 1];
|
||||||
const String &to = path_remaps[i + 1];
|
String remap_file = "[remap]\n\npath=\"" + to.c_escape() + "\"\n";
|
||||||
String remap_file = "[remap]\n\npath=\"" + to.c_escape() + "\"\n";
|
CharString utf8 = remap_file.utf8();
|
||||||
CharString utf8 = remap_file.utf8();
|
Vector<uint8_t> new_file;
|
||||||
Vector<uint8_t> new_file;
|
new_file.resize(utf8.length());
|
||||||
new_file.resize(utf8.length());
|
for (int j = 0; j < utf8.length(); j++) {
|
||||||
for (int j = 0; j < utf8.length(); j++) {
|
new_file.write[j] = utf8[j];
|
||||||
new_file.write[j] = utf8[j];
|
}
|
||||||
}
|
|
||||||
|
err = save_proxy.save_file(p_udata, from + ".remap", new_file, idx, total, enc_in_filters, enc_ex_filters, key, seed);
|
||||||
err = save_proxy.save_file(p_udata, from + ".remap", new_file, idx, total, enc_in_filters, enc_ex_filters, key, seed);
|
if (err != OK) {
|
||||||
if (err != OK) {
|
return err;
|
||||||
return err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//old remap mode, will still work, but it's unused because it's not multiple pck export friendly
|
|
||||||
custom_map["path_remap/remapped_paths"] = path_remaps;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1595,6 +1589,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
|
||||||
|
|
||||||
String config_file = "project.binary";
|
String config_file = "project.binary";
|
||||||
String engine_cfb = EditorPaths::get_singleton()->get_temp_dir().path_join("tmp" + config_file);
|
String engine_cfb = EditorPaths::get_singleton()->get_temp_dir().path_join("tmp" + config_file);
|
||||||
|
ProjectSettings::CustomMap custom_map = get_custom_project_settings(p_preset);
|
||||||
ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list);
|
ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list);
|
||||||
Vector<uint8_t> data = FileAccess::get_file_as_bytes(engine_cfb);
|
Vector<uint8_t> data = FileAccess::get_file_as_bytes(engine_cfb);
|
||||||
DirAccess::remove_file_or_error(engine_cfb);
|
DirAccess::remove_file_or_error(engine_cfb);
|
||||||
|
|
|
@ -759,8 +759,6 @@ Error Main::test_setup() {
|
||||||
translation_server->load_translations();
|
translation_server->load_translations();
|
||||||
ResourceLoader::load_translation_remaps(); //load remaps for resources
|
ResourceLoader::load_translation_remaps(); //load remaps for resources
|
||||||
|
|
||||||
ResourceLoader::load_path_remaps();
|
|
||||||
|
|
||||||
// Initialize ThemeDB early so that scene types can register their theme items.
|
// Initialize ThemeDB early so that scene types can register their theme items.
|
||||||
// Default theme will be initialized later, after modules and ScriptServer are ready.
|
// Default theme will be initialized later, after modules and ScriptServer are ready.
|
||||||
initialize_theme_db();
|
initialize_theme_db();
|
||||||
|
@ -3475,8 +3473,6 @@ Error Main::setup2(bool p_show_boot_logo) {
|
||||||
translation_server->load_translations();
|
translation_server->load_translations();
|
||||||
ResourceLoader::load_translation_remaps(); //load remaps for resources
|
ResourceLoader::load_translation_remaps(); //load remaps for resources
|
||||||
|
|
||||||
ResourceLoader::load_path_remaps();
|
|
||||||
|
|
||||||
OS::get_singleton()->benchmark_end_measure("Startup", "Translations and Remaps");
|
OS::get_singleton()->benchmark_end_measure("Startup", "Translations and Remaps");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4915,7 +4911,6 @@ void Main::cleanup(bool p_force) {
|
||||||
OS::get_singleton()->_local_clipboard = "";
|
OS::get_singleton()->_local_clipboard = "";
|
||||||
|
|
||||||
ResourceLoader::clear_translation_remaps();
|
ResourceLoader::clear_translation_remaps();
|
||||||
ResourceLoader::clear_path_remaps();
|
|
||||||
|
|
||||||
WorkerThreadPool::get_singleton()->exit_languages_threads();
|
WorkerThreadPool::get_singleton()->exit_languages_threads();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue