2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#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;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Config
|
|
|
|
{
|
2009-05-21 08:18:34 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Option in generalized types.
|
|
|
|
/// </summary>
|
2009-04-19 18:07:22 +00:00
|
|
|
public class GeneralizedOption
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
private string name;
|
|
|
|
private List<GeneralizedBit> bits;
|
Changed, Select Similar Sectors action: when "Effect" option is enabled, all sectors with at least one matching generalized/predefined effect will be selected.
Added, Tag Explorer plugin: a separate category for each generalized/predefined effect is now created when "Sort by action special" sort mode is used.
Added, Edit Effect window: normal and generalized effects can now be set at the same time.
Fixed, Edit Action window: in some cases Generalized actions were incorrectly processed.
Fixed, Edit Effect window: in some cases Generalized effects were incorrectly processed.
Fixed, Select Similar window: Tab control was incorrectly anchored.
Fixed, Nodes Viewer mode, cosmetic: segs angles were calculated incorrectly when showing nodes in classic format.
Fixed: HiRes textures, which didn't override any texture or flat were not loaded.
Fixed, Tag Explorer plugin: linedef action categories were missing title when "Sort by action special" sort mode was used.
Cosmetic: renamed "Grid Setup" action to "Grid and Backdrop Setup".
2016-03-21 15:19:14 +00:00
|
|
|
private int bitstep; //mxd
|
|
|
|
public int BitsStep { get { return bitstep; } } // mxd. Each subsequent value is incremented by this number
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public string Name { get { return name; } }
|
|
|
|
public List<GeneralizedBit> Bits { get { return bits; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
internal GeneralizedOption(string structure, string cat, string name, IDictionary bitslist)
|
|
|
|
{
|
|
|
|
string fullpath;
|
|
|
|
|
|
|
|
// Determine path
|
|
|
|
if(cat.Length > 0) fullpath = structure + "." + cat;
|
|
|
|
else fullpath = structure;
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
this.name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name);
|
|
|
|
this.bits = new List<GeneralizedBit>();
|
|
|
|
|
|
|
|
// Go for all bits
|
|
|
|
foreach(DictionaryEntry de in bitslist)
|
|
|
|
{
|
|
|
|
// Check if the item key is numeric
|
2015-12-28 15:01:53 +00:00
|
|
|
int index;
|
2009-04-19 18:07:22 +00:00
|
|
|
if(int.TryParse(de.Key.ToString(), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.InvariantCulture, out index))
|
|
|
|
{
|
|
|
|
// Add to list
|
|
|
|
this.bits.Add(new GeneralizedBit(index, de.Value.ToString()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-22 08:04:06 +00:00
|
|
|
General.ErrorLogger.Add(ErrorType.Warning, "Structure \"" + fullpath + "." + name + "\" contains invalid entries. The keys must be numeric.");
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort the list
|
|
|
|
bits.Sort();
|
Changed, Select Similar Sectors action: when "Effect" option is enabled, all sectors with at least one matching generalized/predefined effect will be selected.
Added, Tag Explorer plugin: a separate category for each generalized/predefined effect is now created when "Sort by action special" sort mode is used.
Added, Edit Effect window: normal and generalized effects can now be set at the same time.
Fixed, Edit Action window: in some cases Generalized actions were incorrectly processed.
Fixed, Edit Effect window: in some cases Generalized effects were incorrectly processed.
Fixed, Select Similar window: Tab control was incorrectly anchored.
Fixed, Nodes Viewer mode, cosmetic: segs angles were calculated incorrectly when showing nodes in classic format.
Fixed: HiRes textures, which didn't override any texture or flat were not loaded.
Fixed, Tag Explorer plugin: linedef action categories were missing title when "Sort by action special" sort mode was used.
Cosmetic: renamed "Grid Setup" action to "Grid and Backdrop Setup".
2016-03-21 15:19:14 +00:00
|
|
|
|
|
|
|
//mxd. Determine and check increment steps
|
|
|
|
if(bits.Count > 1)
|
|
|
|
{
|
|
|
|
// Use the second bit as the structure's step
|
|
|
|
bitstep = bits[1].Index;
|
|
|
|
|
|
|
|
// Check the rest of the values
|
|
|
|
for(int i = 1; i < bits.Count; i++)
|
|
|
|
{
|
|
|
|
if(bits[i].Index - bits[i - 1].Index != bitstep)
|
|
|
|
General.ErrorLogger.Add(ErrorType.Warning, "Structure \"" + fullpath + "." + name + "\" contains options with mixed increments (option \"" + bits[i].Title + "\" increment (" + (bits[i - 1].Index - bits[i].Index) + ") doesn't match the structure increment (" + bitstep + ")).");
|
|
|
|
}
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This presents the item as string
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|