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:
MaxED 2016-06-08 00:06:20 +00:00 committed by spherallic
parent 872b72a98a
commit 93971a78ca
8 changed files with 125 additions and 54 deletions

View file

@ -73,6 +73,9 @@
// //
// groupBox1 // 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.Controls.Add(this.flags);
this.groupBox1.Location = new System.Drawing.Point(12, 7); this.groupBox1.Location = new System.Drawing.Point(12, 7);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";

View file

@ -33,9 +33,27 @@ namespace CodeImp.DoomBuilder.Windows
this.value = value; this.value = value;
flagdefs = inflags; 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 // Fill flags list
foreach(KeyValuePair<string, string> tf in flagdefs) 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 // Parse the value string and check the boxes if necessary
if (!string.IsNullOrEmpty(value.Trim())) if (!string.IsNullOrEmpty(value.Trim()))
@ -44,14 +62,20 @@ namespace CodeImp.DoomBuilder.Windows
{ {
string str = s.Trim(); 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 // Make sure the given flag actually exists
if(!flagdefs.ContainsKey(str)) if(!flagdefs.ContainsKey(str)) continue;
continue;
foreach(CheckBox c in flags.Checkboxes) foreach(CheckBox c in flags.Checkboxes)
{ {
if(c.Text == flagdefs[str]) if(c.Text == flagdefs[str]) c.Checked = setflag;
c.Checked = true;
} }
} }
} }
@ -78,14 +102,14 @@ namespace CodeImp.DoomBuilder.Windows
foreach(CheckBox c in flags.Checkboxes) foreach(CheckBox c in flags.Checkboxes)
{ {
if(c.Checked == false) continue; if(c.CheckState == CheckState.Indeterminate) continue;
foreach(KeyValuePair<string, string> lf in flagdefs) foreach(KeyValuePair<string, string> lf in flagdefs)
{ {
if(lf.Value == c.Text) if(lf.Value == c.Text)
{ {
if (!string.IsNullOrEmpty(value)) value += ","; if(!string.IsNullOrEmpty(value)) value += ",";
value += lf.Key; value += (c.CheckState == CheckState.Unchecked ? "!" + lf.Key : lf.Key);
} }
} }
} }

View file

