2013-04-11 11:04:16 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
2012-11-27 23:04:49 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Types;
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.Tools
|
|
|
|
|
{
|
|
|
|
|
public static class UDMFTools
|
|
|
|
|
{
|
|
|
|
|
//float
|
2013-09-05 13:03:17 +00:00
|
|
|
|
public static void SetFloat(UniFields fields, string key, float value) {
|
|
|
|
|
SetFloat(fields, key, value, 0f);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-10 11:28:51 +00:00
|
|
|
|
public static void SetFloat(UniFields fields, string key, float value, float defaultValue) {
|
2012-11-27 23:04:49 +00:00
|
|
|
|
if(fields == null) return;
|
|
|
|
|
|
|
|
|
|
if(value != defaultValue) {
|
|
|
|
|
if(!fields.ContainsKey(key))
|
|
|
|
|
fields.Add(key, new UniValue(UniversalType.Float, value));
|
|
|
|
|
else
|
|
|
|
|
fields[key].Value = value;
|
|
|
|
|
} else if(fields.ContainsKey(key)) { //don't save default value
|
|
|
|
|
fields.Remove(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-05 13:03:17 +00:00
|
|
|
|
public static float GetFloat(UniFields fields, string key) {
|
|
|
|
|
return GetFloat(fields, key, 0f);
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-10 14:04:23 +00:00
|
|
|
|
public static float GetFloat(UniFields fields, string key, float defaultValue) {
|
|
|
|
|
if(fields == null) return defaultValue;
|
|
|
|
|
return fields.GetValue(key, defaultValue);
|
|
|
|
|
}
|
2012-11-27 23:04:49 +00:00
|
|
|
|
|
2013-06-10 14:04:23 +00:00
|
|
|
|
//int
|
2013-09-05 13:03:17 +00:00
|
|
|
|
public static void SetInteger(UniFields fields, string key, int value) {
|
|
|
|
|
SetInteger(fields, key, value, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-10 11:28:51 +00:00
|
|
|
|
public static void SetInteger(UniFields fields, string key, int value, int defaultValue) {
|
2012-11-27 23:04:49 +00:00
|
|
|
|
if(fields == null) return;
|
|
|
|
|
|
|
|
|
|
if(value != defaultValue) {
|
|
|
|
|
if(!fields.ContainsKey(key))
|
|
|
|
|
fields.Add(key, new UniValue(UniversalType.Integer, value));
|
|
|
|
|
else
|
|
|
|
|
fields[key].Value = value;
|
|
|
|
|
} else if(fields.ContainsKey(key)) { //don't save default value
|
|
|
|
|
fields.Remove(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-10 14:04:23 +00:00
|
|
|
|
|
2013-09-05 13:03:17 +00:00
|
|
|
|
public static int GetInteger(UniFields fields, string key) {
|
|
|
|
|
return GetInteger(fields, key, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-10 14:04:23 +00:00
|
|
|
|
public static int GetInteger(UniFields fields, string key, int defaultValue) {
|
|
|
|
|
if(fields == null) return defaultValue;
|
|
|
|
|
return fields.GetValue(key, defaultValue);
|
|
|
|
|
}
|
2012-11-27 23:04:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|