2009-04-19 18:07:22 +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 CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using System.IO;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
using System.Collections.Specialized;
|
2012-11-02 23:11:38 +00:00
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
2013-03-18 13:52:27 +00:00
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Config
|
|
|
|
{
|
2012-06-01 19:53:14 +00:00
|
|
|
public class ConfigurationInfo : IComparable<ConfigurationInfo>
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
private const string MODE_DISABLED_KEY = "disabled";
|
|
|
|
private const string MODE_ENABLED_KEY = "enabled";
|
|
|
|
|
|
|
|
// The { and } are invalid key names in a configuration so this ensures this string is unique
|
|
|
|
private const string MISSING_NODEBUILDER = "{missing nodebuilder}";
|
2014-02-18 14:04:14 +00:00
|
|
|
private readonly string[] LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR = new[] { "^" }; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
private string name;
|
|
|
|
private string filename;
|
|
|
|
private string settingskey;
|
|
|
|
private string defaultlumpname;
|
|
|
|
private string nodebuildersave;
|
|
|
|
private string nodebuildertest;
|
2014-07-16 13:40:42 +00:00
|
|
|
private string formatinterface; //mxd
|
2014-07-11 10:13:26 +00:00
|
|
|
private readonly string defaultscriptcompiler; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
private DataLocationList resources;
|
2014-02-18 14:04:14 +00:00
|
|
|
private Configuration config; //mxd
|
|
|
|
private bool enabled; //mxd
|
|
|
|
private bool changed; //mxd
|
2013-03-18 13:52:27 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
private List<EngineInfo> testEngines; //mxd
|
|
|
|
private int currentEngineIndex; //mxd
|
|
|
|
private LinedefColorPreset[] linedefColorPresets; //mxd
|
2012-11-02 23:11:38 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
private List<ThingsFilter> thingsfilters;
|
|
|
|
private List<DefinedTextureSet> texturesets;
|
|
|
|
private Dictionary<string, bool> editmodes;
|
2009-07-09 15:15:49 +00:00
|
|
|
private string startmode;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public string Name { get { return name; } }
|
|
|
|
public string Filename { get { return filename; } }
|
|
|
|
public string DefaultLumpName { get { return defaultlumpname; } }
|
2012-06-01 19:53:14 +00:00
|
|
|
public string NodebuilderSave { get { return nodebuildersave; } internal set { nodebuildersave = value; } }
|
|
|
|
public string NodebuilderTest { get { return nodebuildertest; } internal set { nodebuildertest = value; } }
|
2014-07-16 13:40:42 +00:00
|
|
|
public string FormatInterface { get { return formatinterface; } } //mxd
|
2014-07-11 10:13:26 +00:00
|
|
|
public string DefaultScriptCompiler { get { return defaultscriptcompiler; } } //mxd
|
2012-06-01 19:53:14 +00:00
|
|
|
internal DataLocationList Resources { get { return resources; } }
|
2014-02-18 14:04:14 +00:00
|
|
|
internal Configuration Configuration { get { return config; } } //mxd
|
|
|
|
public bool Enabled { get { return enabled; } internal set { enabled = value; } } //mxd
|
|
|
|
public bool Changed { get { return changed; } internal set { changed = value; } } //mxd
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
|
|
|
public string TestProgramName { get { return testEngines[currentEngineIndex].TestProgramName; } internal set { testEngines[currentEngineIndex].TestProgramName = value; } }
|
|
|
|
public string TestProgram { get { return testEngines[currentEngineIndex].TestProgram; } internal set { testEngines[currentEngineIndex].TestProgram = value; } }
|
|
|
|
public string TestParameters { get { return testEngines[currentEngineIndex].TestParameters; } internal set { testEngines[currentEngineIndex].TestParameters = value; } }
|
|
|
|
public bool TestShortPaths { get { return testEngines[currentEngineIndex].TestShortPaths; } internal set { testEngines[currentEngineIndex].TestShortPaths = value; } }
|
|
|
|
public int TestSkill { get { return testEngines[currentEngineIndex].TestSkill; } internal set { testEngines[currentEngineIndex].TestSkill = value; } }
|
|
|
|
public bool CustomParameters { get { return testEngines[currentEngineIndex].CustomParameters; } internal set { testEngines[currentEngineIndex].CustomParameters = value; } }
|
|
|
|
public List<EngineInfo> TestEngines { get { return testEngines; } internal set { testEngines = value; } }
|
|
|
|
public int CurrentEngineIndex { get { return currentEngineIndex; } internal set { currentEngineIndex = value; } }
|
|
|
|
public LinedefColorPreset[] LinedefColorPresets { get { return linedefColorPresets; } internal set { linedefColorPresets = value; } }
|
2012-11-02 23:11:38 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
internal ICollection<ThingsFilter> ThingsFilters { get { return thingsfilters; } }
|
2012-06-01 19:53:14 +00:00
|
|
|
internal List<DefinedTextureSet> TextureSets { get { return texturesets; } }
|
2009-04-19 18:07:22 +00:00
|
|
|
internal Dictionary<string, bool> EditModes { get { return editmodes; } }
|
2009-07-09 15:15:49 +00:00
|
|
|
public string StartMode { get { return startmode; } internal set { startmode = value; } }
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2012-06-01 19:53:14 +00:00
|
|
|
internal ConfigurationInfo(Configuration cfg, string filename)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
this.filename = filename;
|
2014-02-18 14:04:14 +00:00
|
|
|
this.config = cfg; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
this.settingskey = Path.GetFileNameWithoutExtension(filename).ToLower();
|
|
|
|
|
|
|
|
// Load settings from game configuration
|
2014-02-18 14:04:14 +00:00
|
|
|
this.name = config.ReadSetting("game", "<unnamed game>");
|
|
|
|
this.defaultlumpname = config.ReadSetting("defaultlumpname", "");
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Load settings from program configuration
|
|
|
|
this.nodebuildersave = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuildersave", MISSING_NODEBUILDER);
|
|
|
|
this.nodebuildertest = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuildertest", MISSING_NODEBUILDER);
|
2014-07-16 13:40:42 +00:00
|
|
|
this.formatinterface = config.ReadSetting("formatinterface", "").ToLowerInvariant(); //mxd
|
2014-07-11 10:13:26 +00:00
|
|
|
this.defaultscriptcompiler = cfg.ReadSetting("defaultscriptcompiler", ""); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
this.resources = new DataLocationList(General.Settings.Config, "configurations." + settingskey + ".resources");
|
2009-07-09 15:15:49 +00:00
|
|
|
this.startmode = General.Settings.ReadSetting("configurations." + settingskey + ".startmode", "VerticesMode");
|
2014-05-15 08:32:08 +00:00
|
|
|
this.enabled = General.Settings.ReadSetting("configurations." + settingskey + ".enabled", config.ReadSetting("enabledbydefault", false)); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
|
|
|
//mxd. Read test engines
|
2013-09-11 09:47:53 +00:00
|
|
|
testEngines = new List<EngineInfo>();
|
|
|
|
IDictionary list = General.Settings.ReadSetting("configurations." + settingskey + ".engines", new ListDictionary());
|
2015-01-23 23:09:03 +00:00
|
|
|
currentEngineIndex = Math.Max(0, General.Settings.ReadSetting("configurations." + settingskey + ".currentengineindex", 0));
|
2013-09-11 09:47:53 +00:00
|
|
|
|
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
|
|
|
// No engine list found? Use old engine properties
|
|
|
|
if(list.Count == 0)
|
2014-11-25 11:52:01 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
EngineInfo info = new EngineInfo();
|
|
|
|
info.TestProgram = General.Settings.ReadSetting("configurations." + settingskey + ".testprogram", "");
|
|
|
|
info.TestProgramName = General.Settings.ReadSetting("configurations." + settingskey + ".testprogramname", EngineInfo.DEFAULT_ENGINE_NAME);
|
|
|
|
info.TestParameters = General.Settings.ReadSetting("configurations." + settingskey + ".testparameters", "");
|
|
|
|
info.TestShortPaths = General.Settings.ReadSetting("configurations." + settingskey + ".testshortpaths", false);
|
|
|
|
info.CustomParameters = General.Settings.ReadSetting("configurations." + settingskey + ".customparameters", false);
|
|
|
|
info.TestSkill = General.Settings.ReadSetting("configurations." + settingskey + ".testskill", 3);
|
|
|
|
testEngines.Add(info);
|
|
|
|
currentEngineIndex = 0;
|
2014-11-25 11:52:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
//read engines settings from config
|
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
|
|
|
foreach(DictionaryEntry de in list)
|
2014-11-25 11:52:01 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
string path = "configurations." + settingskey + ".engines." + de.Key;
|
|
|
|
EngineInfo info = new EngineInfo();
|
|
|
|
info.TestProgram = General.Settings.ReadSetting(path + ".testprogram", "");
|
|
|
|
info.TestProgramName = General.Settings.ReadSetting(path + ".testprogramname", EngineInfo.DEFAULT_ENGINE_NAME);
|
|
|
|
info.TestParameters = General.Settings.ReadSetting(path + ".testparameters", "");
|
|
|
|
info.TestShortPaths = General.Settings.ReadSetting(path + ".testshortpaths", false);
|
|
|
|
info.CustomParameters = General.Settings.ReadSetting(path + ".customparameters", false);
|
|
|
|
info.TestSkill = General.Settings.ReadSetting(path + ".testskill", 3);
|
|
|
|
testEngines.Add(info);
|
|
|
|
}
|
2013-06-14 11:40:18 +00:00
|
|
|
|
|
|
|
if(currentEngineIndex >= testEngines.Count) currentEngineIndex = 0;
|
2013-09-11 09:47:53 +00:00
|
|
|
}
|
2012-11-02 23:11:38 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd. read custom linedef colors
|
|
|
|
List<LinedefColorPreset> colorPresets = new List<LinedefColorPreset>();
|
|
|
|
list = General.Settings.ReadSetting("configurations." + settingskey + ".linedefcolorpresets", new ListDictionary());
|
2013-03-18 13:52:27 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//no presets? add "classic" ones then.
|
2014-11-25 11:52:01 +00:00
|
|
|
if(list.Count == 0)
|
|
|
|
{
|
2015-07-30 23:48:16 +00:00
|
|
|
colorPresets.Add(new LinedefColorPreset("Any action", PixelColor.FromColor(System.Drawing.Color.PaleGreen), -1, 0, new List<string>(), new List<string>(), true));
|
2014-11-25 11:52:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
//read custom linedef colors from config
|
2014-11-25 11:52:01 +00:00
|
|
|
foreach(DictionaryEntry de in list)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
string path = "configurations." + settingskey + ".linedefcolorpresets." + de.Key;
|
2014-02-18 14:04:14 +00:00
|
|
|
string presetname = General.Settings.ReadSetting(path + ".name", "Unnamed");
|
2015-07-30 23:48:16 +00:00
|
|
|
bool presetenabled = General.Settings.ReadSetting(path + ".enabled", true);
|
2013-09-11 09:47:53 +00:00
|
|
|
PixelColor color = PixelColor.FromInt(General.Settings.ReadSetting(path + ".color", -1));
|
|
|
|
int action = General.Settings.ReadSetting(path + ".action", 0);
|
|
|
|
int activation = General.Settings.ReadSetting(path + ".activation", 0);
|
|
|
|
List<string> flags = new List<string>();
|
|
|
|
flags.AddRange(General.Settings.ReadSetting(path + ".flags", "").Split(LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR, StringSplitOptions.RemoveEmptyEntries));
|
2013-03-18 13:52:27 +00:00
|
|
|
List<string> restrictedFlags = new List<string>();
|
|
|
|
restrictedFlags.AddRange(General.Settings.ReadSetting(path + ".restrictedflags", "").Split(LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR, StringSplitOptions.RemoveEmptyEntries));
|
2015-07-30 23:48:16 +00:00
|
|
|
LinedefColorPreset preset = new LinedefColorPreset(presetname, color, action, activation, flags, restrictedFlags, presetenabled);
|
2013-09-11 09:47:53 +00:00
|
|
|
colorPresets.Add(preset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
linedefColorPresets = colorPresets.ToArray();
|
2013-03-18 13:52:27 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Make list of things filters
|
|
|
|
thingsfilters = new List<ThingsFilter>();
|
|
|
|
IDictionary cfgfilters = General.Settings.ReadSetting("configurations." + settingskey + ".thingsfilters", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in cfgfilters)
|
|
|
|
{
|
|
|
|
thingsfilters.Add(new ThingsFilter(General.Settings.Config, "configurations." + settingskey + ".thingsfilters." + de.Key));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make list of texture sets
|
|
|
|
texturesets = new List<DefinedTextureSet>();
|
|
|
|
IDictionary sets = General.Settings.ReadSetting("configurations." + settingskey + ".texturesets", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in sets)
|
|
|
|
{
|
|
|
|
texturesets.Add(new DefinedTextureSet(General.Settings.Config, "configurations." + settingskey + ".texturesets." + de.Key));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make list of edit modes
|
2014-02-26 14:11:06 +00:00
|
|
|
this.editmodes = new Dictionary<string, bool>(StringComparer.Ordinal);
|
2009-04-19 18:07:22 +00:00
|
|
|
IDictionary modes = General.Settings.ReadSetting("configurations." + settingskey + ".editmodes", new Hashtable());
|
|
|
|
foreach(DictionaryEntry de in modes)
|
|
|
|
{
|
|
|
|
if(de.Key.ToString().StartsWith(MODE_ENABLED_KEY))
|
|
|
|
editmodes.Add(de.Value.ToString(), true);
|
|
|
|
else if(de.Key.ToString().StartsWith(MODE_DISABLED_KEY))
|
|
|
|
editmodes.Add(de.Value.ToString(), false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
private ConfigurationInfo()
|
|
|
|
{
|
|
|
|
}
|
2015-09-16 12:10:43 +00:00
|
|
|
|
|
|
|
//mxd. Destructor
|
|
|
|
~ConfigurationInfo()
|
|
|
|
{
|
2017-02-04 20:03:32 +00:00
|
|
|
if (thingsfilters != null) foreach(ThingsFilter tf in thingsfilters) tf.Dispose();
|
|
|
|
if (testEngines != null) foreach(EngineInfo ei in testEngines) ei.Dispose();
|
2015-09-16 12:10:43 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
2012-06-01 19:53:14 +00:00
|
|
|
/// <summary>
|
|
|
|
/// This returns the resource locations as configured.
|
|
|
|
/// </summary>
|
|
|
|
public DataLocationList GetResources()
|
|
|
|
{
|
|
|
|
return new DataLocationList(resources);
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// This compares it to other ConfigurationInfo objects
|
|
|
|
public int CompareTo(ConfigurationInfo other)
|
|
|
|
{
|
|
|
|
// Compare
|
Game Configurations: added Vanilla Strife, Vanilla Heretic and Vanilla Hexen game configurations.
Added "makedoorceil" game configuration property. Works the same way as "makedoortrack" and "makedoordoor", but for ceilings of door sectors.
Changed, Game configurations: the editor no longer tries to load DECORATE/MODELDEF/VOXELDEF/GLDEFS/REVERBS lumps when "decorategames" setting is not specified / is set to empty string.
Changed, General interface: "Tools -> Reload MODELDEF/VOXELDEF" and "Tools -> Reload GLDEFS" menu items are no longer shown when current game configuration doesn't support DECORATE.
Fixed a crash when pasting linedef/thing properties in Hexen map format.
Fixed, Visual mode: Visual Thing resources were not fully unloaded when resetting D3D device leading to crash when switching to the editor from a DX-using game engine (like ZDoom) running in fullscreen.
Fixed: in some cases, when current game configuration supported multiple script compilers, it was possible to open/create a map or change map options without selecting any script compiler.
Fixed, New Map Options window: default map name was not updated when switching game configurations.
Fixed: copied map element properties were not reset after switching to another map.
Fixed: stored textures for "Make Door" action were not reset after switching to another map.
Fixed, Game Configurations window: currently selected test engine name was not updated when pasting test engines from another configuration.
Fixed, Game Configurations: all "Heretic in Doom map format" configurations were using Doom sector effects list.
Fixed, Game Configurations: all "Strife in Doom map format" configurations were using Doom sector effects list.
2015-10-21 13:35:42 +00:00
|
|
|
return String.Compare(name, other.name, StringComparison.Ordinal);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This saves the settings to program configuration
|
2012-06-01 19:53:14 +00:00
|
|
|
internal void SaveSettings()
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2014-02-18 14:04:14 +00:00
|
|
|
//mxd
|
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".enabled", enabled);
|
|
|
|
if(!changed) return;
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Write to configuration
|
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".nodebuildersave", nodebuildersave);
|
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".nodebuildertest", nodebuildertest);
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
|
|
//mxd. Test Engines
|
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".currentengineindex", currentEngineIndex);
|
2014-08-05 14:27:26 +00:00
|
|
|
SaveTestEngines();
|
2013-09-11 09:47:53 +00:00
|
|
|
|
|
|
|
//mxd. Custom linedef colors
|
2014-08-05 14:27:26 +00:00
|
|
|
SaveLinedefColorPresets();
|
2013-03-18 13:52:27 +00:00
|
|
|
|
2009-07-09 15:15:49 +00:00
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".startmode", startmode);
|
2009-04-19 18:07:22 +00:00
|
|
|
resources.WriteToConfig(General.Settings.Config, "configurations." + settingskey + ".resources");
|
|
|
|
|
|
|
|
// Write filters to configuration
|
2010-10-03 10:03:56 +00:00
|
|
|
General.Settings.DeleteSetting("configurations." + settingskey + ".thingsfilters");
|
2009-04-19 18:07:22 +00:00
|
|
|
for(int i = 0; i < thingsfilters.Count; i++)
|
|
|
|
{
|
|
|
|
thingsfilters[i].WriteSettings(General.Settings.Config,
|
|
|
|
"configurations." + settingskey + ".thingsfilters.filter" + i.ToString(CultureInfo.InvariantCulture));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write texturesets to configuration
|
2014-08-05 14:27:26 +00:00
|
|
|
General.Settings.DeleteSetting("configurations." + settingskey + ".texturesets"); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
for(int i = 0; i < texturesets.Count; i++)
|
|
|
|
{
|
|
|
|
texturesets[i].WriteToConfig(General.Settings.Config,
|
|
|
|
"configurations." + settingskey + ".texturesets.set" + i.ToString(CultureInfo.InvariantCulture));
|
|
|
|
}
|
|
|
|
|
2014-08-05 14:27:26 +00:00
|
|
|
// Write edit modes to configuration
|
2009-04-19 18:07:22 +00:00
|
|
|
ListDictionary modeslist = new ListDictionary();
|
|
|
|
int index = 0;
|
|
|
|
foreach(KeyValuePair<string, bool> em in editmodes)
|
|
|
|
{
|
|
|
|
if(em.Value)
|
|
|
|
modeslist.Add(MODE_ENABLED_KEY + index.ToString(CultureInfo.InvariantCulture), em.Key);
|
|
|
|
else
|
|
|
|
modeslist.Add(MODE_DISABLED_KEY + index.ToString(CultureInfo.InvariantCulture), em.Key);
|
|
|
|
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".editmodes", modeslist);
|
|
|
|
}
|
|
|
|
|
2014-08-05 14:27:26 +00:00
|
|
|
//mxd
|
|
|
|
private void SaveTestEngines()
|
|
|
|
{
|
|
|
|
// Fill structure
|
2014-12-03 23:15:26 +00:00
|
|
|
IDictionary resinfo = new ListDictionary();
|
2014-08-05 14:27:26 +00:00
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
for(int i = 0; i < testEngines.Count; i++)
|
|
|
|
{
|
2015-12-28 15:01:53 +00:00
|
|
|
IDictionary rlinfo = new ListDictionary();
|
2014-08-05 14:27:26 +00:00
|
|
|
rlinfo.Add("testprogramname", testEngines[i].TestProgramName);
|
|
|
|
rlinfo.Add("testprogram", testEngines[i].TestProgram);
|
|
|
|
rlinfo.Add("testparameters", testEngines[i].TestParameters);
|
|
|
|
rlinfo.Add("testshortpaths", testEngines[i].TestShortPaths);
|
|
|
|
rlinfo.Add("customparameters", testEngines[i].CustomParameters);
|
|
|
|
rlinfo.Add("testskill", testEngines[i].TestSkill);
|
|
|
|
|
|
|
|
// Add structure
|
|
|
|
resinfo.Add("engine" + i.ToString(CultureInfo.InvariantCulture), rlinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write to config
|
|
|
|
General.Settings.Config.WriteSetting("configurations." + settingskey + ".engines", resinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
private void SaveLinedefColorPresets()
|
|
|
|
{
|
|
|
|
// Fill structure
|
2014-12-03 23:15:26 +00:00
|
|
|
IDictionary resinfo = new ListDictionary();
|
2014-08-05 14:27:26 +00:00
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
for(int i = 0; i < linedefColorPresets.Length; i++)
|
|
|
|
{
|
2015-12-28 15:01:53 +00:00
|
|
|
IDictionary rlinfo = new ListDictionary();
|
2014-08-05 14:27:26 +00:00
|
|
|
rlinfo.Add("name", linedefColorPresets[i].Name);
|
2015-07-30 23:48:16 +00:00
|
|
|
rlinfo.Add("enabled", linedefColorPresets[i].Enabled);
|
2014-08-05 14:27:26 +00:00
|
|
|
rlinfo.Add("color", linedefColorPresets[i].Color.ToInt());
|
|
|
|
rlinfo.Add("action", linedefColorPresets[i].Action);
|
|
|
|
rlinfo.Add("activation", linedefColorPresets[i].Activation);
|
|
|
|
rlinfo.Add("flags", string.Join(LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR[0], linedefColorPresets[i].Flags.ToArray()));
|
|
|
|
rlinfo.Add("restrictedflags", string.Join(LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR[0], linedefColorPresets[i].RestrictedFlags.ToArray()));
|
|
|
|
|
|
|
|
// Add structure
|
|
|
|
resinfo.Add("preset" + i.ToString(CultureInfo.InvariantCulture), rlinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write to config
|
|
|
|
General.Settings.Config.WriteSetting("configurations." + settingskey + ".linedefcolorpresets", resinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// String representation
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This clones the object
|
2012-06-01 19:53:14 +00:00
|
|
|
internal ConfigurationInfo Clone()
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
ConfigurationInfo ci = new ConfigurationInfo();
|
|
|
|
ci.name = this.name;
|
|
|
|
ci.filename = this.filename;
|
|
|
|
ci.settingskey = this.settingskey;
|
|
|
|
ci.nodebuildersave = this.nodebuildersave;
|
|
|
|
ci.nodebuildertest = this.nodebuildertest;
|
2014-07-16 13:40:42 +00:00
|
|
|
ci.formatinterface = this.formatinterface; //mxd
|
2016-03-18 11:28:09 +00:00
|
|
|
ci.resources = new DataLocationList(this.resources);
|
2013-03-18 13:52:27 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
2014-07-16 13:40:42 +00:00
|
|
|
ci.testEngines = new List<EngineInfo>();
|
2015-12-28 15:01:53 +00:00
|
|
|
foreach(EngineInfo info in testEngines) ci.testEngines.Add(new EngineInfo(info));
|
2014-07-16 13:40:42 +00:00
|
|
|
ci.currentEngineIndex = this.currentEngineIndex;
|
|
|
|
ci.linedefColorPresets = new LinedefColorPreset[linedefColorPresets.Length];
|
2013-09-11 09:47:53 +00:00
|
|
|
for(int i = 0; i < linedefColorPresets.Length; i++)
|
2014-07-16 13:40:42 +00:00
|
|
|
ci.linedefColorPresets[i] = new LinedefColorPreset(linedefColorPresets[i]);
|
2012-11-02 23:11:38 +00:00
|
|
|
|
2009-07-09 15:15:49 +00:00
|
|
|
ci.startmode = this.startmode;
|
2014-02-18 14:04:14 +00:00
|
|
|
ci.config = this.config; //mxd
|
|
|
|
ci.enabled = this.enabled; //mxd
|
|
|
|
ci.changed = this.changed; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
ci.texturesets = new List<DefinedTextureSet>();
|
|
|
|
foreach(DefinedTextureSet s in this.texturesets) ci.texturesets.Add(s.Copy());
|
|
|
|
ci.thingsfilters = new List<ThingsFilter>();
|
|
|
|
foreach(ThingsFilter f in this.thingsfilters) ci.thingsfilters.Add(new ThingsFilter(f));
|
|
|
|
ci.editmodes = new Dictionary<string, bool>(this.editmodes);
|
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This applies settings from an object
|
2012-06-01 19:53:14 +00:00
|
|
|
internal void Apply(ConfigurationInfo ci)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
this.name = ci.name;
|
|
|
|
this.filename = ci.filename;
|
|
|
|
this.settingskey = ci.settingskey;
|
|
|
|
this.nodebuildersave = ci.nodebuildersave;
|
|
|
|
this.nodebuildertest = ci.nodebuildertest;
|
2014-07-16 13:40:42 +00:00
|
|
|
this.formatinterface = ci.formatinterface; //mxd
|
2014-09-08 21:26:30 +00:00
|
|
|
this.currentEngineIndex = ci.currentEngineIndex; //mxd
|
2016-03-18 11:28:09 +00:00
|
|
|
this.resources = new DataLocationList(ci.resources);
|
2013-03-18 13:52:27 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
|
|
|
this.testEngines = new List<EngineInfo>();
|
2015-12-28 15:01:53 +00:00
|
|
|
foreach(EngineInfo info in ci.testEngines) testEngines.Add(new EngineInfo(info));
|
2015-01-23 23:09:03 +00:00
|
|
|
if(this.currentEngineIndex >= testEngines.Count) this.currentEngineIndex = Math.Max(0, testEngines.Count - 1);
|
2013-09-11 09:47:53 +00:00
|
|
|
this.linedefColorPresets = new LinedefColorPreset[ci.linedefColorPresets.Length];
|
|
|
|
for(int i = 0; i < ci.linedefColorPresets.Length; i++)
|
|
|
|
this.linedefColorPresets[i] = new LinedefColorPreset(ci.linedefColorPresets[i]);
|
2012-11-02 23:11:38 +00:00
|
|
|
|
2009-07-09 15:15:49 +00:00
|
|
|
this.startmode = ci.startmode;
|
2014-02-18 14:04:14 +00:00
|
|
|
this.config = ci.config; //mxd
|
|
|
|
this.enabled = ci.enabled; //mxd
|
|
|
|
this.changed = ci.changed;
|
2009-04-19 18:07:22 +00:00
|
|
|
this.texturesets = new List<DefinedTextureSet>();
|
|
|
|
foreach(DefinedTextureSet s in ci.texturesets) this.texturesets.Add(s.Copy());
|
|
|
|
this.thingsfilters = new List<ThingsFilter>();
|
|
|
|
foreach(ThingsFilter f in ci.thingsfilters) this.thingsfilters.Add(new ThingsFilter(f));
|
|
|
|
this.editmodes = new Dictionary<string, bool>(ci.editmodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This applies the defaults
|
2012-06-01 19:53:14 +00:00
|
|
|
internal void ApplyDefaults(GameConfiguration gameconfig)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Some of the defaults can only be applied from game configuration
|
|
|
|
if(gameconfig != null)
|
|
|
|
{
|
|
|
|
// No nodebuildes set?
|
|
|
|
if(nodebuildersave == MISSING_NODEBUILDER) nodebuildersave = gameconfig.DefaultSaveCompiler;
|
|
|
|
if(nodebuildertest == MISSING_NODEBUILDER) nodebuildertest = gameconfig.DefaultTestCompiler;
|
|
|
|
|
|
|
|
// No texture sets?
|
|
|
|
if(texturesets.Count == 0)
|
|
|
|
{
|
|
|
|
// Copy the default texture sets from the game configuration
|
|
|
|
foreach(DefinedTextureSet s in gameconfig.TextureSets)
|
|
|
|
{
|
|
|
|
// Add a copy to our list
|
|
|
|
texturesets.Add(s.Copy());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No things filters?
|
|
|
|
if(thingsfilters.Count == 0)
|
|
|
|
{
|
|
|
|
// Copy the things filters from game configuration
|
|
|
|
foreach(ThingsFilter f in gameconfig.ThingsFilters)
|
|
|
|
thingsfilters.Add(new ThingsFilter(f));
|
|
|
|
}
|
2013-03-18 13:52:27 +00:00
|
|
|
|
2015-12-17 10:07:28 +00:00
|
|
|
//mxd. Validate filters. Do it only for currently used ConfigInfo
|
|
|
|
if(General.Map != null && General.Map.ConfigSettings == this)
|
|
|
|
{
|
|
|
|
foreach(ThingsFilter f in thingsfilters) f.Validate();
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Go for all available editing modes
|
|
|
|
foreach(EditModeInfo info in General.Editing.ModesInfo)
|
|
|
|
{
|
2013-03-18 13:52:27 +00:00
|
|
|
// Is this a mode that is optional?
|
2009-04-19 18:07:22 +00:00
|
|
|
if(info.IsOptional)
|
|
|
|
{
|
|
|
|
// Add if not listed yet
|
|
|
|
if(!editmodes.ContainsKey(info.Type.FullName))
|
|
|
|
editmodes.Add(info.Type.FullName, info.Attributes.UseByDefault);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-16 13:40:42 +00:00
|
|
|
|
|
|
|
//mxd
|
|
|
|
internal void PasteResourcesFrom(ConfigurationInfo source)
|
|
|
|
{
|
2016-03-18 11:28:09 +00:00
|
|
|
resources = new DataLocationList(source.resources);
|
2014-07-16 13:40:42 +00:00
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
internal void PasteTestEnginesFrom(ConfigurationInfo source)
|
|
|
|
{
|
2014-09-08 21:26:30 +00:00
|
|
|
currentEngineIndex = source.currentEngineIndex;
|
2014-07-16 13:40:42 +00:00
|
|
|
testEngines = new List<EngineInfo>();
|
|
|
|
foreach(EngineInfo info in source.testEngines) testEngines.Add(new EngineInfo(info));
|
2015-01-23 23:09:03 +00:00
|
|
|
if(currentEngineIndex >= testEngines.Count) currentEngineIndex = Math.Max(0, testEngines.Count - 1);
|
2014-07-16 13:40:42 +00:00
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
internal void PasteColorPresetsFrom(ConfigurationInfo source)
|
|
|
|
{
|
|
|
|
linedefColorPresets = new LinedefColorPreset[source.linedefColorPresets.Length];
|
|
|
|
for(int i = 0; i < source.linedefColorPresets.Length; i++)
|
|
|
|
linedefColorPresets[i] = new LinedefColorPreset(source.linedefColorPresets[i]);
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. Not all properties should be pasted
|
|
|
|
internal void PasteFrom(ConfigurationInfo source)
|
|
|
|
{
|
|
|
|
nodebuildersave = source.nodebuildersave;
|
|
|
|
nodebuildertest = source.nodebuildertest;
|
2014-09-08 21:26:30 +00:00
|
|
|
currentEngineIndex = source.currentEngineIndex;
|
2016-03-18 11:28:09 +00:00
|
|
|
resources = new DataLocationList(source.resources);
|
2014-07-16 13:40:42 +00:00
|
|
|
|
|
|
|
testEngines = new List<EngineInfo>();
|
|
|
|
foreach(EngineInfo info in source.testEngines)
|
2014-09-08 21:26:30 +00:00
|
|
|
testEngines.Add(new EngineInfo(info));
|
2015-01-23 23:09:03 +00:00
|
|
|
if(currentEngineIndex >= testEngines.Count) currentEngineIndex = Math.Max(0, testEngines.Count - 1);
|
2014-07-16 13:40:42 +00:00
|
|
|
linedefColorPresets = new LinedefColorPreset[source.linedefColorPresets.Length];
|
|
|
|
for(int i = 0; i < source.linedefColorPresets.Length; i++)
|
|
|
|
linedefColorPresets[i] = new LinedefColorPreset(source.linedefColorPresets[i]);
|
|
|
|
|
|
|
|
startmode = source.startmode;
|
|
|
|
changed = true;
|
|
|
|
texturesets = new List<DefinedTextureSet>();
|
|
|
|
foreach(DefinedTextureSet s in source.texturesets) texturesets.Add(s.Copy());
|
|
|
|
thingsfilters = new List<ThingsFilter>();
|
|
|
|
foreach(ThingsFilter f in source.thingsfilters) thingsfilters.Add(new ThingsFilter(f));
|
|
|
|
editmodes = new Dictionary<string, bool>(source.editmodes);
|
|
|
|
}
|
2014-12-30 13:21:01 +00:00
|
|
|
|
|
|
|
//mxd. This checks if given map name can cause problems
|
|
|
|
internal bool ValidateMapName(string name)
|
|
|
|
{
|
|
|
|
// Get the map lump names
|
|
|
|
IDictionary maplumpnames = config.ReadSetting("maplumpnames", new Hashtable());
|
|
|
|
|
|
|
|
// Check if given map name overlaps with maplumpnames defined for this game configuration
|
|
|
|
foreach(DictionaryEntry ml in maplumpnames)
|
|
|
|
{
|
|
|
|
// Ignore the map header (it will not be found because the name is different)
|
|
|
|
string lumpname = ml.Key.ToString().ToUpperInvariant();
|
|
|
|
if(lumpname.Contains(name)) return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|