Fixed the "within current selection" option in Find & Replace mode

This commit is contained in:
codeimp 2009-05-09 11:37:55 +00:00
parent 9b8e06299a
commit db132c30e8
15 changed files with 86 additions and 18 deletions

View file

@ -1066,6 +1066,31 @@ namespace CodeImp.DoomBuilder.Map
}
}
// Returns a collection of sidedefs that match a selected linedefs state
public ICollection<Sidedef> GetSidedefsFromSelectedLinedefs(bool selected)
{
if(selected)
{
List<Sidedef> list = new List<Sidedef>(sel_linedefs.Count);
foreach(Linedef ld in sel_linedefs)
{
if(ld.Front != null) list.Add(ld.Front);
if(ld.Back != null) list.Add(ld.Back);
}
return list;
}
else
{
List<Sidedef> list = new List<Sidedef>(linedefs.Count - sel_linedefs.Count);
foreach(Linedef ld in linedefs)
{
if(!ld.Selected && (ld.Front != null)) list.Add(ld.Front);
if(!ld.Selected && (ld.Back != null)) list.Add(ld.Back);
}
return list;
}
}
// Returns a collection of sectors that match a selected state
public ICollection<Sector> GetSelectedSectors(bool selected)
{

View file

@ -106,9 +106,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Interpret the find
long longfind = Lump.MakeLongName(value.Trim());
// Where to search?
ICollection<Sector> seclist = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors;
ICollection<Sidedef> sidelist = withinselection ? General.Map.Map.GetSidedefsFromSelectedLinedefs(true) : General.Map.Map.Sidedefs;
// Go for all sectors
foreach(Sector s in General.Map.Map.Sectors)
foreach(Sector s in seclist)
{
// Flat matches?
if(s.LongCeilTexture == longfind)
@ -127,7 +131,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Go for all sidedefs
foreach(Sidedef sd in General.Map.Map.Sidedefs)
foreach(Sidedef sd in sidelist)
{
string side = sd.IsFront ? "front" : "back";

View file

@ -111,8 +111,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int tag = 0;
if(int.TryParse(value, out tag))
{
// Where to search?
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
// Go for all linedefs
foreach(Linedef l in General.Map.Map.Linedefs)
foreach(Linedef l in list)
{
bool addline = false;

View file

@ -110,8 +110,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int tag = 0;
if(int.TryParse(value, out tag))
{
// Where to search?
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
// Go for all linedefs
foreach(Linedef l in General.Map.Map.Linedefs)
foreach(Linedef l in list)
{
// Tag matches?
if(l.Tag == tag)

View file

@ -111,8 +111,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int tag = 0;
if(int.TryParse(value, out tag))
{
// Where to search?
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
// Go for all linedefs
foreach(Linedef l in General.Map.Map.Linedefs)
foreach(Linedef l in list)
{
bool addline = false;

View file

@ -105,8 +105,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int action = 0;
if(int.TryParse(value, out action))
{
// Where to search?
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
// Go for all linedefs
foreach(Linedef l in General.Map.Map.Linedefs)
foreach(Linedef l in list)
{
// Action matches?
if(l.Action == action)

View file

@ -106,8 +106,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int effect = 0;
if(int.TryParse(value, out effect))
{
// Where to search?
ICollection<Sector> list = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors;
// Go for all sectors
foreach(Sector s in General.Map.Map.Sectors)
foreach(Sector s in list)
{
// Tag matches?
if(s.Effect == effect)

View file

@ -99,9 +99,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Interpret the find
long longfind = Lump.MakeLongName(value.Trim());
// Where to search?
ICollection<Sector> list = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors;
// Go for all sectors
foreach(Sector s in General.Map.Map.Sectors)
foreach(Sector s in list)
{
// Flat matches?
if(s.LongCeilTexture == longfind)

View file

@ -103,8 +103,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int tag = 0;
if(int.TryParse(value, out tag))
{
// Where to search?
ICollection<Sector> list = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors;
// Go for all sectors
foreach(Sector s in General.Map.Map.Sectors)
foreach(Sector s in list)
{
// Tag matches?
if(s.Tag == tag)

View file

@ -99,9 +99,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Interpret the find
long longfind = Lump.MakeLongName(value.Trim());
// Where to search?
ICollection<Sidedef> list = withinselection ? General.Map.Map.GetSidedefsFromSelectedLinedefs(true) : General.Map.Map.Sidedefs;
// Go for all sidedefs
foreach(Sidedef sd in General.Map.Map.Sidedefs)
foreach(Sidedef sd in list)
{
string side = sd.IsFront ? "front" : "back";

View file

@ -113,8 +113,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int findaction = 0;
if(int.TryParse(value, out findaction))
{
// Where to search?
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
// Go for all things
foreach(Thing t in General.Map.Map.Things)
foreach(Thing t in list)
{
// Match?
if(t.Action == findaction)

View file

@ -111,8 +111,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int tag = 0;
if(int.TryParse(value, out tag))
{
// Where to search?
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
// Go for all things
foreach(Thing t in General.Map.Map.Things)
foreach(Thing t in list)
{
bool addthing = false;

View file

@ -110,8 +110,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int tag = 0;
if(int.TryParse(value, out tag))
{
// Where to search?
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
// Go for all things
foreach(Thing t in General.Map.Map.Things)
foreach(Thing t in list)
{
// Match?
if(t.Tag == tag)

View file

@ -111,8 +111,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int tag = 0;
if(int.TryParse(value, out tag))
{
// Where to search?
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
// Go for all things
foreach(Thing t in General.Map.Map.Things)
foreach(Thing t in list)
{
bool addthing = false;

View file

@ -106,8 +106,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int findtype = 0;
if(int.TryParse(value, out findtype))
{
// Where to search?
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
// Go for all things
foreach(Thing t in General.Map.Map.Things)
foreach(Thing t in list)
{
// Match?
if(t.Type == findtype)