diff --git a/Build/Configurations/ZDoom_Doom.cfg b/Build/Configurations/ZDoom_Doom.cfg index f358a979..e7b31784 100644 --- a/Build/Configurations/ZDoom_Doom.cfg +++ b/Build/Configurations/ZDoom_Doom.cfg @@ -3650,3 +3650,13 @@ thingtypes 9046 = "Sector Secret"; } } + + +texturesets +{ + startan + { + name = "Startans"; + filter0 = "START*"; + } +} diff --git a/Source/Builder.csproj b/Source/Builder.csproj index 07edea61..e845e8d2 100644 --- a/Source/Builder.csproj +++ b/Source/Builder.csproj @@ -346,6 +346,12 @@ UserControl + + Form + + + TextureSetForm.cs + Form @@ -640,6 +646,10 @@ Designer TextEditForm.cs + + Designer + TextureSetForm.cs + Designer ThingEditForm.cs diff --git a/Source/Config/ConfigurationInfo.cs b/Source/Config/ConfigurationInfo.cs index 7c083dbc..13374acd 100644 --- a/Source/Config/ConfigurationInfo.cs +++ b/Source/Config/ConfigurationInfo.cs @@ -46,7 +46,8 @@ namespace CodeImp.DoomBuilder.Config private bool customparameters; private int testskill; private List thingsfilters; - + private List texturesets; + #endregion #region ================== Properties @@ -62,6 +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 ThingsFilters { get { return thingsfilters; } } + public List TextureSets { get { return texturesets; } } #endregion @@ -94,6 +96,14 @@ namespace CodeImp.DoomBuilder.Config { thingsfilters.Add(new ThingsFilter(General.Settings.Config, "configurations." + settingskey + ".thingsfilters." + de.Key)); } + + // Make list of texture sets + texturesets = new List(); + IDictionary sets = General.Settings.ReadSetting("configurations." + settingskey + ".texturesets", new Hashtable()); + foreach(DictionaryEntry de in sets) + { + texturesets.Add(new DefinedTextureSet(General.Settings.Config, "configurations." + settingskey + ".texturesets." + de.Key)); + } } // Constructor @@ -130,6 +140,13 @@ namespace CodeImp.DoomBuilder.Config thingsfilters[i].WriteSettings(General.Settings.Config, "configurations." + settingskey + ".thingsfilters.filter" + i.ToString(CultureInfo.InvariantCulture)); } + + // Write texturesets to configuration + for(int i = 0; i < texturesets.Count; i++) + { + texturesets[i].WriteToConfig(General.Settings.Config, + "configurations." + settingskey + ".texturesets.set" + i.ToString(CultureInfo.InvariantCulture)); + } } // String representation @@ -153,6 +170,8 @@ namespace CodeImp.DoomBuilder.Config ci.testparameters = this.testparameters; ci.customparameters = this.customparameters; ci.testskill = this.testskill; + ci.texturesets = new List(); + foreach(TextureSet s in this.texturesets) ci.texturesets.Add(s.Copy()); return ci; } @@ -170,6 +189,23 @@ namespace CodeImp.DoomBuilder.Config this.testparameters = ci.testparameters; this.customparameters = ci.customparameters; this.testskill = ci.testskill; + this.texturesets = new List(); + foreach(TextureSet s in ci.texturesets) this.texturesets.Add(s.Copy()); + } + + // This applies the defaults + public void ApplyDefaults() + { + // No texture sets? + if(texturesets.Count == 0) + { + // Copy the default texture sets from the game configuration + foreach(TextureSet s in General.Map.Config.TextureSets) + { + // Add a copy to our list + texturesets.Add(s.Copy()); + } + } } #endregion diff --git a/Source/Config/DefinedTextureSet.cs b/Source/Config/DefinedTextureSet.cs index d65146a9..0f3ec341 100644 --- a/Source/Config/DefinedTextureSet.cs +++ b/Source/Config/DefinedTextureSet.cs @@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Config foreach(DictionaryEntry de in dic) { // If not the name of this texture set, add value as filter - if(de.Key.ToString() != "name") filters.Add(de.Value.ToString()); + if(de.Key.ToString() != "name") filters.Add(de.Value.ToString().ToUpperInvariant()); } } @@ -85,7 +85,7 @@ namespace CodeImp.DoomBuilder.Config for(int i = 0; i < filters.Count; i++) { // Add filters - dic.Add(i.ToString(), filters[i]); + dic.Add("filter" + i.ToString(), filters[i].ToUpperInvariant()); } // Write to config @@ -101,8 +101,11 @@ namespace CodeImp.DoomBuilder.Config StringBuilder regexstr = new StringBuilder(""); foreach(string s in filters) { + // Make sure filter is in uppercase + string ss = s.ToUpperInvariant(); + // Replace the * with the regex code - string ss = s.Replace("*", ".*?"); + ss = ss.Replace("*", ".*?"); // Escape other regex characters, except the ? ss = ss.Replace("+", "\\+"); @@ -133,8 +136,7 @@ namespace CodeImp.DoomBuilder.Config // Make the regex regex = new Regex(regexstr.ToString(), RegexOptions.Compiled | - RegexOptions.CultureInvariant | - RegexOptions.IgnoreCase); + RegexOptions.CultureInvariant); } // This matches a name against the regex and adds a texture to @@ -142,7 +144,7 @@ namespace CodeImp.DoomBuilder.Config internal virtual bool Add(ImageData image) { // Check against regex - if(regex.IsMatch(image.Name)) + if(regex.IsMatch(image.Name.ToUpperInvariant())) { // Matches! Add it. return base.Add(image); @@ -154,6 +156,22 @@ namespace CodeImp.DoomBuilder.Config } } + // Duplication + internal override TextureSet Copy() + { + // Make a copy + DefinedTextureSet s = new DefinedTextureSet(this.name); + s.filters = new List(this.filters); + return s; + } + + // This applies the filters and name of one set to this one + internal override void Apply(TextureSet set) + { + this.name = set.Name; + this.filters = new List(set.Filters); + } + #endregion } } diff --git a/Source/Config/GameConfiguration.cs b/Source/Config/GameConfiguration.cs index 3e6fa3b3..6dbfafdd 100644 --- a/Source/Config/GameConfiguration.cs +++ b/Source/Config/GameConfiguration.cs @@ -98,6 +98,9 @@ namespace CodeImp.DoomBuilder.Config // Enums private Dictionary enums; + // Default Texture Sets + private List texturesets; + #endregion #region ================== Properties @@ -157,6 +160,9 @@ namespace CodeImp.DoomBuilder.Config // Enums public IDictionary Enums { get { return enums; } } + + // Texture Sets + internal List TextureSets { get { return texturesets; } } #endregion @@ -184,7 +190,8 @@ namespace CodeImp.DoomBuilder.Config this.geneffectoptions = new List(); this.enums = new Dictionary(); this.skills = new List(); - + this.texturesets = new List(); + // Read general settings configname = cfg.ReadSetting("game", ""); enginename = cfg.ReadSetting("engine", ""); @@ -243,6 +250,9 @@ namespace CodeImp.DoomBuilder.Config sidedeffields = LoadUniversalFields("sidedef"); thingfields = LoadUniversalFields("thing"); vertexfields = LoadUniversalFields("vertex"); + + // Texture sets + LoadTextureSets(); } // Destructor @@ -578,6 +588,20 @@ namespace CodeImp.DoomBuilder.Config } } + // Texture Sets + private void LoadTextureSets() + { + IDictionary dic; + + // Get sets + dic = cfg.ReadSetting("texturesets", new Hashtable()); + foreach(DictionaryEntry de in dic) + { + TextureSet s = new DefinedTextureSet(cfg, "texturesets." + de.Key.ToString()); + texturesets.Add(s); + } + } + #endregion #region ================== Methods diff --git a/Source/Config/OthersTextureSet.cs b/Source/Config/OthersTextureSet.cs index f1a16824..19cfb1ef 100644 --- a/Source/Config/OthersTextureSet.cs +++ b/Source/Config/OthersTextureSet.cs @@ -50,14 +50,5 @@ namespace CodeImp.DoomBuilder.Config } #endregion - - #region ================== Methods - - // This does absolutely nothing - internal override void WriteToConfig(Configuration cfg, string path) - { - } - - #endregion } } diff --git a/Source/Config/TextureSet.cs b/Source/Config/TextureSet.cs index f06cee2d..5be58891 100644 --- a/Source/Config/TextureSet.cs +++ b/Source/Config/TextureSet.cs @@ -33,7 +33,7 @@ using System.Collections.Specialized; namespace CodeImp.DoomBuilder.Config { - internal abstract class TextureSet + public abstract class TextureSet { #region ================== Variables @@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.Config #region ================== Methods // This writes the texture set to configuration - internal abstract void WriteToConfig(Configuration cfg, string path); + internal virtual void WriteToConfig(Configuration cfg, string path) { } // This resets the matches and recreates the regex internal virtual void Reset() @@ -103,6 +103,10 @@ namespace CodeImp.DoomBuilder.Config return name; } + // This is optional + internal virtual TextureSet Copy() { return null; } + internal virtual void Apply(TextureSet set) { } + #endregion } } diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs index cf1dbd10..7d4ff1a7 100644 --- a/Source/General/MapManager.cs +++ b/Source/General/MapManager.cs @@ -216,6 +216,7 @@ namespace CodeImp.DoomBuilder General.WriteLogLine("Loading game configuration..."); configinfo = General.GetConfigurationInfo(options.ConfigFile); config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile)); + configinfo.ApplyDefaults(); General.Plugins.GameConfigurationChanged(); // Create map data @@ -286,6 +287,7 @@ namespace CodeImp.DoomBuilder General.WriteLogLine("Loading game configuration..."); configinfo = General.GetConfigurationInfo(options.ConfigFile); config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile)); + configinfo.ApplyDefaults(); General.Plugins.GameConfigurationChanged(); // Create map data @@ -1062,6 +1064,7 @@ namespace CodeImp.DoomBuilder General.WriteLogLine("Loading game configuration..."); configinfo = General.GetConfigurationInfo(options.ConfigFile); config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile)); + configinfo.ApplyDefaults(); General.Plugins.GameConfigurationChanged(); // Setup new map format IO diff --git a/Source/Windows/ConfigForm.Designer.cs b/Source/Windows/ConfigForm.Designer.cs index b11effb5..0a4dfa73 100644 --- a/Source/Windows/ConfigForm.Designer.cs +++ b/Source/Windows/ConfigForm.Designer.cs @@ -56,17 +56,17 @@ namespace CodeImp.DoomBuilder.Windows this.labelresult = new System.Windows.Forms.Label(); this.testparameters = new System.Windows.Forms.TextBox(); this.testapplication = new System.Windows.Forms.TextBox(); + this.tabtextures = new System.Windows.Forms.TabPage(); + this.restoretexturesets = new System.Windows.Forms.Button(); + this.edittextureset = new System.Windows.Forms.Button(); + this.pastetexturesets = new System.Windows.Forms.Button(); + this.copytexturesets = new System.Windows.Forms.Button(); + this.removetextureset = new System.Windows.Forms.Button(); + this.addtextureset = new System.Windows.Forms.Button(); + this.listtextures = new System.Windows.Forms.ListBox(); this.listconfigs = new System.Windows.Forms.ListView(); this.columnname = new System.Windows.Forms.ColumnHeader(); this.testprogramdialog = new System.Windows.Forms.OpenFileDialog(); - this.tabtextures = new System.Windows.Forms.TabPage(); - this.listtextures = new System.Windows.Forms.ListBox(); - this.addtextureset = new System.Windows.Forms.Button(); - this.removetextureset = new System.Windows.Forms.Button(); - this.copytexturesets = new System.Windows.Forms.Button(); - this.pastetexturesets = new System.Windows.Forms.Button(); - this.edittextureset = new System.Windows.Forms.Button(); - this.restoretexturesets = new System.Windows.Forms.Button(); label5 = new System.Windows.Forms.Label(); label6 = new System.Windows.Forms.Label(); label3 = new System.Windows.Forms.Label(); @@ -164,6 +164,17 @@ namespace CodeImp.DoomBuilder.Windows label8.TabIndex = 34; label8.Text = "Skill Level:"; // + // label4 + // + label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + label4.AutoEllipsis = true; + label4.Location = new System.Drawing.Point(12, 15); + label4.Name = "label4"; + label4.Size = new System.Drawing.Size(394, 75); + label4.TabIndex = 24; + label4.Text = resources.GetString("label4.Text"); + // // labelparameters // this.labelparameters.AutoSize = true; @@ -399,6 +410,98 @@ namespace CodeImp.DoomBuilder.Windows this.testapplication.TabIndex = 25; this.testapplication.TextChanged += new System.EventHandler(this.testapplication_TextChanged); // + // tabtextures + // + this.tabtextures.Controls.Add(this.restoretexturesets); + this.tabtextures.Controls.Add(this.edittextureset); + this.tabtextures.Controls.Add(this.pastetexturesets); + this.tabtextures.Controls.Add(this.copytexturesets); + this.tabtextures.Controls.Add(this.removetextureset); + this.tabtextures.Controls.Add(this.addtextureset); + this.tabtextures.Controls.Add(this.listtextures); + this.tabtextures.Controls.Add(label4); + this.tabtextures.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tabtextures.Location = new System.Drawing.Point(4, 23); + this.tabtextures.Name = "tabtextures"; + this.tabtextures.Size = new System.Drawing.Size(415, 318); + this.tabtextures.TabIndex = 3; + this.tabtextures.Text = "Textures"; + this.tabtextures.UseVisualStyleBackColor = true; + // + // restoretexturesets + // + this.restoretexturesets.Location = new System.Drawing.Point(15, 275); + this.restoretexturesets.Name = "restoretexturesets"; + this.restoretexturesets.Size = new System.Drawing.Size(140, 24); + this.restoretexturesets.TabIndex = 31; + this.restoretexturesets.Text = "Add Default Sets"; + this.restoretexturesets.UseVisualStyleBackColor = true; + // + // edittextureset + // + this.edittextureset.Enabled = false; + this.edittextureset.Location = new System.Drawing.Point(88, 237); + this.edittextureset.Name = "edittextureset"; + this.edittextureset.Size = new System.Drawing.Size(67, 24); + this.edittextureset.TabIndex = 30; + this.edittextureset.Text = "Edit..."; + this.edittextureset.UseVisualStyleBackColor = true; + this.edittextureset.Click += new System.EventHandler(this.edittextureset_Click); + // + // pastetexturesets + // + this.pastetexturesets.Enabled = false; + this.pastetexturesets.Location = new System.Drawing.Point(339, 237); + this.pastetexturesets.Name = "pastetexturesets"; + this.pastetexturesets.Size = new System.Drawing.Size(58, 24); + this.pastetexturesets.TabIndex = 29; + this.pastetexturesets.Text = "Paste"; + this.pastetexturesets.UseVisualStyleBackColor = true; + // + // copytexturesets + // + this.copytexturesets.Enabled = false; + this.copytexturesets.Location = new System.Drawing.Point(275, 237); + this.copytexturesets.Name = "copytexturesets"; + this.copytexturesets.Size = new System.Drawing.Size(58, 24); + this.copytexturesets.TabIndex = 28; + this.copytexturesets.Text = "Copy"; + this.copytexturesets.UseVisualStyleBackColor = true; + // + // removetextureset + // + this.removetextureset.Enabled = false; + this.removetextureset.Location = new System.Drawing.Point(161, 237); + this.removetextureset.Name = "removetextureset"; + this.removetextureset.Size = new System.Drawing.Size(68, 24); + this.removetextureset.TabIndex = 27; + this.removetextureset.Text = "Remove"; + this.removetextureset.UseVisualStyleBackColor = true; + // + // addtextureset + // + this.addtextureset.Location = new System.Drawing.Point(15, 237); + this.addtextureset.Name = "addtextureset"; + this.addtextureset.Size = new System.Drawing.Size(67, 24); + this.addtextureset.TabIndex = 26; + this.addtextureset.Text = "Add..."; + this.addtextureset.UseVisualStyleBackColor = true; + this.addtextureset.Click += new System.EventHandler(this.addtextureset_Click); + // + // listtextures + // + this.listtextures.ColumnWidth = 120; + this.listtextures.IntegralHeight = false; + this.listtextures.ItemHeight = 14; + this.listtextures.Location = new System.Drawing.Point(15, 84); + this.listtextures.MultiColumn = true; + this.listtextures.Name = "listtextures"; + this.listtextures.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.listtextures.Size = new System.Drawing.Size(382, 147); + this.listtextures.Sorted = true; + this.listtextures.TabIndex = 25; + this.listtextures.SelectedIndexChanged += new System.EventHandler(this.listtextures_SelectedIndexChanged); + // // listconfigs // this.listconfigs.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { @@ -429,107 +532,6 @@ namespace CodeImp.DoomBuilder.Windows this.testprogramdialog.Filter = "Executable Files (*.exe)|*.exe|Batch Files (*.bat)|*.bat"; this.testprogramdialog.Title = "Browse Test Program"; // - // tabtextures - // - this.tabtextures.Controls.Add(this.restoretexturesets); - this.tabtextures.Controls.Add(this.edittextureset); - this.tabtextures.Controls.Add(this.pastetexturesets); - this.tabtextures.Controls.Add(this.copytexturesets); - this.tabtextures.Controls.Add(this.removetextureset); - this.tabtextures.Controls.Add(this.addtextureset); - this.tabtextures.Controls.Add(this.listtextures); - this.tabtextures.Controls.Add(label4); - this.tabtextures.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tabtextures.Location = new System.Drawing.Point(4, 23); - this.tabtextures.Name = "tabtextures"; - this.tabtextures.Size = new System.Drawing.Size(415, 318); - this.tabtextures.TabIndex = 3; - this.tabtextures.Text = "Textures"; - this.tabtextures.UseVisualStyleBackColor = true; - // - // label4 - // - label4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - label4.AutoEllipsis = true; - label4.Location = new System.Drawing.Point(12, 15); - label4.Name = "label4"; - label4.Size = new System.Drawing.Size(394, 75); - label4.TabIndex = 24; - label4.Text = resources.GetString("label4.Text"); - // - // listtextures - // - this.listtextures.ColumnWidth = 120; - this.listtextures.IntegralHeight = false; - this.listtextures.ItemHeight = 14; - this.listtextures.Location = new System.Drawing.Point(15, 93); - this.listtextures.MultiColumn = true; - this.listtextures.Name = "listtextures"; - this.listtextures.ScrollAlwaysVisible = true; - this.listtextures.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.listtextures.Size = new System.Drawing.Size(382, 138); - this.listtextures.Sorted = true; - this.listtextures.TabIndex = 25; - // - // addtextureset - // - this.addtextureset.Location = new System.Drawing.Point(15, 237); - this.addtextureset.Name = "addtextureset"; - this.addtextureset.Size = new System.Drawing.Size(67, 24); - this.addtextureset.TabIndex = 26; - this.addtextureset.Text = "Add..."; - this.addtextureset.UseVisualStyleBackColor = true; - // - // removetextureset - // - this.removetextureset.Enabled = false; - this.removetextureset.Location = new System.Drawing.Point(161, 237); - this.removetextureset.Name = "removetextureset"; - this.removetextureset.Size = new System.Drawing.Size(68, 24); - this.removetextureset.TabIndex = 27; - this.removetextureset.Text = "Remove"; - this.removetextureset.UseVisualStyleBackColor = true; - // - // copytexturesets - // - this.copytexturesets.Enabled = false; - this.copytexturesets.Location = new System.Drawing.Point(275, 237); - this.copytexturesets.Name = "copytexturesets"; - this.copytexturesets.Size = new System.Drawing.Size(58, 24); - this.copytexturesets.TabIndex = 28; - this.copytexturesets.Text = "Copy"; - this.copytexturesets.UseVisualStyleBackColor = true; - // - // pastetexturesets - // - this.pastetexturesets.Enabled = false; - this.pastetexturesets.Location = new System.Drawing.Point(339, 237); - this.pastetexturesets.Name = "pastetexturesets"; - this.pastetexturesets.Size = new System.Drawing.Size(58, 24); - this.pastetexturesets.TabIndex = 29; - this.pastetexturesets.Text = "Paste"; - this.pastetexturesets.UseVisualStyleBackColor = true; - // - // edittextureset - // - this.edittextureset.Enabled = false; - this.edittextureset.Location = new System.Drawing.Point(88, 237); - this.edittextureset.Name = "edittextureset"; - this.edittextureset.Size = new System.Drawing.Size(67, 24); - this.edittextureset.TabIndex = 30; - this.edittextureset.Text = "Edit..."; - this.edittextureset.UseVisualStyleBackColor = true; - // - // restoretexturesets - // - this.restoretexturesets.Location = new System.Drawing.Point(15, 275); - this.restoretexturesets.Name = "restoretexturesets"; - this.restoretexturesets.Size = new System.Drawing.Size(140, 24); - this.restoretexturesets.TabIndex = 31; - this.restoretexturesets.Text = "Add Default Categories"; - this.restoretexturesets.UseVisualStyleBackColor = true; - // // ConfigForm // this.AcceptButton = this.apply; diff --git a/Source/Windows/ConfigForm.cs b/Source/Windows/ConfigForm.cs index 2b672883..20d9ef9f 100644 --- a/Source/Windows/ConfigForm.cs +++ b/Source/Windows/ConfigForm.cs @@ -38,6 +38,7 @@ namespace CodeImp.DoomBuilder.Windows { // Variables private GameConfiguration gameconfig; + private ConfigurationInfo configinfo; // Constructor public ConfigForm() @@ -81,7 +82,6 @@ namespace CodeImp.DoomBuilder.Windows // Configuration item selected private void listconfigs_SelectedIndexChanged(object sender, EventArgs e) { - ConfigurationInfo ci; NodebuilderInfo ni; // Item selected? @@ -91,13 +91,13 @@ namespace CodeImp.DoomBuilder.Windows tabs.Enabled = true; // Get config info of selected item - ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; + configinfo = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; // Load the game configuration - gameconfig = new GameConfiguration(General.LoadGameConfiguration(ci.Filename)); + gameconfig = new GameConfiguration(General.LoadGameConfiguration(configinfo.Filename)); // Fill resources list - configdata.EditResourceLocationList(ci.Resources); + configdata.EditResourceLocationList(configinfo.Resources); // Go for all nodebuilder save items nodebuildersave.SelectedIndex = -1; @@ -107,7 +107,7 @@ namespace CodeImp.DoomBuilder.Windows ni = nodebuildersave.Items[i] as NodebuilderInfo; // Item matches configuration setting? - if(string.Compare(ni.Name, ci.NodebuilderSave, false) == 0) + if(string.Compare(ni.Name, configinfo.NodebuilderSave, false) == 0) { // Select this item nodebuildersave.SelectedIndex = i; @@ -123,7 +123,7 @@ namespace CodeImp.DoomBuilder.Windows ni = nodebuildertest.Items[i] as NodebuilderInfo; // Item matches configuration setting? - if(string.Compare(ni.Name, ci.NodebuilderTest, false) == 0) + if(string.Compare(ni.Name, configinfo.NodebuilderTest, false) == 0) { // Select this item nodebuildertest.SelectedIndex = i; @@ -136,13 +136,17 @@ namespace CodeImp.DoomBuilder.Windows skill.AddInfo(gameconfig.Skills.ToArray()); // Set test application and parameters - if(!ci.CustomParameters) ci.TestParameters = gameconfig.TestParameters; - testapplication.Text = ci.TestProgram; - testparameters.Text = ci.TestParameters; - int skilllevel = ci.TestSkill; + if(!configinfo.CustomParameters) configinfo.TestParameters = gameconfig.TestParameters; + testapplication.Text = configinfo.TestProgram; + testparameters.Text = configinfo.TestParameters; + int skilllevel = configinfo.TestSkill; skill.Value = skilllevel - 1; skill.Value = skilllevel; - customparameters.Checked = ci.CustomParameters; + customparameters.Checked = configinfo.CustomParameters; + + // Fill texture sets list + listtextures.Items.Clear(); + listtextures.Items.AddRange(configinfo.TextureSets.ToArray()); } } @@ -153,6 +157,8 @@ namespace CodeImp.DoomBuilder.Windows if(listconfigs.SelectedItems.Count == 0) { // Disable panels + gameconfig = null; + configinfo = null; configdata.FixedResourceLocationList(new DataLocationList()); configdata.EditResourceLocationList(new DataLocationList()); nodebuildersave.SelectedIndex = -1; @@ -163,7 +169,6 @@ namespace CodeImp.DoomBuilder.Windows skill.ClearInfo(); customparameters.Checked = false; tabs.Enabled = false; - gameconfig = null; } } @@ -176,69 +181,55 @@ namespace CodeImp.DoomBuilder.Windows // Resource locations changed private void resourcelocations_OnContentChanged() { - ConfigurationInfo ci; - // Leave when no configuration selected - if(listconfigs.SelectedItems.Count == 0) return; + if(configinfo == null) return; // Apply to selected configuration - ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; - ci.Resources.Clear(); - ci.Resources.AddRange(configdata.GetResources()); + configinfo.Resources.Clear(); + configinfo.Resources.AddRange(configdata.GetResources()); } // Nodebuilder selection changed private void nodebuildersave_SelectedIndexChanged(object sender, EventArgs e) { - ConfigurationInfo ci; - // Leave when no configuration selected - if(listconfigs.SelectedItems.Count == 0) return; + if(configinfo == null) return; // Apply to selected configuration - ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; if(nodebuildersave.SelectedItem != null) - ci.NodebuilderSave = (nodebuildersave.SelectedItem as NodebuilderInfo).Name; + configinfo.NodebuilderSave = (nodebuildersave.SelectedItem as NodebuilderInfo).Name; } // Nodebuilder selection changed private void nodebuildertest_SelectedIndexChanged(object sender, EventArgs e) { - ConfigurationInfo ci; - // Leave when no configuration selected - if(listconfigs.SelectedItems.Count == 0) return; + if(configinfo == null) return; // Apply to selected configuration - ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; if(nodebuildertest.SelectedItem != null) - ci.NodebuilderTest = (nodebuildertest.SelectedItem as NodebuilderInfo).Name; + configinfo.NodebuilderTest = (nodebuildertest.SelectedItem as NodebuilderInfo).Name; } // Test application changed private void testapplication_TextChanged(object sender, EventArgs e) { - ConfigurationInfo ci; - // Leave when no configuration selected - if(listconfigs.SelectedItems.Count == 0) return; + if(configinfo == null) return; // Apply to selected configuration - ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; - ci.TestProgram = testapplication.Text; + configinfo.TestProgram = testapplication.Text; } // Test parameters changed private void testparameters_TextChanged(object sender, EventArgs e) { - ConfigurationInfo ci; - // Leave when no configuration selected - if(listconfigs.SelectedItems.Count == 0) return; + if(configinfo == null) return; // Apply to selected configuration - ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; - ci.TestParameters = testparameters.Text; + configinfo = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; + configinfo.TestParameters = testparameters.Text; // Show example result CreateParametersExample(); @@ -308,14 +299,11 @@ namespace CodeImp.DoomBuilder.Windows // Customize parameters (un)checked private void customparameters_CheckedChanged(object sender, EventArgs e) { - ConfigurationInfo ci; - // Leave when no configuration selected - if(listconfigs.SelectedItems.Count == 0) return; + if(configinfo == null) return; // Apply to selected configuration - ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; - ci.CustomParameters = customparameters.Checked; + configinfo.CustomParameters = customparameters.Checked; // Update interface labelparameters.Visible = customparameters.Checked; @@ -341,16 +329,49 @@ namespace CodeImp.DoomBuilder.Windows // Skill changes private void skill_ValueChanges(object sender, EventArgs e) { - ConfigurationInfo ci; - // Leave when no configuration selected - if(listconfigs.SelectedItems.Count == 0) return; + if(configinfo == null) return; // Apply to selected configuration - ci = listconfigs.SelectedItems[0].Tag as ConfigurationInfo; - ci.TestSkill = skill.Value; + configinfo.TestSkill = skill.Value; CreateParametersExample(); } + + // Make new texture set + private void addtextureset_Click(object sender, EventArgs e) + { + DefinedTextureSet s = new DefinedTextureSet("New Texture Set"); + TextureSetForm form = new TextureSetForm(); + form.Setup(s); + if(form.ShowDialog(this) == DialogResult.OK) + { + // Add to texture sets + configinfo.TextureSets.Add(s); + listtextures.Items.Add(s); + } + } + + // Edit texture set + private void edittextureset_Click(object sender, EventArgs e) + { + // Texture Set selected? + if(listtextures.SelectedItem is DefinedTextureSet) + { + DefinedTextureSet s = (listtextures.SelectedItem as DefinedTextureSet); + TextureSetForm form = new TextureSetForm(); + form.Setup(s); + form.ShowDialog(this); + } + } + + // Texture Set selected/deselected + private void listtextures_SelectedIndexChanged(object sender, EventArgs e) + { + edittextureset.Enabled = (listtextures.SelectedItem is DefinedTextureSet); + removetextureset.Enabled = (listtextures.SelectedItem is DefinedTextureSet); + copytexturesets.Enabled = (listtextures.SelectedItem is DefinedTextureSet); + pastetexturesets.Enabled = (listtextures.SelectedItem is DefinedTextureSet); + } } } diff --git a/Source/Windows/ConfigForm.resx b/Source/Windows/ConfigForm.resx index f2b7d3b0..8e018399 100644 --- a/Source/Windows/ConfigForm.resx +++ b/Source/Windows/ConfigForm.resx @@ -168,6 +168,15 @@ False + + True + + + False + + + Texture Sets are a way to group textures and flats into categories, so that you can easily find a texture for the specific style or purpose you need by selecting one of the categories. Textures that are not in any category are automatically shown in the "Others" category. + True @@ -246,15 +255,6 @@ True - - True - - - False - - - Texture Sets are a way to group textures and flats into categories, so that you can easily find a texture for the specific style or purpose you need by selecting one of the categories. Textures that are not in any category are automatically shown in the "Others" category. - True diff --git a/Source/Windows/TextureSetForm.Designer.cs b/Source/Windows/TextureSetForm.Designer.cs new file mode 100644 index 00000000..5e9bb9d0 --- /dev/null +++ b/Source/Windows/TextureSetForm.Designer.cs @@ -0,0 +1,208 @@ +namespace CodeImp.DoomBuilder.Windows +{ + partial class TextureSetForm + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.name = new System.Windows.Forms.TextBox(); + this.filters = new System.Windows.Forms.ListView(); + this.filtercolumn = new System.Windows.Forms.ColumnHeader(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.apply = new System.Windows.Forms.Button(); + this.cancel = new System.Windows.Forms.Button(); + this.addfilter = new System.Windows.Forms.Button(); + this.removefilter = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(30, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(37, 14); + this.label1.TabIndex = 0; + this.label1.Text = "Name:"; + // + // name + // + this.name.Location = new System.Drawing.Point(73, 21); + this.name.Name = "name"; + this.name.Size = new System.Drawing.Size(179, 20); + this.name.TabIndex = 1; + // + // filters + // + this.filters.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.filtercolumn}); + this.filters.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.filters.HideSelection = false; + this.filters.LabelEdit = true; + this.filters.Location = new System.Drawing.Point(21, 110); + this.filters.Name = "filters"; + this.filters.ShowGroups = false; + this.filters.Size = new System.Drawing.Size(219, 173); + this.filters.TabIndex = 2; + this.filters.UseCompatibleStateImageBehavior = false; + this.filters.View = System.Windows.Forms.View.Details; + // + // filtercolumn + // + this.filtercolumn.Text = "Filter"; + this.filtercolumn.Width = 192; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(18, 28); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(248, 42); + this.label2.TabIndex = 3; + this.label2.Text = "Add the names of the textures in this set below. You can use the following wildca" + + "rds:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(28, 65); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(175, 14); + this.label3.TabIndex = 4; + this.label3.Text = "? = matches exactly one character"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(28, 83); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(181, 14); + this.label4.TabIndex = 5; + this.label4.Text = "* = matches one or more characters"; + // + // 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.Name = "apply"; + this.apply.Size = new System.Drawing.Size(105, 25); + this.apply.TabIndex = 6; + this.apply.Text = "OK"; + this.apply.UseVisualStyleBackColor = true; + this.apply.Click += new System.EventHandler(this.apply_Click); + // + // 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(177, 417); + this.cancel.Name = "cancel"; + this.cancel.Size = new System.Drawing.Size(105, 25); + this.cancel.TabIndex = 7; + this.cancel.Text = "Cancel"; + this.cancel.UseVisualStyleBackColor = true; + this.cancel.Click += new System.EventHandler(this.cancel_Click); + // + // addfilter + // + this.addfilter.Location = new System.Drawing.Point(21, 289); + this.addfilter.Name = "addfilter"; + this.addfilter.Size = new System.Drawing.Size(97, 24); + this.addfilter.TabIndex = 8; + this.addfilter.Text = "Add Texture"; + this.addfilter.UseVisualStyleBackColor = true; + // + // removefilter + // + 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; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.removefilter); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.addfilter); + this.groupBox1.Controls.Add(this.label3); + this.groupBox1.Controls.Add(this.label2); + 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.TabIndex = 10; + this.groupBox1.TabStop = false; + this.groupBox1.Text = " Filters "; + // + // 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.Controls.Add(this.cancel); + this.Controls.Add(this.apply); + this.Controls.Add(this.name); + this.Controls.Add(this.label1); + this.Controls.Add(this.groupBox1); + 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 = "TextureSetForm"; + this.Opacity = 0; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Edit Texture Set"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox name; + private System.Windows.Forms.ListView filters; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button apply; + private System.Windows.Forms.Button cancel; + private System.Windows.Forms.ColumnHeader filtercolumn; + private System.Windows.Forms.Button addfilter; + private System.Windows.Forms.Button removefilter; + private System.Windows.Forms.GroupBox groupBox1; + } +} \ No newline at end of file diff --git a/Source/Windows/TextureSetForm.cs b/Source/Windows/TextureSetForm.cs new file mode 100644 index 00000000..fed07686 --- /dev/null +++ b/Source/Windows/TextureSetForm.cs @@ -0,0 +1,86 @@ + +#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 +{ + internal partial class TextureSetForm : DelayedForm + { + // Variables + private DefinedTextureSet textureset; + + // Constructor + public TextureSetForm() + { + InitializeComponent(); + } + + // This initializes the set + public void Setup(DefinedTextureSet set) + { + // Keep reference + textureset = set; + + // Set name + name.Text = set.Name; + + // Fill filters list + foreach(string s in set.Filters) + filters.Items.Add(s); + } + + // OK clicked + private void apply_Click(object sender, EventArgs e) + { + // Apply name + textureset.Name = name.Text; + + // Apply filters + textureset.Filters.Clear(); + foreach(ListViewItem i in filters.Items) textureset.Filters.Add(i.Text); + + // Done + this.DialogResult = DialogResult.OK; + this.Close(); + } + + // Cancel clicked + 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/TextureSetForm.resx b/Source/Windows/TextureSetForm.resx new file mode 100644 index 00000000..994cb2e5 --- /dev/null +++ b/Source/Windows/TextureSetForm.resx @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file