Added find types to lookup elements by index number

This commit is contained in:
codeimp 2009-03-10 17:22:22 +00:00
parent 114abfa511
commit 5a5fb75ae5
23 changed files with 839 additions and 35 deletions

View file

@ -228,6 +228,13 @@
<ItemGroup>
<EmbeddedResource Include="Resources\HeightsMode.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="FindReplace\FindLinedefNumber.cs" />
<Compile Include="FindReplace\FindSectorNumber.cs" />
<Compile Include="FindReplace\FindSidedefNumber.cs" />
<Compile Include="FindReplace\FindThingNumber.cs" />
<Compile Include="FindReplace\FindVertexNumber.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -0,0 +1,139 @@
#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("Linedef by Number", BrowseButton = false, Replacable = false)]
internal class FindLinedefNumber : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindLinedefNumber()
{
// Initialize
}
// Destructor
~FindLinedefNumber()
{
}
#endregion
#region ================== Methods
// 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 number given
int index = 0;
if(int.TryParse(value, out index))
{
Linedef l = General.Map.Map.GetLinedefByIndex(index);
if(l != null)
{
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
if(!info.IsNull)
objs.Add(new FindReplaceObject(l, "Linedef " + index + " (" + info.Title + ")"));
else
objs.Add(new FindReplaceObject(l, "Linedef " + index));
}
}
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> linedefs = new List<Linedef>(selection.Length);
foreach(FindReplaceObject o in selection) linedefs.Add(o.Linedef);
General.Interface.ShowEditLinedefs(linedefs);
}
#endregion
}
}

View file

@ -31,6 +31,7 @@ using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
#endregion
@ -114,7 +115,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(replacewith != null) l.Action = replaceaction;
// Add to list
objs.Add(new FindReplaceObject(l, "Linedef at " + l.GetCenterPoint().ToString()));
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
if(!info.IsNull)
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex() + " (" + info.Title + ")"));
else
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex()));
}
}
}

View file

@ -43,6 +43,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
private string displayname;
private bool browsebutton;
private bool replacable;
#endregion
@ -50,6 +51,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public string DisplayName { get { return displayname; } set { displayname = value; } }
public bool BrowseButton { get { return browsebutton; } set { browsebutton = value; } }
public bool Replacable { get { return replacable; } set { replacable = value; } }
#endregion
@ -60,6 +62,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Initialize
this.displayname = displayname;
this.replacable = true;
}
#endregion

View file

@ -50,7 +50,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
public object Object { get { return obj; } set { obj = value; } }
public Sector Sector { get { return (Sector)obj; } }
public Linedef Linedef { get { return (Linedef)obj; } }
public Sidedef Sidedef { get { return (Sidedef)obj; } }
public Thing Thing { get { return (Thing)obj; } }
public Vertex Vertex { get { return (Vertex)obj; } }
public string Title { get { return title; } set { title = value; } }
#endregion
@ -87,6 +89,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
points.Add((obj as Linedef).Start.Position);
points.Add((obj as Linedef).End.Position);
}
else if(obj is Sidedef)
{
points.Add((obj as Sidedef).Line.Start.Position);
points.Add((obj as Sidedef).Line.End.Position);
}
else if(obj is Sector)
{
Sector s = (obj as Sector);

View file

@ -0,0 +1,142 @@
#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 by Number", BrowseButton = false, Replacable = false)]
internal class FindSectorNumber : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindSectorNumber()
{
// Initialize
}
// Destructor
~FindSectorNumber()
{
}
#endregion
#region ================== Methods
// 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 number given
int index = 0;
if(int.TryParse(value, out index))
{
Sector s = General.Map.Map.GetSectorByIndex(index);
if(s != null)
{
SectorEffectInfo info = General.Map.Config.GetSectorEffectInfo(s.Effect);
if(!info.IsNull)
objs.Add(new FindReplaceObject(s, "Sector " + index + " (" + info.Title + ")"));
else
objs.Add(new FindReplaceObject(s, "Sector " + index));
}
}
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

@ -31,6 +31,7 @@ using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Config;
#endregion
@ -111,8 +112,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Replace
if(replacewith != null) s.Tag = replacetag;
// Add to list
objs.Add(new FindReplaceObject(s, "Sector " + s.Map.GetIndexForSector(s)));
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()));
}
}
}

View file

@ -0,0 +1,131 @@
#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;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Sidedef by Number", BrowseButton = false, Replacable = false)]
internal class FindSidedefNumber : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindSidedefNumber()
{
// Initialize
}
// Destructor
~FindSidedefNumber()
{
}
#endregion
#region ================== Methods
// 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 number given
int index = 0;
if(int.TryParse(value, out index))
{
Sidedef sd = General.Map.Map.GetSidedefByIndex(index);
if(sd != null) objs.Add(new FindReplaceObject(sd, "Sidedef " + index));
}
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,136 @@
#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 by Number", BrowseButton = false, Replacable = false)]
internal class FindThingNumber : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindThingNumber()
{
// Initialize
}
// Destructor
~FindThingNumber()
{
}
#endregion
#region ================== Methods
// 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 number given
int index = 0;
if(int.TryParse(value, out index))
{
Thing t = General.Map.Map.GetThingByIndex(index);
if(t != null)
{
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
objs.Add(new FindReplaceObject(t, "Thing " + index + " (" + 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

@ -0,0 +1,131 @@
#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;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
[FindReplace("Vertex by Number", BrowseButton = false, Replacable = false)]
internal class FindVertexNumber : FindReplaceType
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public FindVertexNumber()
{
// Initialize
}
// Destructor
~FindVertexNumber()
{
}
#endregion
#region ================== Methods
// 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 number given
int index = 0;
if(int.TryParse(value, out index))
{
Vertex v = General.Map.Map.GetVertexByIndex(index);
if(v != null) objs.Add(new FindReplaceObject(v, "Vertex " + index));
}
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.ShowVertexInfo(selection[0].Vertex);
}
else
General.Interface.HideInfo();
General.Map.Map.ClearAllSelected();
foreach(FindReplaceObject obj in selection) obj.Vertex.Selected = true;
}
// Render selection
public override void PlotSelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
foreach(FindReplaceObject o in selection)
{
renderer.PlotVertex(o.Vertex, ColorCollection.SELECTION);
}
}
// Edit objects
public override void EditObjects(FindReplaceObject[] selection)
{
List<Vertex> vertices = new List<Vertex>(selection.Length);
foreach(FindReplaceObject o in selection) vertices.Add(o.Vertex);
// TODO: General.Interface.ShowEditVertices(vertices);
}
#endregion
}
}

View file

@ -30,7 +30,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
System.Windows.Forms.Label label1;
System.Windows.Forms.Label label2;
System.Windows.Forms.Label label3;
this.replacelabel = new System.Windows.Forms.Label();
this.searchtypes = new System.Windows.Forms.ComboBox();
this.findinput = new System.Windows.Forms.TextBox();
this.browsefind = new System.Windows.Forms.Button();
@ -49,7 +49,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.doreplace = new System.Windows.Forms.CheckBox();
label1 = new System.Windows.Forms.Label();
label2 = new System.Windows.Forms.Label();
label3 = new System.Windows.Forms.Label();
this.resultspanel.SuspendLayout();
this.groupreplace.SuspendLayout();
this.SuspendLayout();
@ -72,14 +71,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
label2.TabIndex = 2;
label2.Text = "Find what:";
//
// label3
// replacelabel
//
label3.AutoSize = true;
label3.Location = new System.Drawing.Point(12, 28);
label3.Name = "label3";
label3.Size = new System.Drawing.Size(73, 14);
label3.TabIndex = 6;
label3.Text = "Replace with:";
this.replacelabel.AutoSize = true;
this.replacelabel.Location = new System.Drawing.Point(12, 28);
this.replacelabel.Name = "replacelabel";
this.replacelabel.Size = new System.Drawing.Size(73, 14);
this.replacelabel.TabIndex = 6;
this.replacelabel.Text = "Replace with:";
//
// searchtypes
//
@ -233,7 +232,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.groupreplace.Controls.Add(this.keepselection);
this.groupreplace.Controls.Add(this.replaceinput);
this.groupreplace.Controls.Add(this.browsereplace);
this.groupreplace.Controls.Add(label3);
this.groupreplace.Controls.Add(this.replacelabel);
this.groupreplace.Enabled = false;
this.groupreplace.Location = new System.Drawing.Point(9, 108);
this.groupreplace.Name = "groupreplace";
@ -312,5 +311,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
private System.Windows.Forms.CheckBox doreplace;
private System.Windows.Forms.Button editbutton;
private System.Windows.Forms.Button deletebutton;
private System.Windows.Forms.Label replacelabel;
}
}

View file

@ -132,8 +132,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Now setup the interface
browsefind.Enabled = newfinder.Attributes.BrowseButton;
browsereplace.Enabled = newfinder.Attributes.BrowseButton;
if(!newfinder.Attributes.Replacable) doreplace.Checked = false;
doreplace.Enabled = newfinder.Attributes.Replacable;
}
// Browse find button clicked
private void browsefind_Click(object sender, EventArgs e)
{

View file

@ -129,12 +129,9 @@
<metadata name="label2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label3.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="replacelabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="label3.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="searchtypes.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View file

@ -556,7 +556,7 @@ namespace CodeImp.DoomBuilder.Config
CultureInfo.InvariantCulture, out actionnumber))
{
// Make effects
si = new SectorEffectInfo(actionnumber, de.Value.ToString());
si = new SectorEffectInfo(actionnumber, de.Value.ToString(), true, false);
// Add action to category and sorted list
sortedsectoreffects.Add(si);
@ -778,6 +778,46 @@ namespace CodeImp.DoomBuilder.Config
return cfg.SettingExists("editingmodes." + classname.ToString(CultureInfo.InvariantCulture));
}
// This returns information on a linedef type
public LinedefActionInfo GetLinedefActionInfo(int action)
{
// Known type?
if(linedefactions.ContainsKey(action))
{
return linedefactions[action];
}
else if(action == 0)
{
return new LinedefActionInfo(0, "None", true, false);
}
else if(IsGeneralized(action, genactioncategories))
{
return new LinedefActionInfo(action, "Generalized (" + GetGeneralizedActionCategory(action) + ")", true, true);
}
else
{
return new LinedefActionInfo(action, "Unknown", false, false);
}
}
// This returns information on a sector effect
public SectorEffectInfo GetSectorEffectInfo(int effect)
{
// Known type?
if(sectoreffects.ContainsKey(effect))
{
return sectoreffects[effect];
}
else if(effect == 0)
{
return new SectorEffectInfo(0, "None", true, false);
}
else
{
return new SectorEffectInfo(effect, "Unknown", false, false);
}
}
#endregion
}
}

View file

@ -47,6 +47,8 @@ namespace CodeImp.DoomBuilder.Config
private string name;
private string title;
private ArgumentInfo[] args;
private bool isgeneralized;
private bool isknown;
#endregion
@ -57,6 +59,9 @@ namespace CodeImp.DoomBuilder.Config
public string Category { get { return category; } }
public string Name { get { return name; } }
public string Title { get { return title; } }
public bool IsGeneralized { get { return isgeneralized; } }
public bool IsKnown { get { return isknown; } }
public bool IsNull { get { return (index == 0); } }
public ArgumentInfo[] Args { get { return args; } }
#endregion
@ -72,6 +77,8 @@ namespace CodeImp.DoomBuilder.Config
this.index = index;
this.category = categoryname;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
this.isgeneralized = false;
this.isknown = true;
// Read settings
this.name = cfg.ReadSetting(actionsetting + ".title", "Unnamed");
@ -86,6 +93,15 @@ namespace CodeImp.DoomBuilder.Config
// We have no destructor
GC.SuppressFinalize(this);
}
// Constructor for generalized type display
internal LinedefActionInfo(int index, string title, bool isknown, bool isgeneralized)
{
this.index = index;
this.isgeneralized = isgeneralized;
this.isknown = isknown;
this.title = title;
}
#endregion

View file

@ -43,6 +43,8 @@ namespace CodeImp.DoomBuilder.Config
// Properties
private int index;
private string title;
private bool isknown;
private bool isgeneralized;
#endregion
@ -50,18 +52,23 @@ namespace CodeImp.DoomBuilder.Config
public int Index { get { return index; } }
public string Title { get { return title; } }
public bool IsGeneralized { get { return isgeneralized; } }
public bool IsKnown { get { return isknown; } }
public bool IsNull { get { return (index == 0); } }
#endregion
#region ================== Constructor / Disposer
// Constructor
internal SectorEffectInfo(int index, string title)
internal SectorEffectInfo(int index, string title, bool isknown, bool isgeneralized)
{
// Initialize
this.index = index;
this.title = title;
this.isknown = isknown;
this.isgeneralized = isgeneralized;
// We have no destructor
GC.SuppressFinalize(this);
}

View file

@ -63,6 +63,7 @@ namespace CodeImp.DoomBuilder.Config
private bool fixedsize;
private ThingCategory category;
private ArgumentInfo[] args;
private bool isknown;
#endregion
@ -82,6 +83,8 @@ namespace CodeImp.DoomBuilder.Config
public bool FixedSize { get { return fixedsize; } }
public ThingCategory Category { get { return category; } }
public ArgumentInfo[] Args { get { return args; } }
public bool IsKnown { get { return isknown; } }
public bool IsNull { get { return (index == 0); } }
#endregion
@ -105,6 +108,7 @@ namespace CodeImp.DoomBuilder.Config
this.fixedsize = false;
this.spritelongname = long.MaxValue;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
this.isknown = false;
// We have no destructor
GC.SuppressFinalize(this);
@ -119,6 +123,7 @@ namespace CodeImp.DoomBuilder.Config
this.index = index;
this.category = cat;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
this.isknown = true;
// Read properties
this.title = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".title", "<" + key + ">");
@ -158,6 +163,7 @@ namespace CodeImp.DoomBuilder.Config
this.index = index;
this.category = cat;
this.title = title;
this.isknown = true;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i);
@ -192,6 +198,7 @@ namespace CodeImp.DoomBuilder.Config
this.index = actor.DoomEdNum;
this.category = cat;
this.title = "Unnamed";
this.isknown = true;
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i);

View file

@ -53,7 +53,6 @@ namespace CodeImp.DoomBuilder.Controls
// This shows the info
public void ShowInfo(Linedef l)
{
string actioninfo = "";
LinedefActionInfo act = null;
TypeHandler th;
bool upperunpegged, lowerunpegged;
@ -94,17 +93,7 @@ namespace CodeImp.DoomBuilder.Controls
backpanel.Left = frontpanel.Left + frontpanel.Width + frontpanel.Margin.Right + backpanel.Margin.Left;
// Get line action information
if(General.Map.Config.LinedefActions.ContainsKey(l.Action))
{
act = General.Map.Config.LinedefActions[l.Action];
actioninfo = act.ToString();
}
else if(l.Action == 0)
actioninfo = l.Action.ToString() + " - None";
else if(GameConfiguration.IsGeneralized(l.Action, General.Map.Config.GenActionCategories))
actioninfo = l.Action.ToString() + " - Generalized (" + General.Map.Config.GetGeneralizedActionCategory(l.Action) + ")";
else
actioninfo = l.Action.ToString() + " - Unknown";
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
// Determine peggedness
upperunpegged = l.IsFlagSet(General.Map.Config.UpperUnpeggedFlag);
@ -120,7 +109,7 @@ namespace CodeImp.DoomBuilder.Controls
// Linedef info
infopanel.Text = " Lindedef " + l.Map.GetIndexForLinedef(l) + " ";
action.Text = actioninfo;
action.Text = info.ToString();
length.Text = l.Length.ToString("0.##");
angle.Text = l.AngleDeg.ToString() + "\u00B0";
tag.Text = l.Tag.ToString();

View file

@ -219,6 +219,14 @@ namespace CodeImp.DoomBuilder.Map
for(int i = 0; i < NUM_ARGS; i++) s.rwInt(ref args[i]);
}
/// <summary>
/// Returns the index of this linedef. This is a O(n) operation.
/// </summary>
public int GetIndex()
{
return map.GetIndexForLinedef(this);
}
// This sets new start vertex
public void SetStartVertex(Vertex v)
{

View file

@ -258,6 +258,14 @@ namespace CodeImp.DoomBuilder.Map
s.updateneeded = true;
base.CopyPropertiesTo(s);
}
/// <summary>
/// Returns the index of this sector. This is a O(n) operation.
/// </summary>
public int GetIndex()
{
return map.GetIndexForSector(this);
}
// This attaches a sidedef and returns the listitem
public LinkedListNode<Sidedef> AttachSidedef(Sidedef sd)

View file

@ -201,6 +201,15 @@ namespace CodeImp.DoomBuilder.Map
s.longtexnamelow = longtexnamelow;
base.CopyPropertiesTo(s);
}
/// <summary>
/// Returns the index of this sidedef. This is a O(n) operation.
/// </summary>
public int GetIndex()
{
return map.GetIndexForSidedef(this);
}
// This copies textures to another sidedef
// And possibly also the offsets
@ -258,7 +267,7 @@ namespace CodeImp.DoomBuilder.Map
#endregion
#region ================== Methods
// This removes textures that are not required
public void RemoveUnneededTextures(bool removemiddle)
{

View file

@ -184,6 +184,14 @@ namespace CodeImp.DoomBuilder.Map
t.fixedsize = fixedsize;
base.CopyPropertiesTo(t);
}
/// <summary>
/// Returns the index of the specified thing. This is a O(n) operation.
/// </summary>
public int GetIndex()
{
return map.GetIndexForThing(this);
}
// This determines which sector the thing is in and links it
public void DetermineSector()

View file

@ -162,6 +162,14 @@ namespace CodeImp.DoomBuilder.Map
#region ================== Methods
/// <summary>
/// Returns the index of this vertex. This is a O(n) operation.
/// </summary>
public int GetIndex()
{
return map.GetIndexForVertex(this);
}
// This copies all properties to another thing
public void CopyPropertiesTo(Vertex v)
{