mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Add support for using >, <, >= and <= in searches for sector brightness/height/tag, linedef tag and thing type/angle.
This commit is contained in:
parent
cc93734354
commit
365aff2803
7 changed files with 157 additions and 10 deletions
|
@ -75,6 +75,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// Check for comparison operators
|
||||
string comparer;
|
||||
if (value[0].ToString() == ">" || value[0].ToString() == "<")
|
||||
{
|
||||
comparer = value.Substring(0, 1);
|
||||
if (value.Length > 1)
|
||||
if (value[1].ToString() == "=")
|
||||
comparer = value.Substring(0, 2);
|
||||
value = value.Remove(0, comparer.Length);
|
||||
}
|
||||
else
|
||||
comparer = "";
|
||||
|
||||
if (value.Length == 0)
|
||||
return objs.ToArray();
|
||||
|
||||
// Interpret the number given
|
||||
int tag;
|
||||
if(int.TryParse(value, out tag))
|
||||
|
@ -86,8 +102,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(Linedef l in list)
|
||||
{
|
||||
// Tag matches?
|
||||
int index = l.Tags.IndexOf(tag);
|
||||
if(index != -1)
|
||||
int index = -1;
|
||||
for (int i = 0; i < l.Tags.Count; i++)
|
||||
if ((l.Tags[i] == tag && comparer.ToString() == "") ||
|
||||
(l.Tags[i] > tag && comparer.ToString() == ">") ||
|
||||
(l.Tags[i] < tag && comparer.ToString() == "<") ||
|
||||
(l.Tags[i] >= tag && comparer.ToString() == ">=") ||
|
||||
(l.Tags[i] <= tag && comparer.ToString() == "<="))
|
||||
index = l.Tags[i];
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
// Replace
|
||||
if(replace)
|
||||
|
|
|
@ -35,6 +35,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// Check for comparison operators
|
||||
string comparer;
|
||||
if (value[0].ToString() == ">" || value[0].ToString() == "<")
|
||||
{
|
||||
comparer = value.Substring(0, 1);
|
||||
if (value.Length > 1)
|
||||
if (value[1].ToString() == "=")
|
||||
comparer = value.Substring(0, 2);
|
||||
value = value.Remove(0, comparer.Length);
|
||||
}
|
||||
else
|
||||
comparer = "";
|
||||
|
||||
if (value.Length == 0)
|
||||
return objs.ToArray();
|
||||
|
||||
// Interpret the number given
|
||||
int brightness;
|
||||
if(int.TryParse(value, out brightness))
|
||||
|
@ -46,7 +62,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(Sector s in list)
|
||||
{
|
||||
// Brightness matches?
|
||||
if(s.Brightness == brightness)
|
||||
if ((s.Brightness == brightness && comparer.ToString() == "") ||
|
||||
(s.Brightness > brightness && comparer.ToString() == ">") ||
|
||||
(s.Brightness < brightness && comparer.ToString() == "<") ||
|
||||
(s.Brightness >= brightness && comparer.ToString() == ">=") ||
|
||||
(s.Brightness <= brightness && comparer.ToString() == "<="))
|
||||
{
|
||||
// Replace
|
||||
if(replace) s.Brightness = replacebrightness;
|
||||
|
|
|
@ -33,6 +33,22 @@ namespace CodeImp.DoomBuilder.BuilderModes.FindReplace
|
|||
}
|
||||
}
|
||||
|
||||
// Check for comparison operators
|
||||
string comparer;
|
||||
if (value[0].ToString() == ">" || value[0].ToString() == "<")
|
||||
{
|
||||
comparer = value.Substring(0, 1);
|
||||
if (value.Length > 1)
|
||||
if (value[1].ToString() == "=")
|
||||
comparer = value.Substring(0, 2);
|
||||
value = value.Remove(0, comparer.Length);
|
||||
}
|
||||
else
|
||||
comparer = "";
|
||||
|
||||
if (value.Length == 0)
|
||||
return objs.ToArray();
|
||||
|
||||
// Interpret the number given
|
||||
int height;
|
||||
if(int.TryParse(value, out height))
|
||||
|
@ -44,7 +60,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.FindReplace
|
|||
foreach(Sector s in list)
|
||||
{
|
||||
// Height matches?
|
||||
if(s.CeilHeight == height)
|
||||
if ((s.CeilHeight == height && comparer.ToString() == "") ||
|
||||
(s.CeilHeight > height && comparer.ToString() == ">") ||
|
||||
(s.CeilHeight < height && comparer.ToString() == "<") ||
|
||||
(s.CeilHeight >= height && comparer.ToString() == ">=") ||
|
||||
(s.CeilHeight <= height && comparer.ToString() == "<="))
|
||||
{
|
||||
// Replace
|
||||
if(replace) s.CeilHeight = replaceheight;
|
||||
|
|
|
@ -33,6 +33,22 @@ namespace CodeImp.DoomBuilder.BuilderModes.FindReplace
|
|||
}
|
||||
}
|
||||
|
||||
// Check for comparison operators
|
||||
string comparer;
|
||||
if (value[0].ToString() == ">" || value[0].ToString() == "<")
|
||||
{
|
||||
comparer = value.Substring(0, 1);
|
||||
if (value.Length > 1)
|
||||
if (value[1].ToString() == "=")
|
||||
comparer = value.Substring(0, 2);
|
||||
value = value.Remove(0, comparer.Length);
|
||||
}
|
||||
else
|
||||
comparer = "";
|
||||
|
||||
if (value.Length == 0)
|
||||
return objs.ToArray();
|
||||
|
||||
// Interpret the number given
|
||||
int height;
|
||||
if(int.TryParse(value, out height))
|
||||
|
@ -44,7 +60,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.FindReplace
|
|||
foreach(Sector s in list)
|
||||
{
|
||||
// Height matches?
|
||||
if(s.FloorHeight == height)
|
||||
if ((s.FloorHeight == height && comparer.ToString() == "") ||
|
||||
(s.FloorHeight > height && comparer.ToString() == ">") ||
|
||||
(s.FloorHeight < height && comparer.ToString() == "<") ||
|
||||
(s.FloorHeight >= height && comparer.ToString() == ">=") ||
|
||||
(s.FloorHeight <= height && comparer.ToString() == "<="))
|
||||
{
|
||||
// Replace
|
||||
if(replace) s.FloorHeight = replaceheight;
|
||||
|
|
|
@ -68,7 +68,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
return objs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check for comparison operators
|
||||
string comparer;
|
||||
if (value[0].ToString() == ">" || value[0].ToString() == "<")
|
||||
{
|
||||
comparer = value.Substring(0, 1);
|
||||
if (value.Length > 1)
|
||||
if (value[1].ToString() == "=")
|
||||
comparer = value.Substring(0, 2);
|
||||
value = value.Remove(0, comparer.Length);
|
||||
}
|
||||
else
|
||||
comparer = "";
|
||||
|
||||
if (value.Length == 0)
|
||||
return objs.ToArray();
|
||||
|
||||
// Interpret the number given
|
||||
int tag;
|
||||
if(int.TryParse(value, out tag))
|
||||
|
@ -80,8 +96,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(Sector s in list)
|
||||
{
|
||||
// Tag matches?
|
||||
int index = s.Tags.IndexOf(tag);
|
||||
if(index != -1)
|
||||
int index = -1;
|
||||
for (int i = 0; i < s.Tags.Count; i++)
|
||||
if ((s.Tags[i] == tag && comparer.ToString() == "") ||
|
||||
(s.Tags[i] > tag && comparer.ToString() == ">") ||
|
||||
(s.Tags[i] < tag && comparer.ToString() == "<") ||
|
||||
(s.Tags[i] >= tag && comparer.ToString() == ">=") ||
|
||||
(s.Tags[i] <= tag && comparer.ToString() == "<="))
|
||||
index = s.Tags[i];
|
||||
if (index != -1)
|
||||
{
|
||||
// Replace
|
||||
if(replace)
|
||||
|
|
|
@ -82,6 +82,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// Check for comparison operators
|
||||
string comparer;
|
||||
if (value[0].ToString() == ">" || value[0].ToString() == "<")
|
||||
{
|
||||
comparer = value.Substring(0, 1);
|
||||
if (value.Length > 1)
|
||||
if (value[1].ToString() == "=")
|
||||
comparer = value.Substring(0, 2);
|
||||
value = value.Remove(0, comparer.Length);
|
||||
}
|
||||
else
|
||||
comparer = "";
|
||||
|
||||
if (value.Length == 0)
|
||||
return objs.ToArray();
|
||||
|
||||
// Interpret the number given
|
||||
int angle;
|
||||
if(int.TryParse(value, out angle))
|
||||
|
@ -93,7 +109,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(Thing t in list)
|
||||
{
|
||||
// Match?
|
||||
if(t.AngleDoom == angle)
|
||||
if ((t.AngleDoom == angle && comparer.ToString() == "") ||
|
||||
(t.AngleDoom > angle && comparer.ToString() == ">") ||
|
||||
(t.AngleDoom < angle && comparer.ToString() == "<") ||
|
||||
(t.AngleDoom >= angle && comparer.ToString() == ">=") ||
|
||||
(t.AngleDoom <= angle && comparer.ToString() == "<="))
|
||||
{
|
||||
// Replace
|
||||
if(replace) t.Rotate(replaceangle);
|
||||
|
|
|
@ -84,6 +84,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// Check for comparison operators
|
||||
string comparer;
|
||||
if (value[0].ToString() == ">" || value[0].ToString() == "<")
|
||||
{
|
||||
comparer = value.Substring(0, 1);
|
||||
if (value.Length > 1)
|
||||
if (value[1].ToString() == "=")
|
||||
comparer = value.Substring(0, 2);
|
||||
value = value.Remove(0, comparer.Length);
|
||||
}
|
||||
else
|
||||
comparer = "";
|
||||
|
||||
if (value.Length == 0)
|
||||
return objs.ToArray();
|
||||
|
||||
// Interpret the number given
|
||||
int findtype;
|
||||
if(int.TryParse(value, out findtype))
|
||||
|
@ -95,7 +111,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(Thing t in list)
|
||||
{
|
||||
// Match?
|
||||
if(t.SRB2Type == findtype)
|
||||
if ((t.SRB2Type == findtype && comparer.ToString() == "") ||
|
||||
(t.SRB2Type > findtype && comparer.ToString() == ">") ||
|
||||
(t.SRB2Type < findtype && comparer.ToString() == "<") ||
|
||||
(t.SRB2Type >= findtype && comparer.ToString() == ">=") ||
|
||||
(t.SRB2Type <= findtype && comparer.ToString() == "<="))
|
||||
{
|
||||
// Replace
|
||||
if(replace)
|
||||
|
|
Loading…
Reference in a new issue