public void ShowCreateTemplateWizard() { if (_agsEditor.SourceControlProvider.ProjectUnderControl) { if (this.ShowQuestion("This game is under source control. It is not advisable to create a template that is bound to source control. Are you sure you want to continue?", MessageBoxIcon.Warning) == DialogResult.No) { return; } } List<WizardPage> pages = new List<WizardPage>(); MakeTemplateWizardPage templateCreationPage = new MakeTemplateWizardPage(_agsEditor.TemplatesDirectory, ".agt"); pages.Add(templateCreationPage); WizardDialog dialog = new WizardDialog("Create Template", "This wizard will guide you through the process of creating a template. A template allows other people to easily create a game that uses your game as a starting point.", pages); DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { string templateName = templateCreationPage.GetFullPath(); try { _agsEditor.SaveGameFiles(); InteractiveTasks.CreateTemplateFromCurrentGame(templateName); Factory.GUIController.ShowMessage("Template created successfully. To try it out, close AGS, start it up again, and select the 'Start New Game' option.", MessageBoxIcon.Information); } catch (AGSEditorException ex) { Factory.GUIController.ShowMessage("There was an error creating your template:" + Environment.NewLine + ex.Message, MessageBoxIcon.Warning); } catch (Exception ex) { Factory.GUIController.ShowMessage("There was an error creating your template. The error was: " + ex.Message + Environment.NewLine + Environment.NewLine + "Error details: " + ex.ToString(), MessageBoxIcon.Warning); } } dialog.Dispose(); }
public void ShowCreateRoomTemplateWizard(UnloadedRoom room) { List<WizardPage> pages = new List<WizardPage>(); MakeTemplateWizardPage templateCreationPage = new MakeTemplateWizardPage(_agsEditor.TemplatesDirectory, ".art"); pages.Add(templateCreationPage); WizardDialog dialog = new WizardDialog("Room Template", "This wizard will guide you through the process of creating a room template. A room template allows you to easily create new rooms based off an existing one.", pages); DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { string templateFileName = templateCreationPage.GetFullPath(); try { if (File.Exists(templateFileName)) { File.Delete(templateFileName); } BinaryWriter writer = new BinaryWriter(new FileStream(ROOM_TEMPLATE_ID_FILE, FileMode.Create, FileAccess.Write)); writer.Write(ROOM_TEMPLATE_ID_FILE_SIGNATURE); writer.Write(room.Number); writer.Close(); Factory.NativeProxy.CreateTemplateFile(templateFileName, ConstructRoomTemplateFileList(room)); File.Delete(ROOM_TEMPLATE_ID_FILE); Factory.GUIController.ShowMessage("Template created successfully. To try it out, create a new room.", MessageBoxIcon.Information); } catch (AGSEditorException ex) { Factory.GUIController.ShowMessage("There was an error creating your template: " + ex.Message, MessageBoxIcon.Warning); } catch (Exception ex) { Factory.GUIController.ShowMessage("There was an error creating your template. The error was: " + ex.Message + Environment.NewLine + Environment.NewLine + "Error details: " + ex.ToString(), MessageBoxIcon.Warning); } } dialog.Dispose(); }