Added some find/replace types

This commit is contained in:
codeimp 2009-03-11 16:17:04 +00:00
parent db3f23317f
commit a4987007d0
18 changed files with 1268 additions and 13 deletions

View file

@ -230,10 +230,17 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="FindReplace\FindLinedefNumber.cs" /> <Compile Include="FindReplace\FindLinedefNumber.cs" />
<Compile Include="FindReplace\FindLinedefSectorRef.cs" />
<Compile Include="FindReplace\FindLinedefTags.cs" /> <Compile Include="FindReplace\FindLinedefTags.cs" />
<Compile Include="FindReplace\FindSectorEffect.cs" />
<Compile Include="FindReplace\FindSectorFlat.cs" />
<Compile Include="FindReplace\FindSidedefTexture.cs" />
<Compile Include="FindReplace\FindLinedefThingRef.cs" />
<Compile Include="FindReplace\FindSectorNumber.cs" /> <Compile Include="FindReplace\FindSectorNumber.cs" />
<Compile Include="FindReplace\FindSidedefNumber.cs" /> <Compile Include="FindReplace\FindSidedefNumber.cs" />
<Compile Include="FindReplace\FindThingAction.cs" />
<Compile Include="FindReplace\FindThingNumber.cs" /> <Compile Include="FindReplace\FindThingNumber.cs" />
<Compile Include="FindReplace\FindThingType.cs" />
<Compile Include="FindReplace\FindVertexNumber.cs" /> <Compile Include="FindReplace\FindVertexNumber.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
[FindReplace("Linedef by Number", BrowseButton = false, Replacable = false)] [FindReplace("Linedef Index", BrowseButton = false, Replacable = false)]
internal class FindLinedefNumber : FindReplaceType internal class FindLinedefNumber : FindReplaceType
{ {
#region ================== Constants #region ================== Constants

View file

@ -0,0 +1,187 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Types;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Linedef Sector Reference", BrowseButton = false)]
internal class FindLinedefSectorRef : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindLinedefSectorRef()
{
// Initialize
}
// Destructor
~FindLinedefSectorRef()
{
}
#endregion
#region ================== Methods
// This is called to test if the item should be displayed
public override bool DetermineVisiblity()
{
return (General.Map.FormatInterface.GetType().Name == "HexenMapSetIO") ||
(General.Map.FormatInterface.GetType().Name == "UniversalMapSetIO");
}
// This is called when the browse button is pressed
public override string Browse(string initialvalue)
{
return "";
}
// This is called to perform a search (and replace)
// Returns a list of items to show in the results list
// replacewith is null when not replacing
public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
{
List<FindReplaceObject> objs = new List<FindReplaceObject>();
// Interpret the replacement
int replacetag = 0;
if(replacewith != null)
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(!int.TryParse(replacewith, out replacetag)) replacewith = null;
if(replacetag < 0) replacewith = null;
if(replacetag > 255) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the number given
int tag = 0;
if(int.TryParse(value, out tag))
{
// Go for all linedefs
foreach(Linedef l in General.Map.Map.Linedefs)
{
bool addline = false;
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
if(info.IsKnown && !info.IsNull)
{
// Go for all args
for(int i = 0; i < Linedef.NUM_ARGS; i++)
{
// Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.SectorTag))
{
if(l.Args[i] == tag)
{
// Replace
if(replacewith != null) l.Args[i] = replacetag;
addline = true;
}
}
}
}
if(addline)
{
// Add to list
if(!info.IsNull)
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex() + " (" + info.Title + ")"));
else
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex()));
}
}
}
return objs.ToArray();
}
// This is called when a specific object is selected from the list
public override void ObjectSelected(FindReplaceObject[] selection)
{
if(selection.Length == 1)
{
ZoomToSelection(selection);
General.Interface.ShowLinedefInfo(selection[0].Linedef);
}
else
General.Interface.HideInfo();
General.Map.Map.ClearAllSelected();
foreach(FindReplaceObject obj in selection) obj.Linedef.Selected = true;
}
// Render selection
public override void PlotSelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
foreach(FindReplaceObject o in selection)
{
renderer.PlotLinedef(o.Linedef, General.Colors.Selection);
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Linedef> lines = new List<Linedef>(selection.Length);
foreach(FindReplaceObject o in selection) lines.Add(o.Linedef);
General.Interface.ShowEditLinedefs(lines);
}
#endregion
}
}

View file

@ -70,6 +70,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods #region ================== Methods
// This is called to test if the item should be displayed
public override bool DetermineVisiblity()
{
return (General.Map.FormatInterface.GetType().Name == "DoomMapSetIO") ||
(General.Map.FormatInterface.GetType().Name == "UniversalMapSetIO");
}
// This is called when the browse button is pressed // This is called when the browse button is pressed
public override string Browse(string initialvalue) public override string Browse(string initialvalue)
{ {

View file

@ -0,0 +1,187 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Types;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Linedef Thing Reference", BrowseButton = false)]
internal class FindLinedefThingRef : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindLinedefThingRef()
{
// Initialize
}
// Destructor
~FindLinedefThingRef()
{
}
#endregion
#region ================== Methods
// This is called to test if the item should be displayed
public override bool DetermineVisiblity()
{
return (General.Map.FormatInterface.GetType().Name == "HexenMapSetIO") ||
(General.Map.FormatInterface.GetType().Name == "UniversalMapSetIO");
}
// This is called when the browse button is pressed
public override string Browse(string initialvalue)
{
return "";
}
// This is called to perform a search (and replace)
// Returns a list of items to show in the results list
// replacewith is null when not replacing
public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
{
List<FindReplaceObject> objs = new List<FindReplaceObject>();
// Interpret the replacement
int replacetag = 0;
if(replacewith != null)
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(!int.TryParse(replacewith, out replacetag)) replacewith = null;
if(replacetag < 0) replacewith = null;
if(replacetag > 255) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the number given
int tag = 0;
if(int.TryParse(value, out tag))
{
// Go for all linedefs
foreach(Linedef l in General.Map.Map.Linedefs)
{
bool addline = false;
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
if(info.IsKnown && !info.IsNull)
{
// Go for all args
for(int i = 0; i < Linedef.NUM_ARGS; i++)
{
// Argument type matches?
if(info.Args[i].Used && (info.Args[i].Type == (int)UniversalType.ThingTag))
{
if(l.Args[i] == tag)
{
// Replace
if(replacewith != null) l.Args[i] = replacetag;
addline = true;
}
}
}
}
if(addline)
{
// Add to list
if(!info.IsNull)
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex() + " (" + info.Title + ")"));
else
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex()));
}
}
}
return objs.ToArray();
}
// This is called when a specific object is selected from the list
public override void ObjectSelected(FindReplaceObject[] selection)
{
if(selection.Length == 1)
{
ZoomToSelection(selection);
General.Interface.ShowLinedefInfo(selection[0].Linedef);
}
else
General.Interface.HideInfo();
General.Map.Map.ClearAllSelected();
foreach(FindReplaceObject obj in selection) obj.Linedef.Selected = true;
}
// Render selection
public override void PlotSelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
foreach(FindReplaceObject o in selection)
{
renderer.PlotLinedef(o.Linedef, General.Colors.Selection);
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Linedef> lines = new List<Linedef>(selection.Length);
foreach(FindReplaceObject o in selection) lines.Add(o.Linedef);
General.Interface.ShowEditLinedefs(lines);
}
#endregion
}
}

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
[FindReplace("Linedef Types", BrowseButton = true)] [FindReplace("Linedef Actions", BrowseButton = true)]
internal class FindLinedefTypes : FindReplaceType internal class FindLinedefTypes : FindReplaceType
{ {
#region ================== Constants #region ================== Constants

View file

@ -74,6 +74,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods #region ================== Methods
// This is called to test if the item should be displayed
public virtual bool DetermineVisiblity()
{
return true;
}
// This is called when the browse button is pressed // This is called when the browse button is pressed
public virtual string Browse(string initialvalue) public virtual string Browse(string initialvalue)
{ {

View file

@ -0,0 +1,167 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Sector Effect", BrowseButton = true)]
internal class FindSectorEffect : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindSectorEffect()
{
// Initialize
}
// Destructor
~FindSectorEffect()
{
}
#endregion
#region ================== Methods
// This is called when the browse button is pressed
public override string Browse(string initialvalue)
{
int effect;
int.TryParse(initialvalue, out effect);
effect = General.Interface.BrowseSectorEffect(BuilderPlug.Me.FindReplaceForm, effect);
return effect.ToString();
}
// This is called to perform a search (and replace)
// Returns a list of items to show in the results list
// replacewith is null when not replacing
public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
{
List<FindReplaceObject> objs = new List<FindReplaceObject>();
// Interpret the replacement
int replaceeffect = 0;
if(replacewith != null)
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(!int.TryParse(replacewith, out replaceeffect)) replacewith = null;
if(replaceeffect < 0) replacewith = null;
if(replaceeffect > Int16.MaxValue) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the number given
int effect = 0;
if(int.TryParse(value, out effect))
{
// Go for all sectors
foreach(Sector s in General.Map.Map.Sectors)
{
// Tag matches?
if(s.Effect == effect)
{
// Replace
if(replacewith != null) s.Effect = replaceeffect;
SectorEffectInfo info = General.Map.Config.GetSectorEffectInfo(s.Effect);
if(!info.IsNull)
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (" + info.Title + ")"));
else
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex()));
}
}
}
return objs.ToArray();
}
// This is called when a specific object is selected from the list
public override void ObjectSelected(FindReplaceObject[] selection)
{
if(selection.Length == 1)
{
ZoomToSelection(selection);
General.Interface.ShowSectorInfo(selection[0].Sector);
}
else
General.Interface.HideInfo();
General.Map.Map.ClearAllSelected();
foreach(FindReplaceObject obj in selection) obj.Sector.Selected = true;
}
// Render selection
public override void PlotSelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
foreach(FindReplaceObject o in selection)
{
foreach(Sidedef sd in o.Sector.Sidedefs)
{
renderer.PlotLinedef(sd.Line, General.Colors.Selection);
}
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Sector> sectors = new List<Sector>(selection.Length);
foreach(FindReplaceObject o in selection) sectors.Add(o.Sector);
General.Interface.ShowEditSectors(sectors);
}
#endregion
}
}

