2012-11-02 23:11:38 +00:00
|
|
|
|
using System;
|
2015-12-29 11:44:32 +00:00
|
|
|
|
using System.Drawing;
|
2012-11-02 23:11:38 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|
|
|
|
{
|
2016-02-01 22:04:00 +00:00
|
|
|
|
public class EngineInfo : IDisposable
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2016-02-01 22:04:00 +00:00
|
|
|
|
// Disposing
|
|
|
|
|
private bool isdisposed;
|
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
|
public const string DEFAULT_ENGINE_NAME = "Engine with no name";
|
|
|
|
|
|
2015-03-24 14:21:38 +00:00
|
|
|
|
private string testprogramname;
|
|
|
|
|
public string TestProgramName { get { return testprogramname; } set { testprogramname = value; CheckProgramName(); } }
|
2013-09-11 09:47:53 +00:00
|
|
|
|
public string TestProgram;
|
|
|
|
|
public string TestParameters;
|
|
|
|
|
public bool CustomParameters;
|
|
|
|
|
public int TestSkill;
|
|
|
|
|
public bool TestShortPaths;
|
2015-12-29 11:44:32 +00:00
|
|
|
|
private Bitmap icon;
|
|
|
|
|
public Bitmap TestProgramIcon { get { return icon; } }
|
2012-11-02 23:11:38 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public EngineInfo()
|
|
|
|
|
{
|
2015-03-24 14:21:38 +00:00
|
|
|
|
testprogramname = DEFAULT_ENGINE_NAME;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-11-02 23:11:38 +00:00
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
public EngineInfo(EngineInfo other)
|
|
|
|
|
{
|
2015-03-24 14:21:38 +00:00
|
|
|
|
testprogramname = other.TestProgramName;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
TestProgram = other.TestProgram;
|
|
|
|
|
TestParameters = other.TestParameters;
|
|
|
|
|
CustomParameters = other.CustomParameters;
|
|
|
|
|
TestSkill = other.TestSkill;
|
|
|
|
|
TestShortPaths = other.TestShortPaths;
|
2015-12-29 11:44:32 +00:00
|
|
|
|
icon = other.icon;
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-11-02 23:11:38 +00:00
|
|
|
|
|
2015-03-24 14:21:38 +00:00
|
|
|
|
private void CheckProgramName()
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-03-24 14:21:38 +00:00
|
|
|
|
if(testprogramname == DEFAULT_ENGINE_NAME && !String.IsNullOrEmpty(TestProgram))
|
2014-12-03 23:15:26 +00:00
|
|
|
|
{
|
2015-03-24 14:21:38 +00:00
|
|
|
|
//get engine name from path
|
|
|
|
|
testprogramname = Path.GetFileNameWithoutExtension(TestProgram);
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2015-12-29 11:44:32 +00:00
|
|
|
|
|
|
|
|
|
// Update icon
|
|
|
|
|
if(icon != null)
|
|
|
|
|
{
|
|
|
|
|
icon.Dispose();
|
|
|
|
|
icon = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(File.Exists(TestProgram))
|
|
|
|
|
{
|
|
|
|
|
Icon i = Icon.ExtractAssociatedIcon(TestProgram);
|
|
|
|
|
if(i != null) icon = i.ToBitmap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(icon == null)
|
|
|
|
|
{
|
|
|
|
|
icon = new Bitmap(16, 16);
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2016-02-01 22:04:00 +00:00
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
// Not already disposed?
|
|
|
|
|
if(!isdisposed)
|
|
|
|
|
{
|
|
|
|
|
// Clean up
|
|
|
|
|
icon.Dispose();
|
|
|
|
|
|
|
|
|
|
// Done
|
|
|
|
|
isdisposed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-11 09:47:53 +00:00
|
|
|
|
}
|
2012-11-02 23:11:38 +00:00
|
|
|
|
}
|