2007-10-21 18:06:10 +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;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Config
|
|
|
|
{
|
2007-10-24 17:25:03 +00:00
|
|
|
public class GameConfiguration
|
2007-10-21 18:06:10 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Original configuration
|
|
|
|
private Configuration cfg;
|
|
|
|
|
|
|
|
// General settings
|
|
|
|
private float defaulttexturescale;
|
|
|
|
private float defaultflatscale;
|
|
|
|
private string formatinterface;
|
|
|
|
private int soundlinedefflags;
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Map lumps
|
|
|
|
private IDictionary maplumpnames;
|
|
|
|
|
|
|
|
// Things
|
|
|
|
private List<ThingCategory> thingcategories;
|
|
|
|
private Dictionary<int, ThingTypeInfo> things;
|
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
// General settings
|
|
|
|
public float DefaultTextureScale { get { return defaulttexturescale; } }
|
|
|
|
public float DefaultFlatScale { get { return defaultflatscale; } }
|
|
|
|
public string FormatInterface { get { return formatinterface; } }
|
|
|
|
public int SoundLinedefFlags { get { return soundlinedefflags; } }
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Map lumps
|
|
|
|
public IDictionary MapLumpNames { get { return maplumpnames; } }
|
|
|
|
|
|
|
|
// Things
|
|
|
|
public List<ThingCategory> ThingCategories { get { return thingcategories; } }
|
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public GameConfiguration(Configuration cfg)
|
|
|
|
{
|
2007-10-21 22:41:46 +00:00
|
|
|
IDictionary dic;
|
|
|
|
ThingCategory thingcat;
|
|
|
|
|
|
|
|
// Initialize
|
2007-10-21 18:06:10 +00:00
|
|
|
this.cfg = cfg;
|
2007-10-21 22:41:46 +00:00
|
|
|
this.thingcategories = new List<ThingCategory>();
|
|
|
|
this.things = new Dictionary<int, ThingTypeInfo>();
|
2007-10-21 18:06:10 +00:00
|
|
|
|
|
|
|
// Read general settings
|
|
|
|
defaulttexturescale = cfg.ReadSetting("defaulttexturescale", 1f);
|
|
|
|
defaultflatscale = cfg.ReadSetting("defaultflatscale", 1f);
|
|
|
|
formatinterface = cfg.ReadSetting("formatinterface", "");
|
|
|
|
soundlinedefflags = cfg.ReadSetting("soundlinedefflags", 0);
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Get map lumps
|
|
|
|
maplumpnames = cfg.ReadSetting("maplumpnames", new Hashtable());
|
|
|
|
|
|
|
|
// Get thing categories
|
|
|
|
dic = cfg.ReadSetting("thingtypes", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
// Make a category
|
|
|
|
thingcat = new ThingCategory(cfg, de.Key.ToString());
|
|
|
|
|
|
|
|
// Add all thing in category to the big list
|
|
|
|
foreach(ThingTypeInfo t in thingcat.Things) things.Add(t.Index, t);
|
|
|
|
}
|
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// ReadSetting
|
|
|
|
public string ReadSetting(string setting, string defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
|
|
|
public int ReadSetting(string setting, int defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
|
|
|
public float ReadSetting(string setting, float defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
|
|
|
public short ReadSetting(string setting, short defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
|
|
|
public long ReadSetting(string setting, long defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
|
|
|
public bool ReadSetting(string setting, bool defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
|
|
|
public byte ReadSetting(string setting, byte defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
|
|
|
public IDictionary ReadSetting(string setting, IDictionary defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// This gets thing information by index
|
2007-10-24 17:25:03 +00:00
|
|
|
public ThingTypeInfo GetThingInfo(int thingtype)
|
2007-10-21 22:41:46 +00:00
|
|
|
{
|
|
|
|
// Index in config?
|
2007-10-24 17:25:03 +00:00
|
|
|
if(things.ContainsKey(thingtype))
|
2007-10-21 22:41:46 +00:00
|
|
|
{
|
|
|
|
// Return from config
|
2007-10-24 17:25:03 +00:00
|
|
|
return things[thingtype];
|
2007-10-21 22:41:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Create unknown thing info
|
2007-10-24 17:25:03 +00:00
|
|
|
return new ThingTypeInfo(thingtype);
|
2007-10-21 22:41:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|