private void HandleGameTextFormatChange(string oldFormat, string newFormat) { if (oldFormat == newFormat) { return; } if (Factory.GUIController.ShowQuestion("Changing the game text format will make the editor and engine treat all the text in all the game files in accordance to the new setting.\n\n" + "IMPORTANT: the Editor will now convert the game files and scripts to a new format. This may take a while, depending on your game's size.\n\n" + "IMPORTANT: the Translation files will remain unaffected by this setting, as they have their own individual encoding setting.\n\n" + "Are you sure you want to continue?", MessageBoxIcon.Warning) == DialogResult.No) { Factory.AGSEditor.CurrentGame.Settings.GameTextEncoding = oldFormat; } else { Factory.Events.OnGameSettingsChanged(); BusyDialog.Show("Please wait while we convert game files to the new text format...", (IWorkProgress progress, object o) => { Factory.AGSEditor.Tasks.ConvertAllGameTexts( Types.Utilities.EncodingFromName(oldFormat), Types.Utilities.EncodingFromName(newFormat)); return(null); }, null); } }
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); } try { string baseGameFileName = Factory.AGSEditor.BaseGameFileName; string exeFileName = baseGameFileName + ".exe"; string compiledEXE = Path.Combine(Path.Combine(AGSEditor.OUTPUT_DIRECTORY, BuildTargetWindows.WINDOWS_DIRECTORY), exeFileName); string sourceEXE = Path.Combine(Factory.AGSEditor.EditorDirectory, AGSEditor.ENGINE_EXE_FILE_NAME); Utilities.DeleteFileIfExists(compiledEXE); 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 = Path.Combine(AGSEditor.OUTPUT_DIRECTORY, AGSEditor.CONFIG_FILE_NAME); if (!Factory.AGSEditor.Preferences.UseLegacyCompiler) { IBuildTarget targetWin = BuildTargetsInfo.FindBuildTargetByName("Windows"); if (targetWin != null) { cfgFilePath = targetWin.GetCompiledPath(AGSEditor.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); } } catch (Exception ex) { errors.Add(new CompileError("Unexpected error: " + ex.Message)); return(false); } return(true); }
public Game ImportGameFromAGS272(string gameToLoad, bool useWizard) { string backupLocation = ConstructBackupDirectoryName(gameToLoad); Game game = null; bool continueWithImport = true; bool performBackup = false; if (useWizard) { ImportGameWizardPage importPage = new ImportGameWizardPage(backupLocation); List <WizardPage> pages = new List <WizardPage>(); pages.Add(importPage); WizardDialog dialog = new WizardDialog("Import Old Game", "This wizard will guide you through importing a game from a previous version of AGS.", pages); DialogResult result = dialog.ShowDialog(); continueWithImport = (result == DialogResult.OK); performBackup = importPage.BackupEnabled; dialog.Dispose(); } if (continueWithImport) { if (performBackup) { try { BusyDialog.Show("Please wait while your game files are backed up...", new BusyDialog.ProcessingHandler(MakeBackupCopyOfGameFolderThread), backupLocation); } catch (Exception ex) { if (Factory.GUIController.ShowQuestion("An error occured whilst backing up your game files.\n\nError: " + ex.Message + "\n\nDo you want to proceed and upgrade the game anyway?", MessageBoxIcon.Warning) == DialogResult.No) { return(null); } } } ImportGameResult importResult = (ImportGameResult)BusyDialog.Show("Please wait while your game is imported...", new BusyDialog.ProcessingHandler(ImportOldGameThread), gameToLoad); game = importResult.LoadedGame; Factory.Events.OnImportedOldGame(); Factory.GUIController.ShowOutputPanel(importResult.Errors); if (importResult.Errors.Count > 0) { Factory.GUIController.ShowMessage("Some errors were encountered whilst importing the game. Check the output window for details.", MessageBoxIcon.Warning); } } return(game); }
private void btnSendErrorReport_Click(object sender, EventArgs e) { try { string response = (string)BusyDialog.Show("Sending the error report to the AGS Website...", new BusyDialog.ProcessingHandler(SendErrorReportThread), null); if (!response.Contains("<ErrorReport>")) { throw new AGS.Types.InvalidDataException("The server did not accept the error report."); } lblReportSucceeded.Visible = true; } catch (Exception ex) { MessageBox.Show("Failed to send the error report to the server. The AGS Website may be temporarily unavailable. Please copy and paste the error text to a thread in the AGS Technical Forum to report this problem." + Environment.NewLine + Environment.NewLine + "Problem sending data: " + ex.Message, "Error reporting failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } btnSendErrorReport.Visible = false; }
public static void RecreateSpriteFileFromSources() { string tempFilename; try { tempFilename = Path.GetTempFileName(); BusyDialog.Show("Please wait while the sprite file is recreated...", new BusyDialog.ProcessingHandler( (IWorkProgress progress, object o) => { Utils.SpriteTools.WriteSpriteFileFromSources((string)o, progress); return(null); }), tempFilename); } catch (Exception e) { Factory.GUIController.ShowMessage("The recreation of a sprite file was interrupted by error. NO CHANGES were applied to your game.\n\n" + e.Message, MessageBoxIcon.Error); return; } Factory.NativeProxy.ReplaceSpriteFile(tempFilename); File.Delete(tempFilename); }
public static object Show(string message, ProcessingHandler handler, object parameter) { object resultToReturn = null; BusyDialog dialog = new BusyDialog(message, handler, parameter); try { dialog.ShowDialog(); resultToReturn = dialog.Result; if (dialog.ExceptionThrown != null) { // Re-throw the same type of exception ConstructorInfo constructor = dialog.ExceptionThrown.GetType().GetConstructor(new Type[] { dialog.ExceptionThrown.GetType() }); if (constructor != null) { // Copy constructor throw (Exception)constructor.Invoke(new object[] { dialog.ExceptionThrown }); } else { constructor = dialog.ExceptionThrown.GetType().GetConstructor(new Type[] { typeof(string), typeof(Exception) }); if (constructor == null) { // default constructor throw new AGSEditorException(dialog.ExceptionThrown.Message, dialog.ExceptionThrown); } else { throw (Exception)constructor.Invoke(new object[] { dialog.ExceptionThrown.Message, dialog.ExceptionThrown }); } } } } finally { dialog.Dispose(); } return(resultToReturn); }
public static object Show(string message, ProcessingHandler handler, object parameter) { object resultToReturn = null; BusyDialog dialog = new BusyDialog(message, handler, parameter); try { dialog.ShowDialog(); resultToReturn = dialog.Result; if (dialog.ExceptionThrown != null) { // Re-throw the same type of exception ConstructorInfo constructor = dialog.ExceptionThrown.GetType().GetConstructor(new Type[] { dialog.ExceptionThrown.GetType() }); if (constructor != null) { // Copy constructor throw (Exception)constructor.Invoke(new object[] { dialog.ExceptionThrown }); } else { constructor = dialog.ExceptionThrown.GetType().GetConstructor(new Type[] { typeof(string), typeof(Exception) }); if (constructor == null) { // default constructor throw new AGSEditorException(dialog.ExceptionThrown.Message, dialog.ExceptionThrown); } else { throw (Exception)constructor.Invoke(new object[] { dialog.ExceptionThrown.Message, dialog.ExceptionThrown }); } } } } finally { dialog.Dispose(); } return resultToReturn; }
public void CreateTemplateFromCurrentGame(string templateFileName) { BusyDialog.Show("Please wait while the template is created...", new BusyDialog.ProcessingHandler(CreateTemplateFromCurrentGameProcess), templateFileName); }