Merge pull request #1769 from est31/xml-order
Sort xml files, so order is constant
This commit is contained in:
commit
af42e244e0
@ -2243,12 +2243,12 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V
|
|||||||
|
|
||||||
List<Variant> keys;
|
List<Variant> keys;
|
||||||
dict.get_key_list(&keys);
|
dict.get_key_list(&keys);
|
||||||
|
keys.sort();
|
||||||
|
|
||||||
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
|
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
|
||||||
|
|
||||||
//if (!_check_type(dict[E->get()]))
|
//if (!_check_type(dict[E->get()]))
|
||||||
// continue;
|
// continue;
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
write_property("",E->get(),&ok);
|
write_property("",E->get(),&ok);
|
||||||
ERR_CONTINUE(!ok);
|
ERR_CONTINUE(!ok);
|
||||||
@ -2438,7 +2438,7 @@ void ResourceFormatSaverXMLInstance::_find_resources(const Variant& p_variant,bo
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!p_main && (!bundle_resources ) && res->get_path().length() && res->get_path().find("::") == -1 ) {
|
if (!p_main && (!bundle_resources ) && res->get_path().length() && res->get_path().find("::") == -1 ) {
|
||||||
external_resources.insert(res);
|
external_resources.push_back(res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2448,6 +2448,7 @@ void ResourceFormatSaverXMLInstance::_find_resources(const Variant& p_variant,bo
|
|||||||
List<PropertyInfo> property_list;
|
List<PropertyInfo> property_list;
|
||||||
|
|
||||||
res->get_property_list( &property_list );
|
res->get_property_list( &property_list );
|
||||||
|
property_list.sort();
|
||||||
|
|
||||||
List<PropertyInfo>::Element *I=property_list.front();
|
List<PropertyInfo>::Element *I=property_list.front();
|
||||||
|
|
||||||
@ -2525,7 +2526,7 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
|
|||||||
enter_tag("resource_file","type=\""+p_resource->get_type()+"\" subresource_count=\""+itos(saved_resources.size()+external_resources.size())+"\" version=\""+itos(VERSION_MAJOR)+"."+itos(VERSION_MINOR)+"\" version_name=\""+VERSION_FULL_NAME+"\"");
|
enter_tag("resource_file","type=\""+p_resource->get_type()+"\" subresource_count=\""+itos(saved_resources.size()+external_resources.size())+"\" version=\""+itos(VERSION_MAJOR)+"."+itos(VERSION_MINOR)+"\" version_name=\""+VERSION_FULL_NAME+"\"");
|
||||||
write_string("\n",false);
|
write_string("\n",false);
|
||||||
|
|
||||||
for(Set<RES>::Element *E=external_resources.front();E;E=E->next()) {
|
for(List<RES>::Element *E=external_resources.front();E;E=E->next()) {
|
||||||
|
|
||||||
write_tabs();
|
write_tabs();
|
||||||
String p = E->get()->get_path();
|
String p = E->get()->get_path();
|
||||||
@ -2562,6 +2563,7 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
|
|||||||
|
|
||||||
List<PropertyInfo> property_list;
|
List<PropertyInfo> property_list;
|
||||||
res->get_property_list(&property_list);
|
res->get_property_list(&property_list);
|
||||||
|
property_list.sort();
|
||||||
for(List<PropertyInfo>::Element *PE = property_list.front();PE;PE=PE->next()) {
|
for(List<PropertyInfo>::Element *PE = property_list.front();PE;PE=PE->next()) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class ResourceFormatSaverXMLInstance {
|
|||||||
int depth;
|
int depth;
|
||||||
Map<RES,int> resource_map;
|
Map<RES,int> resource_map;
|
||||||
List<RES> saved_resources;
|
List<RES> saved_resources;
|
||||||
Set<RES> external_resources;
|
List<RES> external_resources;
|
||||||
|
|
||||||
void enter_tag(const char* p_tag,const String& p_args=String());
|
void enter_tag(const char* p_tag,const String& p_args=String());
|
||||||
void exit_tag(const char* p_tag);
|
void exit_tag(const char* p_tag);
|
||||||
|
@ -111,6 +111,9 @@ struct PropertyInfo {
|
|||||||
PropertyInfo( Variant::Type p_type, const String p_name, PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_string="",uint32_t p_usage=PROPERTY_USAGE_DEFAULT) {
|
PropertyInfo( Variant::Type p_type, const String p_name, PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_string="",uint32_t p_usage=PROPERTY_USAGE_DEFAULT) {
|
||||||
type=p_type; name=p_name; hint=p_hint; hint_string=p_hint_string; usage=p_usage;
|
type=p_type; name=p_name; hint=p_hint; hint_string=p_hint_string; usage=p_usage;
|
||||||
}
|
}
|
||||||
|
bool operator<(const PropertyInfo& p_info) const {
|
||||||
|
return name<p_info.name;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -456,6 +456,15 @@ bool Variant::operator==(const Variant& p_variant) const {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Variant::operator<(const Variant& p_variant) const {
|
||||||
|
if (type!=p_variant.type) //if types differ, then order by type first
|
||||||
|
return type<p_variant.type;
|
||||||
|
bool v;
|
||||||
|
Variant r;
|
||||||
|
evaluate(OP_LESS,*this,p_variant,r,v);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
bool Variant::is_zero() const {
|
bool Variant::is_zero() const {
|
||||||
|
|
||||||
switch( type ) {
|
switch( type ) {
|
||||||
|
@ -408,7 +408,8 @@ public:
|
|||||||
|
|
||||||
//argsVariant call()
|
//argsVariant call()
|
||||||
|
|
||||||
bool operator==(const Variant& p_variant) const;
|
bool operator==(const Variant& p_variant) const;
|
||||||
|
bool operator<(const Variant& p_variant) const;
|
||||||
uint32_t hash() const;
|
uint32_t hash() const;
|
||||||
|
|
||||||
bool booleanize(bool &valid) const;
|
bool booleanize(bool &valid) const;
|
||||||
|
@ -165,6 +165,12 @@ r_valid=false;\
|
|||||||
return;}
|
return;}
|
||||||
|
|
||||||
#define DEFAULT_OP_ARRAY_EQ(m_name,m_type)\
|
#define DEFAULT_OP_ARRAY_EQ(m_name,m_type)\
|
||||||
|
DEFAULT_OP_ARRAY_OP(m_name,m_type,!=,!=,true,false,false)
|
||||||
|
|
||||||
|
#define DEFAULT_OP_ARRAY_LT(m_name,m_type)\
|
||||||
|
DEFAULT_OP_ARRAY_OP(m_name,m_type,<,!=,false,a_len<array_b.size(),true)
|
||||||
|
|
||||||
|
#define DEFAULT_OP_ARRAY_OP(m_name,m_type,m_opa,m_opb,m_ret_def,m_ret_s,m_ret_f)\
|
||||||
case m_name: { \
|
case m_name: { \
|
||||||
if (p_a.type!=p_b.type) {\
|
if (p_a.type!=p_b.type) {\
|
||||||
r_valid=false;\
|
r_valid=false;\
|
||||||
@ -174,19 +180,19 @@ case m_name: { \
|
|||||||
const DVector<m_type> &array_b=*reinterpret_cast<const DVector<m_type> *>(p_b._data._mem);\
|
const DVector<m_type> &array_b=*reinterpret_cast<const DVector<m_type> *>(p_b._data._mem);\
|
||||||
\
|
\
|
||||||
int a_len = array_a.size();\
|
int a_len = array_a.size();\
|
||||||
if (a_len!=array_b.size()){\
|
if (a_len m_opa array_b.size()){\
|
||||||
_RETURN( false);\
|
_RETURN( m_ret_s);\
|
||||||
}else {\
|
}else {\
|
||||||
\
|
\
|
||||||
DVector<m_type>::Read ra = array_a.read();\
|
DVector<m_type>::Read ra = array_a.read();\
|
||||||
DVector<m_type>::Read rb = array_b.read();\
|
DVector<m_type>::Read rb = array_b.read();\
|
||||||
\
|
\
|
||||||
for(int i=0;i<a_len;i++) {\
|
for(int i=0;i<a_len;i++) {\
|
||||||
if (ra[i]!=rb[i])\
|
if (ra[i] m_opb rb[i])\
|
||||||
_RETURN( false);\
|
_RETURN( m_ret_f);\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
_RETURN( true);\
|
_RETURN( m_ret_def);\
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,14 +363,33 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant&
|
|||||||
} break;
|
} break;
|
||||||
DEFAULT_OP_FAIL(INPUT_EVENT);
|
DEFAULT_OP_FAIL(INPUT_EVENT);
|
||||||
DEFAULT_OP_FAIL(DICTIONARY);
|
DEFAULT_OP_FAIL(DICTIONARY);
|
||||||
DEFAULT_OP_FAIL(ARRAY);
|
case ARRAY: {
|
||||||
DEFAULT_OP_FAIL(RAW_ARRAY);
|
|
||||||
DEFAULT_OP_FAIL(INT_ARRAY);
|
if (p_b.type!=ARRAY)
|
||||||
DEFAULT_OP_FAIL(REAL_ARRAY);
|
_RETURN( false );
|
||||||
DEFAULT_OP_FAIL(STRING_ARRAY);
|
|
||||||
DEFAULT_OP_FAIL(VECTOR2_ARRAY);
|
const Array *arr_a=reinterpret_cast<const Array*>(p_a._data._mem);
|
||||||
DEFAULT_OP_FAIL(VECTOR3_ARRAY);
|
const Array *arr_b=reinterpret_cast<const Array*>(p_b._data._mem);
|
||||||
DEFAULT_OP_FAIL(COLOR_ARRAY);
|
|
||||||
|
int l = arr_a->size();
|
||||||
|
if (arr_b->size()<l)
|
||||||
|
_RETURN( false );
|
||||||
|
for(int i=0;i<l;i++) {
|
||||||
|
if (!((*arr_a)[i]<(*arr_b)[i])) {
|
||||||
|
_RETURN( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_RETURN( false );
|
||||||
|
|
||||||
|
} break;
|
||||||
|
DEFAULT_OP_ARRAY_LT(RAW_ARRAY,uint8_t);
|
||||||
|
DEFAULT_OP_ARRAY_LT(INT_ARRAY,int);
|
||||||
|
DEFAULT_OP_ARRAY_LT(REAL_ARRAY,real_t);
|
||||||
|
DEFAULT_OP_ARRAY_LT(STRING_ARRAY,String);
|
||||||
|
DEFAULT_OP_ARRAY_LT(VECTOR2_ARRAY,Vector3);
|
||||||
|
DEFAULT_OP_ARRAY_LT(VECTOR3_ARRAY,Vector3);
|
||||||
|
DEFAULT_OP_ARRAY_LT(COLOR_ARRAY,Color);
|
||||||
case VARIANT_MAX: {
|
case VARIANT_MAX: {
|
||||||
r_valid=false;
|
r_valid=false;
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user