summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/dictionary.cpp2
-rw-r--r--core/dictionary.h2
-rw-r--r--core/io/resource_loader.cpp44
-rw-r--r--core/variant_call.cpp2
4 files changed, 48 insertions, 2 deletions
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index 44fce2474f..66af6a1a9a 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -215,7 +215,7 @@ const Variant *Dictionary::next(const Variant *p_key) const {
return NULL;
}
-Dictionary Dictionary::copy() const {
+Dictionary Dictionary::duplicate() const {
Dictionary n;
diff --git a/core/dictionary.h b/core/dictionary.h
index c8177d5648..1d8ca0023e 100644
--- a/core/dictionary.h
+++ b/core/dictionary.h
@@ -74,7 +74,7 @@ public:
Array keys() const;
Array values() const;
- Dictionary copy() const;
+ Dictionary duplicate() const;
Dictionary(const Dictionary &p_from);
Dictionary();
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index d2aad1d63a..dea9f38634 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -35,6 +35,7 @@
#include "print_string.h"
#include "project_settings.h"
#include "translation.h"
+#include "variant_parser.h"
ResourceFormatLoader *ResourceLoader::loader[MAX_LOADERS];
int ResourceLoader::loader_count = 0;
@@ -454,6 +455,49 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
if (path_remaps.has(new_path)) {
new_path = path_remaps[new_path];
}
+
+ if (new_path == p_path) { //did not remap
+ //try file remap
+ Error err;
+ FileAccess *f = FileAccess::open(p_path + ".remap", FileAccess::READ, &err);
+
+ if (f) {
+
+ VariantParser::StreamFile stream;
+ stream.f = f;
+
+ String assign;
+ Variant value;
+ VariantParser::Tag next_tag;
+
+ int lines = 0;
+ String error_text;
+ while (true) {
+
+ assign = Variant();
+ next_tag.fields.clear();
+ next_tag.name = String();
+
+ err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true);
+ if (err == ERR_FILE_EOF) {
+ break;
+ } else if (err != OK) {
+ ERR_PRINTS("Parse error: " + p_path + ".remap:" + itos(lines) + " error: " + error_text);
+ break;
+ }
+
+ if (assign == "path") {
+ new_path = value;
+ break;
+ } else if (next_tag.name != "remap") {
+ break;
+ }
+ }
+
+ memdelete(f);
+ }
+ }
+
return new_path;
}
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 2b99a60ba5..0284c4d866 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -462,6 +462,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Dictionary, hash);
VCALL_LOCALMEM0R(Dictionary, keys);
VCALL_LOCALMEM0R(Dictionary, values);
+ VCALL_LOCALMEM0R(Dictionary, duplicate);
VCALL_LOCALMEM2(Array, set);
VCALL_LOCALMEM1R(Array, get);
@@ -1607,6 +1608,7 @@ void register_variant_methods() {
ADDFUNC0R(DICTIONARY, INT, Dictionary, hash, varray());
ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, keys, varray());
ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, values, varray());
+ ADDFUNC0R(DICTIONARY, DICTIONARY, Dictionary, duplicate, varray());
ADDFUNC0R(ARRAY, INT, Array, size, varray());
ADDFUNC0R(ARRAY, BOOL, Array, empty, varray());