From 7c7cccce47e460aba7490145bb4cbbf7ef6071a3 Mon Sep 17 00:00:00 2001 From: Reherc Date: Fri, 16 Apr 2021 01:44:33 +0200 Subject: [PATCH] Added export dialog to the editor --- .../Commands/ExportFileCommand.cs | 24 +++++++++++++++++-- .../Forms/FileChecker/FileCheckWindow.cs | 2 +- App.AdventureMaker.Core/Global/Constants.cs | 2 ++ App.AdventureMaker.Core/Global/Dialogs.cs | 13 ++++++++++ App.AdventureMaker.Core/Global/Messages.cs | 5 ++++ App.AdventureMaker.Core/Global/Project.cs | 8 ++++++- App.AdventureMaker.Core/Menus/MainMenu.cs | 2 +- 7 files changed, 51 insertions(+), 5 deletions(-) diff --git a/App.AdventureMaker.Core/Commands/ExportFileCommand.cs b/App.AdventureMaker.Core/Commands/ExportFileCommand.cs index 29cf427..6a115ce 100644 --- a/App.AdventureMaker.Core/Commands/ExportFileCommand.cs +++ b/App.AdventureMaker.Core/Commands/ExportFileCommand.cs @@ -1,16 +1,36 @@ -using Eto.Forms; +using App.AdventureMaker.Core.Interfaces; +using Distance.AdventureMaker.Common.Models; +using Eto.Forms; +using System; +using static Dialogs; namespace App.AdventureMaker.Core.Commands { public class ExportFileCommand : Command { - public ExportFileCommand() + private readonly IEditor editor; + private readonly SaveFileDialog dialog; + + public ExportFileCommand(IEditor editor) { + this.editor = editor; + MenuText = "&Export"; ToolBarText = "Export"; Shortcut = Application.Instance.CommonModifier | Keys.Shift | Keys.E; + dialog = ExportCampaignDialog("Export campaign as..."); + Enabled = false; + editor.OnLoaded += (_) => Enabled = editor.CurrentFile != null; + } + + protected override void OnExecuted(EventArgs e) + { + if (dialog.ShowDialog(null) == DialogResult.Ok) + { + MessageBox.Show("Unimplemented :("); + } } } } diff --git a/App.AdventureMaker.Core/Forms/FileChecker/FileCheckWindow.cs b/App.AdventureMaker.Core/Forms/FileChecker/FileCheckWindow.cs index eadd4eb..f5d62e4 100644 --- a/App.AdventureMaker.Core/Forms/FileChecker/FileCheckWindow.cs +++ b/App.AdventureMaker.Core/Forms/FileChecker/FileCheckWindow.cs @@ -48,7 +48,7 @@ public FileCheckWindow(CampaignValidator validator) ImageBinding = Binding.Property(message => STATUS_IMAGES[message.status]()), ImageInterpolation = ImageInterpolation.High, VerticalAlignment = VerticalAlignment.Center - + //TextAlignment = TextAlignment.Right BRUH } }, diff --git a/App.AdventureMaker.Core/Global/Constants.cs b/App.AdventureMaker.Core/Global/Constants.cs index 6a62c5a..bafd7a9 100644 --- a/App.AdventureMaker.Core/Global/Constants.cs +++ b/App.AdventureMaker.Core/Global/Constants.cs @@ -22,6 +22,7 @@ public static partial class Constants // Tool-specific filters public const string DIALOG_FILTER_PROJECT = "Json project files (project.json)|project.json"; + public const string DIALOG_FILTER_ARCHIVE = "Extension description|*"; // Image filters public const string DIALOG_FILTER_PNG = "Portable Network Graphics (*.png)|*.png"; @@ -36,6 +37,7 @@ public static partial class Constants public const string DIALOG_MESSAGE_EDITOR_PREVIEW = "This software is currently still work in progress!\nPlease only use it for testing purposes and feedback as many breaking changes may occur in the future."; public const string DIALOG_MESSAGE_UNSAVED_CHANGES = "The currently opened file has unsaved changes!\nContinue without saving?"; public const string DIALOG_MESSAGE_UNSAVED_CHANGES_CONTINUE = "You must save your changes before you continue!\nDo you want to save now?"; + public const string DIALOG_MESSAGE_SAVE_CHANGES_CONTINUE = "You must save your changes to continue!\nSave now?"; public const string DIALOG_MESSAGE_REMOVE_PLAYLIST = "Are you sure you want to remove the following playlist: \"{0}\" ?"; public const string DIALOG_MESSAGE_REMOVE_LEVEL = "Do you want to remove \"{0}\" from this playlist?"; public const string DIALOG_MESSAGE_REMOVE_RESOURCE = "Are you sure you want to remove this resource ?\nObjects requiring this resource will need to be updated manually !"; diff --git a/App.AdventureMaker.Core/Global/Dialogs.cs b/App.AdventureMaker.Core/Global/Dialogs.cs index e3d3b85..e9f75c1 100644 --- a/App.AdventureMaker.Core/Global/Dialogs.cs +++ b/App.AdventureMaker.Core/Global/Dialogs.cs @@ -36,4 +36,17 @@ public static OpenFileDialog SelectBytesFileDialog(string title) } }; } + + public static SaveFileDialog ExportCampaignDialog(string title) + { + return new SaveFileDialog() + { + Title = title, + CheckFileExists = false, + Filters = + { + DIALOG_FILTER_ARCHIVE + } + }; + } } \ No newline at end of file diff --git a/App.AdventureMaker.Core/Global/Messages.cs b/App.AdventureMaker.Core/Global/Messages.cs index 7cd4cef..76936ad 100644 --- a/App.AdventureMaker.Core/Global/Messages.cs +++ b/App.AdventureMaker.Core/Global/Messages.cs @@ -10,6 +10,11 @@ public static DialogResult UnsavedChangesDialog(string caption) return MessageBox.Show(Constants.DIALOG_MESSAGE_UNSAVED_CHANGES, caption, MessageBoxButtons.YesNo, MessageBoxType.Warning); } + public static DialogResult SaveChangesDialog(string caption) + { + return MessageBox.Show(Constants.DIALOG_MESSAGE_UNSAVED_CHANGES, caption, MessageBoxButtons.YesNo, MessageBoxType.Warning); + } + public static DialogResult RemovePlaylist(CampaignPlaylist playlist) { return MessageBox.Show(string.Format(Constants.DIALOG_MESSAGE_REMOVE_PLAYLIST, playlist.Name), Constants.DIALOG_CAPTION_REMOVE_PLAYLIST, MessageBoxButtons.YesNo, MessageBoxType.Question); diff --git a/App.AdventureMaker.Core/Global/Project.cs b/App.AdventureMaker.Core/Global/Project.cs index 8b35dd1..d0640bc 100644 --- a/App.AdventureMaker.Core/Global/Project.cs +++ b/App.AdventureMaker.Core/Global/Project.cs @@ -1,4 +1,5 @@ -using Distance.AdventureMaker.Common.Models; +using App.AdventureMaker.Core.Interfaces; +using Distance.AdventureMaker.Common.Models; using Distance.AdventureMaker.Common.Models.UI; using System; using System.IO; @@ -30,5 +31,10 @@ public static CampaignFile CreateProject(ProjectCreateData data) return null; } } + + public static void ExportProject(FileInfo destination, IEditor editor) + { + + } } } diff --git a/App.AdventureMaker.Core/Menus/MainMenu.cs b/App.AdventureMaker.Core/Menus/MainMenu.cs index 3034b3a..60c723d 100644 --- a/App.AdventureMaker.Core/Menus/MainMenu.cs +++ b/App.AdventureMaker.Core/Menus/MainMenu.cs @@ -21,7 +21,7 @@ public MainMenu(MainWindow form, IEditor editor) Items = { new ImportFileCommand(), - new ExportFileCommand() + new ExportFileCommand(editor) } }); ApplicationItems.Add(new SeparatorMenuItem());