@ -68,11 +68,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs; ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
// Find what? (mxd) // 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)) foreach(string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
string f = flag.Trim(); 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) if(findflagslist.Count == 0)
{ {
@ -81,19 +88,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// Replace with what? (mxd) // Replace with what? (mxd)
List<string> replaceflagslist = new List<string>(); Dictionary<string, bool> replaceflagslist = new Dictionary<string, bool>();
if(replace) if(replace)
{ {
string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach(string flag in replaceflags) foreach(string flag in replaceflags)
{ {
string f = flag.Trim(); 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)) if(!General.Map.Config.LinedefFlags.ContainsKey(f))
{ {
MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray(); return objs.ToArray();
} }
replaceflagslist.Add(f); replaceflagslist.Add(f, setflag);
} }
} }
@ -103,10 +117,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool match = true; bool match = true;
// Parse the value string... // Parse the value string...
foreach(string flag in findflagslist) foreach(KeyValuePair<string, bool> group in findflagslist)
{ {
// ... and check if the flags don't match // ...and check if the flag doesn't match
if(!l.IsFlagSet(flag)) if((group.Value && !l.IsFlagSet(group.Key)) || l.IsFlagSet(group.Key))
{ {
match = false; match = false;
break; break;
@ -119,11 +133,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Replace flags (mxd) // Replace flags (mxd)
if(replace) if(replace)
{ {
// Clear all flags
l.ClearFlags();
// Set new flags // 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 // Add to list

View file

@ -46,11 +46,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
ICollection<Sector> list = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors; ICollection<Sector> list = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors;
// Find what? (mxd) // 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)) foreach(string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
string f = flag.Trim(); 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) if(findflagslist.Count == 0)
{ {
@ -59,19 +66,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// Replace with what? (mxd) // Replace with what? (mxd)
List<string> replaceflagslist = new List<string>(); Dictionary<string, bool> replaceflagslist = new Dictionary<string, bool>();
if(replace) if(replace)
{ {
string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach(string flag in replaceflags) foreach(string flag in replaceflags)
{ {
string f = flag.Trim(); 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)) if(!General.Map.Config.SectorFlags.ContainsKey(f))
{ {
MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray(); return objs.ToArray();
} }
replaceflagslist.Add(f); replaceflagslist.Add(f, setflag);
} }
} }
@ -81,10 +95,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool match = true; bool match = true;
// Parse the value string... // Parse the value string...
foreach(string flag in findflagslist) foreach(KeyValuePair<string, bool> group in findflagslist)
{ {
// ... and check if the flags don't match // ...and check if the flag doesn't match
if(!s.IsFlagSet(flag)) if((group.Value && !s.IsFlagSet(group.Key)) || s.IsFlagSet(group.Key))
{ {
match = false; match = false;
break; break;
@ -97,11 +111,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Replace flags (mxd) // Replace flags (mxd)
if(replace) if(replace)
{ {
// Clear all flags
s.ClearFlags();
// Set new flags // 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 // Add to list

View file

@ -27,7 +27,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
[FindReplace("Sector Flat", BrowseButton = true)] [FindReplace("Sector Flat (Any)", BrowseButton = true)]
internal class FindSectorFlat : BaseFindSector internal class FindSectorFlat : BaseFindSector
{ {
#region ================== Constants #region ================== Constants

View file

@ -45,11 +45,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
ICollection<Sidedef> list = withinselection ? General.Map.Map.GetSidedefsFromSelectedLinedefs(true) : General.Map.Map.Sidedefs; ICollection<Sidedef> list = withinselection ? General.Map.Map.GetSidedefsFromSelectedLinedefs(true) : General.Map.Map.Sidedefs;
// Find what? (mxd) // 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)) foreach(string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
string f = flag.Trim(); 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) if(findflagslist.Count == 0)
{ {
@ -58,19 +65,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// Replace with what? (mxd) // Replace with what? (mxd)
List<string> replaceflagslist = new List<string>(); Dictionary<string, bool> replaceflagslist = new Dictionary<string, bool>();
if(replace) if(replace)
{ {
string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach(string flag in replaceflags) foreach(string flag in replaceflags)
{ {
string f = flag.Trim(); 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)) if(!General.Map.Config.SidedefFlags.ContainsKey(f))
{ {
MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray(); return objs.ToArray();
} }
replaceflagslist.Add(f); replaceflagslist.Add(f, setflag);
} }
} }
@ -80,10 +94,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool match = true; bool match = true;
// Parse the value string... // Parse the value string...
foreach(string flag in findflagslist) foreach(KeyValuePair<string, bool> group in findflagslist)
{ {
// ... and check if the flags don't match // ...and check if the flag doesn't match
if(!sd.IsFlagSet(flag)) if((group.Value && !sd.IsFlagSet(group.Key)) || sd.IsFlagSet(group.Key))
{ {
match = false; match = false;
break; break;
@ -98,11 +112,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Replace flags (mxd) // Replace flags (mxd)
if(replace) if(replace)
{ {
// Clear all flags
sd.ClearFlags();
// Set new flags // 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 // Add to list

View file

@ -27,7 +27,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
[FindReplace("Sidedef Texture", BrowseButton = true)] [FindReplace("Sidedef Texture (Any)", BrowseButton = true)]
internal class FindSidedefTexture : BaseFindSidedef internal class FindSidedefTexture : BaseFindSidedef
{ {
#region ================== Constants #region ================== Constants

View file

@ -76,11 +76,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things; ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
// Find what? (mxd) // 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)) foreach(string flag in value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
string f = flag.Trim(); 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) if(findflagslist.Count == 0)
{ {
@ -89,19 +96,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// Replace with what? (mxd) // Replace with what? (mxd)
List<string> replaceflagslist = new List<string>(); Dictionary<string, bool> replaceflagslist = new Dictionary<string, bool>();
if(replace) if(replace)
{ {
string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] replaceflags = replacewith.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach(string flag in replaceflags) foreach(string flag in replaceflags)
{ {
string f = flag.Trim(); 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)) if(!General.Map.Config.ThingFlags.ContainsKey(f))
{ {
MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Invalid replace value \"" + f + "\" for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray(); return objs.ToArray();
} }
replaceflagslist.Add(f); replaceflagslist.Add(f, setflag);
} }
} }
@ -111,10 +125,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool match = true; bool match = true;
// Parse the value string... // Parse the value string...
foreach(string flag in findflagslist) foreach(KeyValuePair<string, bool> group in findflagslist)
{ {
// ... and check if the flags don't match // ...and check if the flag doesn't match
if(!t.IsFlagSet(flag)) if((group.Value && !t.IsFlagSet(group.Key)) || t.IsFlagSet(group.Key))
{ {
match = false; match = false;
break; break;
@ -127,11 +141,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Replace flags (mxd) // Replace flags (mxd)
if(replace) if(replace)
{ {
// Clear all flags
t.ClearFlags();
// Set new flags // 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 // Add to list