UltimateZoneBuilder/Source/Config/LinedefActionInfo.cs

111 lines
2.9 KiB
C#
Raw Normal View History

2007-12-26 00:31:32 +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
{
public class LinedefActionInfo : INumberedTitle, IComparable<LinedefActionInfo>
{
#region ================== Constants
#endregion
#region ================== Variables
// Properties
private int index;
private string prefix;
private string category;
private string name;
private string title;
2008-05-29 16:44:20 +00:00
private ArgumentInfo[] args;
2007-12-26 00:31:32 +00:00
#endregion
#region ================== Properties
public int Index { get { return index; } }
public string Prefix { get { return prefix; } }
public string Category { get { return category; } }
public string Name { get { return name; } }
public string Title { get { return title; } }
2008-05-29 16:44:20 +00:00
public ArgumentInfo[] Args { get { return args; } }
2007-12-26 00:31:32 +00:00
#endregion
#region ================== Constructor / Disposer
// Constructor
internal LinedefActionInfo(int index, Configuration cfg, string categoryname, IDictionary<string, EnumList> enums)
2007-12-26 00:31:32 +00:00
{
string actionsetting = "linedeftypes." + categoryname + "." + index.ToString(CultureInfo.InvariantCulture);
2007-12-26 00:31:32 +00:00
// Initialize
this.index = index;
this.category = categoryname;
2008-05-29 16:44:20 +00:00
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
// Read settings
this.name = cfg.ReadSetting(actionsetting + ".title", "Unnamed");
this.prefix = cfg.ReadSetting(actionsetting + ".prefix", "");
2007-12-26 00:31:32 +00:00
this.title = this.prefix + " " + this.name;
this.title = this.title.Trim();
2008-05-29 16:44:20 +00:00
// Read the args
2007-12-26 00:31:32 +00:00
for(int i = 0; i < Linedef.NUM_ARGS; i++)
2008-05-29 16:44:20 +00:00
this.args[i] = new ArgumentInfo(cfg, actionsetting, i, enums);
2007-12-26 00:31:32 +00:00
// We have no destructor
GC.SuppressFinalize(this);
}
#endregion
#region ================== Methods
// This presents the item as string
public override string ToString()
{
2007-12-26 14:29:36 +00:00
return index + " - " + title;
2007-12-26 00:31:32 +00:00
}
// This compares against another action info
public int CompareTo(LinedefActionInfo other)
{
if(this.index < other.index) return -1;
else if(this.index > other.index) return 1;
else return 0;
}
#endregion
}
}