2007-12-29 15:50:16 +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;
|
|
|
|
using System.Text;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using System.IO;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Config
|
|
|
|
{
|
2008-02-21 06:47:43 +00:00
|
|
|
public class GeneralizedOption
|
2007-12-29 15:50:16 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
private string name;
|
2008-02-21 06:47:43 +00:00
|
|
|
private List<GeneralizedBit> bits;
|
2007-12-29 15:50:16 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public string Name { get { return name; } }
|
2008-02-21 06:47:43 +00:00
|
|
|
public List<GeneralizedBit> Bits { get { return bits; } }
|
2007-12-29 15:50:16 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2008-02-21 06:47:43 +00:00
|
|
|
internal GeneralizedOption(string structure, string cat, string name, IDictionary bitslist)
|
2007-12-29 15:50:16 +00:00
|
|
|
{
|
|
|
|
int index;
|
2008-02-22 17:11:29 +00:00
|
|
|
string fullpath;
|
2007-12-29 15:50:16 +00:00
|
|
|
|
2008-02-22 17:11:29 +00:00
|
|
|
// Determine path
|
|
|
|
if(cat.Length > 0) fullpath = structure + "." + cat;
|
|
|
|
else fullpath = structure;
|
|
|
|
|
2007-12-29 15:50:16 +00:00
|
|
|
// Initialize
|
|
|
|
this.name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name);
|
2008-02-21 06:47:43 +00:00
|
|
|
this.bits = new List<GeneralizedBit>();
|
2007-12-29 15:50:16 +00:00
|
|
|
|
|
|
|
// Go for all bits
|
|
|
|
foreach(DictionaryEntry de in bitslist)
|
|
|
|
{
|
|
|
|
// Check if the item key is numeric
|
|
|
|
if(int.TryParse(de.Key.ToString(), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.InvariantCulture, out index))
|
|
|
|
{
|
|
|
|
// Add to list
|
2008-02-21 06:47:43 +00:00
|
|
|
this.bits.Add(new GeneralizedBit(index, de.Value.ToString()));
|
2007-12-29 15:50:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-22 17:11:29 +00:00
|
|
|
General.WriteLogLine("WARNING: Structure '" + fullpath + "." + name + "' contains invalid entries!");
|
2007-12-29 15:50:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort the list
|
|
|
|
bits.Sort();
|
|
|
|
|
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// This presents the item as string
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|