2007-09-24 17:41:36 +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
|
|
|
|
|
2007-06-14 23:31:57 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
2007-09-27 22:55:03 +00:00
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Images;
|
|
|
|
using System.IO;
|
2007-06-14 23:31:57 +00:00
|
|
|
|
2007-09-24 17:41:36 +00:00
|
|
|
#endregion
|
|
|
|
|
2007-06-14 23:31:57 +00:00
|
|
|
namespace CodeImp.DoomBuilder
|
|
|
|
{
|
2007-09-27 22:55:03 +00:00
|
|
|
internal class ConfigurationInfo : IComparable<ConfigurationInfo>
|
2007-06-14 23:31:57 +00:00
|
|
|
{
|
2007-09-27 22:55:03 +00:00
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
private string name;
|
|
|
|
private string filename;
|
|
|
|
private string settingskey;
|
|
|
|
private string nodebuilder;
|
|
|
|
private bool buildonsave;
|
|
|
|
private ResourceLocationList resources;
|
2007-09-28 09:55:23 +00:00
|
|
|
private string testprogram;
|
|
|
|
private string testparameters;
|
2007-09-27 22:55:03 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public string Name { get { return name; } }
|
|
|
|
public string Filename { get { return filename; } }
|
|
|
|
public string Nodebuilder { get { return nodebuilder; } }
|
|
|
|
public bool BuildOnSave { get { return buildonsave; } }
|
|
|
|
public ResourceLocationList Resources { get { return resources; } }
|
2007-09-28 09:55:23 +00:00
|
|
|
public string TestProgram { get { return testprogram; } }
|
|
|
|
public string TestParameters { get { return testparameters; } }
|
2007-09-27 22:55:03 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
2007-06-14 23:31:57 +00:00
|
|
|
// Constructor
|
|
|
|
public ConfigurationInfo(string name, string filename)
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
this.name = name;
|
|
|
|
this.filename = filename;
|
2007-09-27 22:55:03 +00:00
|
|
|
this.settingskey = Path.GetFileNameWithoutExtension(filename).ToLower();
|
|
|
|
|
|
|
|
// Load settings from program configuration
|
|
|
|
this.nodebuilder = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuilder", "");
|
|
|
|
this.buildonsave = General.Settings.ReadSetting("configurations." + settingskey + ".buildonsave", true);
|
|
|
|
this.resources = new ResourceLocationList(General.Settings, "configurations." + settingskey + ".resources");
|
2007-09-28 09:55:23 +00:00
|
|
|
this.testprogram = General.Settings.ReadSetting("configurations." + settingskey + ".testprogram", "");
|
|
|
|
this.testparameters = General.Settings.ReadSetting("configurations." + settingskey + ".testparameters", "");
|
2007-06-14 23:31:57 +00:00
|
|
|
}
|
|
|
|
|
2007-09-27 22:55:03 +00:00
|
|
|
// Constructor
|
|
|
|
private ConfigurationInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
2007-06-14 23:31:57 +00:00
|
|
|
// This compares it to other ConfigurationInfo objects
|
|
|
|
public int CompareTo(ConfigurationInfo other)
|
|
|
|
{
|
|
|
|
// Compare
|
|
|
|
return name.CompareTo(other.name);
|
|
|
|
}
|
2007-09-27 22:55:03 +00:00
|
|
|
|
|
|
|
// This saves the settings to program configuration
|
|
|
|
public void SaveSettings()
|
|
|
|
{
|
|
|
|
// Write to configuration
|
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".nodebuilder", nodebuilder);
|
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".buildonsave", buildonsave);
|
|
|
|
resources.WriteToConfig(General.Settings, "configurations." + settingskey + ".resources");
|
2007-09-28 09:55:23 +00:00
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".testprogram", testprogram);
|
|
|
|
General.Settings.WriteSetting("configurations." + settingskey + ".testparameters", testparameters);
|
2007-09-27 22:55:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// String representation
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This clones the object
|
|
|
|
public ConfigurationInfo Clone()
|
|
|
|
{
|
|
|
|
ConfigurationInfo ci = new ConfigurationInfo();
|
|
|
|
ci.name = this.name;
|
|
|
|
ci.filename = this.filename;
|
|
|
|
ci.settingskey = this.settingskey;
|
|
|
|
ci.nodebuilder = this.nodebuilder;
|
|
|
|
ci.buildonsave = this.buildonsave;
|
|
|
|
ci.resources = new ResourceLocationList();
|
|
|
|
ci.resources.AddRange(this.resources);
|
2007-09-28 09:55:23 +00:00
|
|
|
ci.testprogram = this.testprogram;
|
|
|
|
ci.testparameters = this.testparameters;
|
2007-09-27 22:55:03 +00:00
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This applies settings from an object
|
|
|
|
public void Apply(ConfigurationInfo ci)
|
|
|
|
{
|
|
|
|
this.name = ci.name;
|
|
|
|
this.filename = ci.filename;
|
|
|
|
this.settingskey = ci.settingskey;
|
|
|
|
this.nodebuilder = ci.nodebuilder;
|
|
|
|
this.buildonsave = ci.buildonsave;
|
|
|
|
this.resources = new ResourceLocationList();
|
|
|
|
this.resources.AddRange(ci.resources);
|
2007-09-28 09:55:23 +00:00
|
|
|
this.testprogram = ci.testprogram;
|
|
|
|
this.testparameters = ci.testparameters;
|
2007-09-27 22:55:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2007-06-14 23:31:57 +00:00
|
|
|
}
|
|
|
|
}
|