From f41149bb59b17fcb771c47afdf5d4adc5fa18133 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 28 Nov 2016 23:02:25 -0800 Subject: [PATCH] Minor cleanup Change pk6 type ref to pk7 (removes Training Bags from pk7 property list) Move QR7 extra text to bottom line Add placeholder pokefinder stat properties --- PKHeX/Misc/QR.cs | 47 ++++++++++---------- PKHeX/Saves/SAV7.cs | 52 ++++++++++++++++++++++- PKHeX/Subforms/PKM Editors/BatchEditor.cs | 2 +- 3 files changed, 74 insertions(+), 27 deletions(-) diff --git a/PKHeX/Misc/QR.cs b/PKHeX/Misc/QR.cs index 188c8bdae..c018b1c74 100644 --- a/PKHeX/Misc/QR.cs +++ b/PKHeX/Misc/QR.cs @@ -11,16 +11,17 @@ namespace PKHeX { public partial class QR : Form { - public PKM pkm; + private readonly PKM pkm; + private readonly Image icon; + private Image qr; - public Image qr; - public Image icon; - public string top; - public string bottom; - public string left; - public string right; + private readonly string Line1; + private readonly string Line2; + private readonly string Line3; + private readonly string Line4; + private string extraText; - public QR(Image qr, Image icon, string top, string bottom, string left, string right, PKM pk = null) + public QR(Image qr, Image icon, string line1, string line2, string line3, string line4, PKM pk = null) { InitializeComponent(); pkm = pk; @@ -29,17 +30,15 @@ public QR(Image qr, Image icon, string top, string bottom, string left, string r const int stretch = 50; Height += stretch; - if (pkm != null && pkm.Format == 7) - { + 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; + Line1 = line1; + Line2 = line2; + Line3 = line3; + Line4 = line4; if (pkm != null && pkm.Format == 7) updateBoxSlotCopies(null, null); @@ -47,7 +46,7 @@ public QR(Image qr, Image icon, string top, string bottom, string left, string r RefreshImage(); } - public void RefreshImage() + private void RefreshImage() { Font font = Main.unicode ? FontLabel.Font : PKX.getPKXFont((float)8.25); Image preview = new Bitmap(45, 45); @@ -65,10 +64,10 @@ public void RefreshImage() g.FillRectangle(new SolidBrush(Color.White), 0, 0, newpic.Width, newpic.Height); g.DrawImage(pic, 0, 0); - g.DrawString(top, font, Brushes.Black, new PointF(18, qr.Height - 5)); - g.DrawString(bottom, font, Brushes.Black, new PointF(18, qr.Height + 8)); - g.DrawString(left.Replace(Environment.NewLine, "/").Replace("//", " ").Replace(":/", ": "), font, Brushes.Black, new PointF(18, qr.Height + 20)); - g.DrawString(right, font, Brushes.Black, new PointF(18, qr.Height + 32)); + g.DrawString(Line1, font, Brushes.Black, new PointF(18, qr.Height - 5)); + g.DrawString(Line2, font, Brushes.Black, new PointF(18, qr.Height + 8)); + g.DrawString(Line3.Replace(Environment.NewLine, "/").Replace("//", " ").Replace(":/", ": "), font, Brushes.Black, new PointF(18, qr.Height + 20)); + g.DrawString(Line4 + extraText, font, Brushes.Black, new PointF(18, qr.Height + 32)); } PB_QR.BackgroundImage = newpic; } @@ -153,12 +152,10 @@ private void updateBoxSlotCopies(object sender, EventArgs e) 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")})"; + SuspendLayout(); + extraText = $" (Box {box+1}, Slot {slot+1}, {copies} cop{(copies > 1 ? "ies" : "y")})"; RefreshImage(); - top = old_t; - this.ResumeLayout(); + ResumeLayout(); } } } \ No newline at end of file diff --git a/PKHeX/Saves/SAV7.cs b/PKHeX/Saves/SAV7.cs index d1a7ff38d..bf5feeb7a 100644 --- a/PKHeX/Saves/SAV7.cs +++ b/PKHeX/Saves/SAV7.cs @@ -195,7 +195,7 @@ private void getSAVOffsets() /* 23 */ // = 0x54400; // [100] FishingSpot /* 24 */ // = 0x54600; // [10528] LiveMatchData /* 25 */ // = 0x64C00; // [204] BattleSpotData - /* 26 */ // = 0x65000; // [B60] PokeFinderSave + /* 26 */ PokeFinderSave = 0x65000; // [B60] PokeFinderSave /* 27 */ WondercardFlags = 0x65C00; // [3F50] MysteryGiftSave /* 28 */ // = 0x69C00; // [358] Record /* 29 */ // = 0x6A000; // [728] Data Block @@ -243,6 +243,7 @@ private void getSAVOffsets() private int ItemInfo { get; set; } = int.MinValue; private int Overworld { get; set; } = int.MinValue; private int JoinFestaData { get; set; } = int.MinValue; + private int PokeFinderSave { get; set; } = int.MinValue; // Accessible as SAV7 public int TrainerCard { get; private set; } = 0x14000; @@ -465,6 +466,55 @@ public override int PlayedSeconds public ulong AlolaTime { get { return BitConverter.ToUInt64(Data, AdventureInfo + 0x48); } set { BitConverter.GetBytes(value).CopyTo(Data, AdventureInfo+0x48);} } + + public ushort PokeFinderCameraVersion + { + get { return BitConverter.ToUInt16(Data, PokeFinderSave + 0x00); } + set { BitConverter.GetBytes(value).CopyTo(Data, PokeFinderSave + 0x00); } + } + public bool PokeFinderGyroFlag + { + get { return BitConverter.ToUInt16(Data, PokeFinderSave + 0x02) == 1; } + set { BitConverter.GetBytes((ushort)(value ? 1 : 0)).CopyTo(Data, PokeFinderSave + 0x04); } + } + public uint PokeFinderSnapCount + { + get { return BitConverter.ToUInt32(Data, PokeFinderSave + 0x04); } + set + { + if (value > 9999999) // Top bound is unchecked, check anyway + value = 9999999; + BitConverter.GetBytes(value).CopyTo(Data, PokeFinderSave + 0x04); + } + } + public uint PokeFinderThumbsTotalValue + { + get { return BitConverter.ToUInt32(Data, PokeFinderSave + 0x0C); } + set + { + BitConverter.GetBytes(value).CopyTo(Data, PokeFinderSave + 0x0C); + + } + } + public uint PokeFinderThumbsHighValue + { + get { return BitConverter.ToUInt32(Data, PokeFinderSave + 0x10); } + set + { + if (value > 9999999) // 9mil; + value = 9999999; + BitConverter.GetBytes(value).CopyTo(Data, PokeFinderSave + 0x10); + + if (value > PokeFinderThumbsTotalValue) + PokeFinderThumbsHighValue = value; + } + } + public ushort PokeFinderTutorialFlags + { + get { return BitConverter.ToUInt16(Data, PokeFinderSave + 0x14); } + set { BitConverter.GetBytes(value).CopyTo(Data, PokeFinderSave + 0x14); } + } + // Inventory public override InventoryPouch[] Inventory { diff --git a/PKHeX/Subforms/PKM Editors/BatchEditor.cs b/PKHeX/Subforms/PKM Editors/BatchEditor.cs index e312697ed..344b3bea2 100644 --- a/PKHeX/Subforms/PKM Editors/BatchEditor.cs +++ b/PKHeX/Subforms/PKM Editors/BatchEditor.cs @@ -21,7 +21,7 @@ public BatchEditor() private const string CONST_RAND = "$rand"; private const string CONST_SHINY = "$shiny"; private int currentFormat = -1; - private static readonly string[] pk7 = ReflectUtil.getPropertiesCanWritePublic(typeof(PK6)).OrderBy(i => i).ToArray(); + private static readonly string[] pk7 = ReflectUtil.getPropertiesCanWritePublic(typeof(PK7)).OrderBy(i => i).ToArray(); private static readonly string[] pk6 = ReflectUtil.getPropertiesCanWritePublic(typeof(PK6)).OrderBy(i=>i).ToArray(); private static readonly string[] pk5 = ReflectUtil.getPropertiesCanWritePublic(typeof(PK5)).OrderBy(i=>i).ToArray(); private static readonly string[] pk4 = ReflectUtil.getPropertiesCanWritePublic(typeof(PK4)).OrderBy(i=>i).ToArray();