diff --git a/Source/Core/Config/GameConfiguration.cs b/Source/Core/Config/GameConfiguration.cs index 5e7ae43f..7e974bf6 100644 --- a/Source/Core/Config/GameConfiguration.cs +++ b/Source/Core/Config/GameConfiguration.cs @@ -202,7 +202,7 @@ namespace CodeImp.DoomBuilder.Config // Defaults internal List TextureSets { get { return texturesets; } } - internal List ThingsFilters { get { return thingfilters; } } + public List ThingsFilters { get { return thingfilters; } } #endregion diff --git a/Source/Core/Editing/CustomThingsFilter.cs b/Source/Core/Editing/CustomThingsFilter.cs new file mode 100644 index 00000000..0f4b2b0d --- /dev/null +++ b/Source/Core/Editing/CustomThingsFilter.cs @@ -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 RequiredFields { get { return requiredfields; } } + public ICollection ForbiddenFields { get { return forbiddenfields; } } + + #endregion + + #region ================== Constructor / Disposer + + // Constructor for a new filter + public CustomThingsFilter() + { + // Initialize + requiredfields = new List(); + forbiddenfields = new List(); + categoryname = ""; + thingtype = -1; + name = "Unnamed filter"; + + // We have no destructor + GC.SuppressFinalize(this); + } + + // Disposer + public virtual void Dispose() + { + base.Dispose(); + } + + #endregion + + #region ================== Methods + + #endregion + } +} diff --git a/Source/Core/Editing/ThingsFilter.cs b/Source/Core/Editing/ThingsFilter.cs index 97a25482..8c4adde1 100644 --- a/Source/Core/Editing/ThingsFilter.cs +++ b/Source/Core/Editing/ThingsFilter.cs @@ -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 RequiredFields { get { return requiredfields; } } internal ICollection ForbiddenFields { get { return forbiddenfields; } } diff --git a/Source/Core/General/General.cs b/Source/Core/General/General.cs index 7372ffd7..84b9580f 100644 --- a/Source/Core/General/General.cs +++ b/Source/Core/General/General.cs @@ -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(); diff --git a/Source/Core/General/MapManager.cs b/Source/Core/General/MapManager.cs index 70f195f8..dcaa8c21 100644 --- a/Source/Core/General/MapManager.cs +++ b/Source/Core/General/MapManager.cs @@ -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 diff --git a/Source/Core/Windows/MainForm.Designer.cs b/Source/Core/Windows/MainForm.Designer.cs index 320694ca..36563202 100644 --- a/Source/Core/Windows/MainForm.Designer.cs +++ b/Source/Core/Windows/MainForm.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index def56d54..b7a6eaba 100644 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -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