mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 06:02:11 +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
|
||||
internal List<DefinedTextureSet> TextureSets { get { return texturesets; } }
|
||||
internal List<ThingsFilter> ThingsFilters { get { return thingfilters; } }
|
||||
public List<ThingsFilter> ThingsFilters { get { return thingfilters; } }
|
||||
|
||||
#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
|
||||
|
||||
internal string Name { get { return name; } set { name = value; } }
|
||||
internal string CategoryName { get { return categoryname; } set { categoryname = value; } }
|
||||
public string Name { get { return name; } internal set { name = value; } }
|
||||
public string CategoryName { get { return categoryname; } internal set { categoryname = value; } }
|
||||
internal int ThingType { get { return thingtype; } set { thingtype = value; } }
|
||||
internal ICollection<string> RequiredFields { get { return requiredfields; } }
|
||||
internal ICollection<string> ForbiddenFields { get { return forbiddenfields; } }
|
||||
|
|
|
@ -637,6 +637,7 @@ namespace CodeImp.DoomBuilder
|
|||
General.WriteLogLine("Loading main interface window...");
|
||||
mainwindow = new MainForm();
|
||||
mainwindow.UpdateInterface();
|
||||
mainwindow.UpdateThingsFilters();
|
||||
|
||||
if(!delaymainwindow)
|
||||
{
|
||||
|
@ -980,6 +981,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// All done
|
||||
mainwindow.RedrawDisplay();
|
||||
mainwindow.UpdateThingsFilters();
|
||||
mainwindow.UpdateInterface();
|
||||
mainwindow.HideInfo();
|
||||
|
||||
|
@ -1028,6 +1030,7 @@ namespace CodeImp.DoomBuilder
|
|||
editing.UpdateCurrentEditModes();
|
||||
mainwindow.RedrawDisplay();
|
||||
mainwindow.HideInfo();
|
||||
mainwindow.UpdateThingsFilters();
|
||||
mainwindow.UpdateInterface();
|
||||
mainwindow.DisplayReady();
|
||||
General.WriteLogLine("Map unload done");
|
||||
|
@ -1128,6 +1131,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// All done
|
||||
mainwindow.RedrawDisplay();
|
||||
mainwindow.UpdateThingsFilters();
|
||||
mainwindow.UpdateInterface();
|
||||
mainwindow.HideInfo();
|
||||
|
||||
|
|
|
@ -1368,10 +1368,13 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Update settings
|
||||
renderer3d.CreateProjection();
|
||||
|
||||
// Things filters
|
||||
General.MainWindow.UpdateThingsFilters();
|
||||
}
|
||||
|
||||
// This changes thing filter
|
||||
internal void ChangeThingFilter(ThingsFilter newfilter)
|
||||
public void ChangeThingFilter(ThingsFilter newfilter)
|
||||
{
|
||||
// We have a special filter for null
|
||||
if(newfilter == null) newfilter = new NullThingsFilter();
|
||||
|
@ -1384,7 +1387,10 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Activate filter
|
||||
thingsfilter.Activate();
|
||||
|
||||
|
||||
// Update interface
|
||||
General.MainWindow.ReflectThingsFilter();
|
||||
|
||||
// Redraw
|
||||
General.MainWindow.RedrawDisplay();
|
||||
}
|
||||
|
@ -1531,6 +1537,7 @@ namespace CodeImp.DoomBuilder
|
|||
General.Plugins.MapReconfigure();
|
||||
|
||||
// Update interface
|
||||
General.MainWindow.UpdateThingsFilters();
|
||||
General.MainWindow.UpdateInterface();
|
||||
|
||||
// Reload resources
|
||||
|
@ -1552,6 +1559,7 @@ namespace CodeImp.DoomBuilder
|
|||
ThingsFiltersForm f = new ThingsFiltersForm();
|
||||
f.ShowDialog(General.MainWindow);
|
||||
f.Dispose();
|
||||
General.MainWindow.UpdateThingsFilters();
|
||||
}
|
||||
|
||||
// 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.itemcopy = 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.itemautomerge = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator();
|
||||
|
@ -161,13 +162,13 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.xposlabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.yposlabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.panelinfo = new System.Windows.Forms.Panel();
|
||||
this.vertexinfo = new CodeImp.DoomBuilder.Controls.VertexInfoPanel();
|
||||
this.labelcollapsedinfo = new System.Windows.Forms.Label();
|
||||
this.buttontoggleinfo = new System.Windows.Forms.Button();
|
||||
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.sectorinfo = new CodeImp.DoomBuilder.Controls.SectorInfoPanel();
|
||||
this.linedefinfo = new CodeImp.DoomBuilder.Controls.LinedefInfoPanel();
|
||||
this.redrawtimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.display = new CodeImp.DoomBuilder.Controls.RenderTargetControl();
|
||||
this.processor = new System.Windows.Forms.Timer(this.components);
|
||||
|
@ -403,6 +404,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.itemcut,
|
||||
this.itemcopy,
|
||||
this.itempaste,
|
||||
this.pasteSpecialToolStripMenuItem,
|
||||
toolstripSeperator6,
|
||||
this.itemsnaptogrid,
|
||||
this.itemautomerge,
|
||||
|
@ -467,6 +469,15 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.itempaste.Text = "Paste";
|
||||
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
|
||||
//
|
||||
this.itemsnaptogrid.Checked = true;
|
||||
|
@ -1433,6 +1444,17 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.panelinfo.Size = new System.Drawing.Size(1012, 106);
|
||||
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
|
||||
//
|
||||
this.labelcollapsedinfo.AutoSize = true;
|
||||
|
@ -1474,16 +1496,16 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.modename.UseMnemonic = 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.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;
|
||||
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;
|
||||
//
|
||||
// thinginfo
|
||||
//
|
||||
|
@ -1507,17 +1529,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.sectorinfo.TabIndex = 2;
|
||||
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
|
||||
//
|
||||
this.redrawtimer.Interval = 1;
|
||||
|
@ -1728,5 +1739,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem13;
|
||||
private System.Windows.Forms.ToolStripMenuItem itemhelpeditmode;
|
||||
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
|
||||
if((General.Map != null) && !updatingfilters)
|
||||
{
|
||||
updatingfilters = true;
|
||||
|
||||
// Change filter
|
||||
General.Map.ChangeThingFilter(thingfilters.SelectedItem as ThingsFilter);
|
||||
|
||||
updatingfilters = false;
|
||||
}
|
||||
|
||||
// Lose focus
|
||||
|
@ -1312,6 +1316,35 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
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
|
||||
public void AddButton(ToolStripItem button)
|
||||
|
@ -1859,7 +1892,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
thingfilters.Enabled = (General.Map != null);
|
||||
buttonthingsfilter.Enabled = (General.Map != null);
|
||||
buttonscripteditor.Enabled = (General.Map != null);
|
||||
UpdateThingsFilters();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue