mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-17 01:22:18 +00:00
Updated to Doom Builder 2 r1599:
Find and Replace Mode: can now find things and linedefs by their flags
This commit is contained in:
parent
89fad3ee65
commit
e308d2ff15
7 changed files with 677 additions and 0 deletions
|
@ -740,6 +740,12 @@
|
|||
<DependentUpon>ErrorsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\FindReplaceOptions.cs" />
|
||||
<Compile Include="Windows\FlagsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Windows\FlagsForm.Designer.cs">
|
||||
<DependentUpon>FlagsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\MenuSection.cs" />
|
||||
<Compile Include="Windows\PasteOptionsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
@ -924,6 +930,9 @@
|
|||
<SubType>Designer</SubType>
|
||||
<DependentUpon>ErrorsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\FlagsForm.resx">
|
||||
<DependentUpon>FlagsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\PasteOptionsForm.resx">
|
||||
<DependentUpon>PasteOptionsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
113
Source/Core/Windows/FlagsForm.Designer.cs
generated
Normal file
113
Source/Core/Windows/FlagsForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,113 @@
|
|||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
partial class FlagsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Erforderliche Designervariable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Verwendete Ressourcen bereinigen.
|
||||
/// </summary>
|
||||
/// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Vom Windows Form-Designer generierter Code
|
||||
|
||||
/// <summary>
|
||||
/// Erforderliche Methode für die Designerunterstützung.
|
||||
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.flags = new CodeImp.DoomBuilder.Controls.CheckboxArrayControl();
|
||||
this.cancel = new System.Windows.Forms.Button();
|
||||
this.apply = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// flags
|
||||
//
|
||||
this.flags.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.flags.AutoScroll = true;
|
||||
this.flags.Columns = 3;
|
||||
this.flags.Location = new System.Drawing.Point(6, 19);
|
||||
this.flags.Name = "flags";
|
||||
this.flags.Size = new System.Drawing.Size(418, 195);
|
||||
this.flags.TabIndex = 0;
|
||||
//
|
||||
// cancel
|
||||
//
|
||||
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancel.Location = new System.Drawing.Point(351, 238);
|
||||
this.cancel.Name = "cancel";
|
||||
this.cancel.Size = new System.Drawing.Size(91, 25);
|
||||
this.cancel.TabIndex = 4;
|
||||
this.cancel.Text = "Cancel";
|
||||
this.cancel.UseVisualStyleBackColor = true;
|
||||
this.cancel.Click += new System.EventHandler(this.cancel_Click);
|
||||
//
|
||||
// apply
|
||||
//
|
||||
this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.apply.Location = new System.Drawing.Point(254, 238);
|
||||
this.apply.Name = "apply";
|
||||
this.apply.Size = new System.Drawing.Size(91, 25);
|
||||
this.apply.TabIndex = 3;
|
||||
this.apply.Text = "OK";
|
||||
this.apply.UseVisualStyleBackColor = true;
|
||||
this.apply.Click += new System.EventHandler(this.apply_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.flags);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 7);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(430, 225);
|
||||
this.groupBox1.TabIndex = 5;
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// FlagsForm
|
||||
//
|
||||
this.AcceptButton = this.apply;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.CancelButton = this.cancel;
|
||||
this.ClientSize = new System.Drawing.Size(454, 267);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.cancel);
|
||||
this.Controls.Add(this.apply);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FlagsForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Flags";
|
||||
this.Load += new System.EventHandler(this.LinedefFlagsForm_Load);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CodeImp.DoomBuilder.Controls.CheckboxArrayControl flags;
|
||||
private System.Windows.Forms.Button cancel;
|
||||
private System.Windows.Forms.Button apply;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
}
|
||||
}
|
117
Source/Core/Windows/FlagsForm.cs
Normal file
117
Source/Core/Windows/FlagsForm.cs
Normal file
|
@ -0,0 +1,117 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
public partial class FlagsForm : DelayedForm
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private bool setup;
|
||||
private string value;
|
||||
private IDictionary<string, string> flagdefs;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public string Value { get { return value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
public FlagsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// Setup from EnumList
|
||||
public void Setup(string value, IDictionary<string, string> inflags)
|
||||
{
|
||||
setup = true;
|
||||
this.value = value;
|
||||
flagdefs = inflags;
|
||||
|
||||
// Fill flags list
|
||||
foreach (KeyValuePair<string, string> tf in flagdefs)
|
||||
flags.Add(tf.Value, tf.Key);
|
||||
|
||||
// Parse the value string and check the boxes if necessary
|
||||
if (value.Trim() != "")
|
||||
{
|
||||
foreach (string s in value.Split(','))
|
||||
{
|
||||
string str = s.Trim();
|
||||
|
||||
// Make sure the given flag actually exists
|
||||
if(!flagdefs.ContainsKey(str))
|
||||
continue;
|
||||
|
||||
foreach (CheckBox c in flags.Checkboxes)
|
||||
{
|
||||
if (c.Text == flagdefs[str])
|
||||
c.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setup = false;
|
||||
}
|
||||
|
||||
// This shows the dialog
|
||||
// Returns the flags or the same flags when cancelled
|
||||
public static string ShowDialog(IWin32Window owner, string value, IDictionary<string, string> inflags)
|
||||
{
|
||||
string result = value;
|
||||
FlagsForm f = new FlagsForm();
|
||||
f.Setup(value, inflags);
|
||||
if (f.ShowDialog(owner) == DialogResult.OK) result = f.Value;
|
||||
f.Dispose();
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void LinedefFlagsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void apply_Click(object sender, EventArgs e)
|
||||
{
|
||||
value = "";
|
||||
|
||||
foreach (CheckBox c in flags.Checkboxes)
|
||||
{
|
||||
if(c.Checked == false) continue;
|
||||
|
||||
foreach (KeyValuePair<string, string> lf in flagdefs)
|
||||
{
|
||||
if (lf.Value == c.Text)
|
||||
{
|
||||
if (value != "") value += ",";
|
||||
value += lf.Key.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Close
|
||||
DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
120
Source/Core/Windows/FlagsForm.resx
Normal file
120
Source/Core/Windows/FlagsForm.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
|
@ -249,8 +249,10 @@
|
|||
<Compile Include="ErrorChecks\ResultTextureMissing.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnknownFlat.cs" />
|
||||
<Compile Include="ErrorChecks\ResultUnknownTexture.cs" />
|
||||
<Compile Include="FindReplace\FindLinedefFlags.cs" />
|
||||
<Compile Include="FindReplace\FindThingAngle.cs" />
|
||||
<Compile Include="FindReplace\FindAnyTextureFlat.cs" />
|
||||
<Compile Include="FindReplace\FindThingFlags.cs" />
|
||||
<Compile Include="FindReplace\FindThingSectorRef.cs" />
|
||||
<Compile Include="FindReplace\FindThingTag.cs" />
|
||||
<Compile Include="FindReplace\FindLinedefNumber.cs" />
|
||||
|
|
159
Source/Plugins/BuilderModes/FindReplace/FindLinedefFlags.cs
Normal file
159
Source/Plugins/BuilderModes/FindReplace/FindLinedefFlags.cs
Normal file
|
@ -0,0 +1,159 @@
|
|||
|
||||
#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 Flags", BrowseButton = true, Replacable = false)]
|
||||
internal class FindLinedefFlags : FindReplaceType
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override Image BrowseImage { get { return Properties.Resources.List; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
// Constructor
|
||||
public FindLinedefFlags()
|
||||
{
|
||||
// Initialize
|
||||
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~FindLinedefFlags()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This is called when the browse button is pressed
|
||||
public override string Browse(string initialvalue)
|
||||
{
|
||||
return FlagsForm.ShowDialog(Form.ActiveForm, initialvalue, General.Map.Config.LinedefFlags);
|
||||
}
|
||||
|
||||
|
||||
// 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>();
|
||||
|
||||
// Where to search?
|
||||
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
|
||||
|
||||
// Go for all linedefs
|
||||
foreach (Linedef l in list)
|
||||
{
|
||||
bool match = true;
|
||||
|
||||
// Parse the value string...
|
||||
foreach (string s in value.Split(','))
|
||||
{
|
||||
string str = s.Trim();
|
||||
|
||||
// ... and check if the flags don't match
|
||||
if (General.Map.Config.LinedefFlags.ContainsKey(str) && !l.IsFlagSet(str))
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Flags matches?
|
||||
if (match)
|
||||
{
|
||||
// Add to list
|
||||
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
|
||||
if (!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.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> lines = new List<Linedef>(selection.Length);
|
||||
foreach (FindReplaceObject o in selection) lines.Add(o.Linedef);
|
||||
General.Interface.ShowEditLinedefs(lines);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
157
Source/Plugins/BuilderModes/FindReplace/FindThingFlags.cs
Normal file
157
Source/Plugins/BuilderModes/FindReplace/FindThingFlags.cs
Normal file
|
@ -0,0 +1,157 @@
|
|||
|
||||
#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 Flags", BrowseButton = true, Replacable = false)]
|
||||
internal class FindThingFlag : FindReplaceType
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override Presentation RenderPresentation { get { return Presentation.Things; } }
|
||||
public override Image BrowseImage { get { return Properties.Resources.List; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
// Constructor
|
||||
public FindThingFlag()
|
||||
{
|
||||
// Initialize
|
||||
|
||||
}
|
||||
|
||||
// Destructor
|
||||
~FindThingFlag()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This is called when the browse button is pressed
|
||||
public override string Browse(string initialvalue)
|
||||
{
|
||||
return FlagsForm.ShowDialog(Form.ActiveForm, initialvalue, General.Map.Config.ThingFlags);
|
||||
}
|
||||
|
||||
|
||||
// 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>();
|
||||
|
||||
// Where to search?
|
||||
ICollection<Thing> list = withinselection ? General.Map.Map.GetSelectedThings(true) : General.Map.Map.Things;
|
||||
|
||||
// Go for all things
|
||||
foreach (Thing t in list)
|
||||
{
|
||||
bool match = true;
|
||||
|
||||
// Parse the value string...
|
||||
foreach (string s in value.Split(','))
|
||||
{
|
||||
string str = s.Trim();
|
||||
|
||||
// ... and check if the flags don't match
|
||||
if (General.Map.Config.ThingFlags.ContainsKey(str) && !t.IsFlagSet(str))
|
||||
{
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Match?
|
||||
if (match)
|
||||
{
|
||||
// Add to list
|
||||
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue