Retain argument values if new thing/line action has the same argument(s)

This commit is contained in:
spherallic 2023-09-26 15:13:22 +02:00
parent 82ef2ab3de
commit 86422d7498

View file

@ -140,7 +140,8 @@ namespace CodeImp.DoomBuilder.Controls
stringarginfo = General.Map.Config.LinedefActions[showaction].StringArgs;
//mxd. Don't update action args when old and new argument infos match
if (arginfo != null && oldarginfo != null && stringarginfo != null && oldstringarginfo != null && ArgumentInfosMatch(arginfo, oldarginfo) && ArgumentInfosMatch(stringarginfo, oldstringarginfo)) return;
if (arginfo != null && oldarginfo != null && stringarginfo != null && oldstringarginfo != null && ArgumentInfosMatch(arginfo, oldarginfo) && ArgumentInfosMatch(stringarginfo, oldstringarginfo))
return;
// Change the argument descriptions
this.BeginUpdate();
@ -157,6 +158,7 @@ namespace CodeImp.DoomBuilder.Controls
if (showaction != 0)
{
for (int i = 0; i < args.Length; i++)
if (!ArgumentInfoMatches(arginfo, oldarginfo, i))
args[i].SetDefaultValue();
}
else //or set them to 0
@ -166,6 +168,7 @@ namespace CodeImp.DoomBuilder.Controls
}
for (int i = 0; i < stringargs.Length; i++)
if (!ArgumentInfoMatches(stringarginfo, oldstringarginfo, i))
stringargs[i].Text = string.Empty;
}
@ -194,7 +197,8 @@ namespace CodeImp.DoomBuilder.Controls
}
//mxd. Don't update args when old and new argument infos match
if (arginfo != null && oldarginfo != null && stringarginfo != null && oldstringarginfo != null && ArgumentInfosMatch(arginfo, oldarginfo) && ArgumentInfosMatch(stringarginfo, oldstringarginfo)) return;
if (arginfo != null && oldarginfo != null && stringarginfo != null && oldstringarginfo != null && ArgumentInfosMatch(arginfo, oldarginfo) && ArgumentInfosMatch(stringarginfo, oldstringarginfo))
return;
// Change the argument descriptions
this.BeginUpdate();
@ -209,6 +213,7 @@ namespace CodeImp.DoomBuilder.Controls
if (info != null)
{
for (int i = 0; i < args.Length; i++)
if (!ArgumentInfoMatches(arginfo, oldarginfo, i))
args[i].SetDefaultValue();
}
else //or set them to 0
@ -218,6 +223,7 @@ namespace CodeImp.DoomBuilder.Controls
}
for (int i = 0; i < stringargs.Length; i++)
if (!ArgumentInfoMatches(stringarginfo, oldstringarginfo, i))
stringargs[i].Text = string.Empty;
this.EndUpdate();
@ -283,6 +289,13 @@ namespace CodeImp.DoomBuilder.Controls
return haveusedargs;
}
private static bool ArgumentInfoMatches(ArgumentInfo[] info1, ArgumentInfo[] info2, int i)
{
if (info1 == null || info2 == null) return false;
return !(info1[i].Used != info2[i].Used || info1[i].Type != info2[i].Type
|| info1[i].Title.ToUpperInvariant() != info2[i].Title.ToUpperInvariant());
}
#endregion
#region ================== Redraw control