working on texture sets

This commit is contained in:
codeimp 2008-10-01 12:42:30 +00:00
parent 6659577b27
commit 006146b7a8
12 changed files with 426 additions and 49 deletions

View file

@ -104,10 +104,7 @@ namespace CodeImp.DoomBuilder.Config
// Make sure filter is in uppercase
string ss = s.ToUpperInvariant();
// Replace the * with the regex code
ss = ss.Replace("*", ".*?");
// Escape other regex characters, except the ?
// Escape regex characters
ss = ss.Replace("+", "\\+");
ss = ss.Replace("\\", "\\\\");
ss = ss.Replace("|", "\\|");
@ -120,20 +117,32 @@ namespace CodeImp.DoomBuilder.Config
ss = ss.Replace(".", "\\.");
ss = ss.Replace("#", "\\#");
ss = ss.Replace(" ", "\\ ");
// Replace the * with the regex code for optional multiple characters
ss = ss.Replace("*", ".*?");
// Replace the ? with the regex code for single character
ss = ss.Replace("?", ".");
// When a filter has already added, insert a conditional OR operator
if(regexstr.Length > 0) regexstr.Append("|");
// Open group without backreferencing
regexstr.Append("(?:");
// Must be start of string
regexstr.Append("\\A");
// Add the filter
regexstr.Append(ss);
// Must be end of string
regexstr.Append("\\Z");
// Close group
regexstr.Append(")");
}
// Make the regex
regex = new Regex(regexstr.ToString(), RegexOptions.Compiled |
RegexOptions.CultureInvariant);
@ -156,6 +165,12 @@ namespace CodeImp.DoomBuilder.Config
}
}
// This only checks if the given image is a match
internal virtual bool IsMatch(ImageData image)
{
return regex.IsMatch(image.Name.ToUpperInvariant());
}
// Duplication
internal override TextureSet Copy()
{

View file

@ -71,17 +71,19 @@ namespace CodeImp.DoomBuilder.Controls
this.list.MultiSelect = false;
this.list.Name = "list";
this.list.OwnerDraw = true;
this.list.ShowItemToolTips = true;
this.list.Size = new System.Drawing.Size(518, 312);
this.list.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.list.TabIndex = 1;
this.list.UseCompatibleStateImageBehavior = false;
this.list.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(this.list_DrawItem);
this.list.DoubleClick += new System.EventHandler(this.list_DoubleClick);
this.list.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.list_ItemSelectionChanged);
//
// images
//
this.images.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.images.ImageSize = new System.Drawing.Size(64, 64);
this.images.ImageSize = new System.Drawing.Size(40, 64);
this.images.TransparentColor = System.Drawing.Color.Transparent;
//
// objectname

View file

@ -45,15 +45,21 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Delegates / Events
public delegate void SelectedItemChangedDelegate();
public delegate void SelectedItemDoubleClickDelegate();
public event SelectedItemChangedDelegate SelectedItemChanged;
public event SelectedItemDoubleClickDelegate SelectedItemDoubleClicked;
#endregion
#region ================== Variables
// Properties
private bool preventselection;
// States
private bool updating;
private int keepselected;
// All items
private List<ImageBrowserItem> items;
@ -62,6 +68,8 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Properties
public bool PreventSelection { get { return preventselection; } set { preventselection = value; } }
public bool HideInputBox { get { return splitter.Panel2Collapsed; } set { splitter.Panel2Collapsed = value; } }
public string LabelText { get { return label.Text; } set { label.Text = value; objectname.Left = label.Right + label.Margin.Right + objectname.Margin.Left; } }
public ListViewItem SelectedItem { get { if(list.SelectedItems.Count > 0) return list.SelectedItems[0]; else return null; } }
@ -182,12 +190,27 @@ namespace CodeImp.DoomBuilder.Controls
case Keys.Down: SelectNextItem(SearchDirectionHint.Down); e.SuppressKeyPress = true; break;
}
}
// Selection changed
private void list_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
// Raise event
if(SelectedItemChanged != null) SelectedItemChanged();
// Prevent selecting?
if(preventselection)
{
foreach(ListViewItem i in list.SelectedItems) i.Selected = false;
}
else
{
// Raise event
if(SelectedItemChanged != null) SelectedItemChanged();
}
}
// Doublelicking an item
private void list_DoubleClick(object sender, EventArgs e)
{
if(!preventselection && (list.SelectedItems.Count > 0))
if(SelectedItemDoubleClicked != null) SelectedItemDoubleClicked();
}
#endregion
@ -198,7 +221,10 @@ namespace CodeImp.DoomBuilder.Controls
public void SelectItem(string name)
{
ListViewItem lvi;
// Not when selecting is prevented
if(preventselection) return;
// Find item with this text
lvi = list.FindItemWithText(name);
if(lvi != null)
@ -220,6 +246,9 @@ namespace CodeImp.DoomBuilder.Controls
ListViewItem lvi;
Point spos;
// Not when selecting is prevented
if(preventselection) return;
// Nothing selected?
if(list.SelectedItems.Count == 0)
{
@ -255,12 +284,15 @@ namespace CodeImp.DoomBuilder.Controls
if(list.SelectedItems.Count > 0) list.SelectedItems[0].EnsureVisible();
}
}
// This selectes the first item
private void SelectFirstItem()
{
ListViewItem lvi;
// Not when selecting is prevented
if(preventselection) return;
// Select first
if(list.Items.Count > 0)
{
@ -284,8 +316,16 @@ namespace CodeImp.DoomBuilder.Controls
}
// This begins adding items
public void BeginAdding()
public void BeginAdding(bool keepselectedindex)
{
if(keepselectedindex && (list.SelectedItems.Count > 0))
keepselected = list.SelectedIndices[0];
else
keepselected = -1;
// Clean list
items.Clear();
// Stop updating
refreshtimer.Enabled = false;
}
@ -308,6 +348,16 @@ namespace CodeImp.DoomBuilder.Controls
i.Group = group;
items.Add(i);
}
// This adds an item
public void Add(string text, ImageData image, object tag, ListViewGroup group, string tooltiptext)
{
ImageBrowserItem i = new ImageBrowserItem(text, image, tag);
i.ListGroup = group;
i.Group = group;
i.ToolTipText = tooltiptext;
items.Add(i);
}
// This fills the list based on the objectname filter
private void RefillList(bool selectfirst)
@ -334,20 +384,33 @@ namespace CodeImp.DoomBuilder.Controls
showitems.Add(i);
}
}
// Fill list
list.Items.AddRange(showitems.ToArray());
// Select first item?
if(selectfirst) SelectFirstItem();
// Done updating list
updating = false;
list.EndUpdate();
list.ResumeLayout();
// Make selection?
if(!preventselection && (list.Items.Count > 0))
{
// Select specific item?
if(keepselected > -1)
{
list.Items[keepselected].Selected = true;
list.Items[keepselected].EnsureVisible();
}
// Select first item?
else if(selectfirst)
{
SelectFirstItem();
}
}
// Raise event
if(SelectedItemChanged != null) SelectedItemChanged();
if((SelectedItemChanged != null) && !preventselection) SelectedItemChanged();
}
// This validates an item

View file

@ -477,6 +477,7 @@ namespace CodeImp.DoomBuilder.Windows
this.removetextureset.TabIndex = 27;
this.removetextureset.Text = "Remove";
this.removetextureset.UseVisualStyleBackColor = true;
this.removetextureset.Click += new System.EventHandler(this.removetextureset_Click);
//
// addtextureset
//
@ -501,6 +502,7 @@ namespace CodeImp.DoomBuilder.Windows
this.listtextures.Sorted = true;
this.listtextures.TabIndex = 25;
this.listtextures.SelectedIndexChanged += new System.EventHandler(this.listtextures_SelectedIndexChanged);
this.listtextures.DoubleClick += new System.EventHandler(this.listtextures_DoubleClick);
//
// listconfigs
//

View file

@ -92,13 +92,13 @@ namespace CodeImp.DoomBuilder.Windows
// Get config info of selected item
configinfo = listconfigs.SelectedItems[0].Tag as ConfigurationInfo;
// Load the game configuration
gameconfig = new GameConfiguration(General.LoadGameConfiguration(configinfo.Filename));
// Fill resources list
configdata.EditResourceLocationList(configinfo.Resources);
// Go for all nodebuilder save items
nodebuildersave.SelectedIndex = -1;
for(int i = 0; i < nodebuildersave.Items.Count; i++)
@ -114,7 +114,7 @@ namespace CodeImp.DoomBuilder.Windows
break;
}
}
// Go for all nodebuilder save items
nodebuildertest.SelectedIndex = -1;
for(int i = 0; i < nodebuildertest.Items.Count; i++)
@ -143,7 +143,7 @@ namespace CodeImp.DoomBuilder.Windows
skill.Value = skilllevel - 1;
skill.Value = skilllevel;
customparameters.Checked = configinfo.CustomParameters;
// Fill texture sets list
listtextures.Items.Clear();
listtextures.Items.AddRange(configinfo.TextureSets.ToArray());
@ -331,10 +331,10 @@ namespace CodeImp.DoomBuilder.Windows
{
// Leave when no configuration selected
if(configinfo == null) return;
// Apply to selected configuration
configinfo.TestSkill = skill.Value;
CreateParametersExample();
}
@ -364,7 +364,20 @@ namespace CodeImp.DoomBuilder.Windows
form.ShowDialog(this);
}
}
// Remove texture set
private void removetextureset_Click(object sender, EventArgs e)
{
// Texture Set selected?
if(listtextures.SelectedItem is DefinedTextureSet)
{
// Remove from config info and list
DefinedTextureSet s = (listtextures.SelectedItem as DefinedTextureSet);
configinfo.TextureSets.Remove(s);
listtextures.Items.Remove(s);
}
}
// Texture Set selected/deselected
private void listtextures_SelectedIndexChanged(object sender, EventArgs e)
{
@ -373,5 +386,11 @@ namespace CodeImp.DoomBuilder.Windows
copytexturesets.Enabled = (listtextures.SelectedItem is DefinedTextureSet);
pastetexturesets.Enabled = (listtextures.SelectedItem is DefinedTextureSet);
}
// Doubleclicking a texture set
private void listtextures_DoubleClick(object sender, EventArgs e)
{
edittextureset_Click(sender, e);
}
}
}

View file

@ -61,7 +61,7 @@ namespace CodeImp.DoomBuilder.Windows
General.Map.Data.UpdateUsedTextures();
// Start adding
browser.BeginAdding();
browser.BeginAdding(false);
// Add all used flats
foreach(ImageData img in General.Map.Data.Flats)

View file

@ -31,6 +31,8 @@ namespace CodeImp.DoomBuilder.Windows
this.browser = new CodeImp.DoomBuilder.Controls.ImageBrowserControl();
this.cancel = new System.Windows.Forms.Button();
this.apply = new System.Windows.Forms.Button();
this.texturesets = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.SuspendLayout();
//
// browser
@ -39,10 +41,12 @@ namespace CodeImp.DoomBuilder.Windows
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.browser.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.browser.HideInputBox = false;
this.browser.LabelText = "Select or enter a texture name:";
this.browser.Location = new System.Drawing.Point(11, 9);
this.browser.Location = new System.Drawing.Point(187, 9);
this.browser.Name = "browser";
this.browser.Size = new System.Drawing.Size(689, 457);
this.browser.PreventSelection = false;
this.browser.Size = new System.Drawing.Size(513, 457);
this.browser.TabIndex = 0;
this.browser.SelectedItemChanged += new CodeImp.DoomBuilder.Controls.ImageBrowserControl.SelectedItemChangedDelegate(this.browser_SelectedItemChanged);
//
@ -50,9 +54,9 @@ namespace CodeImp.DoomBuilder.Windows
//
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(588, 443);
this.cancel.Location = new System.Drawing.Point(600, 443);
this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(112, 25);
this.cancel.Size = new System.Drawing.Size(100, 25);
this.cancel.TabIndex = 22;
this.cancel.Text = "Cancel";
this.cancel.UseVisualStyleBackColor = true;
@ -61,24 +65,45 @@ namespace CodeImp.DoomBuilder.Windows
// 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(470, 443);
this.apply.Location = new System.Drawing.Point(494, 443);
this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(112, 25);
this.apply.Size = new System.Drawing.Size(100, 25);
this.apply.TabIndex = 21;
this.apply.Text = "OK";
this.apply.UseVisualStyleBackColor = true;
this.apply.Click += new System.EventHandler(this.apply_Click);
//
// texturesets
//
this.texturesets.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.texturesets.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.texturesets.HideSelection = false;
this.texturesets.Location = new System.Drawing.Point(12, 9);
this.texturesets.Name = "texturesets";
this.texturesets.Size = new System.Drawing.Size(166, 423);
this.texturesets.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.texturesets.TabIndex = 23;
this.texturesets.UseCompatibleStateImageBehavior = false;
this.texturesets.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 141;
//
// TextureBrowserForm
//
this.AcceptButton = this.apply;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(712, 478);
this.Controls.Add(this.texturesets);
this.Controls.Add(this.cancel);
this.Controls.Add(this.apply);
this.Controls.Add(this.browser);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "TextureBrowserForm";
this.Opacity = 0;
@ -86,11 +111,11 @@ namespace CodeImp.DoomBuilder.Windows
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Browse Textures";
this.Load += new System.EventHandler(this.TextureBrowserForm_Load);
this.Activated += new System.EventHandler(this.TextureBrowserForm_Activated);
this.Move += new System.EventHandler(this.TextureBrowserForm_Move);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TextureBrowserForm_FormClosing);
this.ResizeEnd += new System.EventHandler(this.TextureBrowserForm_ResizeEnd);
this.Load += new System.EventHandler(this.TextureBrowserForm_Load);
this.ResumeLayout(false);
}
@ -100,5 +125,7 @@ namespace CodeImp.DoomBuilder.Windows
private CodeImp.DoomBuilder.Controls.ImageBrowserControl browser;
private System.Windows.Forms.Button cancel;
private System.Windows.Forms.Button apply;
private System.Windows.Forms.ListView texturesets;
private System.Windows.Forms.ColumnHeader columnHeader1;
}
}

View file

@ -61,7 +61,7 @@ namespace CodeImp.DoomBuilder.Windows
General.Map.Data.UpdateUsedTextures();
// Start adding
browser.BeginAdding();
browser.BeginAdding(false);
// Add all available textures and mark the images for temporary loading
foreach(ImageData img in General.Map.Data.Textures)
@ -118,6 +118,7 @@ namespace CodeImp.DoomBuilder.Windows
// Loading
private void TextureBrowserForm_Load(object sender, EventArgs e)
{
/*
// Position window from configuration settings
this.SuspendLayout();
this.Location = new Point(General.Settings.ReadSetting("browserwindow.positionx", this.Location.X),
@ -126,7 +127,8 @@ namespace CodeImp.DoomBuilder.Windows
General.Settings.ReadSetting("browserwindow.sizeheight", this.Size.Height));
this.WindowState = (FormWindowState)General.Settings.ReadSetting("browserwindow.windowstate", (int)FormWindowState.Normal);
this.ResumeLayout(true);
*/
// Normal windowstate?
if(this.WindowState == FormWindowState.Normal)
{

View file

@ -126,6 +126,9 @@
<metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="texturesets.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View file

@ -28,6 +28,7 @@ namespace CodeImp.DoomBuilder.Windows
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.name = new System.Windows.Forms.TextBox();
this.filters = new System.Windows.Forms.ListView();
@ -40,7 +41,14 @@ namespace CodeImp.DoomBuilder.Windows
this.addfilter = new System.Windows.Forms.Button();
this.removefilter = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.filterstimer = new System.Windows.Forms.Timer(this.components);
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.nomatchesbutton = new System.Windows.Forms.RadioButton();
this.matchesbutton = new System.Windows.Forms.RadioButton();
this.noresultlabel = new System.Windows.Forms.Label();
this.matcheslist = new CodeImp.DoomBuilder.Controls.ImageBrowserControl();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// label1
@ -73,6 +81,9 @@ namespace CodeImp.DoomBuilder.Windows
this.filters.TabIndex = 2;
this.filters.UseCompatibleStateImageBehavior = false;
this.filters.View = System.Windows.Forms.View.Details;
this.filters.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.filters_AfterLabelEdit);
this.filters.SelectedIndexChanged += new System.EventHandler(this.filters_SelectedIndexChanged);
this.filters.DoubleClick += new System.EventHandler(this.filters_DoubleClick);
//
// filtercolumn
//
@ -109,7 +120,7 @@ namespace CodeImp.DoomBuilder.Windows
// 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(58, 417);
this.apply.Location = new System.Drawing.Point(397, 418);
this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(105, 25);
this.apply.TabIndex = 6;
@ -121,7 +132,7 @@ namespace CodeImp.DoomBuilder.Windows
//
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(177, 417);
this.cancel.Location = new System.Drawing.Point(508, 418);
this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(105, 25);
this.cancel.TabIndex = 7;
@ -137,15 +148,18 @@ namespace CodeImp.DoomBuilder.Windows
this.addfilter.TabIndex = 8;
this.addfilter.Text = "Add Texture";
this.addfilter.UseVisualStyleBackColor = true;
this.addfilter.Click += new System.EventHandler(this.addfilter_Click);
//
// removefilter
//
this.removefilter.Enabled = false;
this.removefilter.Location = new System.Drawing.Point(135, 289);
this.removefilter.Name = "removefilter";
this.removefilter.Size = new System.Drawing.Size(105, 24);
this.removefilter.TabIndex = 9;
this.removefilter.Text = "Remove Selection";
this.removefilter.UseVisualStyleBackColor = true;
this.removefilter.Click += new System.EventHandler(this.removefilter_Click);
//
// groupBox1
//
@ -157,17 +171,83 @@ namespace CodeImp.DoomBuilder.Windows
this.groupBox1.Controls.Add(this.filters);
this.groupBox1.Location = new System.Drawing.Point(12, 60);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(269, 333);
this.groupBox1.Size = new System.Drawing.Size(270, 333);
this.groupBox1.TabIndex = 10;
this.groupBox1.TabStop = false;
this.groupBox1.Text = " Filters ";
//
// filterstimer
//
this.filterstimer.Interval = 1;
this.filterstimer.Tick += new System.EventHandler(this.filterstimer_Tick);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.nomatchesbutton);
this.groupBox2.Controls.Add(this.matchesbutton);
this.groupBox2.Controls.Add(this.noresultlabel);
this.groupBox2.Controls.Add(this.matcheslist);
this.groupBox2.Location = new System.Drawing.Point(298, 60);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(315, 333);
this.groupBox2.TabIndex = 11;
this.groupBox2.TabStop = false;
this.groupBox2.Text = " Results ";
//
// nomatchesbutton
//
this.nomatchesbutton.Appearance = System.Windows.Forms.Appearance.Button;
this.nomatchesbutton.Location = new System.Drawing.Point(141, 25);
this.nomatchesbutton.Name = "nomatchesbutton";
this.nomatchesbutton.Size = new System.Drawing.Size(117, 24);
this.nomatchesbutton.TabIndex = 35;
this.nomatchesbutton.Text = "Show Not Matching";
this.nomatchesbutton.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.nomatchesbutton.UseVisualStyleBackColor = true;
this.nomatchesbutton.Click += new System.EventHandler(this.matchesbutton_Click);
//
// matchesbutton
//
this.matchesbutton.Appearance = System.Windows.Forms.Appearance.Button;
this.matchesbutton.Checked = true;
this.matchesbutton.Location = new System.Drawing.Point(18, 25);
this.matchesbutton.Name = "matchesbutton";
this.matchesbutton.Size = new System.Drawing.Size(117, 24);
this.matchesbutton.TabIndex = 34;
this.matchesbutton.TabStop = true;
this.matchesbutton.Text = "Show Matches";
this.matchesbutton.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.matchesbutton.UseVisualStyleBackColor = true;
this.matchesbutton.Click += new System.EventHandler(this.matchesbutton_Click);
//
// noresultlabel
//
this.noresultlabel.Location = new System.Drawing.Point(20, 110);
this.noresultlabel.Name = "noresultlabel";
this.noresultlabel.Size = new System.Drawing.Size(272, 43);
this.noresultlabel.TabIndex = 33;
this.noresultlabel.Text = "An example result cannot be displayed, because it requires a map to be loaded.";
this.noresultlabel.Visible = false;
//
// matcheslist
//
this.matcheslist.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.matcheslist.HideInputBox = true;
this.matcheslist.LabelText = "Select or type object name:";
this.matcheslist.Location = new System.Drawing.Point(18, 55);
this.matcheslist.Name = "matcheslist";
this.matcheslist.PreventSelection = true;
this.matcheslist.Size = new System.Drawing.Size(281, 258);
this.matcheslist.TabIndex = 10;
this.matcheslist.SelectedItemDoubleClicked += new CodeImp.DoomBuilder.Controls.ImageBrowserControl.SelectedItemDoubleClickDelegate(this.matcheslist_SelectedItemDoubleClicked);
//
// TextureSetForm
//
this.AcceptButton = this.apply;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(294, 455);
this.ClientSize = new System.Drawing.Size(625, 455);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.cancel);
this.Controls.Add(this.apply);
this.Controls.Add(this.name);
@ -183,8 +263,10 @@ namespace CodeImp.DoomBuilder.Windows
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Edit Texture Set";
this.Shown += new System.EventHandler(this.TextureSetForm_Shown);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -204,5 +286,11 @@ namespace CodeImp.DoomBuilder.Windows
private System.Windows.Forms.Button addfilter;
private System.Windows.Forms.Button removefilter;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Timer filterstimer;
private System.Windows.Forms.GroupBox groupBox2;
private CodeImp.DoomBuilder.Controls.ImageBrowserControl matcheslist;
private System.Windows.Forms.Label noresultlabel;
private System.Windows.Forms.RadioButton nomatchesbutton;
private System.Windows.Forms.RadioButton matchesbutton;
}
}

