Allow custom flag, angle and parameter labels for custom objects.

This commit is contained in:
sphere 2021-04-04 15:04:37 +02:00
parent f63047400d
commit ae256ac8cb
4 changed files with 81 additions and 5 deletions

View File

@ -446,6 +446,17 @@ namespace CodeImp.DoomBuilder.Config
else
this.spritelongname = long.MaxValue;
// Custom flag, parameter and angle labels
for (int i = 1; i <= 8; i *= 2)
if (o.flagstext.ContainsKey(i.ToString()))
this.flags[i.ToString()] = o.flagstext[i.ToString()];
else
this.flags[i.ToString()] = General.Map.Config.ThingFlags[i.ToString()];
if (o.angletext != "") this.angletext = o.angletext;
if (o.parametertext != "") this.parametertext = o.parametertext;
if (o.flagsvaluetext != "") this.flagsvaluetext = o.flagsvaluetext;
// We have no destructor
GC.SuppressFinalize(this);
}

View File

@ -127,6 +127,10 @@ namespace CodeImp.DoomBuilder.SRB2
int radius = 0;
int height = 0;
int flags = 0;
Dictionary<string, string> newflags = new Dictionary<string, string>();
string angletext = "";
string parametertext = "";
string flagsvaluetext = "";
SkipWhitespace(true);
token = ReadToken();
@ -175,6 +179,30 @@ namespace CodeImp.DoomBuilder.SRB2
token = ReadLine();
category = token;
break;
case "$Flags1Text":
case "$Flags2Text":
case "$Flags4Text":
case "$Flags8Text":
string index = token.Substring(6,1);
SkipWhitespace(true);
token = ReadLine();
newflags[index] = "[" + index + "] " + ZDTextParser.StripQuotes(token);
break;
case "$AngleText":
SkipWhitespace(true);
token = ReadLine();
angletext = ZDTextParser.StripQuotes(token);
break;
case "$ParameterText":
SkipWhitespace(true);
token = ReadLine();
parametertext = ZDTextParser.StripQuotes(token);
break;
case "$FlagsValueText":
SkipWhitespace(true);
token = ReadLine();
flagsvaluetext = ZDTextParser.StripQuotes(token);
break;
case "doomednum":
if (!ReadParameter(out token, out finished)) return false;
if (!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out mapThingNum))
@ -266,7 +294,8 @@ namespace CodeImp.DoomBuilder.SRB2
if (mapThingNum > 0)
{
SRB2Object o = new SRB2Object(name, sprite, category, states, mapThingNum, radius, height, flags);
SRB2Object o = new SRB2Object(name, sprite, category, states, mapThingNum, radius, height, flags,
newflags, angletext, parametertext, flagsvaluetext);
if (objects.ContainsKey(objname))
objects[objname] = o;
else

View File

@ -179,6 +179,10 @@ namespace CodeImp.DoomBuilder.SRB2
int radius = 0;
int height = 0;
int flags = 0;
Dictionary<string, string> newflags = new Dictionary<string, string>();
string angletext = "";
string parametertext = "";
string flagsvaluetext = "";
while (!streamreader.EndOfStream)
{
string line = streamreader.ReadLine();
@ -207,6 +211,28 @@ namespace CodeImp.DoomBuilder.SRB2
category = line.Substring(11);
continue;
}
if (line.StartsWith("#$Flags"))
{
string index = line.Substring(7, 1);
if (line.Substring(8, 5) == "Text ")
newflags[index] = "[" + index + "] " + ZDTextParser.StripQuotes(line.Substring(13));
continue;
}
if (line.StartsWith("#$AngleText "))
{
angletext = ZDTextParser.StripQuotes(line.Substring(12));
continue;
}
if (line.StartsWith("#$ParameterText "))
{
parametertext = ZDTextParser.StripQuotes(line.Substring(16));
continue;
}
if (line.StartsWith("#$FlagsValueText "))
{
flagsvaluetext = ZDTextParser.StripQuotes(line.Substring(17));
continue;
}
if (line.StartsWith("#")) continue;
line = RemoveComments(line);
string[] tokens = line.Split(new char[] { '=' });
@ -266,7 +292,8 @@ namespace CodeImp.DoomBuilder.SRB2
}
if (mapThingNum > 0)
{
SRB2Object o = new SRB2Object(name, sprite, category, states, mapThingNum, radius, height, flags);
SRB2Object o = new SRB2Object(name, sprite, category, states, mapThingNum, radius, height, flags,
newflags, angletext, parametertext, flagsvaluetext);
if (objects.ContainsKey(objname))
objects[objname] = o;
else

View File

@ -43,13 +43,18 @@ namespace CodeImp.DoomBuilder.SRB2
public readonly int radius;
public readonly int height;
public readonly int flags;
public readonly Dictionary<string, string> flagstext;
public readonly string angletext;
public readonly string parametertext;
public readonly string flagsvaluetext;
#endregion
#region ================== Constructor / Disposer
// Constructor
internal SRB2Object(string name, string sprite, string category, string[] states, int mapThingNum, int radius, int height, int flags)
internal SRB2Object(string name, string sprite, string category, string[] states, int mapThingNum, int radius, int height, int flags,
Dictionary<string, string> flagstext, string angletext, string parametertext, string flagsvaluetext)
{
this.name = name;
this.sprite = sprite;
@ -59,6 +64,10 @@ namespace CodeImp.DoomBuilder.SRB2
this.radius = radius;
this.height = height;
this.flags = flags;
this.flagstext = flagstext;
this.angletext = angletext;
this.parametertext = parametertext;
this.flagsvaluetext = flagsvaluetext;
}
#endregion