Skip to content

Commit

Permalink
Added support for savegame.unencrypted to importing and exporting bac…
Browse files Browse the repository at this point in the history
…kups
  • Loading branch information
John committed Mar 23, 2020
1 parent f518559 commit 3f3d0ec
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 144 deletions.
10 changes: 5 additions & 5 deletions DOOMSaveManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@
<DependentUpon>TransferForm.cs</DependentUpon>
</Compile>
<Compile Include="Utilities.cs" />
<Compile Include="SelectUUIDForm.cs">
<Compile Include="SelectForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SelectUUIDForm.Designer.cs">
<DependentUpon>SelectUUIDForm.cs</DependentUpon>
<Compile Include="SelectForm.Designer.cs">
<DependentUpon>SelectForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
Expand All @@ -106,8 +106,8 @@
<EmbeddedResource Include="TransferForm.resx">
<DependentUpon>TransferForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SelectUUIDForm.resx">
<DependentUpon>SelectUUIDForm.cs</DependentUpon>
<EmbeddedResource Include="SelectForm.resx">
<DependentUpon>SelectForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
Expand Down
29 changes: 19 additions & 10 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,25 @@ private void actionOkBtn_Click(object sender, EventArgs e) {
ofd.FilterIndex = 0;
ofd.FileName = "backup.Zip";
if (ofd.ShowDialog() == DialogResult.OK) {
var suf = new SelectUUIDForm("Select Import Destination UUID");
var suf = new SelectForm("Select Import Destination");
if (suf.ShowDialog() == DialogResult.OK) {
Directory.CreateDirectory("tmp");
Utilities.Unarchive(ofd.FileName, "tmp");
DoomEternal.BulkEncrypt("tmp", suf.selectUidComboBox.Text);
Directory.Delete("tmp", true);
if(suf.selectComboBox.Text == "savegame.unencrypted") {
// Directory.CreateDirectory(Path.Combine(DoomEternal.SavePath, "savegame.unencrypted"));
Utilities.Unarchive(ofd.FileName, Path.Combine(DoomEternal.SavePath, "savegame.unencrypted"));
} else {
Directory.CreateDirectory("tmp");
Utilities.Unarchive(ofd.FileName, "tmp");
DoomEternal.BulkEncrypt("tmp", suf.selectComboBox.Text);
Directory.Delete("tmp", true);
}
MessageBox.Show("Import success!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
break;
}
case "Export Backup": {
var suf = new SelectUUIDForm("Select Export Source UUID");
var suf = new SelectForm("Select Export Source");
if(suf.ShowDialog() == DialogResult.OK) {
using (var sfd = new SaveFileDialog()) {
sfd.Title = "Save Backup";
Expand All @@ -55,10 +60,14 @@ private void actionOkBtn_Click(object sender, EventArgs e) {
sfd.FilterIndex = 0;
sfd.FileName = "backup.zip";
if (sfd.ShowDialog() == DialogResult.OK) {
Directory.CreateDirectory("tmp");
DoomEternal.BulkDecrypt(suf.selectUidComboBox.Text, "tmp");
Utilities.Archive(sfd.FileName, "tmp");
Directory.Delete("tmp", true);
if (suf.selectComboBox.Text == "savegame.unencrypted") {
Utilities.Archive(sfd.FileName, Path.Combine(DoomEternal.SavePath, "savegame.unencrypted"));
} else {
Directory.CreateDirectory("tmp");
DoomEternal.BulkDecrypt(suf.selectComboBox.Text, "tmp");
Utilities.Archive(sfd.FileName, "tmp");
Directory.Delete("tmp", true);
}
MessageBox.Show("Export success!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
86 changes: 86 additions & 0 deletions SelectForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions SelectForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Windows.Forms;

using System.IO;

namespace DOOMSaveManager
{
public partial class SelectForm : Form
{
public SelectForm(string title = "") {
InitializeComponent();
if(!String.IsNullOrEmpty(title))
this.Text = title;
}

private void SelectForm_Load(object sender, EventArgs e) {
selectComboBox.Items.AddRange(DoomEternal.GetUserIDs());
if (selectComboBox.Items.Count > 0) {
selectComboBox.SelectedIndex = 0;
}
if (Directory.Exists(Path.Combine(DoomEternal.SavePath, "savegame.unencrypted"))) {
selectComboBox.Items.Add("savegame.unencrypted");
}
}

private void selectOkBtn_Click(object sender, EventArgs e) {
bool res = true;
if(String.IsNullOrEmpty(selectComboBox.Text)) {
res = false;
MessageBox.Show("No item has been selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if(res) {
DialogResult = DialogResult.OK;
}
}

private void selectCancelBtn_Click(object sender, EventArgs e) {
DialogResult = DialogResult.Cancel;
}
}
}
File renamed without changes.
86 changes: 0 additions & 86 deletions SelectUUIDForm.Designer.cs

This file was deleted.

38 changes: 0 additions & 38 deletions SelectUUIDForm.cs

This file was deleted.

4 changes: 1 addition & 3 deletions TransferForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public TransferForm() {

private void TransferForm_Load(object sender, EventArgs e) {
srcComboBox.Items.AddRange(DoomEternal.GetUserIDs());
if (srcComboBox.Items.Count == 0) {
DialogResult = DialogResult.Abort;
} else if(srcComboBox.Items.Count > 0) {
if(srcComboBox.Items.Count > 0) {
srcComboBox.SelectedIndex = 0;
}
if (Directory.Exists(Path.Combine(DoomEternal.SavePath, "savegame.unencrypted"))) {
Expand Down

0 comments on commit 3f3d0ec

Please sign in to comment.