From 08e6f30d0f019bdb376200ce09764622bb6ce9e2 Mon Sep 17 00:00:00 2001 From: codeimp Date: Mon, 30 Aug 2010 13:51:24 +0000 Subject: [PATCH] Added source for Tag Range plugin --- Resources/Icons/tag_blue.png | Bin 0 -> 586 bytes .../Plugins/BuilderModes/BuilderModes.csproj | 3 +- .../ClassicModes/TriangulatorMode.cs | 13 +- .../BuilderModes/Resources/Actions.cfg | 4 +- Source/Plugins/TagRange/BuilderPlug.cs | 105 +++++++++ .../TagRange/Properties/AssemblyInfo.cs | 35 +++ .../TagRange/Properties/Resources.Designer.cs | 70 ++++++ .../TagRange/Properties/Resources.resx | 124 +++++++++++ Source/Plugins/TagRange/Resources/Actions.cfg | 10 + .../Plugins/TagRange/Resources/tag_blue.png | Bin 0 -> 586 bytes Source/Plugins/TagRange/TagRange.csproj | 92 ++++++++ .../Plugins/TagRange/TagRangeForm.Designer.cs | 206 ++++++++++++++++++ Source/Plugins/TagRange/TagRangeForm.cs | 196 +++++++++++++++++ Source/Plugins/TagRange/TagRangeForm.resx | 156 +++++++++++++ Source/Plugins/TagRange/ToolsForm.Designer.cs | 99 +++++++++ Source/Plugins/TagRange/ToolsForm.cs | 55 +++++ Source/Plugins/TagRange/ToolsForm.resx | 123 +++++++++++ 17 files changed, 1280 insertions(+), 11 deletions(-) create mode 100644 Resources/Icons/tag_blue.png create mode 100644 Source/Plugins/TagRange/BuilderPlug.cs create mode 100644 Source/Plugins/TagRange/Properties/AssemblyInfo.cs create mode 100644 Source/Plugins/TagRange/Properties/Resources.Designer.cs create mode 100644 Source/Plugins/TagRange/Properties/Resources.resx create mode 100644 Source/Plugins/TagRange/Resources/Actions.cfg create mode 100644 Source/Plugins/TagRange/Resources/tag_blue.png create mode 100644 Source/Plugins/TagRange/TagRange.csproj create mode 100644 Source/Plugins/TagRange/TagRangeForm.Designer.cs create mode 100644 Source/Plugins/TagRange/TagRangeForm.cs create mode 100644 Source/Plugins/TagRange/TagRangeForm.resx create mode 100644 Source/Plugins/TagRange/ToolsForm.Designer.cs create mode 100644 Source/Plugins/TagRange/ToolsForm.cs create mode 100644 Source/Plugins/TagRange/ToolsForm.resx diff --git a/Resources/Icons/tag_blue.png b/Resources/Icons/tag_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..9757fc6ed6597438eb8e5a70a1ab2402cdebd5d1 GIT binary patch literal 586 zcmV-Q0=4~#P)6YY{78#rvt}vj%qrc zN=UU@y$E6COaj9&r1NAlaUpajQlL~SorN%pOwHs*2laYgHBA$?ZOd~4Rw@5yFm2?1ZIg`0V-$-;GT1Fi5dB7wUSNi^%`^Ge62m>OBeX610Nsukl}DhDG-mxT?nhyYH!4he7Ri8 zrq0Ti&UXUvqX&F@JcJAe14@BNBqAY_QZAPjF(Y3r7P9H_kB#@LgFAf>xz>Qp&n=|a z>ro1XLZK^nmO`PRh#C2OK0ktd7l6-A;O5?fz1gNnCX)yR0 Debug AnyCPU - 9.0.30729 + 8.0.50727 2.0 {B42D5AA0-F9A6-4234-9C4B-A05B11A64851} Library @@ -235,6 +235,7 @@ + diff --git a/Source/Plugins/BuilderModes/ClassicModes/TriangulatorMode.cs b/Source/Plugins/BuilderModes/ClassicModes/TriangulatorMode.cs index f76f4527..0a23d7e7 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/TriangulatorMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/TriangulatorMode.cs @@ -178,9 +178,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing // Set new highlight highlighted = s; - - // Get label positions - if(s != null) labelpos = Tools.FindLabelPositions(s); // Render highlighted item if((highlighted != null) && !highlighted.IsDisposed) @@ -434,7 +431,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing renderer.Present(); } - Thread.Sleep(10); + //Thread.Sleep(10); // Start with a clear display if(renderer.StartPlotter(true)) @@ -452,7 +449,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing } // Wait a bit - Thread.Sleep(40); + //Thread.Sleep(40); Application.DoEvents(); } @@ -506,7 +503,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing { EarClipVertex prev, first; - for(int a = 0; a < 8; a++) + for(int a = 0; a < 2; a++) { // Start with a clear display if(renderer.StartPlotter(true)) @@ -543,7 +540,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing renderer.Finish(); renderer.Present(); } - Thread.Sleep(60); + Thread.Sleep(10); Application.DoEvents(); // Start with a clear display @@ -573,7 +570,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing renderer.Finish(); renderer.Present(); } - Thread.Sleep(40); + //Thread.Sleep(10); } } diff --git a/Source/Plugins/BuilderModes/Resources/Actions.cfg b/Source/Plugins/BuilderModes/Resources/Actions.cfg index 003fb3e7..4ff7837d 100644 --- a/Source/Plugins/BuilderModes/Resources/Actions.cfg +++ b/Source/Plugins/BuilderModes/Resources/Actions.cfg @@ -77,7 +77,7 @@ thingsmode allowscroll = true; } -/* +///* triangulatormode { title = "Triangulator Mode"; @@ -87,7 +87,7 @@ triangulatormode allowmouse = true; allowscroll = true; } -*/ +//*/ drawlinesmode { diff --git a/Source/Plugins/TagRange/BuilderPlug.cs b/Source/Plugins/TagRange/BuilderPlug.cs new file mode 100644 index 00000000..3e5f685e --- /dev/null +++ b/Source/Plugins/TagRange/BuilderPlug.cs @@ -0,0 +1,105 @@ + +#region ================== Copyright (c) 2010 Pascal vd Heiden + +/* + * Copyright (c) 2010 Pascal vd Heiden + * 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.Collections.ObjectModel; +using System.Globalization; +using System.Text; +using System.Windows.Forms; +using System.IO; +using System.Reflection; +using CodeImp.DoomBuilder.Controls; +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.Plugins; +using CodeImp.DoomBuilder.Actions; +using CodeImp.DoomBuilder.Types; +using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.Data; + +#endregion + +namespace CodeImp.DoomBuilder.TagRange +{ + public class BuilderPlug : Plug + { + // Static instance. We can't use a real static class, because BuilderPlug must + // be instantiated by the core, so we keep a static reference. (this technique + // should be familiar to object-oriented programmers) + private static BuilderPlug me; + + // Tools form + private ToolsForm toolsform; + + // Static property to access the BuilderPlug + public static BuilderPlug Me { get { return me; } } + + // This event is called when the plugin is initialized + public override void OnInitialize() + { + base.OnInitialize(); + + // Keep a static reference + me = this; + + // Load form + toolsform = new ToolsForm(); + + General.Actions.BindMethods(this); + } + + // This is called when the plugin is terminated + public override void Dispose() + { + base.Dispose(); + + General.Actions.UnbindMethods(this); + + // Dispose form + if(toolsform != null) + toolsform.Dispose(); + toolsform = null; + } + + // This updates the button on the toolbar + public override void OnEditEngage(EditMode oldmode, EditMode newmode) + { + base.OnEditEngage(oldmode, newmode); + toolsform.UpdateButton(); + } + + [BeginAction("rangetagselectedsectors")] + private void RangeTagSelectedSectors() + { + TagRangeForm f = new TagRangeForm(); + f.Setup(); + if(f.SelectionCount > 0) + f.ShowDialog(Form.ActiveForm); + else + General.Interface.MessageBeep(MessageBeepType.Default); + f.Dispose(); + } + } +} diff --git a/Source/Plugins/TagRange/Properties/AssemblyInfo.cs b/Source/Plugins/TagRange/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..9ef20560 --- /dev/null +++ b/Source/Plugins/TagRange/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TagRange")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Doom Builder")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("CodeImp")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("8b9957c1-629e-45b7-8228-115225999d62")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Source/Plugins/TagRange/Properties/Resources.Designer.cs b/Source/Plugins/TagRange/Properties/Resources.Designer.cs new file mode 100644 index 00000000..ddc76b4a --- /dev/null +++ b/Source/Plugins/TagRange/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.4206 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CodeImp.DoomBuilder.TagRange.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CodeImp.DoomBuilder.TagRange.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + internal static System.Drawing.Bitmap tag_blue { + get { + object obj = ResourceManager.GetObject("tag_blue", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Source/Plugins/TagRange/Properties/Resources.resx b/Source/Plugins/TagRange/Properties/Resources.resx new file mode 100644 index 00000000..1bac6d41 --- /dev/null +++ b/Source/Plugins/TagRange/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\tag_blue.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Source/Plugins/TagRange/Resources/Actions.cfg b/Source/Plugins/TagRange/Resources/Actions.cfg new file mode 100644 index 00000000..baeeafe8 --- /dev/null +++ b/Source/Plugins/TagRange/Resources/Actions.cfg @@ -0,0 +1,10 @@ + +rangetagselectedsectors +{ + title = "Tag Range Sectors"; + category = "sectors"; + description = "Allows giving a range of tags to a selection of sectors."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} diff --git a/Source/Plugins/TagRange/Resources/tag_blue.png b/Source/Plugins/TagRange/Resources/tag_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..9757fc6ed6597438eb8e5a70a1ab2402cdebd5d1 GIT binary patch literal 586 zcmV-Q0=4~#P)6YY{78#rvt}vj%qrc zN=UU@y$E6COaj9&r1NAlaUpajQlL~SorN%pOwHs*2laYgHBA$?ZOd~4Rw@5yFm2?1ZIg`0V-$-;GT1Fi5dB7wUSNi^%`^Ge62m>OBeX610Nsukl}DhDG-mxT?nhyYH!4he7Ri8 zrq0Ti&UXUvqX&F@JcJAe14@BNBqAY_QZAPjF(Y3r7P9H_kB#@LgFAf>xz>Qp&n=|a z>ro1XLZK^nmO`PRh#C2OK0ktd7l6-A;O5?fz1gNnCX)yR0 + + Debug + AnyCPU + 8.0.50727 + 2.0 + {F49EFF6D-51CB-4E49-8223-AAE653C5B62F} + Library + Properties + CodeImp.DoomBuilder.TagRange + TagRange + + + true + ..\..\..\Build\Plugins\ + DEBUG;TRACE + full + x86 + prompt + + + ..\..\..\Build\Plugins\ + + + true + pdbonly + x86 + prompt + + + + + + + + + + + + True + True + Resources.resx + + + Form + + + TagRangeForm.cs + + + Form + + + ToolsForm.cs + + + + + Designer + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + Designer + TagRangeForm.cs + + + Designer + ToolsForm.cs + + + + + {818B3D10-F791-4C3F-9AF5-BB2D0079B63C} + Builder + + + + + \ No newline at end of file diff --git a/Source/Plugins/TagRange/TagRangeForm.Designer.cs b/Source/Plugins/TagRange/TagRangeForm.Designer.cs new file mode 100644 index 00000000..634c032e --- /dev/null +++ b/Source/Plugins/TagRange/TagRangeForm.Designer.cs @@ -0,0 +1,206 @@ +namespace CodeImp.DoomBuilder.TagRange +{ + partial class TagRangeForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.rangestart = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.itemcountlabel = new System.Windows.Forms.Label(); + this.doubletagwarning = new System.Windows.Forms.Label(); + this.skipdoubletags = new System.Windows.Forms.CheckBox(); + this.okbutton = new System.Windows.Forms.Button(); + this.cancelbutton = new System.Windows.Forms.Button(); + this.outoftagswarning = new System.Windows.Forms.Label(); + this.endtaglabel = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // rangestart + // + this.rangestart.AllowDecimal = false; + this.rangestart.AllowNegative = false; + this.rangestart.AllowRelative = false; + this.rangestart.ButtonStep = 1; + this.rangestart.Location = new System.Drawing.Point(110, 56); + this.rangestart.Name = "rangestart"; + this.rangestart.Size = new System.Drawing.Size(96, 24); + this.rangestart.StepValues = null; + this.rangestart.TabIndex = 0; + this.rangestart.WhenTextChanged += new System.EventHandler(this.rangestart_WhenTextChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(44, 61); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(54, 14); + this.label1.TabIndex = 1; + this.label1.Text = "Start Tag:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(30, 27); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(68, 14); + this.label2.TabIndex = 2; + this.label2.Text = "Items to Tag:"; + // + // itemcountlabel + // + this.itemcountlabel.AutoSize = true; + this.itemcountlabel.Location = new System.Drawing.Point(110, 27); + this.itemcountlabel.Name = "itemcountlabel"; + this.itemcountlabel.Size = new System.Drawing.Size(13, 14); + this.itemcountlabel.TabIndex = 3; + this.itemcountlabel.Text = "0"; + // + // doubletagwarning + // + this.doubletagwarning.BackColor = System.Drawing.SystemColors.Info; + this.doubletagwarning.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.doubletagwarning.Location = new System.Drawing.Point(12, 130); + this.doubletagwarning.Name = "doubletagwarning"; + this.doubletagwarning.Padding = new System.Windows.Forms.Padding(3); + this.doubletagwarning.Size = new System.Drawing.Size(273, 50); + this.doubletagwarning.TabIndex = 4; + this.doubletagwarning.Text = "Warning: The tag range contains already used tags."; + this.doubletagwarning.Visible = false; + // + // skipdoubletags + // + this.skipdoubletags.AutoSize = true; + this.skipdoubletags.BackColor = System.Drawing.SystemColors.Info; + this.skipdoubletags.Location = new System.Drawing.Point(63, 154); + this.skipdoubletags.Name = "skipdoubletags"; + this.skipdoubletags.Size = new System.Drawing.Size(161, 18); + this.skipdoubletags.TabIndex = 5; + this.skipdoubletags.Text = "Skip over already used tags"; + this.skipdoubletags.UseVisualStyleBackColor = false; + this.skipdoubletags.Visible = false; + this.skipdoubletags.CheckedChanged += new System.EventHandler(this.skipdoubletags_CheckedChanged); + // + // okbutton + // + this.okbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.okbutton.Location = new System.Drawing.Point(41, 197); + this.okbutton.Name = "okbutton"; + this.okbutton.Size = new System.Drawing.Size(99, 26); + this.okbutton.TabIndex = 6; + this.okbutton.Text = "OK"; + this.okbutton.UseVisualStyleBackColor = true; + this.okbutton.Click += new System.EventHandler(this.okbutton_Click); + // + // cancelbutton + // + this.cancelbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.cancelbutton.Location = new System.Drawing.Point(158, 197); + this.cancelbutton.Name = "cancelbutton"; + this.cancelbutton.Size = new System.Drawing.Size(99, 26); + this.cancelbutton.TabIndex = 7; + this.cancelbutton.Text = "Cancel"; + this.cancelbutton.UseVisualStyleBackColor = true; + this.cancelbutton.Click += new System.EventHandler(this.cancelbutton_Click); + // + // outoftagswarning + // + this.outoftagswarning.BackColor = System.Drawing.SystemColors.Info; + this.outoftagswarning.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.outoftagswarning.Location = new System.Drawing.Point(12, 130); + this.outoftagswarning.Name = "outoftagswarning"; + this.outoftagswarning.Padding = new System.Windows.Forms.Padding(3); + this.outoftagswarning.Size = new System.Drawing.Size(273, 50); + this.outoftagswarning.TabIndex = 8; + this.outoftagswarning.Text = "The range exceeds the maximum allowed tags and cannot be created."; + this.outoftagswarning.Visible = false; + // + // endtaglabel + // + this.endtaglabel.AutoSize = true; + this.endtaglabel.Location = new System.Drawing.Point(110, 95); + this.endtaglabel.Name = "endtaglabel"; + this.endtaglabel.Size = new System.Drawing.Size(13, 14); + this.endtaglabel.TabIndex = 10; + this.endtaglabel.Text = "0"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(49, 95); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(49, 14); + this.label4.TabIndex = 9; + this.label4.Text = "End Tag:"; + // + // TagRangeForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(298, 231); + this.Controls.Add(this.endtaglabel); + this.Controls.Add(this.label4); + this.Controls.Add(this.cancelbutton); + this.Controls.Add(this.okbutton); + this.Controls.Add(this.skipdoubletags); + this.Controls.Add(this.doubletagwarning); + this.Controls.Add(this.itemcountlabel); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Controls.Add(this.rangestart); + this.Controls.Add(this.outoftagswarning); + this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "TagRangeForm"; + this.Opacity = 0; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Tag Selected Range"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox rangestart; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label itemcountlabel; + private System.Windows.Forms.Label doubletagwarning; + private System.Windows.Forms.CheckBox skipdoubletags; + private System.Windows.Forms.Button okbutton; + private System.Windows.Forms.Button cancelbutton; + private System.Windows.Forms.Label outoftagswarning; + private System.Windows.Forms.Label endtaglabel; + private System.Windows.Forms.Label label4; + } +} \ No newline at end of file diff --git a/Source/Plugins/TagRange/TagRangeForm.cs b/Source/Plugins/TagRange/TagRangeForm.cs new file mode 100644 index 00000000..3cb925d6 --- /dev/null +++ b/Source/Plugins/TagRange/TagRangeForm.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using CodeImp.DoomBuilder.Windows; +using CodeImp.DoomBuilder.Types; +using CodeImp.DoomBuilder.Map; +using CodeImp.DoomBuilder.Controls; + +namespace CodeImp.DoomBuilder.TagRange +{ + public partial class TagRangeForm : DelayedForm + { + private UniversalType selectiontype; + private int selectioncount; + Dictionary usedtags; + + public int SelectionCount { get { return selectioncount; } } + + // Constructor + public TagRangeForm() + { + InitializeComponent(); + } + + // This sets up the form + public void Setup() + { + General.Map.Map.ClearAllMarks(false); + + string modename = General.Editing.Mode.GetType().Name; + if(modename == "SectorsMode") + { + selectiontype = UniversalType.SectorTag; + ICollection list = General.Map.Map.GetSelectedSectors(true); + selectioncount = list.Count; + } + else if(modename == "LinedefsMode") + { + selectiontype = UniversalType.LinedefTag; + ICollection list = General.Map.Map.GetSelectedLinedefs(true); + selectioncount = list.Count; + } + else if(modename == "ThingsMode") + { + selectiontype = UniversalType.ThingTag; + ICollection list = General.Map.Map.GetSelectedThings(true); + selectioncount = list.Count; + } + + // Show number of selected items + itemcountlabel.Text = selectioncount.ToString(); + + // Find out which tags are used + usedtags = new Dictionary(); + General.Map.Map.ForAllTags(TagHandler, false, usedtags); + + // Find the first unused tag to use as range start + int starttag = General.Map.Map.GetNewTag(); + rangestart.Text = starttag.ToString(); + } + + // Handler for finding a new tag + private void TagHandler(MapElement element, bool actionargument, UniversalType type, ref int value, Dictionary usedtags) + { + usedtags[value] = true; + } + + // This creates a range + private List CreateRange(int starttag, bool skipusedtags, out bool tagsused, out bool outoftags) + { + List newtags = new List(selectioncount); + outoftags = false; + tagsused = false; + + // Go for the number of tags we need + for(int i = 0; i < selectioncount; i++) + { + if(starttag > General.Map.FormatInterface.MaxTag) + { + outoftags = true; + return newtags; + } + + if(skipusedtags) + { + // Find next unused tag + while(usedtags.ContainsKey(starttag)) + { + if(starttag == General.Map.FormatInterface.MaxTag) + { + outoftags = true; + return newtags; + } + + starttag++; + } + } + else + { + tagsused |= usedtags.ContainsKey(starttag); + } + + newtags.Add(starttag); + + if(starttag < General.Map.FormatInterface.MaxTag) + starttag++; + } + + return newtags; + } + + // This updates the calculated range + private void UpdateChanges() + { + bool outoftags, tagsused; + int starttag = rangestart.GetResult(0); + + List tags = CreateRange(starttag, false, out tagsused, out outoftags); + + outoftagswarning.Visible = outoftags; + doubletagwarning.Visible = tagsused && !outoftags; + skipdoubletags.Visible = tagsused && !outoftags; + + tags = CreateRange(starttag, skipdoubletags.Checked, out tagsused, out outoftags); + + if(tags.Count > 0) + endtaglabel.Text = tags[tags.Count - 1].ToString(); + } + + // Range start changes + private void rangestart_WhenTextChanged(object sender, EventArgs e) + { + UpdateChanges(); + } + + // OK clicked + private void okbutton_Click(object sender, EventArgs e) + { + bool outoftags, tagsused; + int starttag = rangestart.GetResult(0); + + List tags = CreateRange(starttag, skipdoubletags.Checked, out tagsused, out outoftags); + + if(outoftags) + { + General.ShowWarningMessage("The range exceeds the maximum allowed tags and cannot be created.", MessageBoxButtons.OK); + } + else + { + // Apply tags! + if(selectiontype == UniversalType.SectorTag) + { + General.Map.UndoRedo.CreateUndo("Set " + selectioncount + " sector tags"); + ICollection list = General.Map.Map.GetSelectedSectors(true); + int index = 0; + foreach(Sector s in list) + s.Tag = tags[index++]; + } + else if(selectiontype == UniversalType.LinedefTag) + { + General.Map.UndoRedo.CreateUndo("Set " + selectioncount + " linedef tags"); + ICollection list = General.Map.Map.GetSelectedLinedefs(true); + int index = 0; + foreach(Linedef l in list) + l.Tag = tags[index++]; + } + else if(selectiontype == UniversalType.ThingTag) + { + General.Map.UndoRedo.CreateUndo("Set " + selectioncount + " thing tags"); + ICollection list = General.Map.Map.GetSelectedThings(true); + int index = 0; + foreach(Thing t in list) + t.Tag = tags[index++]; + } + } + + this.Close(); + } + + // Cancel clicked + private void cancelbutton_Click(object sender, EventArgs e) + { + this.Close(); + } + + // Skip over used tags changed + private void skipdoubletags_CheckedChanged(object sender, EventArgs e) + { + UpdateChanges(); + } + } +} + diff --git a/Source/Plugins/TagRange/TagRangeForm.resx b/Source/Plugins/TagRange/TagRangeForm.resx new file mode 100644 index 00000000..6f756533 --- /dev/null +++ b/Source/Plugins/TagRange/TagRangeForm.resx @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/Source/Plugins/TagRange/ToolsForm.Designer.cs b/Source/Plugins/TagRange/ToolsForm.Designer.cs new file mode 100644 index 00000000..ffc35e2e --- /dev/null +++ b/Source/Plugins/TagRange/ToolsForm.Designer.cs @@ -0,0 +1,99 @@ +namespace CodeImp.DoomBuilder.TagRange +{ + partial class ToolsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.toolstrip = new System.Windows.Forms.ToolStrip(); + this.tagrangebutton = new System.Windows.Forms.ToolStripButton(); + this.seperator2 = new System.Windows.Forms.ToolStripSeparator(); + this.seperator1 = new System.Windows.Forms.ToolStripSeparator(); + this.toolstrip.SuspendLayout(); + this.SuspendLayout(); + // + // toolstrip + // + this.toolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.seperator1, + this.tagrangebutton, + this.seperator2}); + this.toolstrip.Location = new System.Drawing.Point(0, 0); + this.toolstrip.Name = "toolstrip"; + this.toolstrip.Size = new System.Drawing.Size(330, 25); + this.toolstrip.TabIndex = 0; + this.toolstrip.Text = "toolStrip1"; + // + // tagrangebutton + // + this.tagrangebutton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tagrangebutton.Image = global::CodeImp.DoomBuilder.TagRange.Properties.Resources.tag_blue; + this.tagrangebutton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tagrangebutton.Name = "tagrangebutton"; + this.tagrangebutton.Size = new System.Drawing.Size(23, 22); + this.tagrangebutton.Tag = "rangetagselectedsectors"; + this.tagrangebutton.Text = "Tag Range"; + this.tagrangebutton.Click += new System.EventHandler(this.InvokeTaggedAction); + // + // seperator2 + // + this.seperator2.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0); + this.seperator2.Name = "seperator2"; + this.seperator2.Size = new System.Drawing.Size(6, 25); + // + // seperator1 + // + this.seperator1.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0); + this.seperator1.Name = "seperator1"; + this.seperator1.Size = new System.Drawing.Size(6, 25); + // + // ToolsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.ClientSize = new System.Drawing.Size(330, 230); + this.Controls.Add(this.toolstrip); + this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ToolsForm"; + this.Text = "Tag Range"; + this.toolstrip.ResumeLayout(false); + this.toolstrip.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ToolStrip toolstrip; + private System.Windows.Forms.ToolStripButton tagrangebutton; + private System.Windows.Forms.ToolStripSeparator seperator2; + private System.Windows.Forms.ToolStripSeparator seperator1; + } +} \ No newline at end of file diff --git a/Source/Plugins/TagRange/ToolsForm.cs b/Source/Plugins/TagRange/ToolsForm.cs new file mode 100644 index 00000000..67a0f2aa --- /dev/null +++ b/Source/Plugins/TagRange/ToolsForm.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using CodeImp.DoomBuilder.IO; + +namespace CodeImp.DoomBuilder.TagRange +{ + public partial class ToolsForm : Form + { + bool buttonontoolbar; + + // Constructor + public ToolsForm() + { + InitializeComponent(); + buttonontoolbar = false; + } + + // This invokes an action from control event + private void InvokeTaggedAction(object sender, EventArgs e) + { + General.Interface.InvokeTaggedAction(sender, e); + } + + // This adds or removes the button from the DB toolbar + public void UpdateButton() + { + if(buttonontoolbar) + { + General.Interface.RemoveButton(seperator1); + General.Interface.RemoveButton(tagrangebutton); + General.Interface.RemoveButton(seperator2); + buttonontoolbar = false; + } + + if(General.Editing.Mode == null) + return; + + string modename = General.Editing.Mode.GetType().Name; + IMapSetIO mapset = General.Map.FormatInterface; + if((modename == "SectorsMode") || + ((modename == "LinedefsMode") && mapset.HasLinedefTag) || + ((modename == "ThingsMode") && mapset.HasThingTag)) + { + General.Interface.AddButton(seperator1); + General.Interface.AddButton(tagrangebutton); + General.Interface.AddButton(seperator2); + buttonontoolbar = true; + } + } + } +} diff --git a/Source/Plugins/TagRange/ToolsForm.resx b/Source/Plugins/TagRange/ToolsForm.resx new file mode 100644 index 00000000..e9b8a201 --- /dev/null +++ b/Source/Plugins/TagRange/ToolsForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file