public static void Compile(Batch batch) { var script = new StringBuilder(); script.AppendLine(batch.BeforeExecute); foreach (var step in batch.Steps) { script.AppendLine(batch.BeforeExecuteStep); script.AppendLine(step.BeforeExecute); var cq = step.SystemCommand ? "" : "\""; script.Append(cq).Append(step.Operation).Append(cq).Append(' ').AppendLine(step.Flags); script.AppendLine(step.AfterExecute); script.AppendLine(batch.AfterExecuteStep); } script.AppendLine(batch.AfterExecute); var batchFile = Path.ChangeExtension(batch.TargetFile, "bat"); File.WriteAllText(batchFile, script.ToString()); Process.Start(batchFile); }
public void FileCompile() { _document.SaveFile(); if (_document.MapFile == null) return; var build = SettingsManager.Builds.FirstOrDefault(x => x.ID == _document.Game.BuildID); if (build == null) { if (MessageBox.Show("Please set up the build tools for this game profile.\n\nWould you like to open the settings page now?", "No build configuration", MessageBoxButtons.YesNo) == DialogResult.Yes) { Mediator.Publish(EditorMediator.OpenSettings); } return; } using (var cd = new CompileDialog(build)) { if (cd.ShowDialog() == DialogResult.OK) { var batch = new Batch(_document, build, cd.GetProfile()); batch.Compile(); } } }
public void FileCompile() { _document.SaveFile(); if (_document.MapFile == null) return; var build = SettingsManager.Builds.FirstOrDefault(x => x.ID == _document.Game.BuildID); if (build == null) { if (MessageBox.Show("Please set up the build tools for this game profile.\n\nWould you like to open the settings page now?", "No build configuration", MessageBoxButtons.YesNo) == DialogResult.Yes) { Mediator.Publish(EditorMediator.OpenSettings); } return; } var tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Directory.CreateDirectory(tempDir); _document.Map.WorldSpawn.EntityData.SetPropertyValue("wad", string.Join(";", _document.Game.Wads.Select(x => x.Path))); var map = Path.Combine(tempDir, Path.GetFileNameWithoutExtension(_document.MapFile) + ".map"); SaveWithCordon(map); var batch = new Batch(_document.Game, build, map, _document.MapFile); BatchCompiler.Compile(batch); }
private void CompileStarted(Batch batch) { if (DockBottom.Hidden && Sledge.Settings.View.CompileOpenOutput) DockBottom.Hidden = false; }
private void CompileFinished(Batch batch) { if (batch.Build.AfterRunGame) { if (batch.Build.AfterAskBeforeRun) { if (MessageBox.Show( "The compile of " + batch.Document.MapFileName + " completed successfully.\n" + "Would you like to run the game now?", "Compile Successful!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } var exe = batch.Game.GetExecutable(); if (!File.Exists(exe)) { MessageBox.Show( "The location of the game executable is incorrect. Please ensure that the game configuration has been set up correctly.", "Failed to launch!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var flags = String.Format("{0} +map \"{1}\" {2}", batch.Game.GetGameLaunchArgument(), batch.MapFileName, batch.Game.ExecutableParameters); try { Process.Start(exe, flags); } catch (Exception ex) { MessageBox.Show("Launching game failed: " + ex.Message, "Failed to launch!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } }
private void CompileFailed(Batch batch) { if (batch.Build.AfterRunGame && batch.Build.AfterAskBeforeRun) { MessageBox.Show( "The compile of " + batch.Document.MapFileName + " failed. If any errors were generated, " + "they will appear in the compile output panel.", "Compile Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); if (DockBottom.Hidden) DockBottom.Hidden = false; } }