private void clickSet(object sender, EventArgs e) { if (!checkSpecialWonderCard(mg)) { return; } sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox; int index = Array.IndexOf(pba, sender); // Hijack to the latest unfilled slot if index creates interstitial empty slots. int lastUnfilled = Array.FindIndex(pba, p => p.Image == null); if (lastUnfilled > -1 && lastUnfilled < index) { index = lastUnfilled; } if (mg.Data.Length != mga.Gifts[index].Data.Length) { Util.Alert("Can't set slot here.", $"{mg.GetType()} != {mga.Gifts[index].GetType()}"); return; } setBackground(index, Properties.Resources.slotSet); mga.Gifts[index] = mg; setGiftBoxes(); setCardID(mg.CardID); }
private void L_QR_Click(object sender, EventArgs e) { if (ModifierKeys == Keys.Alt) { byte[] data = QR.getQRData(); if (data == null) { return; } string[] types = mga.Gifts.Select(g => g.GetType().Name).Distinct().ToArray(); MysteryGift gift = MysteryGift.getMysteryGift(data); string giftType = gift.GetType().Name; if (mga.Gifts.All(card => card.Data.Length != data.Length)) { Util.Alert("Decoded data not valid for loaded save file.", $"QR Data Size: 0x{data.Length.ToString("X")}"); } else if (types.All(type => type != giftType)) { Util.Alert("Gift type is not compatible with the save file.", $"QR Gift Type: {gift.GetType().Name}" + Environment.NewLine + $"Expected Types: {string.Join(", ", types)}"); } else { try { viewGiftData(gift); } catch { Util.Alert("Error loading Mystery Gift data."); } } } else { if (mg.Data.SequenceEqual(new byte[mg.Data.Length])) { Util.Alert("No wondercard data found in loaded slot!"); return; } if (SAV.Generation == 6 && mg.Item == 726 && mg.IsItem) { Util.Alert("Eon Ticket Wonder Cards will not function properly", "Inject to the save file instead."); return; } const string server = "http://lunarcookies.github.io/wc.html#"; Image qr = QR.getQRImage(mg.Data, server); if (qr == null) { return; } string desc = $"({mg.GetType().Name}) {getDescription(mg)}"; new QR(qr, PB_Preview.Image, desc, "", "", "PKHeX Wonder Card @ ProjectPokemon.org").ShowDialog(); } }