summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
Diffstat (limited to 'core/io')
-rw-r--r--core/io/compression.cpp11
-rw-r--r--core/io/compression.h5
-rw-r--r--core/io/file_access_memory.cpp6
-rw-r--r--core/io/file_access_network.cpp2
-rw-r--r--core/io/ip.cpp2
-rw-r--r--core/io/packet_peer.cpp4
-rw-r--r--core/io/resource_format_binary.cpp16
-rw-r--r--core/io/resource_import.cpp7
-rw-r--r--core/io/resource_loader.cpp14
-rw-r--r--core/io/resource_saver.cpp4
10 files changed, 41 insertions, 30 deletions
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index 8c8f0b3655..ca35ece8f5 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "compression.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "os/copymem.h"
#include "zip_io.h"
@@ -61,7 +61,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
strm.zalloc = zipio_alloc;
strm.zfree = zipio_free;
strm.opaque = Z_NULL;
- int level = p_mode == MODE_DEFLATE ? GLOBAL_GET("compression/zlib/compression_level") : GLOBAL_GET("compression/gzip/compression_level");
+ int level = p_mode == MODE_DEFLATE ? zlib_level : gzip_level;
int err = deflateInit2(&strm, level, Z_DEFLATED, window_bits, 8, Z_DEFAULT_STRATEGY);
if (err != Z_OK)
return -1;
@@ -80,8 +80,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
case MODE_ZSTD: {
int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD);
- int level = GLOBAL_GET("compression/zstd/compression_level");
- return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, level);
+ return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, zstd_level);
} break;
}
@@ -173,3 +172,7 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
ERR_FAIL_V(-1);
}
+
+int Compression::zlib_level = Z_DEFAULT_COMPRESSION;
+int Compression::gzip_level = Z_DEFAULT_COMPRESSION;
+int Compression::zstd_level = 3;
diff --git a/core/io/compression.h b/core/io/compression.h
index bc39fc4185..5eb7806d7b 100644
--- a/core/io/compression.h
+++ b/core/io/compression.h
@@ -33,7 +33,12 @@
#include "typedefs.h"
class Compression {
+
public:
+ static int zlib_level;
+ static int gzip_level;
+ static int zstd_level;
+
enum Mode {
MODE_FASTLZ,
MODE_DEFLATE,
diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp
index 32ea4ce096..2197b187eb 100644
--- a/core/io/file_access_memory.cpp
+++ b/core/io/file_access_memory.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "file_access_memory.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "map.h"
#include "os/copymem.h"
#include "os/dir_access.h"
@@ -43,8 +43,8 @@ void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) {
}
String name;
- if (GlobalConfig::get_singleton())
- name = GlobalConfig::get_singleton()->globalize_path(p_name);
+ if (ProjectSettings::get_singleton())
+ name = ProjectSettings::get_singleton()->globalize_path(p_name);
else
name = p_name;
//name = DirAccess::normalize_path(name);
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 50e78899fb..46457d1425 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_access_network.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "io/ip.h"
#include "marshalls.h"
#include "os/os.h"
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 6c463b983c..c869bdad9b 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -240,7 +240,7 @@ void IP::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_resolve_item_address", "id"), &IP::get_resolve_item_address);
ClassDB::bind_method(D_METHOD("erase_resolve_item", "id"), &IP::erase_resolve_item);
ClassDB::bind_method(D_METHOD("get_local_addresses"), &IP::_get_local_addresses);
- ClassDB::bind_method(D_METHOD("clear_cache"), &IP::clear_cache, DEFVAL(""));
+ ClassDB::bind_method(D_METHOD("clear_cache", "hostname"), &IP::clear_cache, DEFVAL(""));
BIND_CONSTANT(RESOLVER_STATUS_NONE);
BIND_CONSTANT(RESOLVER_STATUS_WAITING);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index ac68d5240c..81446a3886 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "packet_peer.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "io/marshalls.h"
/* helpers / binders */
@@ -254,7 +254,7 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
PacketPeerStream::PacketPeerStream() {
- int rbsize = GLOBAL_GET("network/packets/packet_stream_peer_max_buffer_po2");
+ int rbsize = GLOBAL_GET("network/limits/packet_peer_stream/max_buffer_po2");
ring_buffer.resize(rbsize);
temp_buffer.resize(1 << rbsize);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 728cd5d4ff..602cbe6f30 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_format_binary.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "image.h"
#include "io/file_access_compressed.h"
#include "io/marshalls.h"
@@ -317,7 +317,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
if (remaps.find(path)) {
@@ -346,7 +346,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
if (path.find("://") == -1 && path.is_rel_path()) {
// path is relative to file being loaded, so convert to a resource path
- path = GlobalConfig::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
}
RES res = ResourceLoader::load(path, type);
@@ -1017,7 +1017,7 @@ Ref<ResourceInteractiveLoader> ResourceFormatLoaderBinary::load_interactive(cons
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->open(f);
@@ -1065,7 +1065,7 @@ void ResourceFormatLoaderBinary::get_dependencies(const String &p_path, List<Str
ERR_FAIL_COND(!f);
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
ria->get_dependencies(f, p_dependencies, p_add_types);
@@ -1152,7 +1152,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
ria->remaps = p_map;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
@@ -1281,7 +1281,7 @@ String ResourceFormatLoaderBinary::get_resource_type(const String &p_path) const
}
Ref<ResourceInteractiveLoaderBinary> ria = memnew(ResourceInteractiveLoaderBinary);
- ria->local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ria->res_path = ria->local_path;
//ria->set_local_path( Globals::get_singleton()->localize_path(p_path) );
String r = ria->recognize(f);
@@ -1984,7 +1984,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
Error ResourceFormatSaverBinary::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
- String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
ResourceFormatSaverBinaryInstance saver;
return saver.save(local_path, p_resource, p_flags);
}
diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp
index ffb27bc26a..61da4f3350 100644
--- a/core/io/resource_import.cpp
+++ b/core/io/resource_import.cpp
@@ -49,6 +49,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
int lines = 0;
String error_text;
+ bool path_found = false; //first match must have priority
while (true) {
assign = Variant();
@@ -66,14 +67,16 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
}
if (assign != String()) {
- if (assign.begins_with("path.") && r_path_and_type.path == String()) {
+ if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) {
String feature = assign.get_slicec('.', 1);
if (OS::get_singleton()->check_feature_support(feature)) {
r_path_and_type.path = value;
+ path_found = true; //first match must have priority
}
- } else if (assign == "path") {
+ } else if (!path_found && assign == "path") {
r_path_and_type.path = value;
+ path_found = true; //first match must have priority
} else if (assign == "type") {
r_path_and_type.type = value;
}
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index bb7be38413..57acb6c754 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_loader.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "io/resource_import.h"
#include "os/file_access.h"
#include "os/os.h"
@@ -166,7 +166,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
@@ -233,7 +233,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
bool xl_remapped = false;
String path = _path_remap(local_path, &xl_remapped);
@@ -304,7 +304,7 @@ void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_depe
if (path.is_rel_path())
local_path = "res://" + path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(path);
+ local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
@@ -327,7 +327,7 @@ Error ResourceLoader::rename_dependencies(const String &p_path, const Map<String
if (path.is_rel_path())
local_path = "res://" + path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(path);
+ local_path = ProjectSettings::get_singleton()->localize_path(path);
for (int i = 0; i < loader_count; i++) {
@@ -350,7 +350,7 @@ String ResourceLoader::get_resource_type(const String &p_path) {
if (p_path.is_rel_path())
local_path = "res://" + p_path;
else
- local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ local_path = ProjectSettings::get_singleton()->localize_path(p_path);
for (int i = 0; i < loader_count; i++) {
@@ -430,7 +430,7 @@ void ResourceLoader::reload_translation_remaps() {
void ResourceLoader::load_translation_remaps() {
- Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps");
+ Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps");
List<Variant> keys;
remaps.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 8592346a72..58913b80cc 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "resource_saver.h"
-#include "global_config.h"
+#include "project_settings.h"
#include "os/file_access.h"
#include "resource_loader.h"
#include "script_language.h"
@@ -64,7 +64,7 @@ Error ResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t
String old_path = p_resource->get_path();
- String local_path = GlobalConfig::get_singleton()->localize_path(p_path);
+ String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
RES rwcopy = p_resource;
if (p_flags & FLAG_CHANGE_PATH)