mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-15 08:31:21 -05:00
Add Interface for QR7 customization
This commit is contained in:
parent
8542138c13
commit
3d76ce191c
|
|
@ -1576,6 +1576,7 @@ private void clickQR(object sender, EventArgs e)
|
|||
if (!verifiedPKM()) return;
|
||||
PKM pkx = preparePKM();
|
||||
byte[] ekx = pkx.EncryptedBoxData;
|
||||
|
||||
const string server = "http://loadcode.projectpokemon.org/b1s1.html#"; // Rehosted with permission from LC/MS -- massive thanks!
|
||||
Image qr;
|
||||
switch (pkx.Format)
|
||||
|
|
@ -1594,7 +1595,7 @@ private void clickQR(object sender, EventArgs e)
|
|||
|
||||
string[] r = pkx.QRText;
|
||||
const string refURL = "PKHeX @ ProjectPokemon.org";
|
||||
new QR(qr, dragout.Image, r[0], r[1], r[2], $"{refURL} ({pkx.GetType().Name})").ShowDialog();
|
||||
new QR(qr, dragout.Image, r[0], r[1], r[2], $"{refURL} ({pkx.GetType().Name})", pkx).ShowDialog();
|
||||
}
|
||||
}
|
||||
private void clickFriendship(object sender, EventArgs e)
|
||||
|
|
|
|||
136
PKHeX/Misc/QR.Designer.cs
generated
136
PKHeX/Misc/QR.Designer.cs
generated
|
|
@ -31,18 +31,27 @@ private void InitializeComponent()
|
|||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QR));
|
||||
this.PB_QR = new System.Windows.Forms.PictureBox();
|
||||
this.FontLabel = new System.Windows.Forms.Label();
|
||||
this.NUD_Box = new System.Windows.Forms.NumericUpDown();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.NUD_Slot = new System.Windows.Forms.NumericUpDown();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.NUD_Copies = new System.Windows.Forms.NumericUpDown();
|
||||
this.B_Refresh = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_QR)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Box)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Slot)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Copies)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PB_QR
|
||||
//
|
||||
this.PB_QR.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
this.PB_QR.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.PB_QR.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||
this.PB_QR.Location = new System.Drawing.Point(2, 1);
|
||||
this.PB_QR.Name = "PB_QR";
|
||||
this.PB_QR.Size = new System.Drawing.Size(405, 405);
|
||||
this.PB_QR.Size = new System.Drawing.Size(405, 455);
|
||||
this.PB_QR.TabIndex = 0;
|
||||
this.PB_QR.TabStop = false;
|
||||
this.PB_QR.Click += new System.EventHandler(this.PB_QR_Click);
|
||||
|
|
@ -57,11 +66,121 @@ private void InitializeComponent()
|
|||
this.FontLabel.Text = "<3";
|
||||
this.FontLabel.Visible = false;
|
||||
//
|
||||
// NUD_Box
|
||||
//
|
||||
this.NUD_Box.Location = new System.Drawing.Point(38, 465);
|
||||
this.NUD_Box.Maximum = new decimal(new int[] {
|
||||
32,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Box.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Box.Name = "NUD_Box";
|
||||
this.NUD_Box.Size = new System.Drawing.Size(61, 20);
|
||||
this.NUD_Box.TabIndex = 2;
|
||||
this.NUD_Box.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(4, 467);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(28, 13);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Box:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(105, 467);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(28, 13);
|
||||
this.label2.TabIndex = 5;
|
||||
this.label2.Text = "Slot:";
|
||||
//
|
||||
// NUD_Slot
|
||||
//
|
||||
this.NUD_Slot.Location = new System.Drawing.Point(139, 465);
|
||||
this.NUD_Slot.Maximum = new decimal(new int[] {
|
||||
30,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Slot.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Slot.Name = "NUD_Slot";
|
||||
this.NUD_Slot.Size = new System.Drawing.Size(61, 20);
|
||||
this.NUD_Slot.TabIndex = 4;
|
||||
this.NUD_Slot.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(211, 467);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(42, 13);
|
||||
this.label3.TabIndex = 7;
|
||||
this.label3.Text = "Copies:";
|
||||
//
|
||||
// NUD_Copies
|
||||
//
|
||||
this.NUD_Copies.Location = new System.Drawing.Point(259, 465);
|
||||
this.NUD_Copies.Maximum = new decimal(new int[] {
|
||||
960,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Copies.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.NUD_Copies.Name = "NUD_Copies";
|
||||
this.NUD_Copies.Size = new System.Drawing.Size(52, 20);
|
||||
this.NUD_Copies.TabIndex = 6;
|
||||
this.NUD_Copies.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// B_Refresh
|
||||
//
|
||||
this.B_Refresh.Location = new System.Drawing.Point(317, 464);
|
||||
this.B_Refresh.Name = "B_Refresh";
|
||||
this.B_Refresh.Size = new System.Drawing.Size(80, 23);
|
||||
this.B_Refresh.TabIndex = 8;
|
||||
this.B_Refresh.Text = "Refresh";
|
||||
this.B_Refresh.UseVisualStyleBackColor = true;
|
||||
this.B_Refresh.Click += new System.EventHandler(this.updateBoxSlotCopies);
|
||||
//
|
||||
// QR
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(409, 407);
|
||||
this.Controls.Add(this.B_Refresh);
|
||||
this.Controls.Add(this.label3);
|
||||
this.Controls.Add(this.NUD_Copies);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.NUD_Slot);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.NUD_Box);
|
||||
this.Controls.Add(this.FontLabel);
|
||||
this.Controls.Add(this.PB_QR);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
|
|
@ -71,7 +190,11 @@ private void InitializeComponent()
|
|||
this.Name = "QR";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "PKHeX QR Code (Click QR to Copy Image)";
|
||||
this.Click += new System.EventHandler(this.updateBoxSlotCopies);
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_QR)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Box)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Slot)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_Copies)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
|
@ -81,5 +204,12 @@ private void InitializeComponent()
|
|||
|
||||
private System.Windows.Forms.PictureBox PB_QR;
|
||||
private System.Windows.Forms.Label FontLabel;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Box;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Slot;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.NumericUpDown NUD_Copies;
|
||||
private System.Windows.Forms.Button B_Refresh;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,27 +5,60 @@
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Windows.Forms;
|
||||
using PKHeX.Saves.Substructures;
|
||||
|
||||
namespace PKHeX
|
||||
{
|
||||
public partial class QR : Form
|
||||
{
|
||||
public QR(Image qr, Image pkm, string top, string bottom, string left, string right)
|
||||
public PKM pkm;
|
||||
|
||||
public Image qr;
|
||||
public Image icon;
|
||||
public string top;
|
||||
public string bottom;
|
||||
public string left;
|
||||
public string right;
|
||||
|
||||
public QR(Image qr, Image icon, string top, string bottom, string left, string right, PKM pk = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
pkm = pk;
|
||||
|
||||
// Layer on Text
|
||||
const int stretch = 50;
|
||||
Height += stretch;
|
||||
|
||||
if (pkm != null && pkm.Format == 7)
|
||||
{
|
||||
Height += 40;
|
||||
}
|
||||
|
||||
this.qr = qr;
|
||||
this.icon = icon;
|
||||
this.top = top;
|
||||
this.bottom = bottom;
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
|
||||
if (pkm != null && pkm.Format == 7)
|
||||
updateBoxSlotCopies(null, null);
|
||||
else
|
||||
RefreshImage();
|
||||
}
|
||||
|
||||
public void RefreshImage()
|
||||
{
|
||||
Font font = Main.unicode ? FontLabel.Font : PKX.getPKXFont((float)8.25);
|
||||
Image preview = new Bitmap(45, 45);
|
||||
using (Graphics gfx = Graphics.FromImage(preview))
|
||||
{
|
||||
gfx.FillRectangle(new SolidBrush(Color.White), 0, 0, preview.Width, preview.Height);
|
||||
gfx.DrawImage(pkm, preview.Width / 2 - pkm.Width / 2, preview.Height / 2 - pkm.Height / 2);
|
||||
gfx.DrawImage(icon, preview.Width / 2 - icon.Width / 2, preview.Height / 2 - icon.Height / 2);
|
||||
}
|
||||
// Layer on Preview Image
|
||||
Image pic = Util.LayerImage(qr, preview, qr.Width / 2 - preview.Width / 2, qr.Height / 2 - preview.Height / 2, 1);
|
||||
|
||||
// Layer on Text
|
||||
const int stretch = 50;
|
||||
Height += stretch;
|
||||
|
||||
Image newpic = new Bitmap(PB_QR.Width, PB_QR.Height);
|
||||
using (Graphics g = Graphics.FromImage(newpic))
|
||||
{
|
||||
|
|
@ -39,6 +72,7 @@ public QR(Image qr, Image pkm, string top, string bottom, string left, string ri
|
|||
}
|
||||
PB_QR.BackgroundImage = newpic;
|
||||
}
|
||||
|
||||
private void PB_QR_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Copy QR Image to Clipboard?")) return;
|
||||
|
|
@ -109,5 +143,22 @@ internal static Image getQRImage(byte[] data, string server)
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateBoxSlotCopies(object sender, EventArgs e)
|
||||
{
|
||||
if (pkm == null || pkm.Format != 7)
|
||||
throw new ArgumentException("Can't update QR7 if pkm isn't a PK7!");
|
||||
var box = (int) NUD_Box.Value - 1;
|
||||
var slot = (int) NUD_Slot.Value - 1;
|
||||
var copies = (int) NUD_Copies.Value;
|
||||
var new_qr = QR7.GenerateQRCode7((PK7)pkm, box, slot, copies);
|
||||
qr = new_qr;
|
||||
this.SuspendLayout();
|
||||
var old_t = top;
|
||||
top += $" (Box {box+1}, Slot {slot+1}, {copies} cop{(copies > 1 ? "ies" : "y")})";
|
||||
RefreshImage();
|
||||
top = old_t;
|
||||
this.ResumeLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user