diff --git a/Resources/Icons/ColorPick.png b/Resources/Icons/ColorPick.png new file mode 100644 index 00000000..4cf7c053 Binary files /dev/null and b/Resources/Icons/ColorPick.png differ diff --git a/Source/Builder.csproj b/Source/Builder.csproj index 6b50f93d..44e2c358 100644 --- a/Source/Builder.csproj +++ b/Source/Builder.csproj @@ -54,8 +54,8 @@ <Compile Include="Data\SpriteImage.cs" /> <Compile Include="Data\TextureImage.cs" /> <Compile Include="Editing\EditMode.cs" /> - <Compile Include="Editing\FrozenOverviewMode.cs" /> - <Compile Include="Editing\ViewClassicMode.cs" /> + <Compile Include="Editing\VerticesMode.cs" /> + <Compile Include="Editing\ClassicMode.cs" /> <Compile Include="Controls\ActionDelegate.cs" /> <Compile Include="Controls\Action.cs" /> <Compile Include="Controls\ActionManager.cs" /> @@ -80,6 +80,12 @@ <Compile Include="Interface\AboutForm.Designer.cs"> <DependentUpon>AboutForm.cs</DependentUpon> </Compile> + <Compile Include="Interface\ColorControl.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="Interface\ColorControl.Designer.cs"> + <DependentUpon>ColorControl.cs</DependentUpon> + </Compile> <Compile Include="Interface\ConfigForm.cs"> <SubType>Form</SubType> </Compile> @@ -141,6 +147,7 @@ </Compile> <Compile Include="Map\Linedef.cs" /> <Compile Include="Map\MapOptions.cs" /> + <Compile Include="Map\MapSelection.cs" /> <Compile Include="Map\MapSet.cs" /> <Compile Include="Data\DataLocation.cs" /> <Compile Include="Map\Sector.cs" /> @@ -154,6 +161,8 @@ <DependentUpon>Resources.resx</DependentUpon> </Compile> <Compile Include="Rendering\Base2DShader.cs" /> + <Compile Include="Rendering\ColorCollection.cs" /> + <Compile Include="Rendering\ColorSetting.cs" /> <Compile Include="Rendering\D3DGraphics.cs" /> <Compile Include="Data\ImageData.cs" /> <Compile Include="Rendering\D3DShader.cs" /> @@ -201,6 +210,7 @@ </ItemGroup> <ItemGroup> <Content Include="Resources\Builder.ico" /> + <None Include="Resources\ColorPick.png" /> <None Include="Resources\Zoom.png" /> <None Include="Resources\Properties.png" /> <None Include="Resources\NewMap2.png" /> @@ -210,6 +220,10 @@ <None Include="Resources\Splash2small.png" /> </ItemGroup> <ItemGroup> + <EmbeddedResource Include="Interface\ColorControl.resx"> + <SubType>Designer</SubType> + <DependentUpon>ColorControl.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Interface\ConfigForm.resx"> <SubType>Designer</SubType> <DependentUpon>ConfigForm.cs</DependentUpon> diff --git a/Source/Editing/ViewClassicMode.cs b/Source/Editing/ClassicMode.cs similarity index 92% rename from Source/Editing/ViewClassicMode.cs rename to Source/Editing/ClassicMode.cs index bbfb2dd6..b7e4133a 100644 --- a/Source/Editing/ViewClassicMode.cs +++ b/Source/Editing/ClassicMode.cs @@ -36,7 +36,7 @@ using System.Drawing; namespace CodeImp.DoomBuilder.Editing { - internal class ViewClassicMode : EditMode + internal abstract class ClassicMode : EditMode { #region ================== Constants @@ -61,7 +61,7 @@ namespace CodeImp.DoomBuilder.Editing #region ================== Constructor / Disposer // Constructor - public ViewClassicMode() + public ClassicMode() { // Initialize this.renderer = General.Map.Graphics.Renderer2D; @@ -271,5 +271,15 @@ namespace CodeImp.DoomBuilder.Editing } #endregion + + #region ================== Display + + // This just refreshes the display + public override void RefreshDisplay() + { + renderer.Present(); + } + + #endregion } } diff --git a/Source/Editing/FrozenOverviewMode.cs b/Source/Editing/VerticesMode.cs similarity index 75% rename from Source/Editing/FrozenOverviewMode.cs rename to Source/Editing/VerticesMode.cs index 78c5b694..b7c84551 100644 --- a/Source/Editing/FrozenOverviewMode.cs +++ b/Source/Editing/VerticesMode.cs @@ -33,7 +33,7 @@ using CodeImp.DoomBuilder.Rendering; namespace CodeImp.DoomBuilder.Editing { - internal class FrozenOverviewMode : ViewClassicMode + internal class VerticesMode : ClassicMode { #region ================== Constants @@ -41,6 +41,9 @@ namespace CodeImp.DoomBuilder.Editing #region ================== Variables + // Selection + private MapSelection selection; + #endregion #region ================== Properties @@ -49,10 +52,20 @@ namespace CodeImp.DoomBuilder.Editing #region ================== Constructor / Disposer - // Constructor - public FrozenOverviewMode() + /// <summary> + /// Fresh mode + /// </summary> + public VerticesMode() { - CenterInScreen(); + } + + /// <summary> + /// From dragging + /// </summary> + public VerticesMode(MapSelection selection) + { + // Keep selection + this.selection = selection; } // Diposer @@ -71,20 +84,18 @@ namespace CodeImp.DoomBuilder.Editing #endregion #region ================== Methods - - // This just refreshes the display - public override void RefreshDisplay() - { - renderer.Present(); - } // This redraws the display public unsafe override void RedrawDisplay() { - if(renderer.StartRendering()) + // Start with a clear display + if(renderer.StartRendering(true)) { + // Render stuff renderer.RenderLinedefs(General.Map.Map, General.Map.Map.Linedefs); renderer.RenderVertices(General.Map.Map, General.Map.Map.Vertices); + + // Done renderer.FinishRendering(); } } diff --git a/Source/General/General.cs b/Source/General/General.cs index 6364ab09..40d2757f 100644 --- a/Source/General/General.cs +++ b/Source/General/General.cs @@ -31,6 +31,7 @@ using CodeImp.DoomBuilder.Geometry; using System.Runtime.InteropServices; using CodeImp.DoomBuilder.Controls; using System.Diagnostics; +using CodeImp.DoomBuilder.Rendering; #endregion @@ -105,6 +106,7 @@ namespace CodeImp.DoomBuilder private static Configuration settings; private static MapManager map; private static ActionManager actions; + private static ColorCollection colors; // Configurations private static List<ConfigurationInfo> configs; @@ -122,6 +124,7 @@ namespace CodeImp.DoomBuilder public static string CompilersPath { get { return compilerspath; } } public static MainForm MainWindow { get { return mainwindow; } } public static Configuration Settings { get { return settings; } } + public static ColorCollection Colors { get { return colors; } } public static List<ConfigurationInfo> Configs { get { return configs; } } public static List<NodebuilderInfo> Nodebuilders { get { return nodebuilders; } } public static List<CompilerInfo> Compilers { get { return compilers; } } @@ -429,6 +432,10 @@ namespace CodeImp.DoomBuilder General.WriteLogLine("Loading nodebuilder configurations..."); LoadAllNodebuilderConfigurations(); + // Load color settings + General.WriteLogLine("Loading color settings..."); + colors = new ColorCollection(settings); + // Run application from the main window General.WriteLogLine("Startup done"); mainwindow.DisplayReady(); @@ -512,6 +519,9 @@ namespace CodeImp.DoomBuilder mainwindow.Dispose(); actions.Dispose(); + // Save colors + colors.SaveColors(settings); + // Save action controls actions.SaveSettings(); diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs index 248bbb66..ec3b285e 100644 --- a/Source/General/MapManager.cs +++ b/Source/General/MapManager.cs @@ -201,7 +201,7 @@ namespace CodeImp.DoomBuilder ActionAttribute.BindMethods(this); // Set default mode - ChangeMode(typeof(FrozenOverviewMode)); + ChangeMode(new VerticesMode()); // Success General.WriteLogLine("Map creation done"); @@ -279,8 +279,11 @@ namespace CodeImp.DoomBuilder ActionAttribute.BindMethods(this); // Set default mode - ChangeMode(typeof(FrozenOverviewMode)); + ChangeMode(new VerticesMode()); + // Center map in screen + (General.Map.Mode as ClassicMode).CenterInScreen(); + // Success General.WriteLogLine("Map loading done"); return true; @@ -842,14 +845,14 @@ namespace CodeImp.DoomBuilder } // This changes editing mode - public void ChangeMode(Type modetype, params object[] args) + public void ChangeMode(EditMode newmode) { // Dispose current mode if(mode != null) mode.Dispose(); - // Create a new mode - General.WriteLogLine("Switching edit mode to " + modetype.Name + "..."); - mode = EditMode.Create(modetype, args); + // Set new mode + General.WriteLogLine("Switched edit mode to " + newmode.GetType().Name); + mode = newmode; // Redraw the display General.MainWindow.RedrawDisplay(); diff --git a/Source/Interface/ColorControl.Designer.cs b/Source/Interface/ColorControl.Designer.cs new file mode 100644 index 00000000..b849e33b --- /dev/null +++ b/Source/Interface/ColorControl.Designer.cs @@ -0,0 +1,93 @@ +namespace CodeImp.DoomBuilder.Interface +{ + partial class ColorControl + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.label = new System.Windows.Forms.Label(); + this.panel = new System.Windows.Forms.Panel(); + this.button = new System.Windows.Forms.Button(); + this.dialog = new System.Windows.Forms.ColorDialog(); + this.SuspendLayout(); + // + // label + // + this.label.Location = new System.Drawing.Point(-3, 0); + this.label.Name = "label"; + this.label.Size = new System.Drawing.Size(175, 23); + this.label.TabIndex = 0; + this.label.Text = "Color name:"; + this.label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // panel + // + this.panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); + this.panel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panel.Location = new System.Drawing.Point(178, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(27, 23); + this.panel.TabIndex = 1; + // + // button + // + this.button.Image = global::CodeImp.DoomBuilder.Properties.Resources.ColorPick; + this.button.ImageAlign = System.Drawing.ContentAlignment.BottomCenter; + this.button.Location = new System.Drawing.Point(322, 0); + this.button.Name = "button"; + this.button.Size = new System.Drawing.Size(26, 23); + this.button.TabIndex = 2; + this.button.UseVisualStyleBackColor = true; + this.button.Click += new System.EventHandler(this.button_Click); + // + // dialog + // + this.dialog.FullOpen = true; + // + // ColorControl + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.BackColor = System.Drawing.SystemColors.Control; + this.Controls.Add(this.button); + this.Controls.Add(this.panel); + this.Controls.Add(this.label); + this.MaximumSize = new System.Drawing.Size(10000, 23); + this.MinimumSize = new System.Drawing.Size(100, 23); + this.Name = "ColorControl"; + this.Size = new System.Drawing.Size(348, 23); + this.Resize += new System.EventHandler(this.ColorControl_Resize); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label; + private System.Windows.Forms.Panel panel; + private System.Windows.Forms.Button button; + private System.Windows.Forms.ColorDialog dialog; + } +} diff --git a/Source/Interface/ColorControl.cs b/Source/Interface/ColorControl.cs new file mode 100644 index 00000000..07a9fd8d --- /dev/null +++ b/Source/Interface/ColorControl.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using CodeImp.DoomBuilder.Rendering; + +namespace CodeImp.DoomBuilder.Interface +{ + public partial class ColorControl : UserControl + { + // Constructor + public ColorControl() + { + // Initialize + InitializeComponent(); + } + + // Properties + public string Label { get { return label.Text; } set { label.Text = value; } } + public PixelColor Color { get { return PixelColor.FromColor(panel.BackColor); } set { panel.BackColor = System.Drawing.Color.FromArgb(value.ToInt()); } } + + // Button clicked + private void button_Click(object sender, EventArgs e) + { + // Show color dialog + dialog.Color = panel.BackColor; + if(dialog.ShowDialog(this.ParentForm) == DialogResult.OK) + { + // Apply new color + panel.BackColor = dialog.Color; + } + } + + // Resized + private void ColorControl_Resize(object sender, EventArgs e) + { + try + { + button.Left = ClientSize.Width - button.Width; + panel.Left = ClientSize.Width - button.Width - panel.Width - 3; + label.Left = 0; + label.Width = panel.Left; + } + catch(Exception) { } + } + } +} diff --git a/Source/Interface/ColorControl.resx b/Source/Interface/ColorControl.resx new file mode 100644 index 00000000..a5699c41 --- /dev/null +++ b/Source/Interface/ColorControl.resx @@ -0,0 +1,123 @@ +<?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> + <metadata name="dialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> +</root> \ No newline at end of file diff --git a/Source/Interface/MainForm.cs b/Source/Interface/MainForm.cs index a1970898..bab2d510 100644 --- a/Source/Interface/MainForm.cs +++ b/Source/Interface/MainForm.cs @@ -287,7 +287,7 @@ namespace CodeImp.DoomBuilder.Interface if(General.Map == null) return; // In classic mode? - if(General.Map.Mode is ViewClassicMode) + if(General.Map.Mode is ClassicMode) { // Requested from menu? if(sender is ToolStripMenuItem) @@ -296,7 +296,7 @@ namespace CodeImp.DoomBuilder.Interface zoom = int.Parse((sender as ToolStripMenuItem).Tag.ToString(), CultureInfo.InvariantCulture); // Zoom now - (General.Map.Mode as ViewClassicMode).SetZoom((float)zoom / 100f); + (General.Map.Mode as ClassicMode).SetZoom((float)zoom / 100f); } } } @@ -307,8 +307,8 @@ namespace CodeImp.DoomBuilder.Interface if(General.Map == null) return; // In classic mode? - if(General.Map.Mode is ViewClassicMode) - (General.Map.Mode as ViewClassicMode).CenterInScreen(); + if(General.Map.Mode is ClassicMode) + (General.Map.Mode as ClassicMode).CenterInScreen(); } #endregion diff --git a/Source/Interface/PreferencesForm.Designer.cs b/Source/Interface/PreferencesForm.Designer.cs index f8b780e8..7824ef07 100644 --- a/Source/Interface/PreferencesForm.Designer.cs +++ b/Source/Interface/PreferencesForm.Designer.cs @@ -31,6 +31,17 @@ namespace CodeImp.DoomBuilder.Interface System.Windows.Forms.Label label7; System.Windows.Forms.Label label6; System.Windows.Forms.Label label5; + this.colorsgroup1 = new System.Windows.Forms.GroupBox(); + this.colorgrid64 = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorgrid = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorassociations = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorsoundlinedefs = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorspeciallinedefs = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorbackcolor = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorselection = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorvertices = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorhighlight = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorlinedefs = new CodeImp.DoomBuilder.Interface.ColorControl(); this.cancel = new System.Windows.Forms.Button(); this.apply = new System.Windows.Forms.Button(); this.tabs = new System.Windows.Forms.TabControl(); @@ -45,12 +56,29 @@ namespace CodeImp.DoomBuilder.Interface this.actioncontrolclear = new System.Windows.Forms.Button(); this.actionkey = new System.Windows.Forms.TextBox(); this.actiondescription = new System.Windows.Forms.Label(); + this.tabcolors = new System.Windows.Forms.TabPage(); + this.colorsgroup3 = new System.Windows.Forms.GroupBox(); + this.colorconstants = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorliterals = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorControl1 = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorkeywords = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorlinenumbers = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorcomments = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorplaintext = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorsgroup2 = new System.Windows.Forms.GroupBox(); + this.colorselection3d = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorhighlight3d = new CodeImp.DoomBuilder.Interface.ColorControl(); + this.colorcrosshair3d = new CodeImp.DoomBuilder.Interface.ColorControl(); label7 = new System.Windows.Forms.Label(); label6 = new System.Windows.Forms.Label(); label5 = new System.Windows.Forms.Label(); + this.colorsgroup1.SuspendLayout(); this.tabs.SuspendLayout(); this.tabkeys.SuspendLayout(); this.actioncontrolpanel.SuspendLayout(); + this.tabcolors.SuspendLayout(); + this.colorsgroup3.SuspendLayout(); + this.colorsgroup2.SuspendLayout(); this.SuspendLayout(); // // label7 @@ -80,12 +108,142 @@ namespace CodeImp.DoomBuilder.Interface label5.TabIndex = 4; label5.Text = "Press the desired key combination here:"; // + // colorsgroup1 + // + this.colorsgroup1.Controls.Add(this.colorgrid64); + this.colorsgroup1.Controls.Add(this.colorgrid); + this.colorsgroup1.Controls.Add(this.colorassociations); + this.colorsgroup1.Controls.Add(this.colorsoundlinedefs); + this.colorsgroup1.Controls.Add(this.colorspeciallinedefs); + this.colorsgroup1.Controls.Add(this.colorbackcolor); + this.colorsgroup1.Controls.Add(this.colorselection); + this.colorsgroup1.Controls.Add(this.colorvertices); + this.colorsgroup1.Controls.Add(this.colorhighlight); + this.colorsgroup1.Controls.Add(this.colorlinedefs); + this.colorsgroup1.Location = new System.Drawing.Point(12, 10); + this.colorsgroup1.Name = "colorsgroup1"; + this.colorsgroup1.Size = new System.Drawing.Size(181, 330); + this.colorsgroup1.TabIndex = 10; + this.colorsgroup1.TabStop = false; + this.colorsgroup1.Text = " Classic modes "; + this.colorsgroup1.Visible = false; + // + // colorgrid64 + // + this.colorgrid64.BackColor = System.Drawing.SystemColors.Control; + this.colorgrid64.Label = "64 Block grid:"; + this.colorgrid64.Location = new System.Drawing.Point(15, 288); + this.colorgrid64.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorgrid64.MinimumSize = new System.Drawing.Size(100, 23); + this.colorgrid64.Name = "colorgrid64"; + this.colorgrid64.Size = new System.Drawing.Size(150, 23); + this.colorgrid64.TabIndex = 15; + // + // colorgrid + // + this.colorgrid.BackColor = System.Drawing.SystemColors.Control; + this.colorgrid.Label = "Custom grid:"; + this.colorgrid.Location = new System.Drawing.Point(15, 259); + this.colorgrid.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorgrid.MinimumSize = new System.Drawing.Size(100, 23); + this.colorgrid.Name = "colorgrid"; + this.colorgrid.Size = new System.Drawing.Size(150, 23); + this.colorgrid.TabIndex = 14; + // + // colorassociations + // + this.colorassociations.BackColor = System.Drawing.SystemColors.Control; + this.colorassociations.Label = "Associations:"; + this.colorassociations.Location = new System.Drawing.Point(15, 230); + this.colorassociations.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorassociations.MinimumSize = new System.Drawing.Size(100, 23); + this.colorassociations.Name = "colorassociations"; + this.colorassociations.Size = new System.Drawing.Size(150, 23); + this.colorassociations.TabIndex = 13; + // + // colorsoundlinedefs + // + this.colorsoundlinedefs.BackColor = System.Drawing.SystemColors.Control; + this.colorsoundlinedefs.Label = "Sound lines:"; + this.colorsoundlinedefs.Location = new System.Drawing.Point(15, 143); + this.colorsoundlinedefs.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorsoundlinedefs.MinimumSize = new System.Drawing.Size(100, 23); + this.colorsoundlinedefs.Name = "colorsoundlinedefs"; + this.colorsoundlinedefs.Size = new System.Drawing.Size(150, 23); + this.colorsoundlinedefs.TabIndex = 12; + // + // colorspeciallinedefs + // + this.colorspeciallinedefs.BackColor = System.Drawing.SystemColors.Control; + this.colorspeciallinedefs.Label = "Action lines:"; + this.colorspeciallinedefs.Location = new System.Drawing.Point(15, 114); + this.colorspeciallinedefs.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorspeciallinedefs.MinimumSize = new System.Drawing.Size(100, 23); + this.colorspeciallinedefs.Name = "colorspeciallinedefs"; + this.colorspeciallinedefs.Size = new System.Drawing.Size(150, 23); + this.colorspeciallinedefs.TabIndex = 11; + // + // colorbackcolor + // + this.colorbackcolor.BackColor = System.Drawing.SystemColors.Control; + this.colorbackcolor.Label = "Background:"; + this.colorbackcolor.Location = new System.Drawing.Point(15, 27); + this.colorbackcolor.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorbackcolor.MinimumSize = new System.Drawing.Size(100, 23); + this.colorbackcolor.Name = "colorbackcolor"; + this.colorbackcolor.Size = new System.Drawing.Size(150, 23); + this.colorbackcolor.TabIndex = 5; + // + // colorselection + // + this.colorselection.BackColor = System.Drawing.SystemColors.Control; + this.colorselection.Label = "Selection:"; + this.colorselection.Location = new System.Drawing.Point(15, 201); + this.colorselection.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorselection.MinimumSize = new System.Drawing.Size(100, 23); + this.colorselection.Name = "colorselection"; + this.colorselection.Size = new System.Drawing.Size(150, 23); + this.colorselection.TabIndex = 9; + // + // colorvertices + // + this.colorvertices.BackColor = System.Drawing.SystemColors.Control; + this.colorvertices.Label = "Vertices:"; + this.colorvertices.Location = new System.Drawing.Point(15, 56); + this.colorvertices.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorvertices.MinimumSize = new System.Drawing.Size(100, 23); + this.colorvertices.Name = "colorvertices"; + this.colorvertices.Size = new System.Drawing.Size(150, 23); + this.colorvertices.TabIndex = 6; + // + // colorhighlight + // + this.colorhighlight.BackColor = System.Drawing.SystemColors.Control; + this.colorhighlight.Label = "Highlight:"; + this.colorhighlight.Location = new System.Drawing.Point(15, 172); + this.colorhighlight.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorhighlight.MinimumSize = new System.Drawing.Size(100, 23); + this.colorhighlight.Name = "colorhighlight"; + this.colorhighlight.Size = new System.Drawing.Size(150, 23); + this.colorhighlight.TabIndex = 8; + // + // colorlinedefs + // + this.colorlinedefs.BackColor = System.Drawing.SystemColors.Control; + this.colorlinedefs.Label = "Common lines:"; + this.colorlinedefs.Location = new System.Drawing.Point(15, 85); + this.colorlinedefs.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorlinedefs.MinimumSize = new System.Drawing.Size(100, 23); + this.colorlinedefs.Name = "colorlinedefs"; + this.colorlinedefs.Size = new System.Drawing.Size(150, 23); + this.colorlinedefs.TabIndex = 7; + // // cancel // this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.cancel.Location = new System.Drawing.Point(497, 406); this.cancel.Name = "cancel"; - this.cancel.Size = new System.Drawing.Size(112, 27); + this.cancel.Size = new System.Drawing.Size(112, 25); this.cancel.TabIndex = 20; this.cancel.Text = "Cancel"; this.cancel.UseVisualStyleBackColor = true; @@ -95,7 +253,7 @@ namespace CodeImp.DoomBuilder.Interface // this.apply.Location = new System.Drawing.Point(379, 406); this.apply.Name = "apply"; - this.apply.Size = new System.Drawing.Size(112, 27); + this.apply.Size = new System.Drawing.Size(112, 25); this.apply.TabIndex = 19; this.apply.Text = "OK"; this.apply.UseVisualStyleBackColor = true; @@ -105,6 +263,7 @@ namespace CodeImp.DoomBuilder.Interface // this.tabs.Controls.Add(this.tabinterface); this.tabs.Controls.Add(this.tabkeys); + this.tabs.Controls.Add(this.tabcolors); this.tabs.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tabs.ItemSize = new System.Drawing.Size(110, 19); this.tabs.Location = new System.Drawing.Point(11, 13); @@ -113,6 +272,7 @@ namespace CodeImp.DoomBuilder.Interface this.tabs.Size = new System.Drawing.Size(598, 379); this.tabs.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; this.tabs.TabIndex = 18; + this.tabs.SelectedIndexChanged += new System.EventHandler(this.tabs_SelectedIndexChanged); // // tabinterface // @@ -246,13 +406,166 @@ namespace CodeImp.DoomBuilder.Interface this.actiondescription.TabIndex = 3; this.actiondescription.UseMnemonic = false; // + // tabcolors + // + this.tabcolors.Controls.Add(this.colorsgroup3); + this.tabcolors.Controls.Add(this.colorsgroup2); + this.tabcolors.Controls.Add(this.colorsgroup1); + this.tabcolors.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tabcolors.Location = new System.Drawing.Point(4, 23); + this.tabcolors.Name = "tabcolors"; + this.tabcolors.Size = new System.Drawing.Size(590, 352); + this.tabcolors.TabIndex = 2; + this.tabcolors.Text = "Colors"; + this.tabcolors.UseVisualStyleBackColor = true; + // + // colorsgroup3 + // + this.colorsgroup3.Controls.Add(this.colorconstants); + this.colorsgroup3.Controls.Add(this.colorliterals); + this.colorsgroup3.Controls.Add(this.colorControl1); + this.colorsgroup3.Controls.Add(this.colorkeywords); + this.colorsgroup3.Controls.Add(this.colorlinenumbers); + this.colorsgroup3.Controls.Add(this.colorcomments); + this.colorsgroup3.Controls.Add(this.colorplaintext); + this.colorsgroup3.Location = new System.Drawing.Point(398, 10); + this.colorsgroup3.Name = "colorsgroup3"; + this.colorsgroup3.Size = new System.Drawing.Size(181, 330); + this.colorsgroup3.TabIndex = 12; + this.colorsgroup3.TabStop = false; + this.colorsgroup3.Text = " Script editor "; + this.colorsgroup3.Visible = false; + // + // colorconstants + // + this.colorconstants.BackColor = System.Drawing.SystemColors.Control; + this.colorconstants.Label = "Constants:"; + this.colorconstants.Location = new System.Drawing.Point(15, 201); + this.colorconstants.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorconstants.MinimumSize = new System.Drawing.Size(100, 23); + this.colorconstants.Name = "colorconstants"; + this.colorconstants.Size = new System.Drawing.Size(150, 23); + this.colorconstants.TabIndex = 16; + // + // colorliterals + // + this.colorliterals.BackColor = System.Drawing.SystemColors.Control; + this.colorliterals.Label = "Literals:"; + this.colorliterals.Location = new System.Drawing.Point(15, 172); + this.colorliterals.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorliterals.MinimumSize = new System.Drawing.Size(100, 23); + this.colorliterals.Name = "colorliterals"; + this.colorliterals.Size = new System.Drawing.Size(150, 23); + this.colorliterals.TabIndex = 15; + // + // colorControl1 + // + this.colorControl1.BackColor = System.Drawing.SystemColors.Control; + this.colorControl1.Label = "Background:"; + this.colorControl1.Location = new System.Drawing.Point(15, 27); + this.colorControl1.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorControl1.MinimumSize = new System.Drawing.Size(100, 23); + this.colorControl1.Name = "colorControl1"; + this.colorControl1.Size = new System.Drawing.Size(150, 23); + this.colorControl1.TabIndex = 10; + // + // colorkeywords + // + this.colorkeywords.BackColor = System.Drawing.SystemColors.Control; + this.colorkeywords.Label = "Keywords:"; + this.colorkeywords.Location = new System.Drawing.Point(15, 143); + this.colorkeywords.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorkeywords.MinimumSize = new System.Drawing.Size(100, 23); + this.colorkeywords.Name = "colorkeywords"; + this.colorkeywords.Size = new System.Drawing.Size(150, 23); + this.colorkeywords.TabIndex = 14; + // + // colorlinenumbers + // + this.colorlinenumbers.BackColor = System.Drawing.SystemColors.Control; + this.colorlinenumbers.Label = "Line numbers:"; + this.colorlinenumbers.Location = new System.Drawing.Point(15, 56); + this.colorlinenumbers.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorlinenumbers.MinimumSize = new System.Drawing.Size(100, 23); + this.colorlinenumbers.Name = "colorlinenumbers"; + this.colorlinenumbers.Size = new System.Drawing.Size(150, 23); + this.colorlinenumbers.TabIndex = 11; + // + // colorcomments + // + this.colorcomments.BackColor = System.Drawing.SystemColors.Control; + this.colorcomments.Label = "Comments:"; + this.colorcomments.Location = new System.Drawing.Point(15, 114); + this.colorcomments.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorcomments.MinimumSize = new System.Drawing.Size(100, 23); + this.colorcomments.Name = "colorcomments"; + this.colorcomments.Size = new System.Drawing.Size(150, 23); + this.colorcomments.TabIndex = 13; + // + // colorplaintext + // + this.colorplaintext.BackColor = System.Drawing.SystemColors.Control; + this.colorplaintext.Label = "Plain text:"; + this.colorplaintext.Location = new System.Drawing.Point(15, 85); + this.colorplaintext.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorplaintext.MinimumSize = new System.Drawing.Size(100, 23); + this.colorplaintext.Name = "colorplaintext"; + this.colorplaintext.Size = new System.Drawing.Size(150, 23); + this.colorplaintext.TabIndex = 12; + // + // colorsgroup2 + // + this.colorsgroup2.Controls.Add(this.colorselection3d); + this.colorsgroup2.Controls.Add(this.colorhighlight3d); + this.colorsgroup2.Controls.Add(this.colorcrosshair3d); + this.colorsgroup2.Location = new System.Drawing.Point(205, 10); + this.colorsgroup2.Name = "colorsgroup2"; + this.colorsgroup2.Size = new System.Drawing.Size(181, 330); + this.colorsgroup2.TabIndex = 11; + this.colorsgroup2.TabStop = false; + this.colorsgroup2.Text = " 3D mode "; + this.colorsgroup2.Visible = false; + // + // colorselection3d + // + this.colorselection3d.BackColor = System.Drawing.SystemColors.Control; + this.colorselection3d.Label = "Selection:"; + this.colorselection3d.Location = new System.Drawing.Point(15, 85); + this.colorselection3d.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorselection3d.MinimumSize = new System.Drawing.Size(100, 23); + this.colorselection3d.Name = "colorselection3d"; + this.colorselection3d.Size = new System.Drawing.Size(150, 23); + this.colorselection3d.TabIndex = 8; + // + // colorhighlight3d + // + this.colorhighlight3d.BackColor = System.Drawing.SystemColors.Control; + this.colorhighlight3d.Label = "Highlight:"; + this.colorhighlight3d.Location = new System.Drawing.Point(15, 56); + this.colorhighlight3d.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorhighlight3d.MinimumSize = new System.Drawing.Size(100, 23); + this.colorhighlight3d.Name = "colorhighlight3d"; + this.colorhighlight3d.Size = new System.Drawing.Size(150, 23); + this.colorhighlight3d.TabIndex = 7; + // + // colorcrosshair3d + // + this.colorcrosshair3d.BackColor = System.Drawing.SystemColors.Control; + this.colorcrosshair3d.Label = "Crosshair:"; + this.colorcrosshair3d.Location = new System.Drawing.Point(15, 27); + this.colorcrosshair3d.MaximumSize = new System.Drawing.Size(10000, 23); + this.colorcrosshair3d.MinimumSize = new System.Drawing.Size(100, 23); + this.colorcrosshair3d.Name = "colorcrosshair3d"; + this.colorcrosshair3d.Size = new System.Drawing.Size(150, 23); + this.colorcrosshair3d.TabIndex = 6; + // // PreferencesForm // this.AcceptButton = this.apply; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.cancel; - this.ClientSize = new System.Drawing.Size(619, 442); + this.ClientSize = new System.Drawing.Size(619, 440); this.Controls.Add(this.cancel); this.Controls.Add(this.apply); this.Controls.Add(this.tabs); @@ -265,10 +578,14 @@ namespace CodeImp.DoomBuilder.Interface this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Preferences"; + this.colorsgroup1.ResumeLayout(false); this.tabs.ResumeLayout(false); this.tabkeys.ResumeLayout(false); this.actioncontrolpanel.ResumeLayout(false); this.actioncontrolpanel.PerformLayout(); + this.tabcolors.ResumeLayout(false); + this.colorsgroup3.ResumeLayout(false); + this.colorsgroup2.ResumeLayout(false); this.ResumeLayout(false); } @@ -289,5 +606,29 @@ namespace CodeImp.DoomBuilder.Interface private System.Windows.Forms.Button actioncontrolclear; private System.Windows.Forms.TextBox actionkey; private System.Windows.Forms.Label actiondescription; + private System.Windows.Forms.TabPage tabcolors; + private ColorControl colorselection; + private ColorControl colorhighlight; + private ColorControl colorlinedefs; + private ColorControl colorvertices; + private ColorControl colorbackcolor; + private System.Windows.Forms.GroupBox colorsgroup3; + private System.Windows.Forms.GroupBox colorsgroup2; + private ColorControl colorselection3d; + private ColorControl colorhighlight3d; + private ColorControl colorcrosshair3d; + private ColorControl colorControl1; + private ColorControl colorkeywords; + private ColorControl colorlinenumbers; + private ColorControl colorcomments; + private ColorControl colorplaintext; + private ColorControl colorliterals; + private ColorControl colorconstants; + private ColorControl colorspeciallinedefs; + private ColorControl colorsoundlinedefs; + private ColorControl colorassociations; + private ColorControl colorgrid64; + private ColorControl colorgrid; + private System.Windows.Forms.GroupBox colorsgroup1; } } \ No newline at end of file diff --git a/Source/Interface/PreferencesForm.cs b/Source/Interface/PreferencesForm.cs index be05748c..9cd3f8a1 100644 --- a/Source/Interface/PreferencesForm.cs +++ b/Source/Interface/PreferencesForm.cs @@ -279,5 +279,19 @@ namespace CodeImp.DoomBuilder.Interface } #endregion + + #region ================== Tabs + + // Tab changes + private void tabs_SelectedIndexChanged(object sender, EventArgs e) + { + if(tabs.SelectedTab != tabkeys) this.AcceptButton = apply; else this.AcceptButton = null; + if(tabs.SelectedTab != tabkeys) this.CancelButton = cancel; else this.CancelButton = null; + colorsgroup1.Visible = (tabs.SelectedTab == tabcolors); + colorsgroup2.Visible = (tabs.SelectedTab == tabcolors); + colorsgroup3.Visible = (tabs.SelectedTab == tabcolors); + } + + #endregion } } \ No newline at end of file diff --git a/Source/Interface/PreferencesForm.resx b/Source/Interface/PreferencesForm.resx index 87f1b787..f1d996d1 100644 --- a/Source/Interface/PreferencesForm.resx +++ b/Source/Interface/PreferencesForm.resx @@ -150,39 +150,12 @@ <metadata name="tabkeys.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> - <metadata name="tabinterface.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> - <metadata name="tabkeys.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> <metadata name="listactions.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> <metadata name="actioncontrolpanel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> - <metadata name="listactions.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> - <metadata name="actioncontrolpanel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> - <metadata name="actioncontrol.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> - <metadata name="actiontitle.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> - <metadata name="actioncontrolclear.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> - <metadata name="actionkey.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> - <metadata name="actiondescription.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </metadata> <metadata name="actioncontrol.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </metadata> diff --git a/Source/Map/Linedef.cs b/Source/Map/Linedef.cs index 8d9a2030..fb58440a 100644 --- a/Source/Map/Linedef.cs +++ b/Source/Map/Linedef.cs @@ -70,6 +70,9 @@ namespace CodeImp.DoomBuilder.Map private int tag; private byte[] args; + // Selections + private int selected; + // Disposing private bool isdisposed = false; @@ -86,6 +89,7 @@ namespace CodeImp.DoomBuilder.Map public int Flags { get { return flags; } } public int Action { get { return action; } } public int Tag { get { return tag; } } + public int Selected { get { return selected; } set { selected = value; } } #endregion diff --git a/Source/Map/MapSelection.cs b/Source/Map/MapSelection.cs new file mode 100644 index 00000000..16273ee4 --- /dev/null +++ b/Source/Map/MapSelection.cs @@ -0,0 +1,193 @@ + +#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 CodeImp.DoomBuilder.Geometry; + +#endregion + +namespace CodeImp.DoomBuilder.Map +{ + internal class MapSelection : IDisposable + { + #region ================== Constants + + #endregion + + #region ================== Variables + + // Selected items + private List<Vertex> vertices; + private List<Linedef> linedefs; + private List<Sector> sectors; + private List<Thing> things; + + // Disposing + private bool isdisposed = false; + + #endregion + + #region ================== Properties + + public ICollection<Vertex> Vertices { get { return vertices; } } + public ICollection<Linedef> Linedefs { get { return linedefs; } } + public ICollection<Sector> Sectors { get { return sectors; } } + public ICollection<Thing> Things { get { return things; } } + public bool IsDisposed { get { return isdisposed; } } + + #endregion + + #region ================== Constructor / Disposer + + // Constructor + public MapSelection() + { + // Initialize + vertices = new List<Vertex>(); + linedefs = new List<Linedef>(); + sectors = new List<Sector>(); + things = new List<Thing>(); + + // We have no destructor + GC.SuppressFinalize(this); + } + + // Diposer + public void Dispose() + { + // Not already disposed? + if(!isdisposed) + { + // Clean up + ClearThings(); + ClearSectors(); + ClearLinedefs(); + ClearVertices(); + + // Done + isdisposed = true; + } + } + + #endregion + + #region ================== Management + + // This adds a vertex + public void AddVertex(Vertex v) + { + // Select it + v.Selected++; + vertices.Add(v); + } + + // This adds a linedef + public void AddLinedef(Linedef l) + { + // Select it + l.Selected++; + linedefs.Add(l); + } + + // This adds a sector + public void AddSector(Sector s) + { + // Select it + s.Selected++; + sectors.Add(s); + } + + // This adds a thing + public void AddThing(Thing t) + { + // Select it + t.Selected++; + things.Add(t); + } + + // This removes a vertex + public void RemoveVertex(Vertex v) + { + // Remove it + v.Selected--; + vertices.Remove(v); + } + + // This adds a linedef + public void RemoveLinedef(Linedef l) + { + // Remove it + l.Selected--; + linedefs.Remove(l); + } + + // This adds a sector + public void RemoveSector(Sector s) + { + // Remove it + s.Selected--; + sectors.Remove(s); + } + + // This adds a thing + public void RemoveThing(Thing t) + { + // Remove it + t.Selected--; + things.Remove(t); + } + + // This clears vertices + public void ClearVertices() + { + // Remove it + foreach(Vertex v in vertices) v.Selected--; + vertices.Clear(); + } + + // This clears linedefs + public void ClearLinedefs() + { + // Remove it + foreach(Linedef l in linedefs) l.Selected--; + linedefs.Clear(); + } + + // This clears sectors + public void ClearSectors() + { + // Remove it + foreach(Sector s in sectors) s.Selected--; + sectors.Clear(); + } + + // This clears things + public void ClearThings() + { + // Remove it + foreach(Thing t in things) t.Selected--; + things.Clear(); + } + + #endregion + } +} diff --git a/Source/Map/Sector.cs b/Source/Map/Sector.cs index e1445761..40830231 100644 --- a/Source/Map/Sector.cs +++ b/Source/Map/Sector.cs @@ -55,6 +55,9 @@ namespace CodeImp.DoomBuilder.Map private int tag; private int brightness; + // Selections + private int selected; + // Disposing private bool isdisposed = false; @@ -71,6 +74,7 @@ namespace CodeImp.DoomBuilder.Map public int Special { get { return special; } } public int Tag { get { return tag; } } public int Brightness { get { return brightness; } } + public int Selected { get { return selected; } set { selected = value; } } #endregion diff --git a/Source/Map/Thing.cs b/Source/Map/Thing.cs index fe6ad5d3..97eb4762 100644 --- a/Source/Map/Thing.cs +++ b/Source/Map/Thing.cs @@ -55,6 +55,9 @@ namespace CodeImp.DoomBuilder.Map private int tag; private int action; private byte[] args; + + // Selections + private int selected; // Disposing private bool isdisposed = false; @@ -69,6 +72,7 @@ namespace CodeImp.DoomBuilder.Map public bool IsDisposed { get { return isdisposed; } } public float Angle { get { return angle; } } public int Flags { get { return flags; } } + public int Selected { get { return selected; } set { selected = value; } } #endregion diff --git a/Source/Map/Vertex.cs b/Source/Map/Vertex.cs index b204b20d..2aca9f65 100644 --- a/Source/Map/Vertex.cs +++ b/Source/Map/Vertex.cs @@ -53,6 +53,9 @@ namespace CodeImp.DoomBuilder.Map // References private LinkedList<Linedef> linedefs; + + // Selections + private int selected; // Disposing private bool isdisposed = false; @@ -67,6 +70,7 @@ namespace CodeImp.DoomBuilder.Map public int X { get { return x; } } public int Y { get { return y; } } public bool IsDisposed { get { return isdisposed; } } + public int Selected { get { return selected; } set { selected = value; } } #endregion diff --git a/Source/Properties/Resources.Designer.cs b/Source/Properties/Resources.Designer.cs index 54362404..c13ecb32 100644 --- a/Source/Properties/Resources.Designer.cs +++ b/Source/Properties/Resources.Designer.cs @@ -60,6 +60,13 @@ namespace CodeImp.DoomBuilder.Properties { } } + internal static System.Drawing.Bitmap ColorPick { + get { + object obj = ResourceManager.GetObject("ColorPick", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + internal static System.Drawing.Bitmap File { get { object obj = ResourceManager.GetObject("File", resourceCulture); diff --git a/Source/Properties/Resources.resx b/Source/Properties/Resources.resx index a5410a15..4c89bd5b 100644 --- a/Source/Properties/Resources.resx +++ b/Source/Properties/Resources.resx @@ -118,28 +118,31 @@ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> - <data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> <data name="Splash2small" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\Splash2small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> - <data name="SaveMap" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\SaveMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> - <data name="NewMap" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\NewMap2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> - <data name="Splash2" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\Splash2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> <data name="File" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\NewMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> - <data name="Properties" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\Properties.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + <data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="Splash2" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\Splash2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> <data name="Zoom" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\Zoom.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> + <data name="NewMap" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\NewMap2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="SaveMap" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\SaveMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="Properties" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\Properties.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> + <data name="ColorPick" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\ColorPick.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> </root> \ No newline at end of file diff --git a/Source/Rendering/Base2DShader.cs b/Source/Rendering/Base2DShader.cs index 5c8b356a..8da5e006 100644 --- a/Source/Rendering/Base2DShader.cs +++ b/Source/Rendering/Base2DShader.cs @@ -37,7 +37,7 @@ using System.Drawing.Imaging; namespace CodeImp.DoomBuilder.Rendering { - internal class Base2DShader : D3DShader + internal sealed class Base2DShader : D3DShader { #region ================== Variables diff --git a/Source/Rendering/ColorCollection.cs b/Source/Rendering/ColorCollection.cs new file mode 100644 index 00000000..cc5364dd --- /dev/null +++ b/Source/Rendering/ColorCollection.cs @@ -0,0 +1,123 @@ + +#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.Reflection; +using System.Drawing; +using CodeImp.DoomBuilder.IO; + +#endregion + +namespace CodeImp.DoomBuilder.Rendering +{ + internal sealed class ColorCollection + { + #region ================== Constants + + #endregion + + #region ================== Variables + + // Colors + private Dictionary<string, ColorSetting> colors; + + #endregion + + #region ================== Properties + + private ColorSetting Background { get { return colors["background"]; } } + private ColorSetting Vertex { get { return colors["vertex"]; } } + private ColorSetting Linedef { get { return colors["linedef"]; } } + private ColorSetting Highlight { get { return colors["highlight"]; } } + private ColorSetting Selection { get { return colors["selection"]; } } + + #endregion + + #region ================== Constructor / Disposer + + // Constructor for settings from configuration + public ColorCollection(Configuration cfg) + { + IDictionary cs; + + // Initialize + colors = new Dictionary<string, ColorSetting>(); + + // Read all colors from config + cs = cfg.ReadSetting("colors", new Hashtable()); + foreach(DictionaryEntry c in cs) + { + // Add color + if(c.Value is int) + colors.Add(c.Key.ToString(), new ColorSetting(c.Key.ToString(), PixelColor.FromInt((int)c.Value))); + } + + // We have no destructor + GC.SuppressFinalize(this); + } + + // Copy constructor + public ColorCollection(ColorCollection collection) + { + // Initialize + colors = new Dictionary<string, ColorSetting>(); + + // Go for all elements in the original collection + foreach(KeyValuePair<string, ColorSetting> c in collection.colors) + { + // Copy + colors.Add(c.Key, new ColorSetting(c.Key, c.Value.Color)); + } + + // We have no destructor + GC.SuppressFinalize(this); + } + + #endregion + + #region ================== Methods + + // This applies colors to this collection + public void Apply(ColorCollection collection) + { + // Go for all elements in the original collection + foreach(KeyValuePair<string, ColorSetting> c in collection.colors) + { + // Add or update + colors[c.Key] = new ColorSetting(c.Key, c.Value.Color); + } + } + + // This saves colors to configuration + public void SaveColors(Configuration cfg) + { + // Go for all elements in the original collection + foreach(KeyValuePair<string, ColorSetting> c in colors) + { + // Write to configuration + cfg.WriteSetting("colors." + c.Key, c.Value.Color.ToInt()); + } + } + + #endregion + } +} diff --git a/Source/Rendering/ColorSetting.cs b/Source/Rendering/ColorSetting.cs new file mode 100644 index 00000000..fae4c7ff --- /dev/null +++ b/Source/Rendering/ColorSetting.cs @@ -0,0 +1,82 @@ + +#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.Reflection; +using System.Drawing; + +#endregion + +namespace CodeImp.DoomBuilder.Rendering +{ + internal sealed class ColorSetting : IEquatable<ColorSetting> + { + #region ================== Constants + + #endregion + + #region ================== Variables + + private string name; + private PixelColor color; + + #endregion + + #region ================== Properties + + public PixelColor Color { get { return color; } } + public string Name { get { return name; } } + + #endregion + + #region ================== Constructor / Disposer + + // Constructor + public ColorSetting(string name, PixelColor color) + { + // Initialize + this.name = name; + this.color = color; + + // We have no destructor + GC.SuppressFinalize(this); + } + + #endregion + + #region ================== Methods + + // Equal? + public bool Equals(ColorSetting other) + { + return this.name == other.name; + } + + // To PixelColor + public static implicit operator PixelColor(ColorSetting c) + { + return c.color; + } + + #endregion + } +} diff --git a/Source/Rendering/PixelColor.cs b/Source/Rendering/PixelColor.cs index 79f75491..6d7a8ddc 100644 --- a/Source/Rendering/PixelColor.cs +++ b/Source/Rendering/PixelColor.cs @@ -78,6 +78,12 @@ namespace CodeImp.DoomBuilder.Rendering return FromColor(Color.FromArgb(c)); } + // To int + public int ToInt() + { + return Color.FromArgb(a, r, g, b).ToArgb(); + } + #endregion #region ================== Methods diff --git a/Source/Rendering/Plotter.cs b/Source/Rendering/Plotter.cs index 119d750b..ff6d4407 100644 --- a/Source/Rendering/Plotter.cs +++ b/Source/Rendering/Plotter.cs @@ -37,7 +37,7 @@ using System.Drawing.Imaging; namespace CodeImp.DoomBuilder.Rendering { - internal unsafe class Plotter + internal unsafe sealed class Plotter { #region ================== Constants diff --git a/Source/Rendering/Renderer2D.cs b/Source/Rendering/Renderer2D.cs index 10197ee3..35e8a092 100644 --- a/Source/Rendering/Renderer2D.cs +++ b/Source/Rendering/Renderer2D.cs @@ -198,7 +198,7 @@ namespace CodeImp.DoomBuilder.Rendering } // This begins a drawing session - public unsafe bool StartRendering() + public unsafe bool StartRendering(bool cleardisplay) { LockedRect rect; @@ -210,8 +210,8 @@ namespace CodeImp.DoomBuilder.Rendering // Create plotter plotter = new Plotter((PixelColor*)rect.Data.DataPointer.ToPointer(), rect.Pitch / sizeof(PixelColor), pheight, width, height); - plotter.Clear(); - + if(cleardisplay) plotter.Clear(); + // Ready for rendering return true; } diff --git a/Source/Resources/ColorPick.png b/Source/Resources/ColorPick.png new file mode 100644 index 00000000..4cf7c053 Binary files /dev/null and b/Source/Resources/ColorPick.png differ