View file

@ -0,0 +1,165 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Sector Flat", BrowseButton = true)]
internal class FindSectorFlat : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindSectorFlat()
{
// Initialize
}
// Destructor
~FindSectorFlat()
{
}
#endregion
#region ================== Methods
// This is called when the browse button is pressed
public override string Browse(string initialvalue)
{
return General.Interface.BrowseFlat(BuilderPlug.Me.FindReplaceForm, initialvalue);
}
// This is called to perform a search (and replace)
// Returns a list of items to show in the results list
// replacewith is null when not replacing
public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
{
List<FindReplaceObject> objs = new List<FindReplaceObject>();
// Interpret the replacement
if(replacewith != null)
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(replacewith.Length < 0) replacewith = null;
if(replacewith.Length > 8) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the find
long longfind = Lump.MakeLongName(value.Trim());
// Go for all sectors
foreach(Sector s in General.Map.Map.Sectors)
{
// Flat matches?
if(s.LongCeilTexture == longfind)
{
// Replace and add to list
if(replacewith != null) s.SetCeilTexture(replacewith);
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (ceiling)"));
}
if(s.LongFloorTexture == longfind)
{
// Replace and add to list
if(replacewith != null) s.SetFloorTexture(replacewith);
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (floor)"));
}
}
// When replacing, make sure we keep track of used textures
if(replacewith != null) General.Map.Data.UpdateUsedTextures();
return objs.ToArray();
}
// This is called when a specific object is selected from the list
public override void ObjectSelected(FindReplaceObject[] selection)
{
if(selection.Length == 1)
{
ZoomToSelection(selection);
General.Interface.ShowSectorInfo(selection[0].Sector);
}
else
General.Interface.HideInfo();
General.Map.Map.ClearAllSelected();
foreach(FindReplaceObject obj in selection) obj.Sector.Selected = true;
}
// Render selection
public override void PlotSelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
foreach(FindReplaceObject o in selection)
{
foreach(Sidedef sd in o.Sector.Sidedefs)
{
renderer.PlotLinedef(sd.Line, General.Colors.Selection);
}
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Sector> sectors = new List<Sector>(selection.Length);
foreach(FindReplaceObject o in selection) sectors.Add(o.Sector);
General.Interface.ShowEditSectors(sectors);
}
#endregion
}
}

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
[FindReplace("Sector by Number", BrowseButton = false, Replacable = false)] [FindReplace("Sector Index", BrowseButton = false, Replacable = false)]
internal class FindSectorNumber : FindReplaceType internal class FindSectorNumber : FindReplaceType
{ {
#region ================== Constants #region ================== Constants

View file

@ -36,7 +36,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
[FindReplace("Sidedef by Number", BrowseButton = false, Replacable = false)] [FindReplace("Sidedef Index", BrowseButton = false, Replacable = false)]
internal class FindSidedefNumber : FindReplaceType internal class FindSidedefNumber : FindReplaceType
{ {
#region ================== Constants #region ================== Constants

View file

@ -0,0 +1,170 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Sidedef Texture", BrowseButton = true)]
internal class FindSidedefTexture : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindSidedefTexture()
{
// Initialize
}
// Destructor
~FindSidedefTexture()
{
}
#endregion
#region ================== Methods
// This is called when the browse button is pressed
public override string Browse(string initialvalue)
{
return General.Interface.BrowseTexture(BuilderPlug.Me.FindReplaceForm, initialvalue);
}
// This is called to perform a search (and replace)
// Returns a list of items to show in the results list
// replacewith is null when not replacing
public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
{
List<FindReplaceObject> objs = new List<FindReplaceObject>();
// Interpret the replacement
if(replacewith != null)
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(replacewith.Length < 0) replacewith = null;
if(replacewith.Length > 8) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the find
long longfind = Lump.MakeLongName(value.Trim());
// Go for all sidedefs
foreach(Sidedef sd in General.Map.Map.Sidedefs)
{
string side = sd.IsFront ? "front" : "back";
if(sd.LongHighTexture == longfind)
{
// Replace and add to list
if(replacewith != null) sd.SetTextureHigh(replacewith);
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", high)"));
}
if(sd.LongMiddleTexture == longfind)
{
// Replace and add to list
if(replacewith != null) sd.SetTextureMid(replacewith);
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", middle)"));
}
if(sd.LongLowTexture == longfind)
{
// Replace and add to list
if(replacewith != null) sd.SetTextureLow(replacewith);
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", low)"));
}
}
// When replacing, make sure we keep track of used textures
if(replacewith != null) General.Map.Data.UpdateUsedTextures();
return objs.ToArray();
}
// This is called when a specific object is selected from the list
public override void ObjectSelected(FindReplaceObject[] selection)
{
if(selection.Length == 1)
{
ZoomToSelection(selection);
General.Interface.ShowLinedefInfo(selection[0].Sidedef.Line);
}
else
General.Interface.HideInfo();
General.Map.Map.ClearAllSelected();
foreach(FindReplaceObject obj in selection) obj.Sidedef.Line.Selected = true;
}
// Render selection
public override void PlotSelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
foreach(FindReplaceObject o in selection)
{
renderer.PlotLinedef(o.Sidedef.Line, General.Colors.Selection);
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Linedef> linedefs = new List<Linedef>(selection.Length);
foreach(FindReplaceObject o in selection) linedefs.Add(o.Sidedef.Line);
General.Interface.ShowEditLinedefs(linedefs);
}
#endregion
}
}

