Beispiel #1
0
    /// <summary>
    /// Gets a QR Message from the input <see cref="MysteryGift"/> data.
    /// </summary>
    /// <param name="mg">Gift data to encode</param>
    /// <returns>QR Message</returns>
    public static string GetMessage(DataMysteryGift mg)
    {
        var server = GetExploitURLPrefixWC(mg.Generation);
        var data   = mg.Write();

        return(GetMessageBase64(data, server));
    }
Beispiel #2
0
        public SAV_Wondercard(SaveFile sav, DataMysteryGift g = null)
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            SAV = (Origin = sav).Clone();
            mga = SAV.GiftAlbum;

            switch (SAV.Generation)
            {
            case 4:
                pba = PopulateViewGiftsG4().ToArray();
                break;

            case 5:
            case 6:
            case 7:
                pba = PopulateViewGiftsG567().ToArray();
                break;

            default:
                throw new ArgumentException("Game not supported.");
            }

            foreach (PictureBox pb in pba)
            {
                pb.AllowDrop        = true;
                pb.DragDrop        += BoxSlot_DragDrop;
                pb.DragEnter       += BoxSlot_DragEnter;
                pb.MouseDown       += BoxSlot_MouseDown;
                pb.ContextMenuStrip = mnuVSD;
            }

            SetGiftBoxes();
            GetReceivedFlags();

            if (LB_Received.Items.Count > 0)
            {
                LB_Received.SelectedIndex = 0;
            }

            DragEnter += Main_DragEnter;
            DragDrop  += Main_DragDrop;

            if (g == null)
            {
                ClickView(pba[0], null);
            }
            else
            {
                ViewGiftData(g);
            }
        }
Beispiel #3
0
        private void ViewGiftData(DataMysteryGift g)
        {
            try
            {
                // only check if the form is visible (not opening)
                if (Visible && g.GiftUsed && DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgMsyteryGiftUsedAlert, MsgMysteryGiftUsedFix))
                {
                    g.GiftUsed = false;
                }

                RTB.Lines        = g.GetDescription().ToArray();
                PB_Preview.Image = g.Sprite();
                mg = g;
            }
            catch (Exception e)
            {
                WinFormsUtil.Error(MsgMysteryGiftParseTypeUnknown, e);
                RTB.Clear();
            }
        }
Beispiel #4
0
        private void ClickSet(object sender, EventArgs e)
        {
            if (!mg.IsCardCompatible(SAV, out var msg))
            {
                WinFormsUtil.Alert(MsgMysteryGiftSlotFail, msg);
                return;
            }

            var pb    = WinFormsUtil.GetUnderlyingControl <PictureBox>(sender);
            int index = Array.IndexOf(pba, pb);

            // Hijack to the latest unfilled slot if index creates interstitial empty slots.
            int lastUnfilled = GetLastUnfilledByType(mg, mga);

            if (lastUnfilled > -1 && lastUnfilled < index)
            {
                index = lastUnfilled;
            }

            if (mg is PCD pcd && mga.Gifts[index] is PGT)
            {
                mg = pcd.Gift;
            }
Beispiel #5
0
        private void ViewGiftData(DataMysteryGift g)
        {
            try
            {
                // only check if the form is visible (not opening)
                if (Visible && g.GiftUsed && DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgMsyteryGiftUsedAlert, MsgMysteryGiftUsedFix))
                {
                    g.GiftUsed = false;
                }

                RTB.Lines        = g.GetDescription().ToArray();
                PB_Preview.Image = g.Sprite();
                mg = g;
            }
            // Some user input mystery gifts can have out-of-bounds values. Just swallow any exception.
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                WinFormsUtil.Error(MsgMysteryGiftParseTypeUnknown, e);
                RTB.Clear();
            }
        }
Beispiel #6
0
 public static Image GenerateQRCode(DataMysteryGift mg) => GenerateQRCode(QRMessageUtil.GetMessage(mg));