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;
|
2016-06-19 00:09:53 +00:00
|
|
|
using System.Collections.Generic;
|
2009-04-19 18:07:22 +00:00
|
|
|
using System.Diagnostics;
|
2016-03-18 11:28:09 +00:00
|
|
|
using System.IO;
|
2009-04-19 18:07:22 +00:00
|
|
|
using System.Windows.Forms;
|
2016-03-18 11:28:09 +00:00
|
|
|
using CodeImp.DoomBuilder.Actions;
|
|
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
2009-04-19 18:07:22 +00:00
|
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder
|
|
|
|
{
|
|
|
|
internal class Launcher : IDisposable
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
private string tempwad;
|
2016-06-19 00:09:53 +00:00
|
|
|
private Dictionary<Process, string> processes; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
private bool isdisposed;
|
2014-03-23 09:08:51 +00:00
|
|
|
|
2016-06-19 00:09:53 +00:00
|
|
|
delegate void EngineExitedCallback(Process p); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
public string TempWAD { get { return tempwad; } }
|
2014-03-23 09:08:51 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public Launcher(MapManager manager)
|
|
|
|
{
|
|
|
|
// Initialize
|
2009-07-02 14:15:47 +00:00
|
|
|
CleanTempFile(manager);
|
2016-06-19 00:09:53 +00:00
|
|
|
processes = new Dictionary<Process, string>(); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Bind actions
|
|
|
|
General.Actions.BindMethods(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disposer
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
// Not yet disposed?
|
|
|
|
if(!isdisposed)
|
|
|
|
{
|
|
|
|
// Unbind actions
|
|
|
|
General.Actions.UnbindMethods(this);
|
2014-03-23 09:08:51 +00:00
|
|
|
|
2016-06-19 00:09:53 +00:00
|
|
|
//mxd. Terminate running processes?
|
|
|
|
if(processes != null)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2016-06-19 00:09:53 +00:00
|
|
|
foreach(KeyValuePair<Process, string> group in processes)
|
|
|
|
{
|
|
|
|
// Close engine
|
|
|
|
group.Key.CloseMainWindow();
|
|
|
|
group.Key.Close();
|
|
|
|
|
|
|
|
// Remove temporary file
|
|
|
|
if(File.Exists(group.Value))
|
|
|
|
{
|
|
|
|
try { File.Delete(group.Value); }
|
|
|
|
catch { }
|
|
|
|
}
|
|
|
|
}
|
2014-03-23 09:08:51 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2009-07-02 14:15:47 +00:00
|
|
|
// Remove temporary file
|
2016-06-19 00:09:53 +00:00
|
|
|
if(File.Exists(tempwad))
|
|
|
|
{
|
|
|
|
try { File.Delete(tempwad); }
|
|
|
|
catch { }
|
|
|
|
}
|
2009-07-02 14:15:47 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Done
|
|
|
|
isdisposed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Parameters
|
|
|
|
|
|
|
|
// This takes the unconverted parameters (with placeholders) and converts it
|
|
|
|
// to parameters with full paths, names and numbers where placeholders were put.
|
|
|
|
// The tempfile must be the full path and filename to the PWAD file to test.
|
2019-12-25 17:45:19 +00:00
|
|
|
public string ConvertParameters(string parameters, int skill, bool shortpaths, bool linuxpaths)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
string outp = parameters;
|
|
|
|
DataLocation iwadloc;
|
|
|
|
string p_wp = "", p_wf = "";
|
|
|
|
string p_ap = "", p_apq = "";
|
2023-06-02 22:09:26 +00:00
|
|
|
string p_aa = "", p_aaq = "";
|
|
|
|
string p_af = "", p_afq = "";
|
2009-04-19 18:07:22 +00:00
|
|
|
string p_l1 = "", p_l2 = "";
|
|
|
|
string p_nm = "";
|
|
|
|
string f = tempwad;
|
|
|
|
|
|
|
|
// Make short path if needed
|
|
|
|
if(shortpaths) f = General.GetShortFilePath(f);
|
2019-12-25 17:45:19 +00:00
|
|
|
else if (linuxpaths) f = General.GetLinuxFilePath(f);
|
2009-04-19 18:07:22 +00:00
|
|
|
// Find the first IWAD file
|
|
|
|
if(General.Map.Data.FindFirstIWAD(out iwadloc))
|
|
|
|
{
|
|
|
|
// %WP and %WF result in IWAD file
|
|
|
|
p_wp = iwadloc.location;
|
|
|
|
p_wf = Path.GetFileName(p_wp);
|
|
|
|
if(shortpaths)
|
|
|
|
{
|
|
|
|
p_wp = General.GetShortFilePath(p_wp);
|
|
|
|
p_wf = General.GetShortFilePath(p_wf);
|
|
|
|
}
|
2019-12-25 17:45:19 +00:00
|
|
|
else if (linuxpaths)
|
|
|
|
{
|
|
|
|
p_wp = General.GetLinuxFilePath(p_wp);
|
|
|
|
p_wf = General.GetLinuxFilePath(p_wf);
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make a list of all data locations, including map location
|
2016-03-18 11:28:09 +00:00
|
|
|
DataLocationList locations = DataLocationList.Combined(General.Map.ConfigSettings.Resources, General.Map.Options.Resources);
|
|
|
|
|
|
|
|
//mxd. General.Map.FilePathName will be empty when a newly created map was not saved yet.
|
|
|
|
if(!string.IsNullOrEmpty(General.Map.FilePathName))
|
|
|
|
{
|
2022-09-18 17:54:53 +00:00
|
|
|
DataLocation maplocation = new DataLocation(DataLocation.RESOURCE_WAD, General.Map.FilePathName, false, false, false, null);
|
2016-03-18 11:28:09 +00:00
|
|
|
locations.Remove(maplocation); //If maplocation was already added as a resource, make sure it's singular and is last in the list
|
|
|
|
locations.Add(maplocation);
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Go for all data locations
|
|
|
|
foreach(DataLocation dl in locations)
|
|
|
|
{
|
|
|
|
// Location not the IWAD file?
|
2021-12-10 10:10:42 +00:00
|
|
|
if((dl.location != iwadloc.location))
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-07-02 14:15:47 +00:00
|
|
|
// Location not included?
|
|
|
|
if(!dl.notfortesting)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-07-02 14:15:47 +00:00
|
|
|
// Add to string of files
|
|
|
|
if(shortpaths)
|
|
|
|
{
|
|
|
|
p_ap += General.GetShortFilePath(dl.location) + " ";
|
|
|
|
p_apq += "\"" + General.GetShortFilePath(dl.location) + "\" ";
|
2023-06-02 22:09:26 +00:00
|
|
|
if (dl.type == DataLocation.RESOURCE_WAD || dl.type == DataLocation.RESOURCE_PK3)
|
|
|
|
{
|
|
|
|
p_aa += General.GetShortFilePath(dl.location) + " ";
|
|
|
|
p_aaq += "\"" + General.GetShortFilePath(dl.location) + "\" ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p_af += General.GetShortFilePath(dl.location) + " ";
|
|
|
|
p_afq += "\"" + General.GetShortFilePath(dl.location) + "\" ";
|
|
|
|
}
|
2009-07-02 14:15:47 +00:00
|
|
|
}
|
2019-12-25 17:45:19 +00:00
|
|
|
else if (linuxpaths)
|
|
|
|
{
|
|
|
|
p_ap += General.GetLinuxFilePath(dl.location) + " ";
|
|
|
|
p_apq += "\"" + General.GetLinuxFilePath(dl.location) + "\" ";
|
2023-06-02 22:09:26 +00:00
|
|
|
if (dl.type == DataLocation.RESOURCE_WAD || dl.type == DataLocation.RESOURCE_PK3)
|
|
|
|
{
|
|
|
|
p_aa += General.GetLinuxFilePath(dl.location) + " ";
|
|
|
|
p_aaq += "\"" + General.GetLinuxFilePath(dl.location) + "\" ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p_af += General.GetLinuxFilePath(dl.location) + " ";
|
|
|
|
p_afq += "\"" + General.GetLinuxFilePath(dl.location) + "\" ";
|
|
|
|
}
|
2019-12-25 17:45:19 +00:00
|
|
|
}
|
2009-07-02 14:15:47 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
p_ap += dl.location + " ";
|
|
|
|
p_apq += "\"" + dl.location + "\" ";
|
2023-06-02 22:09:26 +00:00
|
|
|
if (dl.type == DataLocation.RESOURCE_WAD || dl.type == DataLocation.RESOURCE_PK3)
|
|
|
|
{
|
|
|
|
p_aa += dl.location + " ";
|
|
|
|
p_aaq += "\"" + dl.location + "\" ";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p_af += dl.location + " ";
|
|
|
|
p_afq += "\"" + dl.location + "\" ";
|
|
|
|
}
|
2009-07-02 14:15:47 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trim last space from resource file locations
|
|
|
|
p_ap = p_ap.TrimEnd(' ');
|
|
|
|
p_apq = p_apq.TrimEnd(' ');
|
2023-06-02 22:09:26 +00:00
|
|
|
p_aa = p_aa.TrimEnd(' ');
|
|
|
|
p_aaq = p_aaq.TrimEnd(' ');
|
|
|
|
p_af = p_af.TrimEnd(' ');
|
|
|
|
p_afq = p_afq.TrimEnd(' ');
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Try finding the L1 and L2 numbers from the map name
|
|
|
|
string numstr = "";
|
|
|
|
bool first = true;
|
|
|
|
foreach(char c in General.Map.Options.CurrentName)
|
|
|
|
{
|
|
|
|
// Character is a number?
|
2013-12-18 09:11:04 +00:00
|
|
|
if(Configuration.NUMBERS.IndexOf(c) > -1)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Include it
|
|
|
|
numstr += c;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Store the number if we found one
|
|
|
|
if(numstr.Length > 0)
|
|
|
|
{
|
2014-02-21 14:42:12 +00:00
|
|
|
int num;
|
2009-04-19 18:07:22 +00:00
|
|
|
int.TryParse(numstr, out num);
|
|
|
|
if(first) p_l1 = num.ToString(); else p_l2 = num.ToString();
|
|
|
|
numstr = "";
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store the number if we found one
|
|
|
|
if(numstr.Length > 0)
|
|
|
|
{
|
2014-02-21 14:42:12 +00:00
|
|
|
int num;
|
2009-04-19 18:07:22 +00:00
|
|
|
int.TryParse(numstr, out num);
|
|
|
|
if(first) p_l1 = num.ToString(); else p_l2 = num.ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
// No monsters?
|
|
|
|
if(!General.Settings.TestMonsters) p_nm = "-nomonsters";
|
|
|
|
|
|
|
|
// Make sure all our placeholders are in uppercase
|
|
|
|
outp = outp.Replace("%f", "%F");
|
|
|
|
outp = outp.Replace("%wp", "%WP");
|
|
|
|
outp = outp.Replace("%wf", "%WF");
|
|
|
|
outp = outp.Replace("%wP", "%WP");
|
|
|
|
outp = outp.Replace("%wF", "%WF");
|
|
|
|
outp = outp.Replace("%Wp", "%WP");
|
|
|
|
outp = outp.Replace("%Wf", "%WF");
|
|
|
|
outp = outp.Replace("%l1", "%L1");
|
|
|
|
outp = outp.Replace("%l2", "%L2");
|
|
|
|
outp = outp.Replace("%l", "%L");
|
|
|
|
outp = outp.Replace("%ap", "%AP");
|
|
|
|
outp = outp.Replace("%aP", "%AP");
|
|
|
|
outp = outp.Replace("%Ap", "%AP");
|
|
|
|
outp = outp.Replace("%s", "%S");
|
|
|
|
outp = outp.Replace("%nM", "%NM");
|
|
|
|
outp = outp.Replace("%Nm", "%NM");
|
|
|
|
outp = outp.Replace("%nm", "%NM");
|
|
|
|
|
|
|
|
// Replace placeholders with actual values
|
|
|
|
outp = outp.Replace("%F", f);
|
|
|
|
outp = outp.Replace("%WP", p_wp);
|
|
|
|
outp = outp.Replace("%WF", p_wf);
|
|
|
|
outp = outp.Replace("%L1", p_l1);
|
|
|
|
outp = outp.Replace("%L2", p_l2);
|
|
|
|
outp = outp.Replace("%L", General.Map.Options.CurrentName);
|
|
|
|
outp = outp.Replace("\"%AP\"", p_apq);
|
2023-06-02 22:09:26 +00:00
|
|
|
outp = outp.Replace("\"%AA\"", p_aaq);
|
|
|
|
outp = outp.Replace("\"%AF\"", p_afq);
|
2009-04-19 18:07:22 +00:00
|
|
|
outp = outp.Replace("%AP", p_ap);
|
2023-06-02 22:09:26 +00:00
|
|
|
outp = outp.Replace("%AA", p_aa);
|
|
|
|
outp = outp.Replace("%AF", p_af);
|
2009-04-19 18:07:22 +00:00
|
|
|
outp = outp.Replace("%S", skill.ToString());
|
|
|
|
outp = outp.Replace("%NM", p_nm);
|
|
|
|
|
|
|
|
// Return result
|
|
|
|
return outp;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Test
|
|
|
|
|
|
|
|
// This saves the map to a temporary file and launches a test
|
|
|
|
[BeginAction("testmap")]
|
|
|
|
public void Test()
|
|
|
|
{
|
2016-06-19 00:09:53 +00:00
|
|
|
TestAtSkill(General.Map.ConfigSettings.TestSkill, false);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2012-06-07 01:06:37 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
|
|
|
[BeginAction("testmapfromview")]
|
2014-12-03 23:15:26 +00:00
|
|
|
public void TestFromView()
|
|
|
|
{
|
2016-06-19 00:09:53 +00:00
|
|
|
TestAtSkill(General.Map.ConfigSettings.TestSkill, true);
|
2013-09-11 09:47:53 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2015-09-06 22:15:21 +00:00
|
|
|
// This saves the map to a temporary file and launches a test with the given skill
|
2016-06-19 00:09:53 +00:00
|
|
|
public void TestAtSkill(int skill) { TestAtSkill(skill, false); }
|
|
|
|
public void TestAtSkill(int skill, bool testfromcurrentposition)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2016-06-19 00:09:53 +00:00
|
|
|
if(!General.Editing.Mode.OnMapTestBegin(testfromcurrentposition)) return; //mxd
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
Cursor oldcursor = Cursor.Current;
|
|
|
|
|
|
|
|
// Check if configuration is OK
|
2016-02-01 22:04:00 +00:00
|
|
|
if(string.IsNullOrEmpty(General.Map.ConfigSettings.TestProgram) || !File.Exists(General.Map.ConfigSettings.TestProgram))
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2012-11-13 21:11:53 +00:00
|
|
|
//mxd. Let's be more precise
|
|
|
|
string message;
|
|
|
|
if(General.Map.ConfigSettings.TestProgram == "")
|
|
|
|
message = "Your test program is not set for the current game configuration";
|
|
|
|
else
|
|
|
|
message = "Current test program has invalid path";
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Show message
|
|
|
|
Cursor.Current = Cursors.Default;
|
2012-11-13 21:11:53 +00:00
|
|
|
DialogResult result = General.ShowWarningMessage(message + ". Would you like to set up your test program now?", MessageBoxButtons.YesNo);
|
2009-04-19 18:07:22 +00:00
|
|
|
if(result == DialogResult.Yes)
|
|
|
|
{
|
|
|
|
// Show game configuration on the right page
|
|
|
|
General.MainWindow.ShowConfigurationPage(2);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// No custom parameters?
|
|
|
|
if(!General.Map.ConfigSettings.CustomParameters)
|
|
|
|
{
|
|
|
|
// Set parameters to the default ones
|
|
|
|
General.Map.ConfigSettings.TestParameters = General.Map.Config.TestParameters;
|
|
|
|
General.Map.ConfigSettings.TestShortPaths = General.Map.Config.TestShortPaths;
|
2019-12-25 17:45:19 +00:00
|
|
|
General.Map.ConfigSettings.TestLinuxPaths = General.Map.Config.TestLinuxPaths;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2009-07-02 14:15:47 +00:00
|
|
|
|
|
|
|
// Remove temporary file
|
2016-06-19 00:09:53 +00:00
|
|
|
if(File.Exists(tempwad) && !processes.ContainsValue(tempwad))
|
|
|
|
{
|
|
|
|
try { File.Delete(tempwad); }
|
|
|
|
catch { }
|
|
|
|
}
|
2009-07-02 14:15:47 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Save map to temporary file
|
|
|
|
Cursor.Current = Cursors.WaitCursor;
|
|
|
|
tempwad = General.MakeTempFilename(General.Map.TempPath, "wad");
|
2009-08-23 13:55:49 +00:00
|
|
|
General.Plugins.OnMapSaveBegin(SavePurpose.Testing);
|
|
|
|
if(General.Map.SaveMap(tempwad, SavePurpose.Testing))
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2021-09-27 14:33:35 +00:00
|
|
|
bool canceled = false;
|
|
|
|
|
2009-05-10 19:04:47 +00:00
|
|
|
// No compiler errors?
|
2021-09-27 14:33:35 +00:00
|
|
|
if (General.Map.Errors.Count == 0)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2021-09-27 14:33:35 +00:00
|
|
|
// Check if there's a pre command to run, and try to execute it
|
|
|
|
if (!string.IsNullOrWhiteSpace(General.Map.Options.TestPreCommand.Commands))
|
2009-05-10 19:04:47 +00:00
|
|
|
{
|
2021-09-27 14:33:35 +00:00
|
|
|
if (!General.Map.ExecuteExternalCommand(General.Map.Options.TestPreCommand, tempwad))
|
|
|
|
{
|
|
|
|
General.WriteLogLine("Testing was canceled when executing the testing pre command.");
|
|
|
|
|
|
|
|
// Reset status
|
|
|
|
General.MainWindow.DisplayStatus(StatusType.Warning, "Testing was canceled.");
|
|
|
|
canceled = true;
|
|
|
|
}
|
2009-05-10 19:04:47 +00:00
|
|
|
}
|
2021-09-27 14:33:35 +00:00
|
|
|
|
|
|
|
if (!canceled)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2021-09-27 14:33:35 +00:00
|
|
|
// Make arguments
|
|
|
|
string args = ConvertParameters(General.Map.ConfigSettings.TestParameters, skill, General.Map.ConfigSettings.TestShortPaths, General.Map.ConfigSettings.TestLinuxPaths);
|
|
|
|
|
2021-12-14 17:15:23 +00:00
|
|
|
// Add additional parameters
|
|
|
|
if (!string.IsNullOrWhiteSpace(General.Map.ConfigSettings.TestAdditionalParameters))
|
|
|
|
args += " " + General.Map.ConfigSettings.TestAdditionalParameters;
|
|
|
|
|
2021-09-27 14:33:35 +00:00
|
|
|
// Setup process info
|
|
|
|
ProcessStartInfo processinfo = new ProcessStartInfo();
|
|
|
|
processinfo.Arguments = args;
|
|
|
|
processinfo.FileName = General.Map.ConfigSettings.TestProgram;
|
|
|
|
processinfo.CreateNoWindow = false;
|
|
|
|
processinfo.ErrorDialog = false;
|
|
|
|
processinfo.UseShellExecute = true;
|
|
|
|
processinfo.WindowStyle = ProcessWindowStyle.Normal;
|
|
|
|
processinfo.WorkingDirectory = Path.GetDirectoryName(processinfo.FileName);
|
|
|
|
|
|
|
|
// Output info
|
|
|
|
General.WriteLogLine("Running test program: " + processinfo.FileName);
|
|
|
|
General.WriteLogLine("Program parameters: " + processinfo.Arguments);
|
|
|
|
General.MainWindow.DisplayStatus(StatusType.Info, "Launching " + processinfo.FileName + "...");
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Start the program
|
|
|
|
Process process = Process.Start(processinfo);
|
|
|
|
process.EnableRaisingEvents = true; //mxd
|
|
|
|
process.Exited += ProcessOnExited; //mxd
|
|
|
|
processes.Add(process, tempwad); //mxd
|
|
|
|
Cursor.Current = oldcursor; //mxd
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
// Unable to start the program
|
|
|
|
General.ShowErrorMessage("Unable to start the test program, " + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if there's a post command to run, and try to execute it
|
|
|
|
// TODO: currently modifying the commands is disabled since it'd have to be executed after the test program ends, which is not
|
|
|
|
// the case in the current situation, since this code here is reached immediately after launching the test program
|
|
|
|
/*
|
|
|
|
if (!string.IsNullOrWhiteSpace(General.Map.Options.TestPostCommand.Commands))
|
|
|
|
{
|
|
|
|
if (!General.Map.ExecuteExternalCommand(General.Map.Options.TestPostCommand, tempwad))
|
|
|
|
{
|
|
|
|
General.WriteLogLine("Failed to execute the test post command successfully.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-10 19:04:47 +00:00
|
|
|
else
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-05-10 19:04:47 +00:00
|
|
|
General.MainWindow.DisplayStatus(StatusType.Warning, "Unable to test the map due to script errors.");
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
General.Plugins.OnMapSaveEnd(SavePurpose.Testing);
|
2016-06-19 00:09:53 +00:00
|
|
|
General.Editing.Mode.OnMapTestEnd(testfromcurrentposition); //mxd
|
2014-03-23 09:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
2016-06-19 00:09:53 +00:00
|
|
|
private void TestingFinished(Process process)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
// Done
|
2014-03-23 09:08:51 +00:00
|
|
|
TimeSpan deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks);
|
2016-06-19 00:09:53 +00:00
|
|
|
General.WriteLogLine("Testing with \"" + process.StartInfo.FileName + "\" has finished.");
|
2014-03-23 09:08:51 +00:00
|
|
|
General.WriteLogLine("Run time: " + deltatime.TotalSeconds.ToString("###########0.00") + " seconds");
|
2016-06-19 00:09:53 +00:00
|
|
|
|
|
|
|
//mxd. Remove from active processes list
|
|
|
|
string closedtempfile = processes[process];
|
|
|
|
processes.Remove(process);
|
|
|
|
|
|
|
|
//mxd. Still have running engines?..
|
|
|
|
if(processes.Count > 0)
|
|
|
|
{
|
|
|
|
// Remove temp file
|
|
|
|
if(File.Exists(closedtempfile))
|
|
|
|
{
|
|
|
|
try { File.Delete(closedtempfile); }
|
|
|
|
catch { }
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-23 09:08:51 +00:00
|
|
|
General.MainWindow.DisplayReady();
|
|
|
|
|
2009-07-02 14:15:47 +00:00
|
|
|
// Clean up temp file
|
|
|
|
CleanTempFile(General.Map);
|
2013-09-11 15:01:55 +00:00
|
|
|
|
Added, Sector Edit window, UDMF: added UI for sector damage-realted properties.
Added, DECORATE parser: damage types are now parsed.
Added: the editor now reports duplicate textures/flats/patches/sprites/colormaps/voxels in the loaded wads.
Added, all text parsers: added #region/#endregion support.
Added TERRAIN parser.
Added, Script Editor: added special handling for DECORATE special comments.
Added, Sector Edit window, UDMF: Soundsequence value was setup incorrectly when showing the window for multiple sectors with mixed Soundsequence value.
Fixed, Map Options window: "Strictly load patches between P_START and P_END" was not applied when applying the changes.
Fixed, MAPINFO parser: MapInfo should be treated as defined when a map MAPINFO block corresponding to current map is encountered even if it doesn't define any properties recognized by the editor.
Fixed, all text parsers: in some cases error line was calculated incorrectly when reporting an error detected by a text parser.
Cosmetic: changed ' to " in the rest of Error and Warning messages.
Internal: added text resource tracking.
Updated ZDoom_DECORATE.cfg.
Updated documentation ("Game Configuration - Basic Settings" page).
2016-02-22 12:33:19 +00:00
|
|
|
if(General.Map != null)
|
|
|
|
{
|
|
|
|
// Device reset may be needed...
|
|
|
|
if(General.Editing.Mode is ClassicMode)
|
|
|
|
{
|
|
|
|
General.MainWindow.RedrawDisplay();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
General.MainWindow.FocusDisplay();
|
|
|
|
}
|
2014-03-23 09:08:51 +00:00
|
|
|
|
|
|
|
//mxd
|
2016-06-19 00:09:53 +00:00
|
|
|
private void ProcessOnExited(object sender, EventArgs e)
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2016-06-19 00:09:53 +00:00
|
|
|
General.MainWindow.Invoke(new EngineExitedCallback(TestingFinished), new[] { sender });
|
2014-03-23 09:08:51 +00:00
|
|
|
}
|
|
|
|
|
2009-07-02 14:15:47 +00:00
|
|
|
// This deletes the previous temp file and creates a new, empty temp file
|
|
|
|
private void CleanTempFile(MapManager manager)
|
|
|
|
{
|
|
|
|
// Remove temporary file
|
|
|
|
try { File.Delete(tempwad); }
|
2016-06-19 00:09:53 +00:00
|
|
|
catch { }
|
2009-07-02 14:15:47 +00:00
|
|
|
|
|
|
|
// Make new empty temp file
|
|
|
|
tempwad = General.MakeTempFilename(manager.TempPath, "wad");
|
|
|
|
File.WriteAllText(tempwad, "");
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|