mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-05-31 00:51:37 +00:00
Added classes/functions for plugins to create and/or select new/existing things filters
This commit is contained in:
parent
e10eccf01e
commit
f33d0ed1ff
7 changed files with 163 additions and 28 deletions
|
@ -202,7 +202,7 @@ namespace CodeImp.DoomBuilder.Config
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
internal List<DefinedTextureSet> TextureSets { get { return texturesets; } }
|
internal List<DefinedTextureSet> TextureSets { get { return texturesets; } }
|
||||||
internal List<ThingsFilter> ThingsFilters { get { return thingfilters; } }
|
public List<ThingsFilter> ThingsFilters { get { return thingfilters; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
79
Source/Core/Editing/CustomThingsFilter.cs
Normal file
79
Source/Core/Editing/CustomThingsFilter.cs
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
|
||||||
|
#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.Map;
|
||||||
|
using CodeImp.DoomBuilder.IO;
|
||||||
|
using CodeImp.DoomBuilder.Config;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace CodeImp.DoomBuilder.Editing
|
||||||
|
{
|
||||||
|
public class CustomThingsFilter : ThingsFilter
|
||||||
|
{
|
||||||
|
#region ================== Variables
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Properties
|
||||||
|
|
||||||
|
public string Name { get { return name; } set { name = value; } }
|
||||||
|
public string CategoryName { get { return categoryname; } set { categoryname = value; } }
|
||||||
|
public int ThingType { get { return thingtype; } set { thingtype = value; } }
|
||||||
|
public ICollection<string> RequiredFields { get { return requiredfields; } }
|
||||||
|
public ICollection<string> ForbiddenFields { get { return forbiddenfields; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
|
// Constructor for a new filter
|
||||||
|
public CustomThingsFilter()
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
requiredfields = new List<string>();
|
||||||
|
forbiddenfields = new List<string>();
|
||||||
|
categoryname = "";
|
||||||
|
thingtype = -1;
|
||||||
|
name = "Unnamed filter";
|
||||||
|
|
||||||
|
// We have no destructor
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disposer
|
||||||
|
public virtual void Dispose()
|
||||||
|
{
|
||||||
|
base.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Methods
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -65,8 +65,8 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
|
||||||
internal string Name { get { return name; } set { name = value; } }
|
public string Name { get { return name; } internal set { name = value; } }
|
||||||
internal string CategoryName { get { return categoryname; } set { categoryname = value; } }
|
public string CategoryName { get { return categoryname; } internal set { categoryname = value; } }
|
||||||
internal int ThingType { get { return thingtype; } set { thingtype = value; } }
|
internal int ThingType { get { return thingtype; } set { thingtype = value; } }
|
||||||
internal ICollection<string> RequiredFields { get { return requiredfields; } }
|
internal ICollection<string> RequiredFields { get { return requiredfields; } }
|
||||||
internal ICollection<string> ForbiddenFields { get { return forbiddenfields; } }
|
internal ICollection<string> ForbiddenFields { get { return forbiddenfields; } }
|
||||||
|
|
|
@ -637,6 +637,7 @@ namespace CodeImp.DoomBuilder
|
||||||
General.WriteLogLine("Loading main interface window...");
|
General.WriteLogLine("Loading main interface window...");
|
||||||
mainwindow = new MainForm();
|
mainwindow = new MainForm();
|
||||||
mainwindow.UpdateInterface();
|
mainwindow.UpdateInterface();
|
||||||
|
mainwindow.UpdateThingsFilters();
|
||||||
|
|
||||||
if(!delaymainwindow)
|
if(!delaymainwindow)
|
||||||
{
|
{
|
||||||
|
@ -980,6 +981,7 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// All done
|
// All done
|
||||||
mainwindow.RedrawDisplay();
|
mainwindow.RedrawDisplay();
|
||||||
|
mainwindow.UpdateThingsFilters();
|
||||||
mainwindow.UpdateInterface();
|
mainwindow.UpdateInterface();
|
||||||
mainwindow.HideInfo();
|
mainwindow.HideInfo();
|
||||||
|
|
||||||
|
@ -1028,6 +1030,7 @@ namespace CodeImp.DoomBuilder
|
||||||
editing.UpdateCurrentEditModes();
|
editing.UpdateCurrentEditModes();
|
||||||
mainwindow.RedrawDisplay();
|
mainwindow.RedrawDisplay();
|
||||||
mainwindow.HideInfo();
|
mainwindow.HideInfo();
|
||||||
|
mainwindow.UpdateThingsFilters();
|
||||||
mainwindow.UpdateInterface();
|
mainwindow.UpdateInterface();
|
||||||
mainwindow.DisplayReady();
|
mainwindow.DisplayReady();
|
||||||
General.WriteLogLine("Map unload done");
|
General.WriteLogLine("Map unload done");
|
||||||
|
@ -1128,6 +1131,7 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// All done
|
// All done
|
||||||
mainwindow.RedrawDisplay();
|
mainwindow.RedrawDisplay();
|
||||||
|
mainwindow.UpdateThingsFilters();
|
||||||
mainwindow.UpdateInterface();
|
mainwindow.UpdateInterface();
|
||||||
mainwindow.HideInfo();
|
mainwindow.HideInfo();
|
||||||
|
|
||||||
|
|
|
@ -1368,10 +1368,13 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Update settings
|
// Update settings
|
||||||
renderer3d.CreateProjection();
|
renderer3d.CreateProjection();
|
||||||
|
|
||||||
|
// Things filters
|
||||||
|
General.MainWindow.UpdateThingsFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This changes thing filter
|
// This changes thing filter
|
||||||
internal void ChangeThingFilter(ThingsFilter newfilter)
|
public void ChangeThingFilter(ThingsFilter newfilter)
|
||||||
{
|
{
|
||||||
// We have a special filter for null
|
// We have a special filter for null
|
||||||
if(newfilter == null) newfilter = new NullThingsFilter();
|
if(newfilter == null) newfilter = new NullThingsFilter();
|
||||||
|
@ -1384,7 +1387,10 @@ namespace CodeImp.DoomBuilder
|
||||||
|
|
||||||
// Activate filter
|
// Activate filter
|
||||||
thingsfilter.Activate();
|
thingsfilter.Activate();
|
||||||
|
|
||||||
|
// Update interface
|
||||||
|
General.MainWindow.ReflectThingsFilter();
|
||||||
|
|
||||||
// Redraw
|
// Redraw
|
||||||
General.MainWindow.RedrawDisplay();
|
General.MainWindow.RedrawDisplay();
|
||||||
}
|
}
|
||||||
|
@ -1531,6 +1537,7 @@ namespace CodeImp.DoomBuilder
|
||||||
General.Plugins.MapReconfigure();
|
General.Plugins.MapReconfigure();
|
||||||
|
|
||||||
// Update interface
|
// Update interface
|
||||||
|
General.MainWindow.UpdateThingsFilters();
|
||||||
General.MainWindow.UpdateInterface();
|
General.MainWindow.UpdateInterface();
|
||||||
|
|
||||||
// Reload resources
|
// Reload resources
|
||||||
|
@ -1552,6 +1559,7 @@ namespace CodeImp.DoomBuilder
|
||||||
ThingsFiltersForm f = new ThingsFiltersForm();
|
ThingsFiltersForm f = new ThingsFiltersForm();
|
||||||
f.ShowDialog(General.MainWindow);
|
f.ShowDialog(General.MainWindow);
|
||||||
f.Dispose();
|
f.Dispose();
|
||||||
|
General.MainWindow.UpdateThingsFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This returns true is the given type matches
|
// This returns true is the given type matches
|
||||||
|
|
56
Source/Core/Windows/MainForm.Designer.cs
generated
56
Source/Core/Windows/MainForm.Designer.cs
generated
|
@ -64,6 +64,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
this.itemcut = new System.Windows.Forms.ToolStripMenuItem();
|
this.itemcut = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.itemcopy = new System.Windows.Forms.ToolStripMenuItem();
|
this.itemcopy = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.itempaste = new System.Windows.Forms.ToolStripMenuItem();
|
this.itempaste = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.pasteSpecialToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.itemsnaptogrid = new System.Windows.Forms.ToolStripMenuItem();
|
this.itemsnaptogrid = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.itemautomerge = new System.Windows.Forms.ToolStripMenuItem();
|
this.itemautomerge = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
|
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
@ -161,13 +162,13 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
this.xposlabel = new System.Windows.Forms.ToolStripStatusLabel();
|
this.xposlabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.yposlabel = new System.Windows.Forms.ToolStripStatusLabel();
|
this.yposlabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
this.panelinfo = new System.Windows.Forms.Panel();
|
this.panelinfo = new System.Windows.Forms.Panel();
|
||||||
|
this.vertexinfo = new CodeImp.DoomBuilder.Controls.VertexInfoPanel();
|
||||||
this.labelcollapsedinfo = new System.Windows.Forms.Label();
|
this.labelcollapsedinfo = new System.Windows.Forms.Label();
|
||||||
this.buttontoggleinfo = new System.Windows.Forms.Button();
|
this.buttontoggleinfo = new System.Windows.Forms.Button();
|
||||||
this.modename = new System.Windows.Forms.Label();
|
this.modename = new System.Windows.Forms.Label();
|
||||||
this.vertexinfo = new CodeImp.DoomBuilder.Controls.VertexInfoPanel();
|
this.linedefinfo = new CodeImp.DoomBuilder.Controls.LinedefInfoPanel();
|
||||||
this.thinginfo = new CodeImp.DoomBuilder.Controls.ThingInfoPanel();
|
this.thinginfo = new CodeImp.DoomBuilder.Controls.ThingInfoPanel();
|
||||||
this.sectorinfo = new CodeImp.DoomBuilder.Controls.SectorInfoPanel();
|
this.sectorinfo = new CodeImp.DoomBuilder.Controls.SectorInfoPanel();
|
||||||
this.linedefinfo = new CodeImp.DoomBuilder.Controls.LinedefInfoPanel();
|
|
||||||
this.redrawtimer = new System.Windows.Forms.Timer(this.components);
|
this.redrawtimer = new System.Windows.Forms.Timer(this.components);
|
||||||
this.display = new CodeImp.DoomBuilder.Controls.RenderTargetControl();
|
this.display = new CodeImp.DoomBuilder.Controls.RenderTargetControl();
|
||||||
this.processor = new System.Windows.Forms.Timer(this.components);
|
this.processor = new System.Windows.Forms.Timer(this.components);
|
||||||
|
@ -403,6 +404,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
this.itemcut,
|
this.itemcut,
|
||||||
this.itemcopy,
|
this.itemcopy,
|
||||||
this.itempaste,
|
this.itempaste,
|
||||||
|
this.pasteSpecialToolStripMenuItem,
|
||||||
toolstripSeperator6,
|
toolstripSeperator6,
|
||||||
this.itemsnaptogrid,
|
this.itemsnaptogrid,
|
||||||
this.itemautomerge,
|
this.itemautomerge,
|
||||||
|
@ -467,6 +469,15 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
this.itempaste.Text = "Paste";
|
this.itempaste.Text = "Paste";
|
||||||
this.itempaste.Click += new System.EventHandler(this.InvokeTaggedAction);
|
this.itempaste.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||||
//
|
//
|
||||||
|
// pasteSpecialToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.pasteSpecialToolStripMenuItem.Image = global::CodeImp.DoomBuilder.Properties.Resources.PasteSpecial;
|
||||||
|
this.pasteSpecialToolStripMenuItem.Name = "pasteSpecialToolStripMenuItem";
|
||||||
|
this.pasteSpecialToolStripMenuItem.Size = new System.Drawing.Size(165, 22);
|
||||||
|
this.pasteSpecialToolStripMenuItem.Tag = "builder_pasteselectionspecial";
|
||||||
|
this.pasteSpecialToolStripMenuItem.Text = "Paste Special...";
|
||||||
|
this.pasteSpecialToolStripMenuItem.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||||
|
//
|
||||||
// itemsnaptogrid
|
// itemsnaptogrid
|
||||||
//
|
//
|
||||||
this.itemsnaptogrid.Checked = true;
|
this.itemsnaptogrid.Checked = true;
|
||||||
|
@ -1433,6 +1444,17 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
this.panelinfo.Size = new System.Drawing.Size(1012, 106);
|
this.panelinfo.Size = new System.Drawing.Size(1012, 106);
|
||||||
this.panelinfo.TabIndex = 4;
|
this.panelinfo.TabIndex = 4;
|
||||||
//
|
//
|
||||||
|
// vertexinfo
|
||||||
|
//
|
||||||
|
this.vertexinfo.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.vertexinfo.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.vertexinfo.MaximumSize = new System.Drawing.Size(10000, 100);
|
||||||
|
this.vertexinfo.MinimumSize = new System.Drawing.Size(100, 100);
|
||||||
|
this.vertexinfo.Name = "vertexinfo";
|
||||||
|
this.vertexinfo.Size = new System.Drawing.Size(310, 100);
|
||||||
|
this.vertexinfo.TabIndex = 1;
|
||||||
|
this.vertexinfo.Visible = false;
|
||||||
|
//
|
||||||
// labelcollapsedinfo
|
// labelcollapsedinfo
|
||||||
//
|
//
|
||||||
this.labelcollapsedinfo.AutoSize = true;
|
this.labelcollapsedinfo.AutoSize = true;
|
||||||
|
@ -1474,16 +1496,16 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
this.modename.UseMnemonic = false;
|
this.modename.UseMnemonic = false;
|
||||||
this.modename.Visible = false;
|
this.modename.Visible = false;
|
||||||
//
|
//
|
||||||
// vertexinfo
|
// linedefinfo
|
||||||
//
|
//
|
||||||
this.vertexinfo.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.linedefinfo.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.vertexinfo.Location = new System.Drawing.Point(3, 3);
|
this.linedefinfo.Location = new System.Drawing.Point(3, 3);
|
||||||
this.vertexinfo.MaximumSize = new System.Drawing.Size(10000, 100);
|
this.linedefinfo.MaximumSize = new System.Drawing.Size(10000, 100);
|
||||||
this.vertexinfo.MinimumSize = new System.Drawing.Size(100, 100);
|
this.linedefinfo.MinimumSize = new System.Drawing.Size(100, 100);
|
||||||
this.vertexinfo.Name = "vertexinfo";
|
this.linedefinfo.Name = "linedefinfo";
|
||||||
this.vertexinfo.Size = new System.Drawing.Size(310, 100);
|
this.linedefinfo.Size = new System.Drawing.Size(1039, 100);
|
||||||
this.vertexinfo.TabIndex = 1;
|
this.linedefinfo.TabIndex = 0;
|
||||||
this.vertexinfo.Visible = false;
|
this.linedefinfo.Visible = false;
|
||||||
//
|
//
|
||||||
// thinginfo
|
// thinginfo
|
||||||
//
|
//
|
||||||
|
@ -1507,17 +1529,6 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
this.sectorinfo.TabIndex = 2;
|
this.sectorinfo.TabIndex = 2;
|
||||||
this.sectorinfo.Visible = false;
|
this.sectorinfo.Visible = false;
|
||||||
//
|
//
|
||||||
// linedefinfo
|
|
||||||
//
|
|
||||||
this.linedefinfo.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
||||||
this.linedefinfo.Location = new System.Drawing.Point(3, 3);
|
|
||||||
this.linedefinfo.MaximumSize = new System.Drawing.Size(10000, 100);
|
|
||||||
this.linedefinfo.MinimumSize = new System.Drawing.Size(100, 100);
|
|
||||||
this.linedefinfo.Name = "linedefinfo";
|
|
||||||
this.linedefinfo.Size = new System.Drawing.Size(1039, 100);
|
|
||||||
this.linedefinfo.TabIndex = 0;
|
|
||||||
this.linedefinfo.Visible = false;
|
|
||||||
//
|
|
||||||
// redrawtimer
|
// redrawtimer
|
||||||
//
|
//
|
||||||
this.redrawtimer.Interval = 1;
|
this.redrawtimer.Interval = 1;
|
||||||
|
@ -1728,5 +1739,6 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem13;
|
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem13;
|
||||||
private System.Windows.Forms.ToolStripMenuItem itemhelpeditmode;
|
private System.Windows.Forms.ToolStripMenuItem itemhelpeditmode;
|
||||||
private System.Windows.Forms.ToolStripMenuItem itemtoggleinfo;
|
private System.Windows.Forms.ToolStripMenuItem itemtoggleinfo;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem pasteSpecialToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1254,8 +1254,12 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
// Only possible when a map is open
|
// Only possible when a map is open
|
||||||
if((General.Map != null) && !updatingfilters)
|
if((General.Map != null) && !updatingfilters)
|
||||||
{
|
{
|
||||||
|
updatingfilters = true;
|
||||||
|
|
||||||
// Change filter
|
// Change filter
|
||||||
General.Map.ChangeThingFilter(thingfilters.SelectedItem as ThingsFilter);
|
General.Map.ChangeThingFilter(thingfilters.SelectedItem as ThingsFilter);
|
||||||
|
|
||||||
|
updatingfilters = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lose focus
|
// Lose focus
|
||||||
|
@ -1312,6 +1316,35 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
thingfilters.Items.Clear();
|
thingfilters.Items.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This selects the things filter based on the filter set on the map manager
|
||||||
|
internal void ReflectThingsFilter()
|
||||||
|
{
|
||||||
|
if(!updatingfilters)
|
||||||
|
{
|
||||||
|
updatingfilters = true;
|
||||||
|
|
||||||
|
// Select current filter
|
||||||
|
bool selecteditemfound = false;
|
||||||
|
foreach(ThingsFilter f in thingfilters.Items)
|
||||||
|
{
|
||||||
|
if(f == General.Map.ThingsFilter)
|
||||||
|
{
|
||||||
|
thingfilters.SelectedItem = f;
|
||||||
|
selecteditemfound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not in the list?
|
||||||
|
if(!selecteditemfound)
|
||||||
|
{
|
||||||
|
// Select nothing
|
||||||
|
thingfilters.SelectedIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
updatingfilters = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This adds a button to the toolbar
|
// This adds a button to the toolbar
|
||||||
public void AddButton(ToolStripItem button)
|
public void AddButton(ToolStripItem button)
|
||||||
|
@ -1859,7 +1892,6 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
thingfilters.Enabled = (General.Map != null);
|
thingfilters.Enabled = (General.Map != null);
|
||||||
buttonthingsfilter.Enabled = (General.Map != null);
|
buttonthingsfilter.Enabled = (General.Map != null);
|
||||||
buttonscripteditor.Enabled = (General.Map != null);
|
buttonscripteditor.Enabled = (General.Map != null);
|
||||||
UpdateThingsFilters();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue