working on texture sets

This commit is contained in:
codeimp 2008-10-01 14:17:52 +00:00
parent 006146b7a8
commit dfab6c4183
17 changed files with 484 additions and 235 deletions

View file

@ -49,6 +49,8 @@
<Compile Include="Config\DefinedTextureSet.cs" />
<Compile Include="Config\EnumItem.cs" />
<Compile Include="Config\EnumList.cs" />
<Compile Include="Config\IFilledTextureSet.cs" />
<Compile Include="Config\MatchingTextureSet.cs" />
<Compile Include="Config\OthersTextureSet.cs" />
<Compile Include="Config\SectorEffectInfo.cs" />
<Compile Include="Config\GeneralizedBit.cs" />

View file

@ -46,7 +46,7 @@ namespace CodeImp.DoomBuilder.Config
private bool customparameters;
private int testskill;
private List<ThingsFilter> thingsfilters;
private List<TextureSet> texturesets;
private List<DefinedTextureSet> texturesets;
#endregion
@ -63,7 +63,7 @@ namespace CodeImp.DoomBuilder.Config
public int TestSkill { get { return testskill; } set { testskill = value; } }
public bool CustomParameters { get { return customparameters; } set { customparameters = value; } }
internal ICollection<ThingsFilter> ThingsFilters { get { return thingsfilters; } }
public List<TextureSet> TextureSets { get { return texturesets; } }
public List<DefinedTextureSet> TextureSets { get { return texturesets; } }
#endregion
@ -98,7 +98,7 @@ namespace CodeImp.DoomBuilder.Config
}
// Make list of texture sets
texturesets = new List<TextureSet>();
texturesets = new List<DefinedTextureSet>();
IDictionary sets = General.Settings.ReadSetting("configurations." + settingskey + ".texturesets", new Hashtable());
foreach(DictionaryEntry de in sets)
{
@ -170,8 +170,8 @@ namespace CodeImp.DoomBuilder.Config
ci.testparameters = this.testparameters;
ci.customparameters = this.customparameters;
ci.testskill = this.testskill;
ci.texturesets = new List<TextureSet>();
foreach(TextureSet s in this.texturesets) ci.texturesets.Add(s.Copy());
ci.texturesets = new List<DefinedTextureSet>();
foreach(DefinedTextureSet s in this.texturesets) ci.texturesets.Add(s.Copy());
return ci;
}
@ -189,8 +189,8 @@ namespace CodeImp.DoomBuilder.Config
this.testparameters = ci.testparameters;
this.customparameters = ci.customparameters;
this.testskill = ci.testskill;
this.texturesets = new List<TextureSet>();
foreach(TextureSet s in ci.texturesets) this.texturesets.Add(s.Copy());
this.texturesets = new List<DefinedTextureSet>();
foreach(DefinedTextureSet s in ci.texturesets) this.texturesets.Add(s.Copy());
}
// This applies the defaults
@ -200,7 +200,7 @@ namespace CodeImp.DoomBuilder.Config
if(texturesets.Count == 0)
{
// Copy the default texture sets from the game configuration
foreach(TextureSet s in General.Map.Config.TextureSets)
foreach(DefinedTextureSet s in General.Map.Config.TextureSets)
{
// Add a copy to our list
texturesets.Add(s.Copy());

View file

@ -33,13 +33,10 @@ using System.Collections.Specialized;
namespace CodeImp.DoomBuilder.Config
{
internal class DefinedTextureSet : TextureSet
internal sealed class DefinedTextureSet : TextureSet
{
#region ================== Variables
// Never stored, only used at run-time
private Regex regex;
#endregion
#region ================== Constructor / Destructor
@ -72,7 +69,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Methods
// This writes the texture set to configuration
internal override void WriteToConfig(Configuration cfg, string path)
internal void WriteToConfig(Configuration cfg, string path)
{
IDictionary dic;
@ -92,87 +89,8 @@ namespace CodeImp.DoomBuilder.Config
cfg.WriteSetting(path, dic);
}
// This resets the matches and recreates the regex
internal override void Reset()
{
base.Reset();
// Make the regex string that handles all filters
StringBuilder regexstr = new StringBuilder("");
foreach(string s in filters)
{
// Make sure filter is in uppercase
string ss = s.ToUpperInvariant();
// Escape regex characters
ss = ss.Replace("+", "\\+");
ss = ss.Replace("\\", "\\\\");
ss = ss.Replace("|", "\\|");
ss = ss.Replace("{", "\\{");
ss = ss.Replace("[", "\\[");
ss = ss.Replace("(", "\\(");
ss = ss.Replace(")", "\\)");
ss = ss.Replace("^", "\\^");
ss = ss.Replace("$", "\\$");
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);
}
// This matches a name against the regex and adds a texture to
// the list if it matches. Returns true when matched and added.
internal virtual bool Add(ImageData image)
{
// Check against regex
if(regex.IsMatch(image.Name.ToUpperInvariant()))
{
// Matches! Add it.
return base.Add(image);
}
else
{
// Doesn't match
return false;
}
}
// 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()
internal DefinedTextureSet Copy()
{
// Make a copy
DefinedTextureSet s = new DefinedTextureSet(this.name);
@ -181,7 +99,7 @@ namespace CodeImp.DoomBuilder.Config
}
// This applies the filters and name of one set to this one
internal override void Apply(TextureSet set)
internal void Apply(TextureSet set)
{
this.name = set.Name;
this.filters = new List<string>(set.Filters);

View file

@ -99,7 +99,7 @@ namespace CodeImp.DoomBuilder.Config
private Dictionary<string, EnumList> enums;
// Default Texture Sets
private List<TextureSet> texturesets;
private List<DefinedTextureSet> texturesets;
#endregion
@ -162,7 +162,7 @@ namespace CodeImp.DoomBuilder.Config
public IDictionary<string, EnumList> Enums { get { return enums; } }
// Texture Sets
internal List<TextureSet> TextureSets { get { return texturesets; } }
internal List<DefinedTextureSet> TextureSets { get { return texturesets; } }
#endregion
@ -190,7 +190,7 @@ namespace CodeImp.DoomBuilder.Config
this.geneffectoptions = new List<GeneralizedOption>();
this.enums = new Dictionary<string, EnumList>();
this.skills = new List<SkillInfo>();
this.texturesets = new List<TextureSet>();
this.texturesets = new List<DefinedTextureSet>();
// Read general settings
configname = cfg.ReadSetting("game", "<unnamed game>");
@ -597,7 +597,7 @@ namespace CodeImp.DoomBuilder.Config
dic = cfg.ReadSetting("texturesets", new Hashtable());
foreach(DictionaryEntry de in dic)
{
TextureSet s = new DefinedTextureSet(cfg, "texturesets." + de.Key.ToString());
DefinedTextureSet s = new DefinedTextureSet(cfg, "texturesets." + de.Key.ToString());
texturesets.Add(s);
}
}

View file

@ -0,0 +1,42 @@
#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 System.Windows.Forms;
using CodeImp.DoomBuilder.Rendering;
#endregion
namespace CodeImp.DoomBuilder.Config
{
internal interface IFilledTextureSet
{
// Properties
string Name { get; }
ICollection<ImageData> Textures { get; }
ICollection<ImageData> Flats { get; }
}
}

View file

@ -0,0 +1,186 @@
#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 System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Collections.Specialized;
#endregion
namespace CodeImp.DoomBuilder.Config
{
internal sealed class MatchingTextureSet : TextureSet, IFilledTextureSet
{
#region ================== Variables
// Never stored, only used at run-time
private Regex regex;
// Matching textures and flats
private List<ImageData> textures;
private List<ImageData> flats;
#endregion
#region ================== Properties
public ICollection<ImageData> Textures { get { return textures; } }
public ICollection<ImageData> Flats { get { return flats; } }
#endregion
#region ================== Constructor / Destructor
// New texture set for quick matching
public MatchingTextureSet(ICollection<string> filters)
{
this.filters = new List<string>(filters);
// Setup
Setup();
}
// Texture set from defined set
public MatchingTextureSet(DefinedTextureSet definedset)
{
// Copy the name
this.name = definedset.Name;
// Copy the filters
this.filters = new List<string>(definedset.Filters);
// Setup
Setup();
}
#endregion
#region ================== Methods
// This sets up the object
private void Setup()
{
// Make the regex string that handles all filters
StringBuilder regexstr = new StringBuilder("");
foreach(string s in this.filters)
{
// Make sure filter is in uppercase
string ss = s.ToUpperInvariant();
// Escape regex characters
ss = ss.Replace("+", "\\+");
ss = ss.Replace("\\", "\\\\");
ss = ss.Replace("|", "\\|");
ss = ss.Replace("{", "\\{");
ss = ss.Replace("[", "\\[");
ss = ss.Replace("(", "\\(");
ss = ss.Replace(")", "\\)");
ss = ss.Replace("^", "\\^");
ss = ss.Replace("$", "\\$");
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);
// Initialize collections
textures = new List<ImageData>();
flats = new List<ImageData>();
}
// This matches a name against the regex and adds a texture to
// the list if it matches. Returns true when matched and added.
internal bool AddTexture(ImageData image)
{
// Check against regex
if(regex.IsMatch(image.Name.ToUpperInvariant()))
{
// Matches! Add it.
textures.Add(image);
return true;
}
else
{
// Doesn't match
return false;
}
}
// This matches a name against the regex and adds a flat to
// the list if it matches. Returns true when matched and added.
internal bool AddFlat(ImageData image)
{
// Check against regex
if(regex.IsMatch(image.Name.ToUpperInvariant()))
{
// Matches! Add it.
flats.Add(image);
return true;
}
else
{
// Doesn't match
return false;
}
}
// This only checks if the given image is a match
internal bool IsMatch(ImageData image)
{
return regex.IsMatch(image.Name.ToUpperInvariant());
}
#endregion
}
}

View file

@ -33,22 +33,53 @@ using System.Collections.Specialized;
namespace CodeImp.DoomBuilder.Config
{
internal class OthersTextureSet : TextureSet
internal sealed class OthersTextureSet : TextureSet, IFilledTextureSet
{
#region ================== Constants
public const string NAME = "Other";
#endregion
#region ================== Variables
// Matching textures and flats
private List<ImageData> textures;
private List<ImageData> flats;
#endregion
#region ================== Properties
public ICollection<ImageData> Textures { get { return textures; } }
public ICollection<ImageData> Flats { get { return flats; } }
#endregion
#region ================== Constructor / Destructor
// New texture set constructor
public OthersTextureSet()
{
this.name = NAME;
this.textures = new List<ImageData>();
this.flats = new List<ImageData>();
}
#endregion
#region ================== Methods
internal void AddTexture(ImageData image)
{
textures.Add(image);
}
internal void AddFlat(ImageData image)
{
flats.Add(image);
}
#endregion
}
}

View file

@ -33,16 +33,13 @@ using System.Collections.Specialized;
namespace CodeImp.DoomBuilder.Config
{
public abstract class TextureSet
public abstract class TextureSet : IComparable<TextureSet>
{
#region ================== Variables
protected string name;
protected List<string> filters;
// Never stored, only used at run-time
protected Dictionary<long, ImageData> matches;
#endregion
#region ================== Properties
@ -64,48 +61,17 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Methods
// This writes the texture set to configuration
internal virtual void WriteToConfig(Configuration cfg, string path) { }
// This resets the matches and recreates the regex
internal virtual void Reset()
{
// Clear matches
matches = new Dictionary<long, ImageData>();
}
// This adds a texture to this set
internal virtual bool Add(ImageData image)
{
// Can we add it?
if(!matches.ContainsKey(image.LongName))
{
// Add it
matches.Add(image.LongName, image);
return true;
}
else
{
// Can't add it
return false;
}
}
// This tests if a texture is in this texturset
public virtual bool Exists(long longname)
{
return matches.ContainsKey(longname);
}
// This returns the name
public override string ToString()
{
return name;
}
// This is optional
internal virtual TextureSet Copy() { return null; }
internal virtual void Apply(TextureSet set) { }
// Comparer for sorting alphabetically
public int CompareTo(TextureSet other)
{
return string.Compare(this.name, other.name);
}
#endregion
}

View file

@ -104,22 +104,6 @@ namespace CodeImp.DoomBuilder.Controls
{
// Stop refresh timer
refreshtimer.Enabled = false;
// Begin updating list
updating = true;
list.SuspendLayout();
list.BeginUpdate();
// Dispose items
foreach(ImageBrowserItem i in list.Items) i.Dispose();
// Trash list items
list.Clear();
// Done updating list
list.EndUpdate();
list.ResumeLayout();
updating = false;
}
#endregion
@ -366,7 +350,7 @@ namespace CodeImp.DoomBuilder.Controls
// Begin updating list
updating = true;
list.SuspendLayout();
//list.SuspendLayout();
list.BeginUpdate();
// Clear list first
@ -391,7 +375,8 @@ namespace CodeImp.DoomBuilder.Controls
// Done updating list
updating = false;
list.EndUpdate();
list.ResumeLayout();
list.Invalidate();
//list.ResumeLayout();
// Make selection?
if(!preventselection && (list.Items.Count > 0))

View file

@ -43,7 +43,7 @@ namespace CodeImp.DoomBuilder.Controls
// Display image
public ImageData icon;
// Group
private ListViewGroup listgroup;
@ -70,13 +70,6 @@ namespace CodeImp.DoomBuilder.Controls
this.Tag = tag;
}
// Disposer
public void Dispose()
{
icon = null;
listgroup = null;
}
#endregion
#region ================== Methods

View file

@ -42,23 +42,21 @@ namespace CodeImp.DoomBuilder.Data
#endregion
#region ================== Variables
// Data containers
private List<DataReader> containers;
// Palette
private Playpal palette;
// Textures
// Textures, Flats and Sprites
private Dictionary<long, ImageData> textures;
private List<string> texturenames;
// Flats
private Dictionary<long, ImageData> flats;
private List<string> flatnames;
// Sprites
private Dictionary<long, ImageData> sprites;
private List<MatchingTextureSet> texturesets;
private OthersTextureSet othertextures;
// Background loading
private Queue<ImageData> imageque;
@ -88,6 +86,8 @@ namespace CodeImp.DoomBuilder.Data
public bool IsDisposed { get { return isdisposed; } }
public ImageData MissingTexture3D { get { return missingtexture3d; } }
public ImageData Hourglass3D { get { return hourglass3d; } }
internal ICollection<MatchingTextureSet> TextureSets { get { return texturesets; } }
internal OthersTextureSet OthersTextureSet { get { return othertextures; } }
public bool IsLoading
{
@ -171,6 +171,14 @@ namespace CodeImp.DoomBuilder.Data
flatnames = new List<string>();
imageque = new Queue<ImageData>();
previews = new PreviewManager();
texturesets = new List<MatchingTextureSet>();
// Load texture sets
foreach(DefinedTextureSet ts in General.Map.ConfigSettings.TextureSets)
texturesets.Add(new MatchingTextureSet(ts));
// Other textures set
othertextures = new OthersTextureSet();
// Go for all locations
foreach(DataLocation dl in locations)
@ -213,20 +221,44 @@ namespace CodeImp.DoomBuilder.Data
// Add container
if(c != null) containers.Add(c);
}
// Load stuff
LoadPalette();
texcount = LoadTextures();
flatcount = LoadFlats();
spritecount = LoadSprites();
// Sort names
texturenames.Sort();
flatnames.Sort();
// Add texture names to texture sets
foreach(KeyValuePair<long, ImageData> img in textures)
{
// Add to all sets where it matches
bool matchfound = false;
foreach(MatchingTextureSet ms in texturesets)
matchfound |= ms.AddTexture(img.Value);
// If not matched in any set, add it to the others
othertextures.AddTexture(img.Value);
}
// Add flat names to texture sets
foreach(KeyValuePair<long, ImageData> img in flats)
{
// Add to all sets where it matches
bool matchfound = false;
foreach(MatchingTextureSet ms in texturesets)
matchfound |= ms.AddFlat(img.Value);
// If not matched in any set, add it to the others
othertextures.AddFlat(img.Value);
}
// Start background loading
StartBackgroundLoader();
// Output info
General.WriteLogLine("Loaded " + texcount + " textures, " + flatcount + " flats, " + spritecount + " sprites");
}
@ -246,11 +278,11 @@ namespace CodeImp.DoomBuilder.Data
foreach(KeyValuePair<long, ImageData> i in flats) i.Value.Dispose();
foreach(KeyValuePair<long, ImageData> i in sprites) i.Value.Dispose();
palette = null;
// Dispose containers
foreach(DataReader c in containers) c.Dispose();
containers.Clear();
// Trash collections
containers = null;
textures = null;
@ -260,7 +292,7 @@ namespace CodeImp.DoomBuilder.Data
flatnames = null;
imageque = null;
}
#endregion
#region ================== Suspend / Resume

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 flat 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(525, 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(612, 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,48 @@ 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(506, 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.FullRowSelect = true;
this.texturesets.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.texturesets.HideSelection = false;
this.texturesets.Location = new System.Drawing.Point(12, 9);
this.texturesets.MultiSelect = false;
this.texturesets.Name = "texturesets";
this.texturesets.Size = new System.Drawing.Size(166, 423);
this.texturesets.TabIndex = 24;
this.texturesets.UseCompatibleStateImageBehavior = false;
this.texturesets.View = System.Windows.Forms.View.Details;
this.texturesets.SelectedIndexChanged += new System.EventHandler(this.texturesets_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 141;
//
// FlatBrowserForm
//
this.AcceptButton = this.apply;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(712, 478);
this.ClientSize = new System.Drawing.Size(724, 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.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FlatBrowserForm";
this.Opacity = 0;
@ -86,11 +114,11 @@ namespace CodeImp.DoomBuilder.Windows
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Browse Flats";
this.Load += new System.EventHandler(this.FlatBrowserForm_Load);
this.Activated += new System.EventHandler(this.FlatBrowserForm_Activated);
this.Move += new System.EventHandler(this.FlatBrowserForm_Move);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FlatBrowserForm_FormClosing);
this.ResizeEnd += new System.EventHandler(this.FlatBrowserForm_ResizeEnd);
this.Load += new System.EventHandler(this.FlatBrowserForm_Load);
this.ResumeLayout(false);
}
@ -100,5 +128,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

@ -40,6 +40,8 @@ namespace CodeImp.DoomBuilder.Windows
private string selectedname;
private Point lastposition;
private Size lastsize;
private ListViewGroup usedgroup;
private ListViewGroup availgroup;
// Properties
public string SelectedName { get { return selectedname; } }
@ -48,31 +50,34 @@ namespace CodeImp.DoomBuilder.Windows
public FlatBrowserForm()
{
Cursor.Current = Cursors.WaitCursor;
ListViewItem item;
// Initialize
InitializeComponent();
browser.ApplyColorSettings();
// Make groups
ListViewGroup used = browser.AddGroup("Used Flats");
ListViewGroup avail = browser.AddGroup("Available Flats");
// Update the used textures
General.Map.Data.UpdateUsedTextures();
// Start adding
browser.BeginAdding(false);
// Add all used flats
foreach(ImageData img in General.Map.Data.Flats)
if(img.UsedInMap) browser.Add(img.Name, img, img, used);
// Add all available flats
foreach(ImageData img in General.Map.Data.Flats)
browser.Add(img.Name, img, img, avail);
// Done adding
browser.EndAdding();
// Fill texture sets list with normal texture sets
foreach(IFilledTextureSet ts in General.Map.Data.TextureSets)
{
item = texturesets.Items.Add(ts.Name);
item.Tag = ts;
}
// Sort and add other textures set
texturesets.Sort();
item = texturesets.Items.Add(General.Map.Data.OthersTextureSet.Name);
item.Tag = General.Map.Data.OthersTextureSet;
// Select one
// TODO: Remember selection
texturesets.Items[0].Selected = true;
// Make groups
usedgroup = browser.AddGroup("Used Textures");
availgroup = browser.AddGroup("Available Textures");
// Keep last position and size
lastposition = this.Location;
@ -114,6 +119,7 @@ namespace CodeImp.DoomBuilder.Windows
// Loading
private void FlatBrowserForm_Load(object sender, EventArgs e)
{
/*
// Position window from configuration settings
this.SuspendLayout();
this.Location = new Point(General.Settings.ReadSetting("browserwindow.positionx", this.Location.X),
@ -122,7 +128,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)
{
@ -194,5 +201,30 @@ namespace CodeImp.DoomBuilder.Windows
return null;
}
}
// Texture set selected
private void texturesets_SelectedIndexChanged(object sender, EventArgs e)
{
// Anything slected?
if(texturesets.SelectedItems.Count > 0)
{
// Get the selected texture set
IFilledTextureSet set = (texturesets.SelectedItems[0].Tag as IFilledTextureSet);
// Start adding
browser.BeginAdding(false);
// Add all used flats
foreach(ImageData img in set.Flats)
if(img.UsedInMap) browser.Add(img.Name, img, img, usedgroup);
// Add all available flats
foreach(ImageData img in set.Flats)
browser.Add(img.Name, img, img, availgroup);
// Done adding
browser.EndAdding();
}
}
}
}

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

@ -46,7 +46,7 @@ namespace CodeImp.DoomBuilder.Windows
this.browser.Location = new System.Drawing.Point(187, 9);
this.browser.Name = "browser";
this.browser.PreventSelection = false;
this.browser.Size = new System.Drawing.Size(513, 457);
this.browser.Size = new System.Drawing.Size(525, 457);
this.browser.TabIndex = 0;
this.browser.SelectedItemChanged += new CodeImp.DoomBuilder.Controls.ImageBrowserControl.SelectedItemChangedDelegate(this.browser_SelectedItemChanged);
//
@ -54,7 +54,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(600, 443);
this.cancel.Location = new System.Drawing.Point(612, 443);
this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(100, 25);
this.cancel.TabIndex = 22;
@ -65,7 +65,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(494, 443);
this.apply.Location = new System.Drawing.Point(506, 443);
this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(100, 25);
this.apply.TabIndex = 21;
@ -77,15 +77,17 @@ namespace CodeImp.DoomBuilder.Windows
//
this.texturesets.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.texturesets.FullRowSelect = true;
this.texturesets.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.texturesets.HideSelection = false;
this.texturesets.Location = new System.Drawing.Point(12, 9);
this.texturesets.MultiSelect = false;
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;
this.texturesets.SelectedIndexChanged += new System.EventHandler(this.texturesets_SelectedIndexChanged);
//
// columnHeader1
//
@ -97,12 +99,13 @@ namespace CodeImp.DoomBuilder.Windows
this.AcceptButton = this.apply;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(712, 478);
this.ClientSize = new System.Drawing.Size(724, 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.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "TextureBrowserForm";

View file

@ -40,6 +40,8 @@ namespace CodeImp.DoomBuilder.Windows
private string selectedname;
private Point lastposition;
private Size lastsize;
private ListViewGroup usedgroup;
private ListViewGroup availgroup;
// Properties
public string SelectedName { get { return selectedname; } }
@ -48,36 +50,35 @@ namespace CodeImp.DoomBuilder.Windows
public TextureBrowserForm()
{
Cursor.Current = Cursors.WaitCursor;
ListViewItem item;
// Initialize
InitializeComponent();
browser.ApplyColorSettings();
// Make groups
ListViewGroup used = browser.AddGroup("Used Textures");
ListViewGroup avail = browser.AddGroup("Available Textures");
// Update the used textures
General.Map.Data.UpdateUsedTextures();
// Fill texture sets list with normal texture sets
foreach(IFilledTextureSet ts in General.Map.Data.TextureSets)
{
item = texturesets.Items.Add(ts.Name);
item.Tag = ts;
}
// Sort and add other textures set
texturesets.Sort();
item = texturesets.Items.Add(General.Map.Data.OthersTextureSet.Name);
item.Tag = General.Map.Data.OthersTextureSet;
// Select one
// TODO: Remember selection
texturesets.Items[0].Selected = true;
// Make groups
usedgroup = browser.AddGroup("Used Textures");
availgroup = browser.AddGroup("Available Textures");
// Start adding
browser.BeginAdding(false);
// Add all available textures and mark the images for temporary loading
foreach(ImageData img in General.Map.Data.Textures)
{
browser.Add(img.Name, img, img, avail);
}
// Add all used textures and mark the images for permanent loading
foreach(ImageData img in General.Map.Data.Textures)
{
if(img.UsedInMap) browser.Add(img.Name, img, img, used);
}
// Done adding
browser.EndAdding();
// Keep last position and size
lastposition = this.Location;
lastsize = this.Size;
@ -200,5 +201,30 @@ namespace CodeImp.DoomBuilder.Windows
return null;
}
}
// Texture set selected
private void texturesets_SelectedIndexChanged(object sender, EventArgs e)
{
// Anything slected?
if(texturesets.SelectedItems.Count > 0)
{
// Get the selected texture set
IFilledTextureSet set = (texturesets.SelectedItems[0].Tag as IFilledTextureSet);
// Start adding
browser.BeginAdding(false);
// Add all available textures and mark the images for temporary loading
foreach(ImageData img in set.Textures)
browser.Add(img.Name, img, img, availgroup);
// Add all used textures and mark the images for permanent loading
foreach(ImageData img in set.Textures)
if(img.UsedInMap) browser.Add(img.Name, img, img, usedgroup);
// Done adding
browser.EndAdding();
}
}
}
}

View file

@ -150,9 +150,9 @@ namespace CodeImp.DoomBuilder.Windows
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();
List<string> filterslist = new List<string>(filters.Items.Count);
foreach(ListViewItem i in filters.Items) filterslist.Add(i.Text);
MatchingTextureSet set = new MatchingTextureSet(filterslist);
// Determine tooltip text
string tooltiptext = null;