Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Added export dialog to the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
REHERC committed Apr 15, 2021
1 parent e75d590 commit 7c7cccc
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 5 deletions.
24 changes: 22 additions & 2 deletions App.AdventureMaker.Core/Commands/ExportFileCommand.cs
Original file line number Diff line number Diff line change
@@ -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<CampaignFile> editor;
private readonly SaveFileDialog dialog;

public ExportFileCommand(IEditor<CampaignFile> 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 :(");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public FileCheckWindow(CampaignValidator validator)
ImageBinding = Binding.Property<ValidationItem, Image>(message => STATUS_IMAGES[message.status]()),
ImageInterpolation = ImageInterpolation.High,
VerticalAlignment = VerticalAlignment.Center

//TextAlignment = TextAlignment.Right BRUH
}
},
Expand Down
2 changes: 2 additions & 0 deletions App.AdventureMaker.Core/Global/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 !";
Expand Down
13 changes: 13 additions & 0 deletions App.AdventureMaker.Core/Global/Dialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
};
}
}
5 changes: 5 additions & 0 deletions App.AdventureMaker.Core/Global/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion App.AdventureMaker.Core/Global/Project.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -30,5 +31,10 @@ public static CampaignFile CreateProject(ProjectCreateData data)
return null;
}
}

public static void ExportProject(FileInfo destination, IEditor<CampaignFile> editor)
{

}
}
}
2 changes: 1 addition & 1 deletion App.AdventureMaker.Core/Menus/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public MainMenu(MainWindow form, IEditor<CampaignFile> editor)
Items =
{
new ImportFileCommand(),
new ExportFileCommand()
new ExportFileCommand(editor)
}
});
ApplicationItems.Add(new SeparatorMenuItem());
Expand Down

0 comments on commit 7c7cccc

Please sign in to comment.