View file

@ -43,6 +43,12 @@ namespace CodeImp.DoomBuilder.Windows
public TextureSetForm()
{
InitializeComponent();
// Show/hide components
matchesbutton.Visible = (General.Map != null);
nomatchesbutton.Visible = (General.Map != null);
matcheslist.Visible = (General.Map != null);
noresultlabel.Visible = (General.Map == null);
}
// This initializes the set
@ -50,10 +56,10 @@ namespace CodeImp.DoomBuilder.Windows
{
// Keep reference
textureset = set;
// Set name
name.Text = set.Name;
// Fill filters list
foreach(string s in set.Filters)
filters.Items.Add(s);
@ -64,12 +70,13 @@ namespace CodeImp.DoomBuilder.Windows
{
// Apply name
textureset.Name = name.Text;
// Apply filters
textureset.Filters.Clear();
foreach(ListViewItem i in filters.Items) textureset.Filters.Add(i.Text);
// Done
matcheslist.CleanUp();
this.DialogResult = DialogResult.OK;
this.Close();
}
@ -78,9 +85,140 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
// Be gone.
matcheslist.CleanUp();
this.DialogResult = DialogResult.Cancel;
this.Close();
}
// Add texture
private void addfilter_Click(object sender, EventArgs e)
{
ListViewItem i = new ListViewItem("");
filters.Items.Add(i);
i.BeginEdit();
}
// Remove selected items
private void removefilter_Click(object sender, EventArgs e)
{
foreach(ListViewItem i in filters.SelectedItems) i.Remove();
// Run the timer
filterstimer.Start();
}
// Items selected/deselected
private void filters_SelectedIndexChanged(object sender, EventArgs e)
{
removefilter.Enabled = (filters.SelectedItems.Count > 0);
}
// Double clicking an item
private void filters_DoubleClick(object sender, EventArgs e)
{
// Edit item
if(filters.SelectedItems.Count == 1)
filters.SelectedItems[0].BeginEdit();
}
// This removes empty items and makes others uppercase
private void filterstimer_Tick(object sender, EventArgs e)
{
// Stop timer
filterstimer.Stop();
// Update labels
for(int i = filters.Items.Count - 1; i >= 0; i--)
{
// Empty label?
if((filters.Items[i].Text == null) ||
(filters.Items[i].Text.Trim().Length == 0))
{
// Remove it
filters.Items.RemoveAt(i);
}
else
{
// Make uppercase
filters.Items[i].Text = filters.Items[i].Text.ToUpperInvariant();
}
}
// Show example results if when we can
if(General.Map != null)
{
Cursor.Current = Cursors.AppStarting;
// Make a set for comparing
DefinedTextureSet set = new DefinedTextureSet("");
foreach(ListViewItem i in filters.Items) set.Filters.Add(i.Text);
set.Reset();
// Determine tooltip text
string tooltiptext = null;
if(nomatchesbutton.Checked) tooltiptext = "Doubleclick to include this texture";
// Start adding
matcheslist.PreventSelection = matchesbutton.Checked;
matcheslist.BeginAdding(true);
// Go for all textures
foreach(ImageData img in General.Map.Data.Textures)
{
bool ismatch = set.IsMatch(img);
if((ismatch && matchesbutton.Checked) || (!ismatch && nomatchesbutton.Checked))
matcheslist.Add(img.Name, img, img, null, tooltiptext);
}
// If not already mixed, add flats as well
if(!General.Map.Config.MixTexturesFlats)
{
// Go for all flats
foreach(ImageData img in General.Map.Data.Flats)
{
bool ismatch = set.IsMatch(img);
if((ismatch && matchesbutton.Checked) || (!ismatch && nomatchesbutton.Checked))
matcheslist.Add(img.Name, img, img, null, tooltiptext);
}
}
// Done adding
matcheslist.EndAdding();
Cursor.Current = Cursors.Default;
}
}
// Done editing a filter
private void filters_AfterLabelEdit(object sender, LabelEditEventArgs e)
{
// Run the timer
filterstimer.Start();
}
// When first shown
private void TextureSetForm_Shown(object sender, EventArgs e)
{
// Run the timer
filterstimer.Start();
}
// Show (not) matches clicked
private void matchesbutton_Click(object sender, EventArgs e)
{
// Run the timer
filterstimer.Start();
}
// Texture doubleclicked
private void matcheslist_SelectedItemDoubleClicked()
{
// Add texture name to the list
if(matcheslist.SelectedItem != null)
filters.Items.Add(matcheslist.SelectedItem.Text);
// Run the timer
filterstimer.Start();
}
}
}
}

View file

@ -150,6 +150,24 @@
<metadata name="groupBox1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="filterstimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="groupBox2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="nomatchesbutton.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="matchesbutton.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="noresultlabel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="matcheslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>