View file

@ -0,0 +1,170 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Thing Action", BrowseButton = true)]
internal class FindThingAction : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindThingAction()
{
// Initialize
}
// Destructor
~FindThingAction()
{
}
#endregion
#region ================== Methods
// This is called to test if the item should be displayed
public override bool DetermineVisiblity()
{
return (General.Map.FormatInterface.GetType().Name == "HexenMapSetIO") ||
(General.Map.FormatInterface.GetType().Name == "UniversalMapSetIO");
}
// This is called when the browse button is pressed
public override string Browse(string initialvalue)
{
int action;
int.TryParse(initialvalue, out action);
action = General.Interface.BrowseLinedefActions(BuilderPlug.Me.FindReplaceForm, action);
return action.ToString();
}
// This is called to perform a search (and replace)
// Returns a list of items to show in the results list
// replacewith is null when not replacing
public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
{
List<FindReplaceObject> objs = new List<FindReplaceObject>();
// Interpret the replacement
int replaceaction = 0;
if(replacewith != null)
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(!int.TryParse(replacewith, out replaceaction)) replacewith = null;
if(replaceaction < 0) replacewith = null;
if(replaceaction > Int16.MaxValue) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the number given
int findaction = 0;
if(int.TryParse(value, out findaction))
{
// Go for all things
foreach(Thing t in General.Map.Map.Things)
{
// Match?
if(t.Action == findaction)
{
// Replace
if(replacewith != null) t.Action = findaction;
// Add to list
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
objs.Add(new FindReplaceObject(t, "Thing " + t.GetIndex() + " (" + ti.Title + ")"));
}
}
}
return objs.ToArray();
}
// This is called when a specific object is selected from the list
public override void ObjectSelected(FindReplaceObject[] selection)
{
if(selection.Length == 1)
{
ZoomToSelection(selection);
General.Interface.ShowThingInfo(selection[0].Thing);
}
else
General.Interface.HideInfo();
General.Map.Map.ClearAllSelected();
foreach(FindReplaceObject obj in selection) obj.Thing.Selected = true;
}
// Render selection
public override void RenderThingsSelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
foreach(FindReplaceObject o in selection)
{
renderer.RenderThing(o.Thing, General.Colors.Selection, 1.0f);
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Thing> things = new List<Thing>(selection.Length);
foreach(FindReplaceObject o in selection) things.Add(o.Thing);
General.Interface.ShowEditThings(things);
}
#endregion
}
}

