summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/globals.cpp20
-rw-r--r--core/globals.h7
2 files changed, 25 insertions, 2 deletions
diff --git a/core/globals.cpp b/core/globals.cpp
index fd0f2dbe14..eed37c2308 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -132,8 +132,12 @@ bool Globals::_set(const StringName& p_name, const Variant& p_value) {
if (props.has(p_name)) {
if (!props[p_name].overrided)
props[p_name].variant=p_value;
+
+ if (props[p_name].order>=NO_ORDER_BASE && registering_order) {
+ props[p_name].order=last_order++;
+ }
} else {
- props[p_name]=VariantContainer(p_value,last_order++);
+ props[p_name]=VariantContainer(p_value,last_order++ + registering_order?0:NO_ORDER_BASE);
}
}
@@ -741,6 +745,10 @@ static Variant _decode_variant(const String& p_string) {
return Variant();
}
+void Globals::set_registering_order(bool p_enable) {
+
+ registering_order=p_enable;
+}
Error Globals::_load_settings_binary(const String p_path) {
@@ -760,6 +768,8 @@ Error Globals::_load_settings_binary(const String p_path) {
ERR_FAIL_V(ERR_FILE_CORRUPT;)
}
+ set_registering_order(false);
+
uint32_t count=f->get_32();
for(int i=0;i<count;i++) {
@@ -784,6 +794,9 @@ Error Globals::_load_settings_binary(const String p_path) {
set_persisting(key,true);
}
+ set_registering_order(true);
+
+
return OK;
}
Error Globals::_load_settings(const String p_path) {
@@ -802,6 +815,8 @@ Error Globals::_load_settings(const String p_path) {
String section;
String subpath;
+ set_registering_order(false);
+
int line_count = 0;
while(!f->eof_reached()) {
@@ -877,6 +892,7 @@ Error Globals::_load_settings(const String p_path) {
memdelete(f);
+ set_registering_order(true);
return OK;
}
@@ -1388,7 +1404,7 @@ Globals::Globals() {
singleton=this;
last_order=0;
disable_platform_override=false;
-
+ registering_order=true;
Array va;
diff --git a/core/globals.h b/core/globals.h
index 25c7f96be2..bfa400988f 100644
--- a/core/globals.h
+++ b/core/globals.h
@@ -54,6 +54,10 @@ public:
protected:
+ enum {
+ NO_ORDER_BASE=1<<18
+ };
+
struct VariantContainer {
int order;
bool persist;
@@ -64,6 +68,7 @@ protected:
VariantContainer(const Variant& p_variant, int p_order, bool p_persist=false) { variant=p_variant; order=p_order; hide_from_editor=false; persist=p_persist; overrided=false; }
};
+ bool registering_order;
int last_order;
Map<StringName,VariantContainer> props;
String resource_path;
@@ -134,6 +139,8 @@ public:
bool is_using_datapack() const;
+ void set_registering_order(bool p_registering);
+
Globals();
~Globals();