UltimateZoneBuilder/Source/Plugins/BuilderModes/FindReplace/FindSectorFloorHeight.cs
MaxED 6c1dbc0bf3 Find and Replace mode:
"Find Any Texture or Flat", "Find Sector Flat" and "Find Sidedef Texture" options now support "*" (match any number of characters) and "?" (match any single character) wildcards.
"Find Any Texture or Flat" is now available any game configuration (previously it was disabled when "MixTexturesFlats" game configuration option was disabled, now only "Replace" functionality is disabled).
"Find Thing Flags" and "Find Linedef Flags" can now replace flags.
Added "Find Sidedef Flags" and "Find Sector Flags" search options.
2014-11-05 12:32:48 +00:00

62 lines
1.8 KiB
C#

#region ================== Namespaces
using System.Collections.Generic;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Map;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.FindReplace
{
[FindReplace("Sector Floor Height", BrowseButton = false)]
internal class FindSectorFloorHeight : BaseFindSector
{
#region ================== Methods
// 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, bool replace, string replacewith, bool keepselection) {
List<FindReplaceObject> objs = new List<FindReplaceObject>();
// Interpret the replacement
int replaceheight = 0;
if(replace) {
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(!int.TryParse(replacewith, out replaceheight)) 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 height;
if(int.TryParse(value, out height)) {
// Where to search?
ICollection<Sector> list = withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors;
// Go for all sectors
foreach(Sector s in list) {
// Height matches?
if(s.FloorHeight == height) {
// Replace
if(replace) s.FloorHeight = replaceheight;
objs.Add(new FindReplaceObject(s, "Sector " + s.Index));
}
}
}
//refresh map
if(replace) {
General.Map.Map.Update();
General.Map.IsChanged = true;
}
return objs.ToArray();
}
#endregion
}
}