View file

@ -37,7 +37,7 @@ using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
[FindReplace("Thing by Number", BrowseButton = false, Replacable = false)] [FindReplace("Thing Index", BrowseButton = false, Replacable = false)]
internal class FindThingNumber : FindReplaceType internal class FindThingNumber : FindReplaceType
{ {
#region ================== Constants #region ================== Constants

View file

@ -0,0 +1,166 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Thing Type", BrowseButton = true)]
internal class FindThingType : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindThingType()
{
// Initialize
}
// Destructor
~FindThingType()
{
}
#endregion
#region ================== Methods
// This is called when the browse button is pressed
public override string Browse(string initialvalue)
{
int type;
int.TryParse(initialvalue, out type);
//TODO: type = General.Interface.BrowseThingType(BuilderPlug.Me.FindReplaceForm, type);
return type.ToString();
}
// This is called to perform a search (and replace)
// Returns a list of items to show in the results list
// replacewith is null when not replacing
public override FindReplaceObject[] Find(string value, bool withinselection, string replacewith, bool keepselection)
{
List<FindReplaceObject> objs = new List<FindReplaceObject>();
// Interpret the replacement
int replacetype = 0;
if(replacewith != null)
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(!int.TryParse(replacewith, out replacetype)) replacewith = null;
if(replacetype < 0) replacewith = null;
if(replacetype > Int16.MaxValue) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the number given
int findtype = 0;
if(int.TryParse(value, out findtype))
{
// Go for all things
foreach(Thing t in General.Map.Map.Things)
{
// Match?
if(t.Type == findtype)
{
// Replace
if(replacewith != null)
{
t.Type = replacetype;
t.UpdateConfiguration();
}
// Add to list
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
objs.Add(new FindReplaceObject(t, "Thing " + t.GetIndex() + " (" + ti.Title + ")"));
}
}
}
return objs.ToArray();
}
// This is called when a specific object is selected from the list
public override void ObjectSelected(FindReplaceObject[] selection)
{
if(selection.Length == 1)
{
ZoomToSelection(selection);
General.Interface.ShowThingInfo(selection[0].Thing);
}
else
General.Interface.HideInfo();
General.Map.Map.ClearAllSelected();
foreach(FindReplaceObject obj in selection) obj.Thing.Selected = true;
}
// Render selection
public override void RenderThingsSelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
foreach(FindReplaceObject o in selection)
{
renderer.RenderThing(o.Thing, General.Colors.Selection, 1.0f);
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Thing> things = new List<Thing>(selection.Length);
foreach(FindReplaceObject o in selection) things.Add(o.Thing);
General.Interface.ShowEditThings(things);
}
#endregion
}
}

