Floodfill and texture alignment now stay within selection, if a selection was made

This commit is contained in:
codeimp 2009-06-12 09:44:38 +00:00
parent 64d06d0417
commit 129dbf241c
3 changed files with 62 additions and 3 deletions

View file

@ -154,8 +154,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.Renderer.SetCrosshairBusy(true);
General.Interface.RedrawDisplay();
if(mode.IsSingleSelection)
{
// Clear all marks, this will align everything it can
General.Map.Map.ClearMarkedSectors(false);
}
else
{
// Limit the alignment to selection only
General.Map.Map.ClearMarkedSectors(true);
List<Sector> sectors = mode.GetSelectedSectors();
foreach(Sector s in sectors) s.Marked = false;
}
// Do the fill
Tools.FloodfillFlats(this.Sector.Sector, fillceilings, oldtexturelong, newtextureimage, true);
Tools.FloodfillFlats(this.Sector.Sector, fillceilings, oldtexturelong, newtextureimage, false);
// Get the changed sectors
List<Sector> changes = General.Map.Map.GetMarkedSectors(true);

View file

@ -332,8 +332,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
ImageData newtextureimage = General.Map.Data.GetTextureImage(newtexture);
if(newtextureimage != null)
{
if(mode.IsSingleSelection)
{
// Clear all marks, this will align everything it can
General.Map.Map.ClearMarkedSidedefs(false);
}
else
{
// Limit the alignment to selection only
General.Map.Map.ClearMarkedSidedefs(true);
List<Sidedef> sides = mode.GetSelectedSidedefs();
foreach(Sidedef sd in sides) sd.Marked = false;
}
// Do the alignment
Tools.FloodfillTextures(this.Sidedef, oldtexturelong, newtextureimage, true);
Tools.FloodfillTextures(this.Sidedef, oldtexturelong, newtextureimage, false);
// Get the changed sidedefs
List<Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true);
@ -365,8 +378,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Make sure the texture is loaded (we need the texture size)
if(!base.Texture.IsImageLoaded) base.Texture.LoadImage();
if(mode.IsSingleSelection)
{
// Clear all marks, this will align everything it can
General.Map.Map.ClearMarkedSidedefs(false);
}
else
{
// Limit the alignment to selection only
General.Map.Map.ClearMarkedSidedefs(true);
List<Sidedef> sides = mode.GetSelectedSidedefs();
foreach(Sidedef sd in sides) sd.Marked = false;
}
// Do the alignment
Tools.AutoAlignTextures(this.Sidedef, base.Texture, alignx, aligny, true);
Tools.AutoAlignTextures(this.Sidedef, base.Texture, alignx, aligny, false);
// Get the changed sidedefs
List<Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true);

View file

@ -643,6 +643,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
return linedefs;
}
// This returns all selected sidedefs, no doubles
public List<Sidedef> GetSelectedSidedefs()
{
Dictionary<Sidedef, int> added = new Dictionary<Sidedef, int>();
List<Sidedef> sidedefs = new List<Sidedef>();
foreach(IVisualEventReceiver i in selectedobjects)
{
if(i is BaseVisualGeometrySidedef)
{
Sidedef sd = (i as BaseVisualGeometrySidedef).Sidedef;
if(!added.ContainsKey(sd))
{
sidedefs.Add(sd);
added.Add(sd, 0);
}
}
}
return sidedefs;
}
// This returns all selected things, no doubles
public List<Thing> GetSelectedThings()
{