2007-10-20 12:34:27 +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;
|
2007-10-21 18:06:10 +00:00
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using System.IO;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Windows.Forms;
|
2007-10-20 12:34:27 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
namespace CodeImp.DoomBuilder.Config
|
2007-10-20 12:34:27 +00:00
|
|
|
{
|
2007-10-24 17:25:03 +00:00
|
|
|
public class ThingTypeInfo
|
2007-10-20 12:34:27 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
2008-05-17 17:43:57 +00:00
|
|
|
public const int THING_BLOCKING_NONE = 0;
|
|
|
|
public const int THING_BLOCKING_FULL = 1;
|
|
|
|
public const int THING_BLOCKING_HEIGHT = 2;
|
2008-10-23 22:01:07 +00:00
|
|
|
public const int THING_ERROR_NONE = 0;
|
|
|
|
public const int THING_ERROR_INSIDE = 1;
|
|
|
|
public const int THING_ERROR_INSIDE_STUCKED = 2;
|
|
|
|
|
2007-10-20 12:34:27 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Properties
|
|
|
|
private int index;
|
|
|
|
private string title;
|
|
|
|
private string sprite;
|
|
|
|
private long spritelongname;
|
|
|
|
private int color;
|
|
|
|
private bool arrow;
|
|
|
|
private float width;
|
|
|
|
private float height;
|
|
|
|
private bool hangs;
|
|
|
|
private int blocking;
|
|
|
|
private int errorcheck;
|
2008-11-17 16:14:45 +00:00
|
|
|
private bool fixedsize;
|
2007-10-21 22:41:46 +00:00
|
|
|
private ThingCategory category;
|
|
|
|
|
2007-10-20 12:34:27 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
public int Index { get { return index; } }
|
|
|
|
public string Title { get { return title; } }
|
|
|
|
public string Sprite { get { return sprite; } }
|
|
|
|
public long SpriteLongName { get { return spritelongname; } }
|
|
|
|
public int Color { get { return color; } }
|
|
|
|
public bool Arrow { get { return arrow; } }
|
|
|
|
public float Width { get { return width; } }
|
|
|
|
public float Height { get { return height; } }
|
|
|
|
public bool Hangs { get { return hangs; } }
|
|
|
|
public int Blocking { get { return blocking; } }
|
|
|
|
public int ErrorCheck { get { return errorcheck; } }
|
2008-11-17 16:14:45 +00:00
|
|
|
public bool FixedSize { get { return fixedsize; } }
|
2007-10-21 22:41:46 +00:00
|
|
|
public ThingCategory Category { get { return category; } }
|
|
|
|
|
2007-10-20 12:34:27 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2008-01-02 21:49:43 +00:00
|
|
|
internal ThingTypeInfo(int index)
|
2007-10-20 12:34:27 +00:00
|
|
|
{
|
|
|
|
// Initialize
|
2007-10-21 22:41:46 +00:00
|
|
|
this.index = index;
|
|
|
|
this.category = null;
|
|
|
|
this.title = "<" + index.ToString(CultureInfo.InvariantCulture) + ">";
|
|
|
|
this.sprite = "";
|
|
|
|
this.color = 0;
|
|
|
|
this.arrow = true;
|
|
|
|
this.width = 16f;
|
|
|
|
this.height = 16f;
|
|
|
|
this.hangs = false;
|
|
|
|
this.blocking = 0;
|
|
|
|
this.errorcheck = 0;
|
2008-11-17 16:14:45 +00:00
|
|
|
this.fixedsize = false;
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Make long name for sprite lookup
|
|
|
|
this.spritelongname = Lump.MakeLongName(this.sprite);
|
|
|
|
|
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor
|
2008-01-02 21:49:43 +00:00
|
|
|
internal ThingTypeInfo(ThingCategory cat, int index, Configuration cfg)
|
2007-10-21 22:41:46 +00:00
|
|
|
{
|
|
|
|
string key = index.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
this.index = index;
|
|
|
|
this.category = cat;
|
|
|
|
|
|
|
|
// Read properties
|
|
|
|
this.title = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".title", "<" + key + ">");
|
|
|
|
this.sprite = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".sprite", cat.Sprite);
|
|
|
|
this.color = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".color", cat.Color);
|
|
|
|
this.arrow = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".arrow", cat.Arrow) != 0);
|
|
|
|
this.width = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".width", cat.Width);
|
|
|
|
this.height = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".height", cat.Height);
|
|
|
|
this.hangs = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".hangs", cat.Hangs) != 0);
|
|
|
|
this.blocking = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".blocking", cat.Blocking);
|
2008-10-23 22:01:07 +00:00
|
|
|
this.errorcheck = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".error", cat.ErrorCheck);
|
2008-11-17 16:14:45 +00:00
|
|
|
this.fixedsize = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".fixedsize", cat.FixedSize);
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Safety
|
2008-06-19 07:25:01 +00:00
|
|
|
if(this.width < 8f) this.width = 8f;
|
|
|
|
if(this.height < 8f) this.height = 8f;
|
2007-10-21 22:41:46 +00:00
|
|
|
|
|
|
|
// Make long name for sprite lookup
|
|
|
|
this.spritelongname = Lump.MakeLongName(this.sprite);
|
|
|
|
|
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public ThingTypeInfo(ThingCategory cat, int index, string title)
|
|
|
|
{
|
|
|
|
string key = index.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
this.index = index;
|
|
|
|
this.category = cat;
|
|
|
|
this.title = title;
|
|
|
|
|
|
|
|
// Read properties
|
|
|
|
this.sprite = cat.Sprite;
|
|
|
|
this.color = cat.Color;
|
|
|
|
this.arrow = (cat.Arrow != 0);
|
|
|
|
this.width = cat.Width;
|
|
|
|
this.height = cat.Height;
|
|
|
|
this.hangs = (cat.Hangs != 0);
|
|
|
|
this.blocking = cat.Blocking;
|
|
|
|
this.errorcheck = cat.ErrorCheck;
|
2008-11-17 16:14:45 +00:00
|
|
|
this.fixedsize = cat.FixedSize;
|
2007-10-21 22:41:46 +00:00
|
|
|
|
|
|
|
// Make long name for sprite lookup
|
|
|
|
this.spritelongname = Lump.MakeLongName(this.sprite);
|
2007-10-21 18:06:10 +00:00
|
|
|
|
2007-10-20 12:34:27 +00:00
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|