public override bool Build(CompileMessages errors, bool forceRebuild) { if (!base.Build(errors, forceRebuild)) { return(false); } try { string baseGameFileName = Factory.AGSEditor.BaseGameFileName; string exeFileName = baseGameFileName + ".exe"; BuildTargetWindows targetWin = BuildTargetsInfo.FindBuildTargetByName("Windows") as BuildTargetWindows; if (targetWin == null) { errors.Add(new CompileError("Debug build depends on Windows build target being available! Your AGS installation may be corrupted!")); return(false); } string compiledEXE = targetWin.GetCompiledPath(exeFileName); string compiledDat = targetWin.GetCompiledPath(baseGameFileName + ".ags"); string sourceEXE = Path.Combine(Factory.AGSEditor.EditorDirectory, AGSEditor.ENGINE_EXE_FILE_NAME); Utilities.DeleteFileIfExists(compiledEXE); Utilities.DeleteFileIfExists(compiledDat); File.Copy(sourceEXE, exeFileName, true); BusyDialog.Show("Please wait while we prepare to run the game...", new BusyDialog.ProcessingHandler(CreateDebugFiles), errors); if (errors.HasErrors) { return(false); } Utilities.DeleteFileIfExists(GetDebugPath(exeFileName)); File.Move(exeFileName, GetDebugPath(exeFileName)); // copy configuration from Compiled folder to use with Debugging string cfgFilePath = targetWin.GetCompiledPath(AGSEditor.CONFIG_FILE_NAME); if (File.Exists(cfgFilePath)) { File.Copy(cfgFilePath, GetDebugPath(AGSEditor.CONFIG_FILE_NAME), true); } else { cfgFilePath = Path.Combine(AGSEditor.OUTPUT_DIRECTORY, Path.Combine(AGSEditor.DATA_OUTPUT_DIRECTORY, AGSEditor.CONFIG_FILE_NAME)); if (File.Exists(cfgFilePath)) { File.Copy(cfgFilePath, GetDebugPath(AGSEditor.CONFIG_FILE_NAME), true); } } foreach (Plugin plugin in Factory.AGSEditor.CurrentGame.Plugins) { File.Copy(Path.Combine(Factory.AGSEditor.EditorDirectory, plugin.FileName), GetDebugPath(plugin.FileName), true); } // Copy files from Compiled/Data to Compiled/Windows, because this is currently where game will be looking them up targetWin.CopyAuxiliaryGameFiles(Path.Combine(AGSEditor.OUTPUT_DIRECTORY, AGSEditor.DATA_OUTPUT_DIRECTORY), false); } catch (Exception ex) { errors.Add(new CompileError("Unexpected error: " + ex.Message)); return(false); } return(true); }
public override bool Build(CompileMessages errors, bool forceRebuild) { if (!base.Build(errors, forceRebuild)) { return(false); } Factory.AGSEditor.SetMODMusicFlag(); DeleteAnyExistingSplitResourceFiles(); if (Factory.AGSEditor.Preferences.UseLegacyCompiler) { Factory.NativeProxy.CompileGameToDTAFile(Factory.AGSEditor.CurrentGame, AGSEditor.COMPILED_DTA_FILE_NAME); // if using the legacy compiler, make sure engine EXE is copied before calling CreateGameEXE string newExeName = GetCompiledPath(Factory.AGSEditor.BaseGameFileName + ".exe"); string sourceEXE = Path.Combine(Factory.AGSEditor.EditorDirectory, AGSEditor.ENGINE_EXE_FILE_NAME); File.Copy(sourceEXE, newExeName, true); BuildTargetWindows targetWindows = (BuildTargetsInfo.FindBuildTargetByName("Windows") as BuildTargetWindows); // updating the Vista game explorer resources after the EXE is fully created is deleting the data file, // corrupting the game resources targetWindows.UpdateWindowsEXE(newExeName, errors); // the above all needs to be done here anyway, so finish up by creating the setup EXE and copying plugins targetWindows.CreateCompiledSetupProgram(); targetWindows.CopyPlugins(errors); Factory.NativeProxy.CreateGameEXE(ConstructFileListForDataFile(), Factory.AGSEditor.CurrentGame, Factory.AGSEditor.BaseGameFileName); } else { if (!DataFileWriter.SaveThisGameToFile(AGSEditor.COMPILED_DTA_FILE_NAME, Factory.AGSEditor.CurrentGame, errors)) { return(false); } string errorMsg = DataFileWriter.MakeDataFile(ConstructFileListForDataFile(), Factory.AGSEditor.CurrentGame.Settings.SplitResources * 1000000, Factory.AGSEditor.BaseGameFileName, true); if (errorMsg != null) { errors.Add(new CompileError(errorMsg)); } } File.Delete(AGSEditor.COMPILED_DTA_FILE_NAME); CreateAudioVOXFile(forceRebuild); // Update config file with current game parameters Factory.AGSEditor.WriteConfigFile(AGSEditor.OUTPUT_DIRECTORY); return(true); }