summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/globals.cpp17
-rw-r--r--core/globals.h2
-rw-r--r--core/io/resource_format_binary.cpp10
-rw-r--r--core/io/resource_format_binary.h1
-rw-r--r--core/io/resource_format_xml.cpp14
-rw-r--r--core/io/resource_format_xml.h1
-rw-r--r--core/io/resource_saver.h1
-rw-r--r--core/resource.cpp15
-rw-r--r--core/resource.h2
-rw-r--r--core/ucaps.h6
10 files changed, 56 insertions, 13 deletions
diff --git a/core/globals.cpp b/core/globals.cpp
index 7df7680827..3a04becef4 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -243,12 +243,27 @@ bool Globals::_load_resource_pack(const String& p_pack) {
return true;
}
-Error Globals::setup(const String& p_path) {
+Error Globals::setup(const String& p_path,const String & p_main_pack) {
//an absolute mess of a function, must be cleaned up and reorganized somehow at some point
//_load_settings(p_path+"/override.cfg");
+ if (p_main_pack!="") {
+
+ bool ok = _load_resource_pack(p_main_pack);
+ ERR_FAIL_COND_V(!ok,ERR_CANT_OPEN);
+
+ if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
+
+ _load_settings("res://override.cfg");
+
+ }
+
+ return OK;
+
+ }
+
if (OS::get_singleton()->get_executable_path()!="") {
if (_load_resource_pack(OS::get_singleton()->get_executable_path())) {
diff --git a/core/globals.h b/core/globals.h
index b8dc3f9367..580fd0fecd 100644
--- a/core/globals.h
+++ b/core/globals.h
@@ -110,7 +110,7 @@ public:
int get_order(const String& p_name) const;
void set_order(const String& p_name, int p_order);
- Error setup(const String& p_path);
+ Error setup(const String& p_path, const String &p_main_pack);
Error save_custom(const String& p_path="",const CustomMap& p_custom=CustomMap(),const Set<String>& p_ignore_masks=Set<String>());
Error save();
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 33f4cafedd..e2371fe24f 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1751,7 +1751,10 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES;
big_endian=p_flags&ResourceSaver::FLAG_SAVE_BIG_ENDIAN;
+ takeover_paths=p_flags&ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
+ if (!p_path.begins_with("res://"))
+ takeover_paths=false;
local_path=p_path.get_base_dir();
//bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create
@@ -1841,9 +1844,12 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) {
RES r = E->get();
- if (r->get_path()=="" || r->get_path().find("::")!=-1)
+ if (r->get_path()=="" || r->get_path().find("::")!=-1) {
save_unicode_string("local://"+itos(ofs_pos.size()));
- else
+ if (takeover_paths) {
+ r->set_path(p_path+"::"+itos(ofs_pos.size()),true);
+ }
+ } else
save_unicode_string(r->get_path()); //actual external
ofs_pos.push_back(f->get_pos());
f->store_64(0); //offset in 64 bits
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index bd33fee82c..cc26357bfb 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -125,6 +125,7 @@ class ResourceFormatSaverBinaryInstance {
bool bundle_resources;
bool skip_editor;
bool big_endian;
+ bool takeover_paths;
int bin_meta_idx;
FileAccess *f;
String magic;
diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp
index dae95097d3..e6eede7de6 100644
--- a/core/io/resource_format_xml.cpp
+++ b/core/io/resource_format_xml.cpp
@@ -2505,6 +2505,10 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
relative_paths=p_flags&ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES;
+ takeover_paths=p_flags&ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
+ if (!p_path.begins_with("res://")) {
+ takeover_paths=false;
+ }
depth=0;
// save resources
@@ -2541,8 +2545,14 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
enter_tag("main_resource",""); //bundled
else if (res->get_path().length() && res->get_path().find("::") == -1 )
enter_tag("resource","type=\""+res->get_type()+"\" path=\""+res->get_path()+"\""); //bundled
- else
- enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(resource_map[res])+"\"");
+ else {
+ int idx = resource_map[res];
+ enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(idx)+"\"");
+ if (takeover_paths) {
+ res->set_path(p_path+"::"+itos(idx),true);
+ }
+
+ }
write_string("\n",false);
diff --git a/core/io/resource_format_xml.h b/core/io/resource_format_xml.h
index cfa4744915..40aaa01451 100644
--- a/core/io/resource_format_xml.h
+++ b/core/io/resource_format_xml.h
@@ -117,6 +117,7 @@ class ResourceFormatSaverXMLInstance {
+ bool takeover_paths;
bool relative_paths;
bool bundle_resources;
bool skip_editor;
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index fd4575c872..e307668721 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -74,6 +74,7 @@ public:
FLAG_OMIT_EDITOR_PROPERTIES=8,
FLAG_SAVE_BIG_ENDIAN=16,
FLAG_COMPRESS=32,
+ FLAG_REPLACE_SUBRESOURCE_PATHS=64,
};
diff --git a/core/resource.cpp b/core/resource.cpp
index f07c37fb06..ccfeaa6bb9 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -157,7 +157,7 @@ void Resource::_resource_path_changed() {
}
-void Resource::set_path(const String& p_path) {
+void Resource::set_path(const String& p_path, bool p_take_over) {
if (path_cache==p_path)
return;
@@ -168,7 +168,16 @@ void Resource::set_path(const String& p_path) {
}
path_cache="";
- ERR_FAIL_COND( ResourceCache::resources.has( p_path ) );
+ if (ResourceCache::resources.has( p_path )) {
+ if (p_take_over) {
+
+ ResourceCache::resources.get(p_path)->set_name("");
+ } else {
+ ERR_EXPLAIN("Another resource is loaded from path: "+p_path);
+ ERR_FAIL_COND( ResourceCache::resources.has( p_path ) );
+ }
+
+ }
path_cache=p_path;
if (path_cache!="") {
@@ -240,7 +249,7 @@ void Resource::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_path","path"),&Resource::set_path);
ObjectTypeDB::bind_method(_MD("get_path"),&Resource::get_path);
- ObjectTypeDB::bind_method(_MD("set_name","name"),&Resource::set_name);
+ ObjectTypeDB::bind_method(_MD("set_name","name","take_over"),&Resource::set_name,DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_name"),&Resource::get_name);
ObjectTypeDB::bind_method(_MD("get_rid"),&Resource::get_rid);
ObjectTypeDB::bind_method(_MD("set_import_metadata","metadata"),&Resource::set_import_metadata);
diff --git a/core/resource.h b/core/resource.h
index 8d2c72d120..2e336e1caf 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -126,7 +126,7 @@ public:
void set_name(const String& p_name);
String get_name() const;
- void set_path(const String& p_path);
+ void set_path(const String& p_path,bool p_take_over=false);
String get_path() const;
Ref<Resource> duplicate(bool p_subresources=false);
diff --git a/core/ucaps.h b/core/ucaps.h
index 855a946c21..9c07828006 100644
--- a/core/ucaps.h
+++ b/core/ucaps.h
@@ -673,7 +673,7 @@ static const int caps_table[CAPS_LEN][2]={
{0xFF5A,0xFF3A},
};
-static const int reverse_caps_table[CAPS_LEN][2]={
+static const int reverse_caps_table[CAPS_LEN-1][2]={
{0x41,0x61},
{0x42,0x62},
{0x43,0x63},
@@ -755,7 +755,7 @@ static const int reverse_caps_table[CAPS_LEN][2]={
{0x12a,0x12b},
{0x12c,0x12d},
{0x12e,0x12f},
-{0x49,0x131},
+//{0x49,0x131},
{0x132,0x133},
{0x134,0x135},
{0x136,0x137},
@@ -1370,7 +1370,7 @@ static int _find_lower(int ch) {
int low = 0;
- int high = CAPS_LEN -1;
+ int high = CAPS_LEN -2;
int middle;
while( low <= high )