View file

@ -36,7 +36,7 @@ using CodeImp.DoomBuilder.Editing;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
[FindReplace("Vertex by Number", BrowseButton = false, Replacable = false)] [FindReplace("Vertex Index", BrowseButton = false, Replacable = false)]
internal class FindVertexNumber : FindReplaceType internal class FindVertexNumber : FindReplaceType
{ {
#region ================== Constants #region ================== Constants

View file

@ -87,6 +87,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.searchtypes.Location = new System.Drawing.Point(100, 12); this.searchtypes.Location = new System.Drawing.Point(100, 12);
this.searchtypes.Name = "searchtypes"; this.searchtypes.Name = "searchtypes";
this.searchtypes.Size = new System.Drawing.Size(139, 22); this.searchtypes.Size = new System.Drawing.Size(139, 22);
this.searchtypes.Sorted = true;
this.searchtypes.TabIndex = 1; this.searchtypes.TabIndex = 1;
this.searchtypes.SelectedIndexChanged += new System.EventHandler(this.searchtypes_SelectedIndexChanged); this.searchtypes.SelectedIndexChanged += new System.EventHandler(this.searchtypes_SelectedIndexChanged);
// //

View file

@ -47,6 +47,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
private FindReplaceType newfinder; private FindReplaceType newfinder;
private FindReplaceType finder; private FindReplaceType finder;
private List<FindReplaceType> findtypeslist;
bool controlpressed = false; bool controlpressed = false;
bool shiftpressed = false; bool shiftpressed = false;
bool suppressevents = false; bool suppressevents = false;
@ -69,6 +70,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Find all find/replace types // Find all find/replace types
Type[] findtypes = BuilderPlug.Me.FindClasses(typeof(FindReplaceType)); Type[] findtypes = BuilderPlug.Me.FindClasses(typeof(FindReplaceType));
findtypeslist = new List<FindReplaceType>(findtypes.Length);
foreach(Type t in findtypes) foreach(Type t in findtypes)
{ {
FindReplaceType finderinst; FindReplaceType finderinst;
@ -96,12 +98,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// Add the finder to the list // Add the finder to the list
searchtypes.Items.Add(finderinst); findtypeslist.Add(finderinst);
} }
} }
// Select first
searchtypes.SelectedIndex = 0;
} }
#endregion #endregion
@ -344,6 +343,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.Location = new Point(owner.Location.X + 20, owner.Location.Y + 90); this.Location = new Point(owner.Location.X + 20, owner.Location.Y + 90);
} }
// Re-fill the search types list
searchtypes.Items.Clear();
foreach(FindReplaceType t in findtypeslist)
{
// Check if it should be visible
if(t.DetermineVisiblity())
{
searchtypes.Items.Add(t);
}
}
// Select previously selected item
for(int i = 0; i < searchtypes.Items.Count; i++)
{
if(searchtypes.Items[i] == newfinder)
searchtypes.SelectedIndex = i;
}
// Select first if none was selected
if(searchtypes.SelectedIndex < 0)
searchtypes.SelectedIndex = 0;
// Close results part // Close results part
resultspanel.Visible = false; resultspanel.Visible = false;
this.Size = new Size(this.Width, this.Height - this.ClientSize.Height + resultspanel.Top); this.Size = new Size(this.Width, this.Height - this.ClientSize.Height + resultspanel.Top);