Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoboss committed Feb 1, 2019
1 parent e0664df commit 8018e7e
Show file tree
Hide file tree
Showing 7 changed files with 701 additions and 37 deletions.
4 changes: 4 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>

Expand Down
135 changes: 117 additions & 18 deletions Frontend.Designer.cs

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

71 changes: 62 additions & 9 deletions Frontend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace nsZip
{
public partial class Frontend : Form
{
private readonly bool VerifWhenCompressing = true;
private string OutputFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
private bool VerifyWhenCompressing = true;

public Frontend()
{
Expand All @@ -22,6 +22,21 @@ public Frontend()

private void Form1_Load(object sender, EventArgs e)
{
MaximumSize = Screen.FromControl(this).WorkingArea.Size;
}

//To properly fit the Form to if moved to a screen with another resolution
private void Frontend_Move(object sender, EventArgs e)
{
var newMaxSize = Screen.FromControl(this).WorkingArea.Size;
if (!MaximumSize.Equals(newMaxSize))
{
MaximumSize = newMaxSize;

//This line is so dumb but required
//for it to refresh it's size properly
Size = Size;
}
}

private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
Expand All @@ -35,26 +50,37 @@ private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
private static Keyset OpenKeyset()
{
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var homeSwitch = Path.Combine(home, ".switch");
var homeKeyFile = Path.Combine(home, ".switch", "prod.keys");
var homeTitleKeyFile = Path.Combine(home, ".switch", "title.keys");
var homeConsoleKeyFile = Path.Combine(home, ".switch", "console.keys");
string keyFile = null;
string titleKeyFile = null;
string consoleKeyFile = null;

if (File.Exists(homeKeyFile))
{
keyFile = homeKeyFile;
}
else

while (true)
{
if (File.Exists(homeKeyFile))
{
keyFile = homeKeyFile;
break;
}

if (File.Exists("keys.txt"))
{
keyFile = "keys.txt";
break;
}
else

Directory.CreateDirectory(homeSwitch);
Process.Start(homeSwitch);
var dialogResult = MessageBox.Show(
@"prod.keys not found! Dump them using Lockpick and put prod.keys (and title.keys if your NSP files have no ticket included) in """ +
homeSwitch + @""" Press OK when you're done.", @"prod.keys not found! Press OK when you're done.",
MessageBoxButtons.OKCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
if (dialogResult == DialogResult.Cancel)
{
Directory.CreateDirectory(Path.Combine(home, ".switch"));
throw new ArgumentException(
@"prod.keys not found! Please put prod.keys in " + homeKeyFile);
}
Expand Down Expand Up @@ -112,6 +138,10 @@ private void RunButton_Click(object sender, EventArgs e)
{
DecompressNSPZ(inFile);
}
else if (infileLowerCase.EndsWith("xciz"))
{
DecompressNSPZ(inFile);
}
else
{
throw new InvalidDataException($"Invalid file type {inFile}");
Expand Down Expand Up @@ -177,7 +207,7 @@ private void CompressExtracted(Keyset keyset)
TrimDeltaNCA.Process("decrypted", keyset, DebugOutput);
CompressFolder.Compress(DebugOutput, "decrypted", "compressed");

if (VerifWhenCompressing)
if (VerifyWhenCompressing)
{
cleanFolder("decrypted");
cleanFolder("encrypted");
Expand Down Expand Up @@ -290,5 +320,28 @@ private void DebugOutput_TextChanged(object sender, EventArgs e)
// scroll it automatically
richTextBox.ScrollToCaret();
}

private void nsZipGitHubLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("https://github.com/nicoboss/nsZip");
}

private void VerifyAfterCompressCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!VerifyAfterCompressCheckBox.Checked)
{
var dialogResult = MessageBox.Show(
@"Without verification corrupted unrecoverable nspz/nciz caused by bugs won't be discovered until you try to decompress them. Due to the early state of nsZip I highly recommend to leave it ON if you don't keep a backup copy of your nsp/xci. Do you really want to turn OFF verification?",
@"Do you really want to turn of verification after compression?", MessageBoxButtons.YesNo,
MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button2);
if (dialogResult != DialogResult.Yes)
{
VerifyAfterCompressCheckBox.Checked = true;
}
}

VerifyWhenCompressing = VerifyAfterCompressCheckBox.Checked;
}
}
}
2 changes: 1 addition & 1 deletion Frontend.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<value>277, 16</value>
</metadata>
<metadata name="SelectOutputDictionaryDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>539, 16</value>
<value>541, 12</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>54</value>
Expand Down
Loading

0 comments on commit 8018e7e

Please sign in to comment.