mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-25 13:21:28 +00:00
UDMF: fixed an issue where user variables with default values were not saved when their value was equal to the type's default value. Fixes #709
This commit is contained in:
parent
c62b8315c4
commit
2dfe043e1e
2 changed files with 8 additions and 4 deletions
|
@ -417,7 +417,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
//mxd
|
||||
public void ApplyUserVars(Dictionary<string, UniversalType> vars, UniFields tofields)
|
||||
public void ApplyUserVars(Dictionary<string, UniversalType> vars, Dictionary<string, object> vardefaults, UniFields tofields)
|
||||
{
|
||||
// Apply user variables when target map element contains user var definition and the value is not default
|
||||
foreach(DataGridViewRow row in fieldslist.Rows)
|
||||
|
@ -434,8 +434,11 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// Skip field when mixed values
|
||||
if(newvalue == null) continue;
|
||||
|
||||
// Remove field
|
||||
if(newvalue.Equals(frow.TypeHandler.GetDefaultValue()))
|
||||
object typedefault = frow.TypeHandler.GetDefaultValue();
|
||||
object userdefault = vardefaults.ContainsKey(frow.Name) ? vardefaults[frow.Name] : typedefault;
|
||||
|
||||
// Remove field, but only if the type's default value is the same as the user var's default value
|
||||
if (newvalue.Equals(typedefault) && typedefault.Equals(userdefault))
|
||||
{
|
||||
if(tofields.ContainsKey(frow.Name)) tofields.Remove(frow.Name);
|
||||
}
|
||||
|
|
|
@ -584,9 +584,10 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
if (ti != null && ti.Actor != null)
|
||||
{
|
||||
Dictionary<string, UniversalType> uservars = ti.Actor.GetAllUserVars();
|
||||
Dictionary<string, object> uservardefaults = ti.Actor.GetAllUserVarDefaults();
|
||||
|
||||
if(uservars.Count > 0)
|
||||
fieldslist.ApplyUserVars(uservars, t.Fields);
|
||||
fieldslist.ApplyUserVars(uservars, uservardefaults, t.Fields);
|
||||
}
|
||||
|
||||
color.ApplyTo(t.Fields, t.Fields.GetValue("fillcolor", 0));
|
||||
|
|
Loading…
Reference in a new issue