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;
|
2008-10-17 09:39:07 +00:00
|
|
|
using CodeImp.DoomBuilder.Map;
|
2009-01-05 15:57:41 +00:00
|
|
|
using CodeImp.DoomBuilder.Editing;
|
2007-10-21 18:06:10 +00:00
|
|
|
|
|
|
|
#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
|
2008-09-22 18:27:50 +00:00
|
|
|
private string configname;
|
2008-06-01 20:25:46 +00:00
|
|
|
private string enginename;
|
2007-10-21 18:06:10 +00:00
|
|
|
private float defaulttexturescale;
|
|
|
|
private float defaultflatscale;
|
2009-01-15 19:42:55 +00:00
|
|
|
private string defaultsavecompiler;
|
|
|
|
private string defaulttestcompiler;
|
2007-10-21 18:06:10 +00:00
|
|
|
private string formatinterface;
|
2008-05-31 19:31:45 +00:00
|
|
|
private string soundlinedefflag;
|
|
|
|
private string singlesidedflag;
|
|
|
|
private string doublesidedflag;
|
|
|
|
private string impassableflag;
|
2008-10-17 09:39:07 +00:00
|
|
|
private string upperunpeggedflag;
|
|
|
|
private string lowerunpeggedflag;
|
2007-11-04 23:09:21 +00:00
|
|
|
private bool mixtexturesflats;
|
2007-12-29 16:42:30 +00:00
|
|
|
private bool generalizedactions;
|
|
|
|
private bool generalizedeffects;
|
2008-01-05 18:11:29 +00:00
|
|
|
private int start3dmodethingtype;
|
2008-05-31 19:31:45 +00:00
|
|
|
private int linedefactivationsfilter;
|
2008-09-09 23:06:31 +00:00
|
|
|
private string testparameters;
|
2008-10-17 09:39:07 +00:00
|
|
|
private string makedoortrack;
|
|
|
|
private int makedooraction;
|
|
|
|
private int[] makedoorargs;
|
2009-01-07 16:05:17 +00:00
|
|
|
private bool linetagindicatesectors;
|
2009-01-22 15:10:41 +00:00
|
|
|
private string decorategames;
|
2007-10-21 18:06:10 +00:00
|
|
|
|
2008-09-09 23:06:31 +00:00
|
|
|
// Skills
|
|
|
|
private List<SkillInfo> skills;
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Map lumps
|
2008-11-10 16:11:44 +00:00
|
|
|
private IDictionary maplumpnames; // This is old, we should use maplumps instead
|
|
|
|
private Dictionary<string, MapLumpInfo> maplumps;
|
2007-10-21 22:41:46 +00:00
|
|
|
|
2007-10-26 13:17:20 +00:00
|
|
|
// Texture/flat sources
|
|
|
|
private IDictionary textureranges;
|
|
|
|
private IDictionary flatranges;
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Things
|
2008-06-10 11:32:06 +00:00
|
|
|
private List<string> defaultthingflags;
|
2008-05-31 19:31:45 +00:00
|
|
|
private Dictionary<string, string> thingflags;
|
2007-10-21 22:41:46 +00:00
|
|
|
private List<ThingCategory> thingcategories;
|
|
|
|
private Dictionary<int, ThingTypeInfo> things;
|
2008-12-31 14:08:40 +00:00
|
|
|
private List<FlagTranslation> thingflagstranslation;
|
2007-10-21 22:41:46 +00:00
|
|
|
|
2007-12-26 00:31:32 +00:00
|
|
|
// Linedefs
|
2008-05-31 19:31:45 +00:00
|
|
|
private Dictionary<string, string> linedefflags;
|
2007-12-26 00:31:32 +00:00
|
|
|
private Dictionary<int, LinedefActionInfo> linedefactions;
|
|
|
|
private List<LinedefActionInfo> sortedlinedefactions;
|
|
|
|
private List<LinedefActionCategory> actioncategories;
|
2007-12-26 14:29:36 +00:00
|
|
|
private List<LinedefActivateInfo> linedefactivates;
|
2008-02-21 06:47:43 +00:00
|
|
|
private List<GeneralizedCategory> genactioncategories;
|
2008-12-31 14:08:40 +00:00
|
|
|
private List<FlagTranslation> linedefflagstranslation;
|
2007-12-26 00:31:32 +00:00
|
|
|
|
2008-02-21 06:47:43 +00:00
|
|
|
// Sectors
|
|
|
|
private Dictionary<int, SectorEffectInfo> sectoreffects;
|
|
|
|
private List<SectorEffectInfo> sortedsectoreffects;
|
2008-02-22 17:11:29 +00:00
|
|
|
private List<GeneralizedOption> geneffectoptions;
|
2008-02-21 06:47:43 +00:00
|
|
|
|
2008-01-25 19:12:34 +00:00
|
|
|
// Universal fields
|
|
|
|
private List<UniversalFieldInfo> linedeffields;
|
2008-02-22 17:11:29 +00:00
|
|
|
private List<UniversalFieldInfo> sectorfields;
|
2008-06-01 20:25:46 +00:00
|
|
|
private List<UniversalFieldInfo> sidedeffields;
|
|
|
|
private List<UniversalFieldInfo> thingfields;
|
|
|
|
private List<UniversalFieldInfo> vertexfields;
|
2008-01-25 19:12:34 +00:00
|
|
|
|
2008-05-28 18:55:01 +00:00
|
|
|
// Enums
|
|
|
|
private Dictionary<string, EnumList> enums;
|
|
|
|
|
2009-01-05 15:57:41 +00:00
|
|
|
// Defaults
|
2008-10-01 14:17:52 +00:00
|
|
|
private List<DefinedTextureSet> texturesets;
|
2009-01-05 15:57:41 +00:00
|
|
|
private List<ThingsFilter> thingfilters;
|
2008-10-01 08:21:10 +00:00
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
// General settings
|
2008-09-22 18:27:50 +00:00
|
|
|
public string Name { get { return configname; } }
|
2008-06-01 20:25:46 +00:00
|
|
|
public string EngineName { get { return enginename; } }
|
2009-01-15 19:42:55 +00:00
|
|
|
public string DefaultSaveCompiler { get { return defaultsavecompiler; } }
|
|
|
|
public string DefaultTestCompiler { get { return defaulttestcompiler; } }
|
2007-10-21 18:06:10 +00:00
|
|
|
public float DefaultTextureScale { get { return defaulttexturescale; } }
|
|
|
|
public float DefaultFlatScale { get { return defaultflatscale; } }
|
|
|
|
public string FormatInterface { get { return formatinterface; } }
|
2008-05-31 19:31:45 +00:00
|
|
|
public string SoundLinedefFlag { get { return soundlinedefflag; } }
|
|
|
|
public string SingleSidedFlag { get { return singlesidedflag; } }
|
|
|
|
public string DoubleSidedFlag { get { return doublesidedflag; } }
|
|
|
|
public string ImpassableFlag { get { return impassableflag; } }
|
2008-10-17 09:39:07 +00:00
|
|
|
public string UpperUnpeggedFlag { get { return upperunpeggedflag; } }
|
|
|
|
public string LowerUnpeggedFlag { get { return lowerunpeggedflag; } }
|
2007-11-04 23:09:21 +00:00
|
|
|
public bool MixTexturesFlats { get { return mixtexturesflats; } }
|
2007-12-29 16:42:30 +00:00
|
|
|
public bool GeneralizedActions { get { return generalizedactions; } }
|
|
|
|
public bool GeneralizedEffects { get { return generalizedeffects; } }
|
2008-01-05 18:11:29 +00:00
|
|
|
public int Start3DModeThingType { get { return start3dmodethingtype; } }
|
2008-05-31 19:31:45 +00:00
|
|
|
public int LinedefActivationsFilter { get { return linedefactivationsfilter; } }
|
2008-09-09 23:06:31 +00:00
|
|
|
public string TestParameters { get { return testparameters; } }
|
2008-10-17 09:39:07 +00:00
|
|
|
public string MakeDoorTrack { get { return makedoortrack; } }
|
|
|
|
public int MakeDoorAction { get { return makedooraction; } }
|
|
|
|
public int[] MakeDoorArgs { get { return makedoorargs; } }
|
2009-01-07 16:05:17 +00:00
|
|
|
public bool LineTagIndicatesSectors { get { return linetagindicatesectors ; } }
|
2009-01-22 15:10:41 +00:00
|
|
|
public string DecorateGames { get { return decorategames; } }
|
2008-09-09 23:06:31 +00:00
|
|
|
|
|
|
|
// Skills
|
|
|
|
public List<SkillInfo> Skills { get { return skills; } }
|
2007-10-21 18:06:10 +00:00
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Map lumps
|
|
|
|
public IDictionary MapLumpNames { get { return maplumpnames; } }
|
2008-11-10 16:11:44 +00:00
|
|
|
public Dictionary<string, MapLumpInfo> MapLumps { get { return maplumps; } }
|
2007-10-21 22:41:46 +00:00
|
|
|
|
2007-10-26 13:17:20 +00:00
|
|
|
// Texture/flat sources
|
|
|
|
public IDictionary TextureRanges { get { return textureranges; } }
|
|
|
|
public IDictionary FlatRanges { get { return flatranges; } }
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Things
|
2008-06-10 11:32:06 +00:00
|
|
|
public ICollection<string> DefaultThingFlags { get { return defaultthingflags; } }
|
2008-05-31 19:31:45 +00:00
|
|
|
public IDictionary<string, string> ThingFlags { get { return thingflags; } }
|
2008-12-31 14:08:40 +00:00
|
|
|
public List<FlagTranslation> ThingFlagsTranslation { get { return thingflagstranslation; } }
|
2007-10-21 22:41:46 +00:00
|
|
|
|
2007-12-26 00:31:32 +00:00
|
|
|
// Linedefs
|
2008-05-31 19:31:45 +00:00
|
|
|
public IDictionary<string, string> LinedefFlags { get { return linedefflags; } }
|
2007-12-26 00:31:32 +00:00
|
|
|
public IDictionary<int, LinedefActionInfo> LinedefActions { get { return linedefactions; } }
|
|
|
|
public List<LinedefActionInfo> SortedLinedefActions { get { return sortedlinedefactions; } }
|
|
|
|
public List<LinedefActionCategory> ActionCategories { get { return actioncategories; } }
|
2007-12-26 14:29:36 +00:00
|
|
|
public List<LinedefActivateInfo> LinedefActivates { get { return linedefactivates; } }
|
2008-02-21 06:47:43 +00:00
|
|
|
public List<GeneralizedCategory> GenActionCategories { get { return genactioncategories; } }
|
2008-12-31 14:08:40 +00:00
|
|
|
public List<FlagTranslation> LinedefFlagsTranslation { get { return linedefflagstranslation; } }
|
2008-02-21 06:47:43 +00:00
|
|
|
|
|
|
|
// Sectors
|
|
|
|
public IDictionary<int, SectorEffectInfo> SectorEffects { get { return sectoreffects; } }
|
|
|
|
public List<SectorEffectInfo> SortedSectorEffects { get { return sortedsectoreffects; } }
|
2008-02-22 17:11:29 +00:00
|
|
|
public List<GeneralizedOption> GenEffectOptions { get { return geneffectoptions; } }
|
2007-12-26 00:31:32 +00:00
|
|
|
|
2008-01-25 19:12:34 +00:00
|
|
|
// Universal fields
|
|
|
|
public List<UniversalFieldInfo> LinedefFields { get { return linedeffields; } }
|
2008-02-22 17:11:29 +00:00
|
|
|
public List<UniversalFieldInfo> SectorFields { get { return sectorfields; } }
|
2008-06-01 20:25:46 +00:00
|
|
|
public List<UniversalFieldInfo> SidedefFields { get { return sidedeffields; } }
|
|
|
|
public List<UniversalFieldInfo> ThingFields { get { return thingfields; } }
|
|
|
|
public List<UniversalFieldInfo> VertexFields { get { return vertexfields; } }
|
2008-05-28 18:55:01 +00:00
|
|
|
|
|
|
|
// Enums
|
|
|
|
public IDictionary<string, EnumList> Enums { get { return enums; } }
|
2008-10-01 08:21:10 +00:00
|
|
|
|
2009-01-05 15:57:41 +00:00
|
|
|
// Defaults
|
2008-10-01 14:17:52 +00:00
|
|
|
internal List<DefinedTextureSet> TextureSets { get { return texturesets; } }
|
2009-01-05 15:57:41 +00:00
|
|
|
internal List<ThingsFilter> ThingsFilters { get { return thingfilters; } }
|
2008-01-25 19:12:34 +00:00
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2008-01-02 21:49:43 +00:00
|
|
|
internal GameConfiguration(Configuration cfg)
|
2007-10-21 18:06:10 +00:00
|
|
|
{
|
2008-05-31 19:31:45 +00:00
|
|
|
object obj;
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Initialize
|
2007-10-21 18:06:10 +00:00
|
|
|
this.cfg = cfg;
|
2008-05-31 19:31:45 +00:00
|
|
|
this.thingflags = new Dictionary<string, string>();
|
2008-06-10 11:32:06 +00:00
|
|
|
this.defaultthingflags = new List<string>();
|
2007-10-21 22:41:46 +00:00
|
|
|
this.thingcategories = new List<ThingCategory>();
|
|
|
|
this.things = new Dictionary<int, ThingTypeInfo>();
|
2008-05-31 19:31:45 +00:00
|
|
|
this.linedefflags = new Dictionary<string, string>();
|
2007-12-26 00:31:32 +00:00
|
|
|
this.linedefactions = new Dictionary<int, LinedefActionInfo>();
|
|
|
|
this.actioncategories = new List<LinedefActionCategory>();
|
|
|
|
this.sortedlinedefactions = new List<LinedefActionInfo>();
|
2007-12-26 14:29:36 +00:00
|
|
|
this.linedefactivates = new List<LinedefActivateInfo>();
|
2008-02-21 06:47:43 +00:00
|
|
|
this.genactioncategories = new List<GeneralizedCategory>();
|
|
|
|
this.sectoreffects = new Dictionary<int, SectorEffectInfo>();
|
|
|
|
this.sortedsectoreffects = new List<SectorEffectInfo>();
|
2008-02-22 17:11:29 +00:00
|
|
|
this.geneffectoptions = new List<GeneralizedOption>();
|
2008-05-28 18:55:01 +00:00
|
|
|
this.enums = new Dictionary<string, EnumList>();
|
2008-09-09 23:06:31 +00:00
|
|
|
this.skills = new List<SkillInfo>();
|
2008-10-01 14:17:52 +00:00
|
|
|
this.texturesets = new List<DefinedTextureSet>();
|
2008-10-17 09:39:07 +00:00
|
|
|
this.makedoorargs = new int[Linedef.NUM_ARGS];
|
2008-11-10 16:11:44 +00:00
|
|
|
this.maplumps = new Dictionary<string, MapLumpInfo>();
|
2008-12-31 14:08:40 +00:00
|
|
|
this.thingflagstranslation = new List<FlagTranslation>();
|
|
|
|
this.linedefflagstranslation = new List<FlagTranslation>();
|
2009-01-05 15:57:41 +00:00
|
|
|
this.thingfilters = new List<ThingsFilter>();
|
2008-10-01 08:21:10 +00:00
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
// Read general settings
|
2008-09-22 18:27:50 +00:00
|
|
|
configname = cfg.ReadSetting("game", "<unnamed game>");
|
2008-06-01 20:25:46 +00:00
|
|
|
enginename = cfg.ReadSetting("engine", "");
|
2009-01-15 19:42:55 +00:00
|
|
|
defaultsavecompiler = cfg.ReadSetting("defaultsavecompiler", "");
|
|
|
|
defaulttestcompiler = cfg.ReadSetting("defaulttestcompiler", "");
|
2007-10-21 18:06:10 +00:00
|
|
|
defaulttexturescale = cfg.ReadSetting("defaulttexturescale", 1f);
|
|
|
|
defaultflatscale = cfg.ReadSetting("defaultflatscale", 1f);
|
|
|
|
formatinterface = cfg.ReadSetting("formatinterface", "");
|
2007-11-04 23:09:21 +00:00
|
|
|
mixtexturesflats = cfg.ReadSetting("mixtexturesflats", false);
|
2007-12-29 16:42:30 +00:00
|
|
|
generalizedactions = cfg.ReadSetting("generalizedlinedefs", false);
|
|
|
|
generalizedeffects = cfg.ReadSetting("generalizedsectors", false);
|
2008-01-05 18:11:29 +00:00
|
|
|
start3dmodethingtype = cfg.ReadSetting("start3dmode", 0);
|
2008-05-31 19:31:45 +00:00
|
|
|
linedefactivationsfilter = cfg.ReadSetting("linedefactivationsfilter", 0);
|
2008-09-09 23:06:31 +00:00
|
|
|
testparameters = cfg.ReadSetting("testparameters", "");
|
2008-10-17 09:39:07 +00:00
|
|
|
makedoortrack = cfg.ReadSetting("makedoortrack", "-");
|
|
|
|
makedooraction = cfg.ReadSetting("makedooraction", 0);
|
2009-01-07 16:05:17 +00:00
|
|
|
linetagindicatesectors = cfg.ReadSetting("linetagindicatesectors", false);
|
2009-01-22 15:10:41 +00:00
|
|
|
decorategames = cfg.ReadSetting("decorategames", "");
|
2008-10-17 09:39:07 +00:00
|
|
|
for(int i = 0; i < Linedef.NUM_ARGS; i++) makedoorargs[i] = cfg.ReadSetting("makedoorarg" + i.ToString(CultureInfo.InvariantCulture), 0);
|
2008-05-31 19:31:45 +00:00
|
|
|
|
|
|
|
// Flags have special (invariant culture) conversion
|
|
|
|
// because they are allowed to be written as integers in the configs
|
|
|
|
obj = cfg.ReadSettingObject("soundlinedefflag", 0);
|
|
|
|
if(obj is int) soundlinedefflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else soundlinedefflag = obj.ToString();
|
2008-06-02 04:55:51 +00:00
|
|
|
obj = cfg.ReadSettingObject("singlesidedflag", 0);
|
2008-05-31 19:31:45 +00:00
|
|
|
if(obj is int) singlesidedflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else singlesidedflag = obj.ToString();
|
2008-06-02 04:55:51 +00:00
|
|
|
obj = cfg.ReadSettingObject("doublesidedflag", 0);
|
2008-05-31 19:31:45 +00:00
|
|
|
if(obj is int) doublesidedflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else doublesidedflag = obj.ToString();
|
2008-06-02 04:55:51 +00:00
|
|
|
obj = cfg.ReadSettingObject("impassableflag", 0);
|
2008-05-31 19:31:45 +00:00
|
|
|
if(obj is int) impassableflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else impassableflag = obj.ToString();
|
2008-10-17 09:39:07 +00:00
|
|
|
obj = cfg.ReadSettingObject("upperunpeggedflag", 0);
|
|
|
|
if(obj is int) upperunpeggedflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else upperunpeggedflag = obj.ToString();
|
|
|
|
obj = cfg.ReadSettingObject("lowerunpeggedflag", 0);
|
|
|
|
if(obj is int) lowerunpeggedflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else lowerunpeggedflag = obj.ToString();
|
2007-10-21 18:06:10 +00:00
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Get map lumps
|
|
|
|
maplumpnames = cfg.ReadSetting("maplumpnames", new Hashtable());
|
|
|
|
|
2007-10-26 13:17:20 +00:00
|
|
|
// Get texture and flat sources
|
|
|
|
textureranges = cfg.ReadSetting("textures", new Hashtable());
|
|
|
|
flatranges = cfg.ReadSetting("flats", new Hashtable());
|
2008-09-09 23:06:31 +00:00
|
|
|
|
2008-11-10 16:11:44 +00:00
|
|
|
// Map lumps
|
|
|
|
LoadMapLumps();
|
|
|
|
|
2008-09-09 23:06:31 +00:00
|
|
|
// Skills
|
|
|
|
LoadSkills();
|
2008-05-28 18:55:01 +00:00
|
|
|
|
|
|
|
// Enums
|
|
|
|
LoadEnums();
|
2007-10-26 13:17:20 +00:00
|
|
|
|
2007-12-26 00:31:32 +00:00
|
|
|
// Things
|
2008-05-17 17:43:57 +00:00
|
|
|
LoadThingFlags();
|
2008-06-10 11:32:06 +00:00
|
|
|
LoadDefaultThingFlags();
|
2007-12-26 00:31:32 +00:00
|
|
|
LoadThingCategories();
|
|
|
|
|
|
|
|
// Linedefs
|
|
|
|
LoadLinedefFlags();
|
|
|
|
LoadLinedefActions();
|
2007-12-26 14:29:36 +00:00
|
|
|
LoadLinedefActivations();
|
2008-02-21 06:47:43 +00:00
|
|
|
LoadLinedefGeneralizedActions();
|
2008-01-25 19:12:34 +00:00
|
|
|
|
2008-02-21 06:47:43 +00:00
|
|
|
// Sectors
|
|
|
|
LoadSectorEffects();
|
|
|
|
LoadSectorGeneralizedEffects();
|
|
|
|
|
2008-01-25 19:12:34 +00:00
|
|
|
// Universal fields
|
2008-06-01 20:25:46 +00:00
|
|
|
linedeffields = LoadUniversalFields("linedef");
|
|
|
|
sectorfields = LoadUniversalFields("sector");
|
|
|
|
sidedeffields = LoadUniversalFields("sidedef");
|
|
|
|
thingfields = LoadUniversalFields("thing");
|
|
|
|
vertexfields = LoadUniversalFields("vertex");
|
2008-10-01 08:21:10 +00:00
|
|
|
|
2009-01-05 15:57:41 +00:00
|
|
|
// Defaults
|
2008-10-01 08:21:10 +00:00
|
|
|
LoadTextureSets();
|
2009-01-05 15:57:41 +00:00
|
|
|
LoadThingFilters();
|
2007-12-26 00:31:32 +00:00
|
|
|
}
|
|
|
|
|
2007-12-29 15:50:16 +00:00
|
|
|
// Destructor
|
|
|
|
~GameConfiguration()
|
|
|
|
{
|
|
|
|
foreach(ThingCategory tc in thingcategories) tc.Dispose();
|
|
|
|
foreach(LinedefActionCategory ac in actioncategories) ac.Dispose();
|
|
|
|
}
|
|
|
|
|
2007-12-26 00:31:32 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Loading
|
2008-11-10 16:11:44 +00:00
|
|
|
|
|
|
|
// This loads the map lumps
|
|
|
|
private void LoadMapLumps()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get map lumps list
|
|
|
|
dic = cfg.ReadSetting("maplumpnames", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
// Make map lumps
|
|
|
|
MapLumpInfo lumpinfo = new MapLumpInfo(de.Key.ToString(), cfg);
|
|
|
|
maplumps.Add(de.Key.ToString(), lumpinfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-28 18:55:01 +00:00
|
|
|
// This loads the enumerations
|
|
|
|
private void LoadEnums()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get enums list
|
|
|
|
dic = cfg.ReadSetting("enums", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
// Make new enum
|
|
|
|
EnumList list = new EnumList(de.Key.ToString(), cfg);
|
|
|
|
enums.Add(de.Key.ToString(), list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-25 19:12:34 +00:00
|
|
|
// This loads a universal fields list
|
|
|
|
private List<UniversalFieldInfo> LoadUniversalFields(string elementname)
|
|
|
|
{
|
|
|
|
List<UniversalFieldInfo> list = new List<UniversalFieldInfo>();
|
|
|
|
UniversalFieldInfo uf;
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get fields
|
|
|
|
dic = cfg.ReadSetting("universalfields." + elementname, new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Read the field info and add to list
|
2008-06-02 20:34:52 +00:00
|
|
|
uf = new UniversalFieldInfo(elementname, de.Key.ToString(), cfg, enums);
|
2008-01-25 19:12:34 +00:00
|
|
|
list.Add(uf);
|
|
|
|
}
|
2008-02-22 17:11:29 +00:00
|
|
|
catch(Exception)
|
2008-01-25 19:12:34 +00:00
|
|
|
{
|
|
|
|
General.WriteLogLine("WARNING: Unable to read universal field definition 'universalfields." + elementname + "." + de.Key + "'!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return result
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2007-12-26 00:31:32 +00:00
|
|
|
// Things and thing categories
|
|
|
|
private void LoadThingCategories()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
ThingCategory thingcat;
|
|
|
|
|
2007-10-21 22:41:46 +00:00
|
|
|
// Get thing categories
|
|
|
|
dic = cfg.ReadSetting("thingtypes", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
// Make a category
|
|
|
|
thingcat = new ThingCategory(cfg, de.Key.ToString());
|
|
|
|
|
2008-05-17 17:43:57 +00:00
|
|
|
// Add all things in category to the big list
|
2008-09-09 23:06:31 +00:00
|
|
|
foreach(ThingTypeInfo t in thingcat.Things)
|
|
|
|
{
|
|
|
|
if(!things.ContainsKey(t.Index))
|
|
|
|
{
|
|
|
|
things.Add(t.Index, t);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
General.WriteLogLine("WARNING: Thing number " + t.Index + " is defined more than once! (as '" + things[t.Index].Title + "' and '" + t.Title + "')");
|
|
|
|
}
|
|
|
|
}
|
2008-05-17 17:43:57 +00:00
|
|
|
|
|
|
|
// Add category to list
|
|
|
|
thingcategories.Add(thingcat);
|
2007-10-21 22:41:46 +00:00
|
|
|
}
|
2007-12-26 00:31:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Linedef flags
|
|
|
|
private void LoadLinedefFlags()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
int bitflagscheck = 0;
|
|
|
|
int bitvalue;
|
|
|
|
|
|
|
|
// Get linedef flags
|
|
|
|
dic = cfg.ReadSetting("linedefflags", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
2008-05-31 19:31:45 +00:00
|
|
|
linedefflags.Add(de.Key.ToString(), de.Value.ToString());
|
2008-12-31 14:08:40 +00:00
|
|
|
|
|
|
|
// Get translations
|
|
|
|
dic = cfg.ReadSetting("linedefflagstranslation", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
linedefflagstranslation.Add(new FlagTranslation(de));
|
|
|
|
|
|
|
|
// Sort the translation flags, because they must be compared highest first!
|
|
|
|
linedefflagstranslation.Sort();
|
2007-10-21 18:06:10 +00:00
|
|
|
}
|
|
|
|
|
2007-12-26 00:31:32 +00:00
|
|
|
// Linedef actions and action categories
|
|
|
|
private void LoadLinedefActions()
|
|
|
|
{
|
|
|
|
Dictionary<string, LinedefActionCategory> cats = new Dictionary<string, LinedefActionCategory>();
|
|
|
|
IDictionary dic;
|
|
|
|
LinedefActionInfo ai;
|
|
|
|
LinedefActionCategory ac;
|
|
|
|
int actionnumber;
|
|
|
|
|
2008-05-27 22:02:51 +00:00
|
|
|
// Get linedef categories
|
2007-12-26 00:31:32 +00:00
|
|
|
dic = cfg.ReadSetting("linedeftypes", new Hashtable());
|
2008-05-27 22:02:51 +00:00
|
|
|
foreach(DictionaryEntry cde in dic)
|
2007-12-26 00:31:32 +00:00
|
|
|
{
|
2008-05-27 22:02:51 +00:00
|
|
|
// Read category title
|
|
|
|
string cattitle = cfg.ReadSetting("linedeftypes." + cde.Key + ".title", "");
|
2007-12-26 00:31:32 +00:00
|
|
|
|
2008-05-27 22:02:51 +00:00
|
|
|
// Make or get category
|
|
|
|
if(cats.ContainsKey(cde.Key.ToString()))
|
|
|
|
ac = cats[cde.Key.ToString()];
|
2007-12-26 00:31:32 +00:00
|
|
|
else
|
|
|
|
{
|
2008-05-27 22:02:51 +00:00
|
|
|
ac = new LinedefActionCategory(cde.Key.ToString(), cattitle);
|
|
|
|
cats.Add(cde.Key.ToString(), ac);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go for all line types in category
|
|
|
|
IDictionary catdic = cfg.ReadSetting("linedeftypes." + cde.Key, new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in catdic)
|
|
|
|
{
|
|
|
|
// Check if the item key is numeric
|
|
|
|
if(int.TryParse(de.Key.ToString(),
|
|
|
|
NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
|
|
|
|
CultureInfo.InvariantCulture, out actionnumber))
|
|
|
|
{
|
|
|
|
// Check if the item value is a structure
|
|
|
|
if(de.Value is IDictionary)
|
|
|
|
{
|
|
|
|
// Make the line type
|
2008-05-28 18:55:01 +00:00
|
|
|
ai = new LinedefActionInfo(actionnumber, cfg, cde.Key.ToString(), enums);
|
2008-05-27 22:02:51 +00:00
|
|
|
|
|
|
|
// Add action to category and sorted list
|
|
|
|
sortedlinedefactions.Add(ai);
|
|
|
|
linedefactions.Add(actionnumber, ai);
|
|
|
|
ac.Add(ai);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Failure
|
|
|
|
General.WriteLogLine("WARNING: Structure 'linedeftypes' contains invalid types! (all types must be expanded structures)");
|
|
|
|
}
|
|
|
|
}
|
2007-12-26 00:31:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort the actions list
|
|
|
|
sortedlinedefactions.Sort();
|
|
|
|
|
|
|
|
// Copy categories to final list
|
|
|
|
actioncategories.Clear();
|
|
|
|
actioncategories.AddRange(cats.Values);
|
|
|
|
|
|
|
|
// Sort the categories list
|
|
|
|
actioncategories.Sort();
|
|
|
|
}
|
2007-12-26 14:29:36 +00:00
|
|
|
|
|
|
|
// Linedef activates
|
|
|
|
private void LoadLinedefActivations()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
int bitvalue;
|
|
|
|
|
|
|
|
// Get linedef activations
|
|
|
|
dic = cfg.ReadSetting("linedefactivations", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
2008-05-31 19:31:45 +00:00
|
|
|
// Add to the list
|
|
|
|
linedefactivates.Add(new LinedefActivateInfo(de.Key.ToString(), de.Value.ToString()));
|
2007-12-26 14:29:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Sort the list
|
|
|
|
linedefactivates.Sort();
|
|
|
|
}
|
2007-12-29 15:50:16 +00:00
|
|
|
|
|
|
|
// Linedef generalized actions
|
2008-02-21 06:47:43 +00:00
|
|
|
private void LoadLinedefGeneralizedActions()
|
2007-12-29 15:50:16 +00:00
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get linedef activations
|
|
|
|
dic = cfg.ReadSetting("gen_linedeftypes", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
// Check for valid structure
|
|
|
|
if(de.Value is IDictionary)
|
|
|
|
{
|
|
|
|
// Add category
|
2008-02-21 06:47:43 +00:00
|
|
|
genactioncategories.Add(new GeneralizedCategory("gen_linedeftypes", de.Key.ToString(), cfg));
|
2007-12-29 15:50:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
General.WriteLogLine("WARNING: Structure 'gen_linedeftypes' contains invalid entries!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-02-21 06:47:43 +00:00
|
|
|
|
|
|
|
// Sector effects
|
|
|
|
private void LoadSectorEffects()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
SectorEffectInfo si;
|
|
|
|
int actionnumber;
|
|
|
|
|
|
|
|
// Get sector effects
|
|
|
|
dic = cfg.ReadSetting("sectortypes", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
// Try paring the action number
|
|
|
|
if(int.TryParse(de.Key.ToString(),
|
|
|
|
NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
|
|
|
|
CultureInfo.InvariantCulture, out actionnumber))
|
|
|
|
{
|
|
|
|
// Make effects
|
|
|
|
si = new SectorEffectInfo(actionnumber, de.Value.ToString());
|
|
|
|
|
|
|
|
// Add action to category and sorted list
|
|
|
|
sortedsectoreffects.Add(si);
|
|
|
|
sectoreffects.Add(actionnumber, si);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
General.WriteLogLine("WARNING: Structure 'sectortypes' contains invalid keys!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort the actions list
|
|
|
|
sortedsectoreffects.Sort();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sector generalized effects
|
|
|
|
private void LoadSectorGeneralizedEffects()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
2008-02-22 17:11:29 +00:00
|
|
|
// Get sector effects
|
2008-02-21 06:47:43 +00:00
|
|
|
dic = cfg.ReadSetting("gen_sectortypes", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
// Check for valid structure
|
|
|
|
if(de.Value is IDictionary)
|
|
|
|
{
|
2008-02-22 17:11:29 +00:00
|
|
|
// Add option
|
|
|
|
geneffectoptions.Add(new GeneralizedOption("gen_sectortypes", "", de.Key.ToString(), de.Value as IDictionary));
|
2008-02-21 06:47:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
General.WriteLogLine("WARNING: Structure 'gen_sectortypes' contains invalid entries!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-17 17:43:57 +00:00
|
|
|
|
|
|
|
// Thing flags
|
|
|
|
private void LoadThingFlags()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get linedef flags
|
|
|
|
dic = cfg.ReadSetting("thingflags", new Hashtable());
|
2008-06-10 11:32:06 +00:00
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
thingflags.Add(de.Key.ToString(), de.Value.ToString());
|
2008-12-31 14:08:40 +00:00
|
|
|
|
|
|
|
// Get translations
|
|
|
|
dic = cfg.ReadSetting("thingflagstranslation", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
thingflagstranslation.Add(new FlagTranslation(de));
|
|
|
|
|
|
|
|
// Sort the translation flags, because they must be compared highest first!
|
|
|
|
thingflagstranslation.Sort();
|
2008-06-10 11:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Default thing flags
|
|
|
|
private void LoadDefaultThingFlags()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get linedef flags
|
|
|
|
dic = cfg.ReadSetting("defaultthingflags", new Hashtable());
|
2008-05-17 17:43:57 +00:00
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
2008-06-10 11:32:06 +00:00
|
|
|
// Check if flag exists
|
|
|
|
if(thingflags.ContainsKey(de.Key.ToString()))
|
2008-05-17 17:43:57 +00:00
|
|
|
{
|
2008-06-10 11:32:06 +00:00
|
|
|
defaultthingflags.Add(de.Key.ToString());
|
2008-05-17 17:43:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-10 11:32:06 +00:00
|
|
|
General.WriteLogLine("WARNING: Structure 'defaultthingflags' contains unknown thing flags!");
|
2008-05-17 17:43:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-09 23:06:31 +00:00
|
|
|
|
|
|
|
// Skills
|
|
|
|
private void LoadSkills()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get skills
|
|
|
|
dic = cfg.ReadSetting("skills", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
int num = 0;
|
|
|
|
if(int.TryParse(de.Key.ToString(), out num))
|
|
|
|
{
|
|
|
|
skills.Add(new SkillInfo(num, de.Value.ToString()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
General.WriteLogLine("WARNING: Structure 'skills' contains invalid skill numbers!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-26 00:31:32 +00:00
|
|
|
|
2008-10-01 08:21:10 +00:00
|
|
|
// Texture Sets
|
|
|
|
private void LoadTextureSets()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get sets
|
|
|
|
dic = cfg.ReadSetting("texturesets", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
2008-10-01 14:17:52 +00:00
|
|
|
DefinedTextureSet s = new DefinedTextureSet(cfg, "texturesets." + de.Key.ToString());
|
2008-10-01 08:21:10 +00:00
|
|
|
texturesets.Add(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-05 15:57:41 +00:00
|
|
|
// Thing Filters
|
|
|
|
private void LoadThingFilters()
|
|
|
|
{
|
|
|
|
IDictionary dic;
|
|
|
|
|
|
|
|
// Get sets
|
|
|
|
dic = cfg.ReadSetting("thingsfilters", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in dic)
|
|
|
|
{
|
|
|
|
ThingsFilter f = new ThingsFilter(cfg, "thingsfilters." + de.Key.ToString());
|
|
|
|
thingfilters.Add(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
#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); }
|
|
|
|
|
2009-01-21 16:18:30 +00:00
|
|
|
// This gets a list of things categories
|
|
|
|
internal List<ThingCategory> GetThingCategories()
|
2007-10-21 22:41:46 +00:00
|
|
|
{
|
2009-01-21 16:18:30 +00:00
|
|
|
return new List<ThingCategory>(thingcategories);
|
2007-10-21 22:41:46 +00:00
|
|
|
}
|
2009-01-21 16:18:30 +00:00
|
|
|
|
|
|
|
// This gets a list of things
|
|
|
|
internal Dictionary<int, ThingTypeInfo> GetThingTypes()
|
2008-05-17 17:43:57 +00:00
|
|
|
{
|
2009-01-21 16:18:30 +00:00
|
|
|
return new Dictionary<int, ThingTypeInfo>(things);
|
2008-05-17 17:43:57 +00:00
|
|
|
}
|
2007-10-21 22:41:46 +00:00
|
|
|
|
2007-12-29 15:50:16 +00:00
|
|
|
// This checks if an action is generalized or predefined
|
2008-02-22 17:11:29 +00:00
|
|
|
public static bool IsGeneralized(int action, List<GeneralizedCategory> categories)
|
2007-12-29 15:50:16 +00:00
|
|
|
{
|
|
|
|
// Only actions above 0
|
|
|
|
if(action > 0)
|
|
|
|
{
|
|
|
|
// Go for all categories
|
2008-02-22 17:11:29 +00:00
|
|
|
foreach(GeneralizedCategory ac in categories)
|
2007-12-29 15:50:16 +00:00
|
|
|
{
|
|
|
|
// Check if the action is within range of this category
|
|
|
|
if((action >= ac.Offset) && (action < (ac.Offset + ac.Length))) return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not generalized
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This gets the generalized action category from action number
|
2008-02-21 06:47:43 +00:00
|
|
|
public GeneralizedCategory GetGeneralizedActionCategory(int action)
|
2007-12-29 15:50:16 +00:00
|
|
|
{
|
|
|
|
// Only actions above 0
|
|
|
|
if(action > 0)
|
|
|
|
{
|
|
|
|
// Go for all categories
|
2008-02-21 06:47:43 +00:00
|
|
|
foreach(GeneralizedCategory ac in genactioncategories)
|
2007-12-29 15:50:16 +00:00
|
|
|
{
|
|
|
|
// Check if the action is within range of this category
|
|
|
|
if((action >= ac.Offset) && (action < (ac.Offset + ac.Length))) return ac;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not generalized
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2008-01-02 21:49:43 +00:00
|
|
|
// This checks if a specific edit mode class is listed
|
|
|
|
public bool IsEditModeSpecified(string classname)
|
|
|
|
{
|
2008-05-26 10:36:41 +00:00
|
|
|
return cfg.SettingExists("editingmodes." + classname.ToString(CultureInfo.InvariantCulture));
|
2008-01-02 21:49:43 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 18:06:10 +00:00
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|