- gameServerSettings refactoring: using ObjectProperties for saving/loading instead of doing it manually

- tabs for different types of server settings
- moved banlist to server settings
- option to select autorestart delay
- character name is always the same as client name (less griefing potential)
This commit is contained in:
Regalis
2016-07-21 21:18:09 +03:00
parent 911846acff
commit 8abea5c0c7
6 changed files with 302 additions and 214 deletions
+17 -14
View File
@@ -247,7 +247,7 @@ namespace Barotrauma
return dictionary;
}
public static void SaveProperties(IPropertyObject obj, XElement element)
public static void SaveProperties(IPropertyObject obj, XElement element, bool saveIfDefault = false)
{
var saveProperties = GetProperties<HasDefaultValue>(obj);
foreach (var property in saveProperties)
@@ -255,22 +255,25 @@ namespace Barotrauma
object value = property.GetValue();
if (value == null) continue;
//only save
// - if the attribute is saveable
// - and it's different from the default value or can be changed in the editor
bool save = false;
foreach (var attribute in property.Attributes.OfType<HasDefaultValue>())
if (!saveIfDefault)
{
if (!attribute.isSaveable) continue;
if (!attribute.defaultValue.Equals(value) || property.Attributes.OfType<Editable>().Any())
//only save
// - if the attribute is saveable
// - and it's different from the default value or can be changed in the editor
bool save = false;
foreach (var attribute in property.Attributes.OfType<HasDefaultValue>())
{
save = true;
break;
}
}
if (!attribute.isSaveable) continue;
if (!save) continue;
if (!attribute.defaultValue.Equals(value) || property.Attributes.OfType<Editable>().Any())
{
save = true;
break;
}
}
if (!save) continue;
}
string stringValue;
if (value is float)