diff --git a/Documents/todo.txt b/Documents/todo.txt
index 8e074a91..520f9cb0 100644
--- a/Documents/todo.txt
+++ b/Documents/todo.txt
@@ -1,8 +1,3 @@
-- Finish the custom fields editor
- - Enums should drop down in list
- - Remember sort order
- - Strings should have a mutliline edit window on browse button
-
- Complete Things filter with UDMF fields
- Controls to increase/decrease grid size
diff --git a/Source/Builder.csproj b/Source/Builder.csproj
index f382761f..0d886175 100644
--- a/Source/Builder.csproj
+++ b/Source/Builder.csproj
@@ -133,6 +133,7 @@
+
@@ -319,6 +320,12 @@
SectorInfoPanel.cs
+
+ Form
+
+
+ TextEditForm.cs
+
Form
@@ -605,6 +612,10 @@
Designer
CustomFieldsForm.cs
+
+ Designer
+ TextEditForm.cs
+
Designer
ThingEditForm.cs
diff --git a/Source/Controls/FieldsEditorControl.Designer.cs b/Source/Controls/FieldsEditorControl.Designer.cs
index cf2c9af6..20d4a888 100644
--- a/Source/Controls/FieldsEditorControl.Designer.cs
+++ b/Source/Controls/FieldsEditorControl.Designer.cs
@@ -82,6 +82,8 @@ namespace CodeImp.DoomBuilder.Controls
this.fieldslist.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.fieldslist_UserDeletingRow);
this.fieldslist.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.fieldslist_CellBeginEdit);
this.fieldslist.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.fieldslist_CellDoubleClick);
+ this.fieldslist.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.fieldslist_ColumnHeaderMouseClick);
+ this.fieldslist.MouseUp += new System.Windows.Forms.MouseEventHandler(this.fieldslist_MouseUp);
this.fieldslist.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.fieldslist_CellEndEdit);
this.fieldslist.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.fieldslist_CellClick);
this.fieldslist.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.fieldslist_DataError);
@@ -98,7 +100,7 @@ namespace CodeImp.DoomBuilder.Controls
this.fieldname.Frozen = true;
this.fieldname.HeaderText = "Property";
this.fieldname.Name = "fieldname";
- this.fieldname.Width = 180;
+ this.fieldname.Width = 150;
//
// fieldtype
//
@@ -137,12 +139,11 @@ namespace CodeImp.DoomBuilder.Controls
this.browsebutton.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.browsebutton.Image = global::CodeImp.DoomBuilder.Properties.Resources.treeview;
this.browsebutton.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
- this.browsebutton.Location = new System.Drawing.Point(370, 46);
+ this.browsebutton.Location = new System.Drawing.Point(343, 75);
this.browsebutton.Name = "browsebutton";
this.browsebutton.Size = new System.Drawing.Size(28, 26);
this.browsebutton.TabIndex = 2;
this.browsebutton.UseVisualStyleBackColor = true;
- this.browsebutton.Visible = false;
this.browsebutton.Click += new System.EventHandler(this.browsebutton_Click);
//
// enumscombo
diff --git a/Source/Controls/FieldsEditorControl.cs b/Source/Controls/FieldsEditorControl.cs
index a3b81ed4..327257be 100644
--- a/Source/Controls/FieldsEditorControl.cs
+++ b/Source/Controls/FieldsEditorControl.cs
@@ -78,6 +78,19 @@ namespace CodeImp.DoomBuilder.Controls
fieldtype.Items.AddRange(General.Types.GetCustomUseAttributes());
}
+ // This applies last sort order
+ private void Sort()
+ {
+ // Sort
+ int sortcolumn = General.Settings.ReadSetting("customfieldssortcolumn", 0);
+ int sortorder = General.Settings.ReadSetting("customfieldssortorder", (int)ListSortDirection.Ascending);
+
+ if(sortorder == (int)SortOrder.Ascending)
+ fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Ascending);
+ else if(sortorder == (int)SortOrder.Descending)
+ fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Descending);
+ }
+
// This adds a list of fixed fields (in undefined state)
public void ListFixedFields(List list)
{
@@ -85,6 +98,9 @@ namespace CodeImp.DoomBuilder.Controls
foreach(UniversalFieldInfo uf in list)
fieldslist.Rows.Add(new FieldsEditorRow(fieldslist, uf));
+ // Sort fields
+ Sort();
+
// Update new row
SetupNewRowStyle();
}
@@ -159,6 +175,9 @@ namespace CodeImp.DoomBuilder.Controls
if(!first) frow.Clear();
}
}
+
+ // Sort fields
+ Sort();
}
// This applies the current fields to a UniFields object
@@ -228,6 +247,24 @@ namespace CodeImp.DoomBuilder.Controls
#endregion
#region ================== Events
+
+ // Column header clicked
+ private void fieldslist_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
+ {
+ // Save sort order
+ if(fieldslist.SortedColumn != null)
+ {
+ int sortcolumn = fieldslist.SortedColumn.Index;
+ int sortorder = (int)fieldslist.SortOrder;
+ General.Settings.WriteSetting("customfieldssortcolumn", sortcolumn);
+ General.Settings.WriteSetting("customfieldssortorder", sortorder);
+ }
+
+ // Stop any cell editing
+ ApplyEnums(true);
+ fieldslist.EndEdit();
+ HideBrowseButton();
+ }
// Resized
private void FieldsEditorControl_Resize(object sender, EventArgs e)
@@ -235,6 +272,7 @@ namespace CodeImp.DoomBuilder.Controls
// Rearrange controls
fieldslist.Size = this.ClientSize;
fieldvalue.Width = fieldslist.ClientRectangle.Width - fieldname.Width - fieldtype.Width - SystemInformation.VerticalScrollBarWidth - 10;
+ UpdateBrowseButton();
}
// Layout change
@@ -328,7 +366,7 @@ namespace CodeImp.DoomBuilder.Controls
enumscombo.Items.Clear();
enumscombo.Items.AddRange(frow.TypeHandler.GetEnumList().ToArray());
enumscombo.Tag = frow;
-
+
// Lock combo to enums?
if(frow.TypeHandler.IsLimitedToEnums)
enumscombo.DropDownStyle = ComboBoxStyle.DropDownList;
@@ -357,10 +395,7 @@ namespace CodeImp.DoomBuilder.Controls
enumscombo.Text = frow.TypeHandler.GetStringValue();
// Show combo
- // Why does it not select all and focus the combobox?
enumscombo.Show();
- enumscombo.Focus();
- enumscombo.SelectAll();
}
}
}
@@ -511,6 +546,7 @@ namespace CodeImp.DoomBuilder.Controls
// Selection changes
private void fieldslist_SelectionChanged(object sender, EventArgs e)
{
+ browsebutton.Visible = false;
ApplyEnums(true);
// Update button
@@ -555,6 +591,17 @@ namespace CodeImp.DoomBuilder.Controls
fieldslist.EndEdit();
HideBrowseButton();
}
+
+ // Mouse up event
+ private void fieldslist_MouseUp(object sender, MouseEventArgs e)
+ {
+ // Focus to enums combobox when visible
+ if(enumscombo.Visible)
+ {
+ enumscombo.Focus();
+ enumscombo.SelectAll();
+ }
+ }
#endregion
diff --git a/Source/Controls/FieldsEditorControl.resx b/Source/Controls/FieldsEditorControl.resx
index 16e40157..658de512 100644
--- a/Source/Controls/FieldsEditorControl.resx
+++ b/Source/Controls/FieldsEditorControl.resx
@@ -117,6 +117,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ True
+
True
@@ -129,4 +132,13 @@
17, 17
+
+ True
+
+
+ True
+
+
+ True
+
\ No newline at end of file
diff --git a/Source/Types/EnumStringsHandler.cs b/Source/Types/EnumStringsHandler.cs
new file mode 100644
index 00000000..b4d5b556
--- /dev/null
+++ b/Source/Types/EnumStringsHandler.cs
@@ -0,0 +1,176 @@
+
+#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.IO;
+using CodeImp.DoomBuilder.Data;
+using System.IO;
+using System.Diagnostics;
+using CodeImp.DoomBuilder.Config;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Types
+{
+ [TypeHandler(16, "Setting", false)]
+ internal class EnumStringsHandler : TypeHandler
+ {
+ #region ================== Constants
+
+ #endregion
+
+ #region ================== Variables
+
+ private EnumList list;
+ private EnumItem value;
+
+ #endregion
+
+ #region ================== Properties
+
+ public override bool IsBrowseable { get { return true; } }
+ public override bool IsEnumerable { get { return true; } }
+
+ #endregion
+
+ #region ================== Constructor
+
+ // When set up for an argument
+ public override void SetupArgument(TypeHandlerAttribute attr, ArgumentInfo arginfo)
+ {
+ base.SetupArgument(attr, arginfo);
+
+ // Keep enum list reference
+ list = arginfo.Enum;
+ }
+
+ // When set up for a universal field
+ public override void SetupField(TypeHandlerAttribute attr, UniversalFieldInfo fieldinfo)
+ {
+ base.SetupField(attr, fieldinfo);
+
+ // Keep enum list reference
+ if(fieldinfo != null) list = fieldinfo.Enum; else list = new EnumList();
+ }
+
+ #endregion
+
+ #region ================== Methods
+
+ public override void SetValue(object value)
+ {
+ this.value = null;
+
+ // Input null?
+ if(value == null)
+ {
+ this.value = new EnumItem("", "");
+ }
+ else
+ {
+ // No match found yet?
+ if(this.value == null)
+ {
+ // First try to match the value against the enum values
+ foreach(EnumItem item in list)
+ {
+ // Matching value?
+ if(item.Value == value.ToString())
+ {
+ // Set this value
+ this.value = item;
+ }
+ }
+ }
+
+ // No match found yet?
+ if(this.value == null)
+ {
+ // Try to match against the titles
+ foreach(EnumItem item in list)
+ {
+ // Matching value?
+ if(item.Title.ToLowerInvariant() == value.ToString().ToLowerInvariant())
+ {
+ // Set this value
+ this.value = item;
+ }
+ }
+ }
+
+ // Still no match found?
+ if(this.value == null)
+ {
+ // Make a dummy value
+ this.value = new EnumItem(value.ToString(), value.ToString());
+ }
+ }
+ }
+
+ public override object GetValue()
+ {
+ if(this.value != null) return this.value.Value; else return "";
+ }
+
+ public override int GetIntValue()
+ {
+ if(this.value != null)
+ {
+ // Parse the value to integer
+ int result;
+ if(int.TryParse(this.value.Value, NumberStyles.Integer,
+ CultureInfo.InvariantCulture, out result))
+ {
+ return result;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ public override string GetStringValue()
+ {
+ if(this.value != null) return this.value.Title; else return "NULL";
+ }
+
+ // This returns an enum list
+ public override EnumList GetEnumList()
+ {
+ return list;
+ }
+
+ // This returns the type to display for fixed fields
+ // Must be a custom usable type
+ public override TypeHandlerAttribute GetDisplayType()
+ {
+ return General.Types.GetAttribute((int)UniversalType.String);
+ }
+
+ #endregion
+ }
+}
diff --git a/Source/Types/StringHandler.cs b/Source/Types/StringHandler.cs
index f999f953..10972c5c 100644
--- a/Source/Types/StringHandler.cs
+++ b/Source/Types/StringHandler.cs
@@ -25,6 +25,8 @@ using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Data;
using System.IO;
using System.Diagnostics;
+using CodeImp.DoomBuilder.Windows;
+using System.Windows.Forms;
#endregion
@@ -45,10 +47,17 @@ namespace CodeImp.DoomBuilder.Types
#region ================== Properties
+ public override bool IsBrowseable { get { return true; } }
+
#endregion
#region ================== Methods
+ public override void Browse(IWin32Window parent)
+ {
+ value = TextEditForm.ShowDialog(parent, value);
+ }
+
public override void SetValue(object value)
{
if(value != null)
diff --git a/Source/Windows/TextEditForm.Designer.cs b/Source/Windows/TextEditForm.Designer.cs
new file mode 100644
index 00000000..105f14d2
--- /dev/null
+++ b/Source/Windows/TextEditForm.Designer.cs
@@ -0,0 +1,104 @@
+namespace CodeImp.DoomBuilder.Windows
+{
+ partial class TextEditForm
+ {
+ ///
+ /// 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.cancel = new System.Windows.Forms.Button();
+ this.apply = new System.Windows.Forms.Button();
+ this.textbox = new System.Windows.Forms.TextBox();
+ this.SuspendLayout();
+ //
+ // cancel
+ //
+ this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.cancel.Location = new System.Drawing.Point(354, 220);
+ this.cancel.Margin = new System.Windows.Forms.Padding(1);
+ this.cancel.Name = "cancel";
+ this.cancel.Size = new System.Drawing.Size(112, 25);
+ this.cancel.TabIndex = 21;
+ this.cancel.Text = "Cancel";
+ this.cancel.UseVisualStyleBackColor = true;
+ this.cancel.Click += new System.EventHandler(this.cancel_Click);
+ //
+ // apply
+ //
+ this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.apply.Location = new System.Drawing.Point(235, 220);
+ this.apply.Margin = new System.Windows.Forms.Padding(1);
+ this.apply.Name = "apply";
+ this.apply.Size = new System.Drawing.Size(112, 25);
+ this.apply.TabIndex = 20;
+ this.apply.Text = "OK";
+ this.apply.UseVisualStyleBackColor = true;
+ this.apply.Click += new System.EventHandler(this.apply_Click);
+ //
+ // textbox
+ //
+ this.textbox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.textbox.Location = new System.Drawing.Point(10, 10);
+ this.textbox.Margin = new System.Windows.Forms.Padding(1);
+ this.textbox.Multiline = true;
+ this.textbox.Name = "textbox";
+ this.textbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.textbox.Size = new System.Drawing.Size(456, 194);
+ this.textbox.TabIndex = 22;
+ //
+ // TextEditForm
+ //
+ this.AcceptButton = this.apply;
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
+ this.CancelButton = this.cancel;
+ this.ClientSize = new System.Drawing.Size(476, 255);
+ this.Controls.Add(this.textbox);
+ this.Controls.Add(this.cancel);
+ this.Controls.Add(this.apply);
+ 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 = "TextEditForm";
+ this.Opacity = 0;
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Edit Text";
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button cancel;
+ private System.Windows.Forms.Button apply;
+ private System.Windows.Forms.TextBox textbox;
+ }
+}
\ No newline at end of file
diff --git a/Source/Windows/TextEditForm.cs b/Source/Windows/TextEditForm.cs
new file mode 100644
index 00000000..96ff7d4c
--- /dev/null
+++ b/Source/Windows/TextEditForm.cs
@@ -0,0 +1,75 @@
+
+#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.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using CodeImp.DoomBuilder.Map;
+using CodeImp.DoomBuilder.Data;
+using CodeImp.DoomBuilder.IO;
+using System.IO;
+using CodeImp.DoomBuilder.Config;
+using CodeImp.DoomBuilder.Editing;
+using CodeImp.DoomBuilder.Controls;
+
+#endregion
+
+namespace CodeImp.DoomBuilder.Windows
+{
+ public partial class TextEditForm : DelayedForm
+ {
+ // Properties
+ public string Value { get { return textbox.Text; } set { textbox.Text = value; } }
+
+ // Constructor
+ public TextEditForm()
+ {
+ // Initialize
+ InitializeComponent();
+ }
+
+ // This shows the dialog, returns the same value when cancelled
+ public static string ShowDialog(IWin32Window owner, string value)
+ {
+ TextEditForm f = new TextEditForm();
+ f.Value = value;
+ if(f.ShowDialog(owner) == DialogResult.OK) value = f.Value;
+ f.Dispose();
+ return value;
+ }
+
+ // OK clicked
+ private void apply_Click(object sender, EventArgs e)
+ {
+ // Done
+ this.DialogResult = DialogResult.OK;
+ this.Close();
+ }
+
+ // Cancel clciked
+ private void cancel_Click(object sender, EventArgs e)
+ {
+ // Be gone
+ this.DialogResult = DialogResult.Cancel;
+ this.Close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Source/Windows/TextEditForm.resx b/Source/Windows/TextEditForm.resx
new file mode 100644
index 00000000..ff31a6db
--- /dev/null
+++ b/Source/Windows/TextEditForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
\ No newline at end of file