Refactor qr server fetch & add notification

This commit is contained in:
Kurt 2017-03-10 20:35:18 -08:00
parent 08a7f818f2
commit bcbebf73ff
2 changed files with 21 additions and 3 deletions

View File

@ -275,7 +275,6 @@ public Main()
private static string BackupPath => Path.Combine(WorkingDirectory, "bak");
private const string ThreadPath = @"https://projectpokemon.org/PKHeX/";
private const string VersionPath = @"https://raw.githubusercontent.com/kwsch/PKHeX/master/PKHeX/Resources/text/version.txt";
private const string QR6Path = @"http://loadcode.projectpokemon.org/b1s1.html#"; // Rehosted with permission from LC/MS -- massive thanks!
#endregion
@ -1671,6 +1670,7 @@ private void setMarkings()
}
}
// Clicked Label Shortcuts //
private bool QR6Notified = false;
private void clickQR(object sender, EventArgs e)
{
if (ModifierKeys == Keys.Alt)
@ -1706,8 +1706,13 @@ private void clickQR(object sender, EventArgs e)
qr = QR.GenerateQRCode7((PK7) pkx);
break;
default:
bool qr6 = pkx.Format == 6;
qr = QR.getQRImage(pkx.EncryptedBoxData, qr6 ? QR6Path : QR.BadQRUrl);
if (pkx.Format == 6 && !QR6Notified) // hint that the user should not be using QR6 injection
{
WinFormsUtil.Alert("QR codes are deprecated in favor of other methods.",
"Consider utilizing homebrew or on-the-fly RAM editing custom firmware (PKMN-NTR).");
QR6Notified = true;
}
qr = QR.getQRImage(pkx.EncryptedBoxData, QR.getQRServer(pkx.Format));
break;
}

View File

@ -82,6 +82,8 @@ private void PB_QR_Click(object sender, EventArgs e)
// QR Utility
public const string BadQRUrl = "null/#"; // prefix to prevent URL from loading
public const string QR6Path = @"http://lunarcookies.github.io/b1s1.html";
internal static byte[] getQRData()
{
// Fetch data from QR code...
@ -176,5 +178,16 @@ public static Image GenerateQRCode(byte[] data, int ppm = 4)
using (var qr_code = new QRCode(qr_data))
return qr_code.GetGraphic(ppm);
}
public static string getQRServer(int format)
{
switch (format)
{
case 6:
return QR6Path;
default:
return BadQRUrl;
}
}
}
}