mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Added, Find and Replace mode: you can now search (and replace) unset sidedef/linedef/thing/sector flags.
Changed, TEXTURES parser: patch loading errors are now treated as warnings for optional textures. Changed, TEXTURES parser: patch loading is now skipped for textures with "NullTexture" option.
This commit is contained in:
parent
872b72a98a
commit
93971a78ca
8 changed files with 125 additions and 54 deletions
3
Source/Core/Windows/FlagsForm.Designer.cs
generated
3
Source/Core/Windows/FlagsForm.Designer.cs
generated
|
@ -73,6 +73,9 @@
|
|||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox1.Controls.Add(this.flags);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 7);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
|
|
|
@ -33,9 +33,27 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.value = value;
|
||||
flagdefs = inflags;
|
||||
|
||||
//mxd. Store current size...
|
||||
int flagswidth = flags.Width;
|
||||
int flagsheight = flags.Height;
|
||||
|
||||
//mxd. How many columns will be required?
|
||||
flags.Columns = Math.Max(1, flagdefs.Count / 8);
|
||||
|
||||
// Fill flags list
|
||||
foreach(KeyValuePair<string, string> tf in flagdefs)
|
||||
flags.Add(tf.Value, tf.Key);
|
||||
{
|
||||
CheckBox cb = flags.Add(tf.Value, tf.Key);
|
||||
cb.ThreeState = true; //mxd
|
||||
cb.CheckState = CheckState.Indeterminate; //mxd
|
||||
}
|
||||
|
||||
//mxd. Resize window?
|
||||
int newflagswidth = flags.GetWidth();
|
||||
int newflagsheight = flags.GetHeight();
|
||||
|
||||
if(flagswidth != newflagswidth) this.Width += (newflagswidth - flagswidth);
|
||||
if(flagsheight != newflagsheight) this.Height += (newflagsheight - flagsheight);
|
||||
|
||||
// Parse the value string and check the boxes if necessary
|
||||
if (!string.IsNullOrEmpty(value.Trim()))
|
||||
|
@ -44,14 +62,20 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
string str = s.Trim();
|
||||
|
||||
//mxd. Negative flag?
|
||||
bool setflag = true;
|
||||
if(str.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
str = str.Substring(1, str.Length - 1);
|
||||
}
|
||||
|
||||
// Make sure the given flag actually exists
|
||||
if(!flagdefs.ContainsKey(str))
|
||||
continue;
|
||||
if(!flagdefs.ContainsKey(str)) continue;
|
||||
|
||||
foreach(CheckBox c in flags.Checkboxes)
|
||||
{
|
||||
if(c.Text == flagdefs[str])
|
||||
c.Checked = true;
|
||||
if(c.Text == flagdefs[str]) c.Checked = setflag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,14 +102,14 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
foreach(CheckBox c in flags.Checkboxes)
|
||||
{
|
||||
if(c.Checked == false) continue;
|
||||
if(c.CheckState == CheckState.Indeterminate) continue;
|
||||
|
||||
foreach(KeyValuePair<string, string> lf in flagdefs)
|
||||
{
|
||||
if(lf.Value == c.Text)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value)) value += ",";
|
||||
value += lf.Key;
|
||||
if(!string.IsNullOrEmpty(value)) value += ",";
|
||||
value += (c.CheckState == CheckState.Unchecked ? "!" + lf.Key : lf.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,11 +68,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
|
||||
|
||||
// Find what? (mxd)
|
||||
List<string> findflagslist = new List<string>();
|
||||
Dictionary<string, bool> findflagslist = new Dictionary<string, bool>();
|
||||
foreach(string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
string f = flag.Trim();
|
||||
if(General.Map.Config.LinedefFlags.ContainsKey(f)) findflagslist.Add(f);
|
||||
bool setflag = true;
|
||||
if(f.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
f = f.Substring(1, f.Length - 1);
|
||||
}
|
||||
|
||||
if(General.Map.Config.LinedefFlags.ContainsKey(f)) findflagslist.Add(f, setflag);
|
||||
}
|
||||
if(findflagslist.Count == 0)
|
||||
{
|
||||
|
@ -81,19 +88,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Replace with what? (mxd)
|
||||
List<string> replaceflagslist = new List<string>();
|
||||
Dictionary<string, bool> replaceflagslist = new Dictionary<string, bool>();
|
||||
if(replace)
|
||||
{
|
||||
string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach(string flag in replaceflags)
|
||||
{
|
||||
string f = flag.Trim();
|
||||
bool setflag = true;
|
||||
if(f.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
f = f.Substring(1, f.Length - 1);
|
||||
}
|
||||
|
||||
if(!General.Map.Config.LinedefFlags.ContainsKey(f))
|
||||
{
|
||||
MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return objs.ToArray();
|
||||
}
|
||||
replaceflagslist.Add(f);
|
||||
replaceflagslist.Add(f, setflag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,10 +117,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
bool match = true;
|
||||
|
||||
// Parse the value string...
|
||||
foreach(string flag in findflagslist)
|
||||
foreach(KeyValuePair<string, bool> group in findflagslist)
|
||||
{
|
||||
// ... and check if the flags don't match
|
||||
if(!l.IsFlagSet(flag))
|
||||
// ...and check if the flag doesn't match
|
||||
if((group.Value && !l.IsFlagSet(group.Key)) || l.IsFlagSet(group.Key))
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
|
@ -119,11 +133,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Replace flags (mxd)
|
||||
if(replace)
|
||||
{
|
||||
// Clear all flags
|
||||
l.ClearFlags();
|
||||
|
||||
// Set new flags
|
||||
foreach(string flag in replaceflagslist) l.SetFlag(flag, true);
|
||||
foreach(KeyValuePair<string, bool> group in replaceflagslist) l.SetFlag(group.Key, group.Value);
|
||||
}
|
||||
|
||||
// Add to list
|
||||
|
|
|
@ -46,11 +46,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
ICollection<Sector> list = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors;
|
||||
|
||||
// Find what? (mxd)
|
||||
List<string> findflagslist = new List<string>();
|
||||
Dictionary<string, bool> findflagslist = new Dictionary<string, bool>();
|
||||
foreach(string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
string f = flag.Trim();
|
||||
if(General.Map.Config.SectorFlags.ContainsKey(f)) findflagslist.Add(f);
|
||||
bool setflag = true;
|
||||
if(f.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
f = f.Substring(1, f.Length - 1);
|
||||
}
|
||||
|
||||
if(General.Map.Config.SectorFlags.ContainsKey(f)) findflagslist.Add(f, setflag);
|
||||
}
|
||||
if(findflagslist.Count == 0)
|
||||
{
|
||||
|
@ -59,19 +66,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Replace with what? (mxd)
|
||||
List<string> replaceflagslist = new List<string>();
|
||||
Dictionary<string, bool> replaceflagslist = new Dictionary<string, bool>();
|
||||
if(replace)
|
||||
{
|
||||
string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach(string flag in replaceflags)
|
||||
{
|
||||
string f = flag.Trim();
|
||||
bool setflag = true;
|
||||
if(f.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
f = f.Substring(1, f.Length - 1);
|
||||
}
|
||||
|
||||
if(!General.Map.Config.SectorFlags.ContainsKey(f))
|
||||
{
|
||||
MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return objs.ToArray();
|
||||
}
|
||||
replaceflagslist.Add(f);
|
||||
replaceflagslist.Add(f, setflag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,10 +95,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
bool match = true;
|
||||
|
||||
// Parse the value string...
|
||||
foreach(string flag in findflagslist)
|
||||
foreach(KeyValuePair<string, bool> group in findflagslist)
|
||||
{
|
||||
// ... and check if the flags don't match
|
||||
if(!s.IsFlagSet(flag))
|
||||
// ...and check if the flag doesn't match
|
||||
if((group.Value && !s.IsFlagSet(group.Key)) || s.IsFlagSet(group.Key))
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
|
@ -97,11 +111,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Replace flags (mxd)
|
||||
if(replace)
|
||||
{
|
||||
// Clear all flags
|
||||
s.ClearFlags();
|
||||
|
||||
// Set new flags
|
||||
foreach(string flag in replaceflagslist) s.SetFlag(flag, true);
|
||||
foreach(KeyValuePair<string, bool> group in replaceflagslist) s.SetFlag(group.Key, group.Value);
|
||||
}
|
||||
|
||||
// Add to list
|
||||
|
|
|
@ -27,7 +27,7 @@ using System.Drawing;
|
|||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
[FindReplace("Sector Flat", BrowseButton = true)]
|
||||
[FindReplace("Sector Flat (Any)", BrowseButton = true)]
|
||||
internal class FindSectorFlat : BaseFindSector
|
||||
{
|
||||
#region ================== Constants
|
||||
|
|
|
@ -45,11 +45,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
ICollection<Sidedef> list = withinselection ? General.Map.Map.GetSidedefsFromSelectedLinedefs(true) : General.Map.Map.Sidedefs;
|
||||
|
||||
// Find what? (mxd)
|
||||
List<string> findflagslist = new List<string>();
|
||||
Dictionary<string, bool> findflagslist = new Dictionary<string, bool>();
|
||||
foreach(string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
string f = flag.Trim();
|
||||
if(General.Map.Config.SidedefFlags.ContainsKey(f)) findflagslist.Add(f);
|
||||
bool setflag = true;
|
||||
if(f.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
f = f.Substring(1, f.Length - 1);
|
||||
}
|
||||
|
||||
if(General.Map.Config.SidedefFlags.ContainsKey(f)) findflagslist.Add(f, setflag);
|
||||
}
|
||||
if(findflagslist.Count == 0)
|
||||
{
|
||||
|
@ -58,19 +65,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Replace with what? (mxd)
|
||||
List<string> replaceflagslist = new List<string>();
|
||||
Dictionary<string, bool> replaceflagslist = new Dictionary<string, bool>();
|
||||
if(replace)
|
||||
{
|
||||
string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach(string flag in replaceflags)
|
||||
{
|
||||
string f = flag.Trim();
|
||||
bool setflag = true;
|
||||
if(f.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
f = f.Substring(1, f.Length - 1);
|
||||
}
|
||||
|
||||
if(!General.Map.Config.SidedefFlags.ContainsKey(f))
|
||||
{
|
||||
MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return objs.ToArray();
|
||||
}
|
||||
replaceflagslist.Add(f);
|
||||
replaceflagslist.Add(f, setflag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,10 +94,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
bool match = true;
|
||||
|
||||
// Parse the value string...
|
||||
foreach(string flag in findflagslist)
|
||||
foreach(KeyValuePair<string, bool> group in findflagslist)
|
||||
{
|
||||
// ... and check if the flags don't match
|
||||
if(!sd.IsFlagSet(flag))
|
||||
// ...and check if the flag doesn't match
|
||||
if((group.Value && !sd.IsFlagSet(group.Key)) || sd.IsFlagSet(group.Key))
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
|
@ -98,11 +112,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Replace flags (mxd)
|
||||
if(replace)
|
||||
{
|
||||
// Clear all flags
|
||||
sd.ClearFlags();
|
||||
|
||||
// Set new flags
|
||||
foreach(string flag in replaceflagslist) sd.SetFlag(flag, true);
|
||||
foreach(KeyValuePair<string, bool> group in replaceflagslist) sd.SetFlag(group.Key, group.Value);
|
||||
}
|
||||
|
||||
// Add to list
|
||||
|
|
|
@ -27,7 +27,7 @@ using System.Drawing;
|
|||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
[FindReplace("Sidedef Texture", BrowseButton = true)]
|
||||
[FindReplace("Sidedef Texture (Any)", BrowseButton = true)]
|
||||
internal class FindSidedefTexture : BaseFindSidedef
|
||||
{
|
||||
#region ================== Constants
|
||||
|
|
|
@ -76,11 +76,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
|
||||
|
||||
// Find what? (mxd)
|
||||
List<string> findflagslist = new List<string>();
|
||||
Dictionary<string, bool> findflagslist = new Dictionary<string, bool>();
|
||||
foreach(string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
string f = flag.Trim();
|
||||
if(General.Map.Config.ThingFlags.ContainsKey(f)) findflagslist.Add(f);
|
||||
bool setflag = true;
|
||||
if(f.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
f = f.Substring(1, f.Length - 1);
|
||||
}
|
||||
|
||||
if(General.Map.Config.ThingFlags.ContainsKey(f)) findflagslist.Add(f, setflag);
|
||||
}
|
||||
if(findflagslist.Count == 0)
|
||||
{
|
||||
|
@ -89,19 +96,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
// Replace with what? (mxd)
|
||||
List<string> replaceflagslist = new List<string>();
|
||||
Dictionary<string, bool> replaceflagslist = new Dictionary<string, bool>();
|
||||
if(replace)
|
||||
{
|
||||
string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
foreach(string flag in replaceflags)
|
||||
{
|
||||
string f = flag.Trim();
|
||||
bool setflag = true;
|
||||
if(f.StartsWith("!"))
|
||||
{
|
||||
setflag = false;
|
||||
f = f.Substring(1, f.Length - 1);
|
||||
}
|
||||
|
||||
if(!General.Map.Config.ThingFlags.ContainsKey(f))
|
||||
{
|
||||
MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return objs.ToArray();
|
||||
}
|
||||
replaceflagslist.Add(f);
|
||||
replaceflagslist.Add(f, setflag);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,10 +125,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
bool match = true;
|
||||
|
||||
// Parse the value string...
|
||||
foreach(string flag in findflagslist)
|
||||
foreach(KeyValuePair<string, bool> group in findflagslist)
|
||||
{
|
||||
// ... and check if the flags don't match
|
||||
if(!t.IsFlagSet(flag))
|
||||
// ...and check if the flag doesn't match
|
||||
if((group.Value && !t.IsFlagSet(group.Key)) || t.IsFlagSet(group.Key))
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
|
@ -127,11 +141,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Replace flags (mxd)
|
||||
if(replace)
|
||||
{
|
||||
// Clear all flags
|
||||
t.ClearFlags();
|
||||
|
||||
// Set new flags
|
||||
foreach(string flag in replaceflagslist) t.SetFlag(flag, true);
|
||||
foreach(KeyValuePair<string, bool> group in replaceflagslist) t.SetFlag(group.Key, group.Value);
|
||||
}
|
||||
|
||||
// Add to list
|
||||
|
|
Loading…
Reference in a new issue