Ejemplo n.º 1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            bool cp = keyData == (Keys.Control | Keys.C) && ActiveControl is DataGridView;

            if (!cp)
            {
                return(base.ProcessCmdKey(ref msg, keyData));
            }

            string data = dgData.GetClipboardContent().GetText();
            var    dr   = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgReportExportTable);

            if (dr != DialogResult.Yes)
            {
                WinFormsUtil.SetClipboardText(data);
                return(true);
            }

            // Reformat datagrid clipboard content
            string[] lines    = data.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            string[] newlines = ConvertTabbedToRedditTable(lines);
            WinFormsUtil.SetClipboardText(string.Join(Environment.NewLine, newlines));
            return(true);
        }
Ejemplo n.º 2
0
        private void GetBags()
        {
            foreach (InventoryPouch pouch in Pouches)
            {
                DataGridView dgv = Controls.Find(DGVPrefix + pouch.Type, true).FirstOrDefault() as DataGridView;

                // Sanity Screen
                var invalid        = pouch.Items.Where(item => item.Index != 0 && !pouch.LegalItems.Contains((ushort)item.Index)).ToArray();
                var outOfBounds    = invalid.Where(item => item.Index >= itemlist.Length).ToArray();
                var incorrectPouch = invalid.Where(item => item.Index < itemlist.Length).ToArray();

                if (outOfBounds.Length > 0)
                {
                    WinFormsUtil.Error(MsgItemPouchUnknown, $"Item ID(s): {string.Join(", ", outOfBounds.Select(item => item.Index))}");
                }
                if (!Main.HaX && incorrectPouch.Length > 0)
                {
                    WinFormsUtil.Alert(string.Format(MsgItemPouchRemoved, pouch.Type), string.Join(", ", incorrectPouch.Select(item => itemlist[item.Index])), MsgItemPouchWarning);
                }

                pouch.Sanitize(Main.HaX, itemlist.Length - 1);
                GetBag(dgv, pouch);
            }
        }
Ejemplo n.º 3
0
        private bool IsSpecialWonderCard(MysteryGift g)
        {
            if (SAV.Generation != 6)
            {
                return(true);
            }

            if (g is WC6)
            {
                if (g.CardID == 2048 && g.ItemID == 726) // Eon Ticket (OR/AS)
                {
                    if (!SAV.ORAS || ((SAV6)SAV).EonTicket < 0)
                    {
                        goto reject;
                    }
                    BitConverter.GetBytes(WC6.EonTicketConst).CopyTo(SAV.Data, ((SAV6)SAV).EonTicket);
                }
            }

            return(true);

            reject : WinFormsUtil.Alert("Unable to insert the Mystery Gift.", "Does this Mystery Gift really belong to this game?");
            return(false);
        }
Ejemplo n.º 4
0
 private void B_Output_Click(object sender, EventArgs e)
 {
     WinFormsUtil.ExportMGDialog(mg, SAV.Version);
 }
Ejemplo n.º 5
0
        public SAV_SimpleTrainer(SaveFile sav)
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            SAV     = (Origin = sav).Clone();
            Loading = true;

            cba = new[] { CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_6, CHK_7, CHK_8 };
            TB_OTName.MaxLength = SAV.OTLength;
            B_MaxCash.Click    += (sender, e) => MT_Money.Text = SAV.MaxMoney.ToString();
            B_MaxCoins.Click   += (sender, e) => MT_Coins.Text = SAV.MaxCoins.ToString();
            MT_Money.Mask       = "00000000000".Substring(0, SAV.MaxMoney.ToString().Length);
            MT_Coins.Mask       = "00000000000".Substring(0, SAV.MaxCoins.ToString().Length);

            CB_Gender.Items.Clear();
            CB_Gender.Items.AddRange(Main.GenderSymbols.Take(2).ToArray()); // m/f depending on unicode selection

            L_SID.Visible     = MT_SID.Visible = SAV.Generation > 2;
            L_Coins.Visible   = B_MaxCoins.Visible = MT_Coins.Visible = SAV.Generation < 3;
            CB_Gender.Visible = SAV.Generation > 1;

            L_PikaFriend.Visible = MT_PikaFriend.Visible = SAV.Generation == 1;

            TB_OTName.Text          = SAV.OT;
            CB_Gender.SelectedIndex = SAV.Gender;
            MT_TID.Text             = SAV.TID.ToString("00000");
            MT_SID.Text             = SAV.SID.ToString("00000");
            MT_Money.Text           = SAV.Money.ToString();
            MT_Hours.Text           = SAV.PlayedHours.ToString();
            MT_Minutes.Text         = SAV.PlayedMinutes.ToString();
            MT_Seconds.Text         = SAV.PlayedSeconds.ToString();

            int badgeval = 0;

            if (SAV is SAV1 sav1)
            {
                MT_Coins.Text = sav1.Coin.ToString();
                badgeval      = sav1.Badges;

                L_Started.Visible = L_Fame.Visible = false;
                CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
                CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
                GB_Map.Visible     = false;
                GB_Options.Visible = true;
                CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
                CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo", "Earphone2", "Earphone3" });
                CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });

                CHK_BattleEffects.Checked    = sav1.BattleEffects;
                CB_BattleStyle.SelectedIndex = sav1.BattleStyleSwitch ? 0 : 1;
                CB_SoundType.SelectedIndex   = sav1.Sound;
                CB_TextSpeed.SelectedIndex   = sav1.TextSpeed;

                MT_PikaFriend.Text = sav1.PikaFriendship.ToString();
            }

            if (SAV is SAV2 sav2)
            {
                MT_Coins.Text = sav2.Coin.ToString();

                L_Started.Visible = L_Fame.Visible = false;
                CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
                CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
                GB_Map.Visible     = false;
                GB_Options.Visible = true;
                CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
                CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo" });
                CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });

                CHK_BattleEffects.Checked    = sav2.BattleEffects;
                CB_BattleStyle.SelectedIndex = sav2.BattleStyleSwitch ? 0 : 1;
                CB_SoundType.SelectedIndex   = sav2.Sound > 0 ? 1 : 0;
                CB_TextSpeed.SelectedIndex   = sav2.TextSpeed;
                badgeval = sav2.Badges;
                cba      = new[] { CHK_1, CHK_2, CHK_3, CHK_4, CHK_6, CHK_5, CHK_7, CHK_8, CHK_H1, CHK_H2, CHK_H3, CHK_H4, CHK_H5, CHK_H6, CHK_H7, CHK_H8 };
            }

            if (SAV is SAV3 sav3)
            {
                GB_Map.Visible = false;
                switch (sav3.Version)
                {
                case GameVersion.E: badgeval = sav3.Badges; break;

                case GameVersion.FRLG: badgeval = sav3.Badges; break;

                default: GB_Badges.Visible = false; break;     // RS
                }

                L_Started.Visible = L_Fame.Visible = false;
                CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
                CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
            }
            if (SAV is SAV3Colosseum || SAV is SAV3XD)
            {
                GB_Map.Visible    = false;
                GB_Badges.Visible = false;
                L_Started.Visible = L_Fame.Visible = false;
                CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
                CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
                GB_Adventure.Visible           = false;
                return;
            }

            if (SAV is SAV4 sav4)
            {
                NUD_M.Value = sav4.M;
                NUD_X.Value = sav4.X;
                NUD_Z.Value = sav4.Z;
                NUD_Y.Value = sav4.Y;

                badgeval = sav4.Badges;
                if (sav4.Version == GameVersion.HGSS)
                {
                    badgeval |= sav4.Badges16 << 8;
                    cba       = cba.Concat(new[] { CHK_H1, CHK_H2, CHK_H3, CHK_H4, CHK_H5, CHK_H6, CHK_H7, CHK_H8 }).ToArray();
                }
            }
            else if (SAV is SAV5 s)
            {
                foreach (var control in new Control[] { L_Coins, B_MaxCoins, MT_Coins })
                {
                    var pos = control.Location;
                    GB_Badges.Controls.Add(control);
                    control.Location = pos;
                    control.Visible  = true;
                }
                L_Coins.Text  = "BP"; // no translation boo
                MT_Coins.Text = s.BP.ToString();

                NUD_M.Value = s.M;
                NUD_X.Value = s.X;
                NUD_Z.Value = s.Z;
                NUD_Y.Value = s.Y;

                badgeval = s.Badges;
            }

            for (int i = 0; i < cba.Length; i++)
            {
                cba[i].Visible = true;
                cba[i].Checked = (badgeval & 1 << i) != 0;
            }

            CAL_HoFDate.Value            = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame);
            CAL_HoFTime.Value            = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame % 86400);
            CAL_AdventureStartDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart);
            CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart % 86400);

            Loading = false;
        }
Ejemplo n.º 6
0
        public SAV_MysteryGiftDB(PKMEditor tabs, SAVEditor sav)
        {
            InitializeComponent();

            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);

            SAV       = sav.SAV;
            BoxView   = sav;
            PKME_Tabs = tabs;

            // Preset Filters to only show PKM available for loaded save
            CB_FormatComparator.SelectedIndex = 3; // <=

            var grid        = MysteryPokeGrid;
            var smallWidth  = grid.Width;
            var smallHeight = grid.Height;

            grid.InitializeGrid(6, 11, SpriteUtil.Spriter);
            grid.SetBackground(Resources.box_wp_clean);
            var newWidth  = grid.Width;
            var newHeight = grid.Height;
            var wdelta    = newWidth - smallWidth;

            if (wdelta != 0)
            {
                Width += wdelta;
            }
            var hdelta = newHeight - smallHeight;

            if (hdelta != 0)
            {
                Height += hdelta;
            }

            PKXBOXES = grid.Entries.ToArray();

            // Enable Scrolling when hovered over
            foreach (var slot in PKXBOXES)
            {
                // Enable Click
                slot.MouseClick += (sender, e) =>
                {
                    if (ModifierKeys == Keys.Control)
                    {
                        ClickView(sender !, e);
                    }
                };

                slot.ContextMenuStrip = mnu;
            }

            Counter              = L_Count.Text;
            Viewed               = L_Viewed.Text;
            L_Viewed.Text        = string.Empty; // invis for now
            L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);

            // Load Data
            B_Search.Enabled = false;
            L_Count.Text     = "Loading...";
            new Task(LoadDatabase).Start();

            CB_Format.Items[0] = MsgAny;
            CenterToParent();
        }
Ejemplo n.º 7
0
        private void pbBoxSlot_MouseMove(object sender, MouseEventArgs e)
        {
            if (DragInfo.DragDropInProgress)
            {
                return;
            }

            if (!DragInfo.LeftMouseIsDown)
            {
                return;
            }

            // The goal is to create a temporary PKX file for the underlying Pokemon
            // and use that file to perform a drag drop operation.

            // Abort if there is no Pokemon in the given slot.
            PictureBox pb = (PictureBox)sender;

            if (pb.Image == null)
            {
                return;
            }

            int slot = getSlot(pb);
            int box  = slot >= 30 ? -1 : CB_BoxSelect.SelectedIndex;

            if (SAV.getIsSlotLocked(box, slot))
            {
                return;
            }

            // Set flag to prevent re-entering.
            DragInfo.DragDropInProgress = true;

            DragInfo.Source.Parent = this;
            DragInfo.Source.Slot   = slot;
            DragInfo.Source.Box    = box;
            DragInfo.Source.Offset = getPKXOffset(DragInfo.Source.Slot);

            // Prepare Data
            DragInfo.Source.Data = SAV.getData(DragInfo.Source.Offset, SAV.SIZE_STORED);

            // Make a new file name based off the PID
            byte[] dragdata = SAV.decryptPKM(DragInfo.Source.Data);
            Array.Resize(ref dragdata, SAV.SIZE_STORED);
            PKM    pkx      = SAV.getPKM(dragdata);
            string filename = pkx.FileName;

            // Make File
            string newfile = Path.Combine(Path.GetTempPath(), Util.CleanFileName(filename));

            try
            {
                File.WriteAllBytes(newfile, dragdata);
                var img = (Bitmap)pb.Image;
                DragInfo.Cursor    = Cursor.Current = new Cursor(img.GetHicon());
                pb.Image           = null;
                pb.BackgroundImage = Resources.slotDrag;
                // Thread Blocks on DoDragDrop
                DragInfo.CurrentPath = newfile;
                DragDropEffects result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move);
                if (!DragInfo.Source.IsValid || result != DragDropEffects.Link) // not dropped to another box slot, restore img
                {
                    pb.Image = img;
                }
                else // refresh image
                {
                    getQuickFiller(pb, SAV.getStoredSlot(DragInfo.Source.Offset));
                }
                pb.BackgroundImage = null;

                if (DragInfo.SameBox && DragInfo.Destination.IsValid)
                {
                    if (SAV.getIsTeamSet(box, DragInfo.Destination.Slot) ^ SAV.getIsTeamSet(box, DragInfo.Source.Slot))
                    {
                        getQuickFiller(SlotPictureBoxes[DragInfo.Destination.Slot], SAV.getStoredSlot(DragInfo.Destination.Offset));
                    }
                    else
                    {
                        SlotPictureBoxes[DragInfo.Destination.Slot].Image = img;
                    }
                }
            }
            catch (Exception x)
            {
                WinFormsUtil.Error("Drag & Drop Error", x);
            }
            parent.notifyBoxViewerRefresh();
            DragInfo.Reset();
            Cursor = DefaultCursor;

            // Browser apps need time to load data since the file isn't moved to a location on the user's local storage.
            // Tested 10ms -> too quick, 100ms was fine. 500ms should be safe?
            new Thread(() =>
            {
                Thread.Sleep(500);
                if (File.Exists(newfile) && DragInfo.CurrentPath == null)
                {
                    File.Delete(newfile);
                }
            }).Start();
        }
Ejemplo n.º 8
0
        private void Save()
        {
            SAV.Game   = (byte)(CB_Game.SelectedIndex + 0x18);
            SAV.Gender = (byte)CB_Gender.SelectedIndex;

            SAV.TID           = (ushort)Util.ToUInt32(MT_TID.Text);
            SAV.SID           = (ushort)Util.ToUInt32(MT_SID.Text);
            SAV.Money         = Util.ToUInt32(MT_Money.Text);
            SAV.Region        = WinFormsUtil.GetIndex(CB_Region);
            SAV.Country       = WinFormsUtil.GetIndex(CB_Country);
            SAV.ConsoleRegion = WinFormsUtil.GetIndex(CB_3DSReg);
            SAV.Language      = WinFormsUtil.GetIndex(CB_Language);

            SAV.OT = TB_OTName.Text;

            var status = SAV.Status;

            status.Saying1 = TB_Saying1.Text;
            status.Saying2 = TB_Saying2.Text;
            status.Saying3 = TB_Saying3.Text;
            status.Saying4 = TB_Saying4.Text;
            status.Saying5 = TB_Saying5.Text;

            // Copy Maison Data in
            if (SAV is ISaveBlock6Main xyao)
            {
                for (int i = 0; i < MaisonBlock.MaisonStatCount; i++)
                {
                    xyao.Maison.SetMaisonStat(i, ushort.Parse(MaisonRecords[i].Text));
                }
            }

            // Copy Position
            var sit = SAV.Situation;

            if (GB_Map.Enabled && MapUpdated)
            {
                sit.M = (int)NUD_M.Value;
                sit.X = (float)NUD_X.Value;
                sit.Z = (float)NUD_Z.Value;
                sit.Y = (float)NUD_Y.Value;
            }

            SAV.BP = ushort.Parse(TB_BP.Text);
            // Set Current PokéMiles
            SAV.SetRecord(63, Util.ToInt32(TB_PM.Text));
            // Set Max Obtained Pokémiles
            SAV.SetRecord(64, Util.ToInt32(TB_PM.Text));
            sit.Style = byte.Parse(TB_Style.Text);

            // Copy Badges
            int badgeval = 0;

            for (int i = 0; i < 8; i++)
            {
                badgeval |= (cba[i].Checked ? 1 : 0) << i;
            }
            SAV.Badges = badgeval;

            // Save PlayTime
            SAV.PlayedHours   = ushort.Parse(MT_Hours.Text);
            SAV.PlayedMinutes = ushort.Parse(MT_Minutes.Text) % 60;
            SAV.PlayedSeconds = ushort.Parse(MT_Seconds.Text) % 60;

            // Sprite
            SAV.MultiplayerSpriteID = Convert.ToByte(CB_MultiplayerSprite.SelectedValue);

            // Appearance
            if (SAV is SAV6XY xy)
            {
                var xystat = (MyStatus6XY)xy.Status;
                xystat.Fashion = (TrainerFashion6)PG_CurrentAppearance.SelectedObject;
                xystat.OT_Nick = TB_TRNick.Text;
            }

            // Vivillon
            SAV.Vivillon = CB_Vivillon.SelectedIndex;

            SAV.SecondsToStart = (uint)DateUtil.GetSecondsFrom2000(CAL_AdventureStartDate.Value, CAL_AdventureStartTime.Value);
            SAV.SecondsToFame  = (uint)DateUtil.GetSecondsFrom2000(CAL_HoFDate.Value, CAL_HoFTime.Value);

            if (SAV.Played.LastSavedDate.HasValue)
            {
                SAV.Played.LastSavedDate = new DateTime(CAL_LastSavedDate.Value.Year, CAL_LastSavedDate.Value.Month, CAL_LastSavedDate.Value.Day, CAL_LastSavedTime.Value.Hour, CAL_LastSavedTime.Value.Minute, 0);
            }

            status.IsMegaEvolutionUnlocked = CHK_MegaUnlocked.Checked;
            status.IsMegaRayquazaUnlocked  = CHK_MegaRayquazaUnlocked.Checked;
        }
Ejemplo n.º 9
0
 private void B_CopyText_Click(object sender, EventArgs e)
 {
     WinFormsUtil.SetClipboardText(RTB.Text);
 }
Ejemplo n.º 10
0
        private void pbBoxSlot_DragDrop(object sender, DragEventArgs e)
        {
            int index = Array.IndexOf(pba, sender);

            // Hijack to the latest unfilled slot if index creates interstitial empty slots.
            int lastUnfilled = getLastUnfilledByType(mg, mga);
            if (lastUnfilled > -1 && lastUnfilled < index && mga.Gifts[lastUnfilled].Type == mga.Gifts[index].Type)
                index = lastUnfilled;
            
            if (wc_slot == -1) // dropped
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

                if (files.Length < 1)
                    return;
                if (PCD.Size < (int)new FileInfo(files[0]).Length)
                { WinFormsUtil.Alert("Data size invalid.", files[0]); return; }
                
                byte[] data = File.ReadAllBytes(files[0]);
                MysteryGift gift = MysteryGift.getMysteryGift(data, new FileInfo(files[0]).Extension);

                if (gift is PCD && mga.Gifts[index] is PGT)
                    gift = (gift as PCD).Gift;
                else if (gift.Type != mga.Gifts[index].Type)
                {
                    WinFormsUtil.Alert("Can't set slot here.", $"{gift.Type} != {mga.Gifts[index].Type}");
                    return;
                }
                setBackground(index, Properties.Resources.slotSet);
                mga.Gifts[index] = gift.Clone();
                
                setCardID(mga.Gifts[index].CardID);
                viewGiftData(mga.Gifts[index]);
            }
            else // Swap Data
            {
                MysteryGift s1 = mga.Gifts[index];
                MysteryGift s2 = mga.Gifts[wc_slot];

                if (s2 is PCD && s1 is PGT)
                {
                    // set the PGT to the PGT slot instead
                    viewGiftData(s2);
                    clickSet(pba[index], null);
                    { WinFormsUtil.Alert($"Set {s2.Type} gift to {s1.Type} slot."); return; }
                }
                if (s1.Type != s2.Type)
                { WinFormsUtil.Alert($"Can't swap {s2.Type} with {s1.Type}."); return; }
                mga.Gifts[wc_slot] = s1;
                mga.Gifts[index] = s2;

                if (mga.Gifts[wc_slot].Empty) // empty slot created, slide down
                {
                    int i = wc_slot;
                    while (i < index)
                    {
                        if (mga.Gifts[i + 1].Empty)
                            break;
                        if (mga.Gifts[i + 1].Type != mga.Gifts[i].Type)
                            break;

                        i++;

                        var mg1 = mga.Gifts[i];
                        var mg2 = mga.Gifts[i - 1];

                        mga.Gifts[i - 1] = mg1;
                        mga.Gifts[i] = mg2;
                    }
                    index = i-1;
                }
            }
            setBackground(index, Properties.Resources.slotView);
            setGiftBoxes();
        }
Ejemplo n.º 11
0
 private void Main_DragDrop(object sender, DragEventArgs e)
 {
     string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
     LoadSAV(WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "FlagDiff Researcher:", "Yes: Old Save" + Environment.NewLine + "No: New Save") == DialogResult.Yes ? B_LoadOld : B_LoadNew, files[0]);
 }
Ejemplo n.º 12
0
        private void DiffSaves()
        {
            if (!File.Exists(TB_OldSAV.Text))
            {
                WinFormsUtil.Alert("Save 1 path invalid."); return;
            }
            if (!File.Exists(TB_NewSAV.Text))
            {
                WinFormsUtil.Alert("Save 2 path invalid."); return;
            }
            if (new FileInfo(TB_OldSAV.Text).Length > 0x100000)
            {
                WinFormsUtil.Alert("Save 1 file invalid."); return;
            }
            if (new FileInfo(TB_NewSAV.Text).Length > 0x100000)
            {
                WinFormsUtil.Alert("Save 2 file invalid."); return;
            }

            SaveFile s1 = SaveUtil.GetVariantSAV(File.ReadAllBytes(TB_OldSAV.Text));
            SaveFile s2 = SaveUtil.GetVariantSAV(File.ReadAllBytes(TB_NewSAV.Text));

            if (s1.GetType() != s2.GetType())
            {
                WinFormsUtil.Alert("Save types are different.", $"S1: {s1.GetType().Name}", $"S2: {s2.GetType().Name}"); return;
            }
            if (s1.Version != s2.Version)
            {
                WinFormsUtil.Alert("Save versions are different.", $"S1: {s1.Version}", $"S2: {s2.Version}"); return;
            }

            string tbIsSet = "";
            string tbUnSet = "";

            try
            {
                bool[] oldBits = s1.EventFlags;
                bool[] newBits = s2.EventFlags;
                if (oldBits.Length != newBits.Length)
                {
                    WinFormsUtil.Alert("Event flag lengths for games are different.", $"S1: {(GameVersion)s1.Game}", $"S2: {(GameVersion)s2.Game}"); return;
                }

                for (int i = 0; i < oldBits.Length; i++)
                {
                    if (oldBits[i] == newBits[i])
                    {
                        continue;
                    }
                    if (newBits[i])
                    {
                        tbIsSet += i.ToString("0000") + ",";
                    }
                    else
                    {
                        tbUnSet += i.ToString("0000") + ",";
                    }
                }
            }
            catch (Exception e)
            {
                WinFormsUtil.Error("An unexpected error has occurred.", e);
                Debug.WriteLine(e);
            }
            TB_IsSet.Text = tbIsSet;
            TB_UnSet.Text = tbUnSet;

            string r = "";

            try
            {
                ushort[] oldConst = s1.EventConsts;
                ushort[] newConst = s2.EventConsts;
                if (oldConst.Length != newConst.Length)
                {
                    WinFormsUtil.Alert("Event flag lengths for games are different.", $"S1: {(GameVersion)s1.Game}", $"S2: {(GameVersion)s2.Game}"); return;
                }

                for (int i = 0; i < newConst.Length; i++)
                {
                    if (oldConst[i] != newConst[i])
                    {
                        r += $"{i}: {oldConst[i]}->{newConst[i]}{Environment.NewLine}";
                    }
                }
            }
            catch (Exception e)
            {
                WinFormsUtil.Error("An unexpected error has occurred.", e);
                Debug.WriteLine(e);
            }

            if (string.IsNullOrEmpty(r))
            {
                WinFormsUtil.Alert("No Event Constant diff found.");
                return;
            }

            if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Copy Event Constant diff to clipboard?"))
            {
                return;
            }
            Clipboard.SetText(r);
        }
Ejemplo n.º 13
0
        private PKM preparePK2()
        {
            PK2 pk2 = pkm as PK2;

            if (pk2 == null)
            {
                return(null);
            }

            pk2.Species           = WinFormsUtil.getIndex(CB_Species);
            pk2.TID               = Util.ToInt32(TB_TID.Text);
            pk2.EXP               = Util.ToUInt32(TB_EXP.Text);
            pk2.HeldItem          = WinFormsUtil.getIndex(CB_HeldItem);
            pk2.IsEgg             = CHK_IsEgg.Checked;
            pk2.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);
            pk2.Met_Level         = Util.ToInt32(TB_MetLevel.Text);
            pk2.Met_Location      = WinFormsUtil.getIndex(CB_MetLocation);
            pk2.Met_TimeOfDay     = CB_MetTimeOfDay.SelectedIndex;

            pk2.EV_HP  = Util.ToInt32(TB_HPEV.Text);
            pk2.EV_ATK = Util.ToInt32(TB_ATKEV.Text);
            pk2.EV_DEF = Util.ToInt32(TB_DEFEV.Text);
            pk2.EV_SPE = Util.ToInt32(TB_SPEEV.Text);
            pk2.EV_SPC = Util.ToInt32(TB_SPAEV.Text);

            if (CHK_Nicknamed.Checked)
            {
                pk2.Nickname = TB_Nickname.Text;
            }
            else
            {
                pk2.setNotNicknamed();
            }
            pk2.Move1       = WinFormsUtil.getIndex(CB_Move1);
            pk2.Move2       = WinFormsUtil.getIndex(CB_Move2);
            pk2.Move3       = WinFormsUtil.getIndex(CB_Move3);
            pk2.Move4       = WinFormsUtil.getIndex(CB_Move4);
            pk2.Move1_PP    = WinFormsUtil.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk2.Move2_PP    = WinFormsUtil.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk2.Move3_PP    = WinFormsUtil.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk2.Move4_PP    = WinFormsUtil.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk2.Move1_PPUps = WinFormsUtil.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk2.Move2_PPUps = WinFormsUtil.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk2.Move3_PPUps = WinFormsUtil.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk2.Move4_PPUps = WinFormsUtil.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;

            pk2.IV_HP  = Util.ToInt32(TB_HPIV.Text);
            pk2.IV_ATK = Util.ToInt32(TB_ATKIV.Text);
            pk2.IV_DEF = Util.ToInt32(TB_DEFIV.Text);
            pk2.IV_SPE = Util.ToInt32(TB_SPEIV.Text);
            pk2.IV_SPA = Util.ToInt32(TB_SPAIV.Text);

            pk2.OT_Name = TB_OT.Text;

            // Toss in Party Stats
            Array.Resize(ref pk2.Data, pk2.SIZE_PARTY);
            pk2.Stat_Level     = Util.ToInt32(TB_Level.Text);
            pk2.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
            pk2.Stat_HPMax     = Util.ToInt32(Stat_HP.Text);
            pk2.Stat_ATK       = Util.ToInt32(Stat_ATK.Text);
            pk2.Stat_DEF       = Util.ToInt32(Stat_DEF.Text);
            pk2.Stat_SPE       = Util.ToInt32(Stat_SPE.Text);
            pk2.Stat_SPA       = Util.ToInt32(Stat_SPA.Text);
            pk2.Stat_SPD       = Util.ToInt32(Stat_SPD.Text);

            if (HaX)
            {
                pk2.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
            }

            // Fix Moves if a slot is empty
            pk2.FixMoves();

            return(pk2);
        }
Ejemplo n.º 14
0
        private void runBackgroundWorker()
        {
            var Filters = StringInstruction.getFilters(RTB_Instructions.Lines).ToArray();

            if (Filters.Any(z => string.IsNullOrWhiteSpace(z.PropertyValue)))
            {
                WinFormsUtil.Error("Empty Filter Value detected."); return;
            }

            var Instructions = StringInstruction.getInstructions(RTB_Instructions.Lines).ToArray();
            var emptyVal     = Instructions.Where(z => string.IsNullOrWhiteSpace(z.PropertyValue)).ToArray();

            if (emptyVal.Any())
            {
                string props = string.Join(", ", emptyVal.Select(z => z.PropertyName));
                if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo,
                                                            $"Empty Property Value{(emptyVal.Length > 1 ? "s" : "")} detected:" + Environment.NewLine + props,
                                                            "Continue?"))
                {
                    return;
                }
            }

            if (!Instructions.Any())
            {
                WinFormsUtil.Error("No instructions defined."); return;
            }

            string destPath = "";

            if (RB_Path.Checked)
            {
                WinFormsUtil.Alert("Please select the folder where the files will be saved to.", "This can be the same folder as the source of PKM files.");
                var fbd = new FolderBrowserDialog();
                var dr  = fbd.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }

                destPath = fbd.SelectedPath;
            }

            FLP_RB.Enabled = RTB_Instructions.Enabled = B_Go.Enabled = false;

            b = new BackgroundWorker {
                WorkerReportsProgress = true
            };
            screenStrings(Filters);
            screenStrings(Instructions);

            b.DoWork += (sender, e) => {
                len = err = ctr = 0;
                if (RB_SAV.Checked)
                {
                    var data = Main.SAV.BoxData;
                    setupProgressBar(data.Length);
                    processSAV(data, Filters, Instructions);
                    Main.SAV.BoxData = data;
                }
                else
                {
                    var files = Directory.GetFiles(TB_Folder.Text, "*", SearchOption.AllDirectories);
                    setupProgressBar(files.Length);
                    processFolder(files, Filters, Instructions, destPath);
                }
            };
            b.ProgressChanged += (sender, e) =>
            {
                setProgressBar(e.ProgressPercentage);
            };
            b.RunWorkerCompleted += (sender, e) => {
                string result = $"Modified {ctr}/{len} files.";
                if (err > 0)
                {
                    result += Environment.NewLine + $"{err} files ignored due to an internal error.";
                }
                WinFormsUtil.Alert(result);
                FLP_RB.Enabled = RTB_Instructions.Enabled = B_Go.Enabled = true;
                setupProgressBar(0);
            };
            b.RunWorkerAsync();
        }
Ejemplo n.º 15
0
        private void ClickShowdownImportPKMModded(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsText())
            {
                WinFormsUtil.Alert("Clipboard does not contain text."); return;
            }

            if (!Directory.Exists(MGDatabasePath))
            {
                Directory.CreateDirectory(MGDatabasePath);
            }

            int    TID           = -1;
            int    SID           = -1;
            string OT            = "";
            int    gender        = 0;
            string Country       = "";
            string SubRegion     = "";
            string ConsoleRegion = "";

            if (File.Exists(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\trainerdata.txt"))
            {
                string   text  = File.ReadAllText(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\trainerdata.txt", System.Text.Encoding.UTF8);
                string[] lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                TID = Convert.ToInt32(lines[0].Split(':')[1].Trim());
                SID = Convert.ToInt32(lines[1].Split(':')[1].Trim());
                OT  = lines[2].Split(':')[1].Trim();
                if (lines[3].Split(':')[1].Trim() == "F" || lines[3].Split(':')[1].Trim() == "Female")
                {
                    gender = 1;
                }
                try
                {
                    Country       = lines[4].Split(':')[1].Trim();
                    SubRegion     = lines[5].Split(':')[1].Trim();
                    ConsoleRegion = lines[6].Split(':')[1].Trim();
                }
                catch { }
            }

            string source = Clipboard.GetText().TrimEnd();

            string[] stringSeparators = new string[] { "\n\r" };
            string[] result;

            // ...
            result = source.Split(stringSeparators, StringSplitOptions.None);
            Console.WriteLine(result.Length);

            if (result.Length > 1)
            {
                for (int i = 0; i < result.Length; i++)
                {
                    ShowdownSet Set = new ShowdownSet(result[i]);
                    if (Set.InvalidLines.Any())
                    {
                        WinFormsUtil.Alert("Invalid lines detected:", string.Join(Environment.NewLine, Set.InvalidLines));
                    }

                    // Set Species & Nickname
                    bool resetForm = false;
                    PKME_Tabs.hardReset();
                    if (Set.Form == null)
                    {
                    }
                    else if (Set.Form.Contains("Mega") || Set.Form == "Primal" || Set.Form == "Busted")
                    {
                        resetForm = true;
                        Console.WriteLine(Set.Species);
                    }
                    PKME_Tabs.LoadShowdownSet(Set);
                    PKM p = PreparePKM();
                    p.Version = (int)GameVersion.MN;
                    Blah b     = new Blah();
                    PKM  legal = b.LoadShowdownSetModded_PKSM(p, Set, resetForm, TID, SID, OT, gender);
                    PKME_Tabs.PopulateFields(legal);
                    if (Country != "" && SubRegion != "" && ConsoleRegion != "")
                    {
                        PKME_Tabs.SetRegions(Country, SubRegion, ConsoleRegion);
                    }
                    PKM pk = PreparePKM();
                    PKME_Tabs.ClickSet(C_SAV.Box.SlotPictureBoxes[0], i);
                }
            }
            else
            {
                // Get Simulator Data
                ShowdownSet Set = new ShowdownSet(Clipboard.GetText());

                if (Set.Species < 0)
                {
                    WinFormsUtil.Alert("Set data not found in clipboard."); return;
                }

                if (Set.Nickname?.Length > C_SAV.SAV.NickLength)
                {
                    Set.Nickname = Set.Nickname.Substring(0, C_SAV.SAV.NickLength);
                }

                if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Import this set?", Set.Text))
                {
                    return;
                }

                if (Set.InvalidLines.Any())
                {
                    WinFormsUtil.Alert("Invalid lines detected:", string.Join(Environment.NewLine, Set.InvalidLines));
                }

                // Set Species & Nickname
                //PKME_Tabs.LoadShowdownSet(Set);
                bool resetForm = false;
                PKME_Tabs.hardReset();
                if (Set.Form == null)
                {
                }
                else if (Set.Form.Contains("Mega") || Set.Form == "Primal" || Set.Form == "Busted")
                {
                    resetForm = true;
                    Console.WriteLine(Set.Species);
                }
                PKME_Tabs.LoadShowdownSet(Set);
                PKM p = PreparePKM();
                p.Version = (int)GameVersion.MN;
                Blah b     = new Blah();
                PKM  legal = b.LoadShowdownSetModded_PKSM(p, Set, resetForm, TID, SID, OT, gender);
                PKME_Tabs.PopulateFields(legal);
                if (Country != "" && SubRegion != "" && ConsoleRegion != "")
                {
                    PKME_Tabs.SetRegions(Country, SubRegion, ConsoleRegion);
                }
            }
        }
Ejemplo n.º 16
0
        private void B_GetTickets_Click(object sender, EventArgs e)
        {
            var Pouches  = SAV.Inventory;
            var itemlist = GameInfo.Strings.GetItemStrings(SAV.Generation, SAV.Version).ToArray();

            for (int i = 0; i < itemlist.Length; i++)
            {
                if (string.IsNullOrEmpty(itemlist[i]))
                {
                    itemlist[i] = $"(Item #{i:000})";
                }
            }

            const int oldsea = 0x178;

            int[] tickets = { 0x109, 0x113, 0x172, 0x173, oldsea }; // item IDs
            if (!SAV.Japanese && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Non Japanese save file. Add {itemlist[oldsea]} (unreleased)?"))
            {
                tickets = tickets.Take(tickets.Length - 1).ToArray(); // remove old sea map
            }
            var p = Array.Find(Pouches, z => z.Type == InventoryType.KeyItems);

            if (p == null)
            {
                return;
            }

            // check for missing tickets
            var missing = tickets.Where(z => !p.Items.Any(item => item.Index == z && item.Count == 1)).ToList();
            var have    = tickets.Except(missing).ToList();

            if (missing.Count == 0)
            {
                WinFormsUtil.Alert("Already have all tickets.");
                B_GetTickets.Enabled = false;
                return;
            }

            // check for space
            int end = Array.FindIndex(p.Items, z => z.Index == 0);

            if (end + missing.Count >= p.Items.Length)
            {
                WinFormsUtil.Alert("Not enough space in pouch.", "Please use the InventoryEditor.");
                B_GetTickets.Enabled = false;
                return;
            }

            var added  = string.Join(", ", missing.Select(u => itemlist[u]));
            var addmsg = $"Add the following items?{Environment.NewLine}{added}";

            if (have.Count > 0)
            {
                string had     = string.Join(", ", have.Select(u => itemlist[u]));
                var    havemsg = $"Already have:{Environment.NewLine}{had}";
                addmsg += Environment.NewLine + Environment.NewLine + havemsg;
            }
            if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, addmsg))
            {
                return;
            }

            // insert items at the end
            for (int i = 0; i < missing.Count; i++)
            {
                var item = p.Items[end + i];
                item.Index = missing[i];
                item.Count = 1;
            }

            string alert = $"Inserted the following items to the Key Items Pouch:{Environment.NewLine}{added}";

            WinFormsUtil.Alert(alert);
            SAV.Inventory = Pouches;

            B_GetTickets.Enabled = false;
        }
Ejemplo n.º 17
0
        private void Write_Entry(object sender, EventArgs e)
        {
            if (!editing)
            {
                return; //Don't do writing until loaded
            }
            Validate_TextBoxes();

            int index       = LB_DataEntry.SelectedIndex;
            int partymember = Convert.ToInt32(NUP_PartyIndex.Value) - 1;
            int offset      = (index * 0x1B4) + (partymember * 0x48);

            BitConverter.GetBytes(Convert.ToUInt16(CB_Species.SelectedValue)).CopyTo(data, offset + 0x00);
            BitConverter.GetBytes(Convert.ToUInt16(CB_HeldItem.SelectedValue)).CopyTo(data, offset + 0x02);
            BitConverter.GetBytes(Convert.ToUInt16(CB_Move1.SelectedValue)).CopyTo(data, offset + 0x04);
            BitConverter.GetBytes(Convert.ToUInt16(CB_Move2.SelectedValue)).CopyTo(data, offset + 0x06);
            BitConverter.GetBytes(Convert.ToUInt16(CB_Move3.SelectedValue)).CopyTo(data, offset + 0x08);
            BitConverter.GetBytes(Convert.ToUInt16(CB_Move4.SelectedValue)).CopyTo(data, offset + 0x0A);
            BitConverter.GetBytes(Util.GetHexValue(TB_EC.Text)).CopyTo(data, offset + 0x0C);

            BitConverter.GetBytes(Convert.ToUInt16(TB_TID.Text)).CopyTo(data, offset + 0x10);
            BitConverter.GetBytes(Convert.ToUInt16(TB_SID.Text)).CopyTo(data, offset + 0x12);

            uint rawslgf = BitConverter.ToUInt32(data, offset + 0x14);
            uint slgf    = 0;

            slgf |= (uint)(CB_Form.SelectedIndex & 0x1F);
            slgf |= (uint)((PKX.GetGenderFromString(Label_Gender.Text) & 0x3) << 5);
            slgf |= (uint)((Convert.ToUInt16(TB_Level.Text) & 0x7F) << 7);
            if (CHK_Shiny.Checked)
            {
                slgf |= 1 << 14;
            }

            slgf |= rawslgf & 0x8000;
            Array.Copy(BitConverter.GetBytes(slgf), 0, data, offset + 0x14, 2);

            uint nick = 0;

            if (CHK_Nicknamed.Checked)
            {
                nick = 1;
            }
            Array.Copy(BitConverter.GetBytes(nick), 0, data, offset + 0x16, 2);

            //Mimic in-game behavior of not clearing strings. It's awful, but accuracy > good.
            string pk = TB_Nickname.Text; if (pk.Length != 12)
            {
                pk = pk.PadRight(pk.Length + 1, '\0');
            }
            string ot = TB_OT.Text; if (ot.Length != 12)

            {
                ot = ot.PadRight(pk.Length + 1, '\0');
            }

            Encoding.Unicode.GetBytes(pk).CopyTo(data, offset + 0x18);
            Encoding.Unicode.GetBytes(ot).CopyTo(data, offset + 0x30);

            offset = index * 0x1B4;

            uint vnd  = 0;
            uint date = 0;

            vnd  |= Convert.ToUInt32(TB_VN.Text) & 0xFF;
            date |= (uint)((CAL_MetDate.Value.Year - 2000) & 0xFF);
            date |= (uint)((CAL_MetDate.Value.Month & 0xF) << 8);
            date |= (uint)((CAL_MetDate.Value.Day & 0x1F) << 12);
            vnd  |= (date & 0x1FFFF) << 14;
            //Fix for top bit
            uint rawvnd = BitConverter.ToUInt32(data, offset + 0x1B0);

            vnd |= rawvnd & 0x80000000;
            Array.Copy(BitConverter.GetBytes(vnd), 0, data, offset + 0x1B0, 4);

            var species = WinFormsUtil.GetIndex(CB_Species);
            var form    = CB_Form.SelectedIndex & 0x1F;
            var gender  = PKX.GetGenderFromString(Label_Gender.Text);
            var item    = WinFormsUtil.GetIndex(CB_HeldItem);

            bpkx.Image = SpriteUtil.GetSprite(species, form, gender, 0, item, false, CHK_Shiny.Checked);
            DisplayEntry(this, EventArgs.Empty); // refresh text view
        }
Ejemplo n.º 18
0
        private PKM preparePK7()
        {
            PK7 pk7 = pkm as PK7;

            if (pk7 == null)
            {
                return(null);
            }

            // Repopulate PK6 with Edited Stuff
            if (WinFormsUtil.getIndex(CB_GameOrigin) < 24)
            {
                uint EC  = Util.getHEXval(TB_EC.Text);
                uint PID = Util.getHEXval(TB_PID.Text);
                uint SID = Util.ToUInt32(TB_TID.Text);
                uint TID = Util.ToUInt32(TB_TID.Text);
                uint LID = PID & 0xFFFF;
                uint HID = PID >> 16;
                uint XOR = TID ^ LID ^ SID ^ HID;

                // Ensure we don't have a shiny.
                if (XOR >> 3 == 1) // Illegal, fix. (not 16<XOR>=8)
                {
                    // Keep as shiny, so we have to mod the PID
                    PID        ^= XOR;
                    TB_PID.Text = PID.ToString("X8");
                    TB_EC.Text  = PID.ToString("X8");
                }
                else if ((XOR ^ 0x8000) >> 3 == 1 && PID != EC)
                {
                    TB_EC.Text = (PID ^ 0x80000000).ToString("X8");
                }
                else // Not Illegal, no fix.
                {
                    TB_EC.Text = PID.ToString("X8");
                }
            }

            pk7.EncryptionConstant = Util.getHEXval(TB_EC.Text);
            pk7.Checksum           = 0; // 0 CHK for now

            // Block A
            pk7.Species  = WinFormsUtil.getIndex(CB_Species);
            pk7.HeldItem = WinFormsUtil.getIndex(CB_HeldItem);
            pk7.TID      = Util.ToInt32(TB_TID.Text);
            pk7.SID      = Util.ToInt32(TB_SID.Text);
            pk7.EXP      = Util.ToUInt32(TB_EXP.Text);

            if (CB_Ability.Text.Length >= 4)
            {
                pk7.Ability       = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
                pk7.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text);   // Number
            }

            // pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag)
            pk7.PID              = Util.getHEXval(TB_PID.Text);
            pk7.Nature           = (byte)WinFormsUtil.getIndex(CB_Nature);
            pk7.FatefulEncounter = CHK_Fateful.Checked;
            pk7.Gender           = PKX.getGender(Label_Gender.Text);
            pk7.AltForm          = (MT_Form.Enabled ? Convert.ToInt32(MT_Form.Text) : CB_Form.Enabled ? CB_Form.SelectedIndex : 0) & 0x1F;
            pk7.EV_HP            = Util.ToInt32(TB_HPEV.Text); // EVs
            pk7.EV_ATK           = Util.ToInt32(TB_ATKEV.Text);
            pk7.EV_DEF           = Util.ToInt32(TB_DEFEV.Text);
            pk7.EV_SPE           = Util.ToInt32(TB_SPEEV.Text);
            pk7.EV_SPA           = Util.ToInt32(TB_SPAEV.Text);
            pk7.EV_SPD           = Util.ToInt32(TB_SPDEV.Text);

            pk7.CNT_Cool   = Util.ToInt32(TB_Cool.Text);     // CNT
            pk7.CNT_Beauty = Util.ToInt32(TB_Beauty.Text);
            pk7.CNT_Cute   = Util.ToInt32(TB_Cute.Text);
            pk7.CNT_Smart  = Util.ToInt32(TB_Smart.Text);
            pk7.CNT_Tough  = Util.ToInt32(TB_Tough.Text);
            pk7.CNT_Sheen  = Util.ToInt32(TB_Sheen.Text);

            pk7.PKRS_Days   = CB_PKRSDays.SelectedIndex;
            pk7.PKRS_Strain = CB_PKRSStrain.SelectedIndex;
            // Already in buff (then transferred to new pkx)
            // 0x2C, 0x2D, 0x2E, 0x2F
            // 0x30, 0x31, 0x32, 0x33
            // 0x34, 0x35, 0x36, 0x37
            // 0x38, 0x39

            // Unused
            // 0x3A, 0x3B
            // 0x3C, 0x3D, 0x3E, 0x3F

            // Block B
            // Convert Nickname field back to bytes
            pk7.Nickname     = TB_Nickname.Text;
            pk7.Move1        = WinFormsUtil.getIndex(CB_Move1);
            pk7.Move2        = WinFormsUtil.getIndex(CB_Move2);
            pk7.Move3        = WinFormsUtil.getIndex(CB_Move3);
            pk7.Move4        = WinFormsUtil.getIndex(CB_Move4);
            pk7.Move1_PP     = WinFormsUtil.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0;
            pk7.Move2_PP     = WinFormsUtil.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0;
            pk7.Move3_PP     = WinFormsUtil.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0;
            pk7.Move4_PP     = WinFormsUtil.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0;
            pk7.Move1_PPUps  = WinFormsUtil.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0;
            pk7.Move2_PPUps  = WinFormsUtil.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0;
            pk7.Move3_PPUps  = WinFormsUtil.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0;
            pk7.Move4_PPUps  = WinFormsUtil.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0;
            pk7.RelearnMove1 = WinFormsUtil.getIndex(CB_RelearnMove1);
            pk7.RelearnMove2 = WinFormsUtil.getIndex(CB_RelearnMove2);
            pk7.RelearnMove3 = WinFormsUtil.getIndex(CB_RelearnMove3);
            pk7.RelearnMove4 = WinFormsUtil.getIndex(CB_RelearnMove4);
            // 0x72 - Ribbon editor sets this flag (Secret Super Training)
            // 0x73
            pk7.IV_HP       = Util.ToInt32(TB_HPIV.Text);
            pk7.IV_ATK      = Util.ToInt32(TB_ATKIV.Text);
            pk7.IV_DEF      = Util.ToInt32(TB_DEFIV.Text);
            pk7.IV_SPE      = Util.ToInt32(TB_SPEIV.Text);
            pk7.IV_SPA      = Util.ToInt32(TB_SPAIV.Text);
            pk7.IV_SPD      = Util.ToInt32(TB_SPDIV.Text);
            pk7.IsEgg       = CHK_IsEgg.Checked;
            pk7.IsNicknamed = CHK_Nicknamed.Checked;

            // Block C
            pk7.HT_Name = TB_OTt2.Text;

            // 0x90-0xAF
            pk7.HT_Gender = PKX.getGender(Label_CTGender.Text) & 1;
            // Plus more, set by MemoryAmie (already in buff)

            // Block D
            pk7.OT_Name           = TB_OT.Text;
            pk7.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);

            DateTime?egg_date     = null;
            int      egg_location = 0;

            if (CHK_AsEgg.Checked)      // If encountered as an egg, load the Egg Met data from fields.
            {
                egg_date     = CAL_EggDate.Value;
                egg_location = WinFormsUtil.getIndex(CB_EggLocation);
            }
            // Egg Met Data
            pk7.EggMetDate   = egg_date;
            pk7.Egg_Location = egg_location;
            // Met Data
            pk7.MetDate      = CAL_MetDate.Value;
            pk7.Met_Location = WinFormsUtil.getIndex(CB_MetLocation);

            if (pk7.IsEgg && pk7.Met_Location == 0)    // If still an egg, it has no hatch location/date. Zero it!
            {
                pk7.MetDate = null;
            }

            // 0xD7 Unknown

            pk7.Ball          = WinFormsUtil.getIndex(CB_Ball);
            pk7.Met_Level     = Util.ToInt32(TB_MetLevel.Text);
            pk7.OT_Gender     = PKX.getGender(Label_OTGender.Text);
            pk7.EncounterType = WinFormsUtil.getIndex(CB_EncounterType);
            pk7.Version       = WinFormsUtil.getIndex(CB_GameOrigin);
            pk7.Country       = WinFormsUtil.getIndex(CB_Country);
            pk7.Region        = WinFormsUtil.getIndex(CB_SubRegion);
            pk7.ConsoleRegion = WinFormsUtil.getIndex(CB_3DSReg);
            pk7.Language      = WinFormsUtil.getIndex(CB_Language);
            // 0xE4-0xE7

            // Toss in Party Stats
            Array.Resize(ref pk7.Data, pk7.SIZE_PARTY);
            pk7.Stat_Level     = Util.ToInt32(TB_Level.Text);
            pk7.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text);
            pk7.Stat_HPMax     = Util.ToInt32(Stat_HP.Text);
            pk7.Stat_ATK       = Util.ToInt32(Stat_ATK.Text);
            pk7.Stat_DEF       = Util.ToInt32(Stat_DEF.Text);
            pk7.Stat_SPE       = Util.ToInt32(Stat_SPE.Text);
            pk7.Stat_SPA       = Util.ToInt32(Stat_SPA.Text);
            pk7.Stat_SPD       = Util.ToInt32(Stat_SPD.Text);

            // Unneeded Party Stats (Status, Flags, Unused)
            pk7.Data[0xE8]              = pk7.Data[0xE9] = pk7.Data[0xEA] = pk7.Data[0xEB] =
                pk7.Data[0xED]          = pk7.Data[0xEE] = pk7.Data[0xEF] =
                    pk7.Data[0xFE]      = pk7.Data[0xFF] = pk7.Data[0x100] =
                        pk7.Data[0x101] = pk7.Data[0x102] = pk7.Data[0x103] = 0;

            // Hax Illegality
            if (HaX)
            {
                pk7.Ability    = (byte)WinFormsUtil.getIndex(DEV_Ability);
                pk7.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue);
            }

            // Fix Moves if a slot is empty
            pk7.FixMoves();
            pk7.FixRelearn();

            // Fix Handler (Memories & OT) -- no foreign memories for Pokemon without a foreign trainer (none for eggs)
            if (Menu_ModifyPKM.Checked)
            {
                pk7.FixMemories();
            }

            // PKX is now filled
            pk7.RefreshChecksum();
            return(pk7);
        }
Ejemplo n.º 19
0
        public SAV_FestivalPlaza(SaveFile sav)
        {
            SAV     = (SAV7)(Origin = sav).Clone();
            editing = true;
            InitializeComponent();
            typeMAX = SAV.USUM ? 0x7F : 0x7C;
            if (SAV.USUM)
            {
                PBs          = new[] { ppkx1, ppkx2, ppkx3 };
                NUD_Trainers = new[] { NUD_Trainer1, NUD_Trainer2, NUD_Trainer3 };
                LoadBattleAgency();
            }
            else
            {
                TC_Editor.TabPages.Remove(Tab_BattleAgency);
            }
            if (Main.Unicode)
            {
                try { TB_OTName.Font = FontUtil.GetPKXFont(11); }
                catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); }
            }
            uint cc = SAV.FestaCoins;
            uint cu = SAV.UsedFestaCoins;

            NUD_FC_Current.Value = Math.Min(cc, NUD_FC_Current.Maximum);
            NUD_FC_Used.Value    = Math.Min(cu, NUD_FC_Used.Maximum);
            L_FC_CollectedV.Text = (cc + cu).ToString();
            string[] res;
            switch (Main.CurrentLanguage)
            {
            case "ja":
                res = new[] {
                    "おじさんの きんのたま だからね!", "かがくの ちからって すげー", "1 2の …… ポカン!", "おーす! みらいの チャンピオン!", "おお! あんたか!", "みんな げんきに なりましたよ!", "とっても 幸せそう!", "なんでも ないです", "いあいぎりで きりますか?", "レポートを かきこんでいます",
                    "…… ぼくも もう いかなきゃ!", "ボンジュール!", "バイビー!", "ばか はずれです……", "やけどなおしの よういは いいか!", "ウー! ハーッ!", "ポケモンは たたかわせるものさ", "ヤドランは そっぽを むいた!", "マサラは まっしろ はじまりのいろ", "10000こうねん はやいんだよ!", "おーい! まてー! まつんじゃあ!", "こんちわ! ぼく ポケモン……!", "っだと こらあ!", "ぐ ぐーッ! そんな ばかなーッ!", "みゅう!", "タチサレ…… タチサレ……",
                    "カイリュー はかいこうせん", "どっちか 遊んでくれないか?", "ぬいぐるみ かっておいたわよ", "ひとのこと じろじろ みてんなよ", "なんのことだか わかんない", "みんな ポケモン やってるやん", "きょうから 24時間 とっくんだ!", "あたいが ホンモノ!", "でんげきで いちころ……", "スイクンを おいかけて 10ねん", "かんどうが よみがえるよ!", "われわれ ついに やりましたよー!", "ヤドンのシッポを うるなんて……", "ショオーッ!!", "ギャーアアス!!", "だいいっぽを ふみだした!",
                    "いちばん つよくて すごいんだよね", "にくらしいほど エレガント!", "そうぞうりょくが たりないよ", "キミは ビッグウェーブ!", "おまえさんには しびれた わい", "なに いってんだろ…… てへへ……", "ぬいぐるみ なんか かってないよ", "ここで ゆっくり して おいき!", "はじけろ! ポケモン トレーナー!", "はいが はいに はいった……", "…できる!", "ぶつかった かいすう 5かい!", "たすけて おくれーっ!!", "マボロシじま みえんのう……", "ひゅああーん!", "しゅわーん!",
                    "あつい きもち つたわってくる!", "こいつが! おれの きりふだ!", "ひとりじめとか そういうの ダメよ!", "ワーオ! ぶんせきどーり!", "ぱるぱるぅ!!!", "グギュグバァッ!!!", "ばっきん 100まんえん な!", "オレ つよくなる……", "ながれる 時間は とめられない!", "ぜったいに お願いだからね", "きみたちから はどうを かんじる!", "あたしのポケモンに なにすんのさ!", "リングは おれの うみ~♪", "オレの おおごえの ひとりごとを", "そう コードネームは ハンサム!", "……わたしが まけるかも だと!?",
                    "やめたげてよぉ!", "ブラボー! スーパー ブラボー!", "ボクは チャンピオンを こえる", "オレは いまから いかるぜッ!", "ライモンで ポケモン つよいもん", "キミ むしポケモン つかいなよ", "ストップ!", "ひとよんで メダルおやじ!", "トレーナーさんも がんばれよ!", "おもうぞんぶん きそおーぜ!", "プラズマズイ!", "ワタクシを とめることは できない!", "けいさんずみ ですとも!", "ババリバリッシュ!", "ンバーニンガガッ!", "ヒュラララ!",
                    "お友達に なっちゃお♪", "じゃあ みんな またねえ!", "このひとたち ムチャクチャです……", "トレーナーとは なにか しりたい", "スマートに くずれおちるぜ", "いのち ばくはつッ!!", "いいんじゃない いいんじゃないの!", "あれだよ あれ おみごとだよ!", "ぜんりょくでいけー! ってことよ!", "おまちなさいな!", "つまり グッド ポイント なわけ!", "ざんねん ですが さようなら", "にくすぎて むしろ 好きよ", "この しれもの が!", "イクシャア!!", "イガレッカ!!",
                    "フェスサークル ランク 100!",
                };
                break;

            default:
                string musical8note = "♪";
                string linedP       = "₽"; //currency Ruble
                res = new[] {              //source:UltraMoon
                    /* (SM)Pokémon House */ "There's nothing funny about Nuggets.", "The Power of science is awesome.", "1, 2, and... Ta-da!", "How's the future Champ today?", "Why, you!", "There! All happy and healthy!", "Your Pokémon seems to be very happy!", "No thanks!", "Would you like to use Cut?", "Saving...",
                    /* (SM)Kanto Tent */ "Well, I better get going!", "Bonjour!", "Smell ya later!", "Sorry! Bad call!", "You better have Burn Heal!", "Hoo hah!", "Pokémon are for battling!", "Slowbro took a snooze...", "Shades of your journey await!", "You're 10,000 light-years from facing Brock!", "Hey! Wait! Don't go out!", "Hiya! I'm a Pokémon...", "What do you want?", "WHAT! This can't be!", "Mew!", "Be gone... Intruders...",
                    /* (SM)Joht Tent */ "Dragonite, Hymer Beam.", "Spread the fun around.", "I bought an adorable doll with your money.", "What are you staring at?", "I just don't understand.", "Everyone is into Pokémon.", "I'm going to train 24 hours a day!", "I'm the real deal!", "With a jolt of electricity...", "For 10 years I chased Suicune.", "I am just so deeply moved!", "We have finally made it!", "...But selling Slowpoke Tails?", "Shaoooh!", "Gyaaas!", "you've taken your first step!",
                    /* (SM)Hoenn Tent */ "I'm just the strongest there is right now.", "And confoundedly elegant!", "You guys need some imagination.", "You made a much bigger splash!", "You ended up giving me a thrill!", "So what am I talking about...", "I'm not buying any Dolls.", "Take your time and rest up!", "Have a blast, Pokémon Trainers!", "I got ashes in my eyelashes!", "You're sharp!", "Number of collisions: 5 times!", "Please! Help me out!", "I can't see Mirage Island today...", "Hyahhn!", "Shwahhn!",
                    /* (SM)Sinnoh Tent */ "Your will is overwhelming me!", "This is it! My trump card!", "Trying to monopolize Pokémon just isn't...", "See? Just as analyzed.", "Gagyagyaah!", "Gugyugubah!", "It's a " + linedP + "10 million fine if you're late!", "I'm going to get tougher...", "You'll never be able to stem the flow of time!", "Please come!", "Your team! I sense your strong aura!", "What do you think you're doing?!", "The ring is my rolling sea. " + musical8note, "I was just thinking out loud.", "My code name, it is Looker.", "It's not possible that I lose!",
                    /* (SM)Unova Tent */ "Knock it off!", "Bravo! Excellent!!", "I'll defeat the Champion.", "You're about to feel my rage!", "Nimbasa's Pokémon can dance a nimble bossa!", "Use Bug-type Pokémon!", "Stop!", "People call me Mr. Medal!", "Trainer, do your best, too!", "See who's stronger!", "Plasbad, for short!", "I won't allow anyone to stop me!", "I was expecting exactly that kind of move!", "Bazzazzazzash!", "Preeeeaah!", "Haaahraaan!",
                    /* (SM)Kalos Tent */ "We'll become friends. " + musical8note, "I'll see you all later!", "These people have a few screws loose...", "I want to know what a \"Trainer\" is.", "When I lose, I go out in style!", "Let's give it all we've got!", "Fantastic! Just fantastic!", "Outstanding!", "Try as hard as possible!", "Stop right there!", "That really hit me right here...", "But this is adieu to you all.", "You're just too much, you know?", "Fool! You silly, unseeing child!", "Xsaaaaaah!", "Yvaaaaaar!",
                    "I reached Festival Plaza Rank 100!",
                };
                break;
            }
            CLB_Phrases.Items.Clear();
            CLB_Phrases.Items.Add(res.Last(), SAV.GetFestaPhraseUnlocked(106)); //add Lv100 before TentPhrases
            for (int i = 0; i < res.Length - 1; i++)
            {
                CLB_Phrases.Items.Add(res[i], SAV.GetFestaPhraseUnlocked(i));
            }

            DateTime dt = SAV.FestaDate ?? new DateTime(2000, 1, 1);

            CAL_FestaStartDate.Value = CAL_FestaStartTime.Value = dt;

            string[] res2 = { "Rank 4: missions", "Rank 8: facility", "Rank 10: fashion", "Rank 20: rename", "Rank 30: special menu", "Rank 40: BGM", "Rank 50: theme Glitz", "Rank 60: theme Fairy", "Rank 70: theme Tone", "Rank 100: phrase", "Current Rank", };
            CLB_Reward.Items.Clear();
            CLB_Reward.Items.Add(res2.Last(), (CheckState)r[SAV.GetFestPrizeReceived(10)]); //add CurrentRank before const-rewards
            for (int i = 0; i < res2.Length - 1; i++)
            {
                CLB_Reward.Items.Add(res2[i], (CheckState)r[SAV.GetFestPrizeReceived(i)]);
            }

            for (int i = 0; i < 7; i++)
            {
                f[i] = new FestaFacility(SAV, i);
            }

            string[] res3 = { "Meet", "Part", "Moved", "Disappointed" };
            CB_FacilityMessage.Items.Clear();
            CB_FacilityMessage.Items.AddRange(res3);
            string[] res5 =
            {
                "Ace Trainer" + gendersymbols[1],
                "Ace Trainer" + gendersymbols[0],
                "Veteran" + gendersymbols[1],
                "Veteran" + gendersymbols[0],
                "Office Worker" + gendersymbols[0],
                "Office Worker" + gendersymbols[1],
                "Punk Guy",
                "Punk Girl",
                "Breeder" + gendersymbols[0],
                "Breeder" + gendersymbols[1],
                "Youngster",
                "Lass"
            };
            CB_FacilityNPC.Items.Clear();
            CB_FacilityNPC.Items.AddRange(res5);
            string[]   res6 = { "Lottery", "Haunted", "Goody", "Food", "Bouncy", "Fortune", "Dye", "Exchange" };
            string[][] res7 =
            {
                new[] { "BigDream",  "GoldRush",  "TreasureHunt"     },
                new[] { "GhostsDen", "TrickRoom", "ConfuseRay"       },
                new[] { "Ball",      "General",   "Battle", "SoftDrink", "Pharmacy"},
                new[] { "Rare",      "Battle",    "FriendshipCafé", "FriendshipParlor"},
                new[] { "Thump",     "Clink",     "Stomp"            },
                new[] { "Kanto",     "Johto",     "Hoenn", "Sinnoh", "Unova", "Kalos", "Pokémon"},
                new[] { "Red",       "Yellow",    "Green", "Blue", "Orange", "NavyBlue", "Purple", "Pink"},
                new[] { "Switcheroo" }
            };
            CB_FacilityType.Items.Clear();
            for (int k = 0; k < RES_FacilityLevelType.Length - (SAV.USUM ? 0 : 1); k++) //Exchange is USUM only
            {
                for (int j = 0; j < RES_FacilityLevelType[k].Length; j++)
                {
                    if (RES_FacilityLevelType[k][j] != 4)
                    {
                        for (int i = 0; i < RES_FacilityLevelType[k][j]; i++)
                        {
                            CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} {i + 1}");
                        }
                    }
                    else
                    {
                        CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} 1");
                        CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} 3");
                        CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} 5");
                    }
                }
            }
            string[] res8 = { "GTS", "Wonder Trade", "Battle Spot", "Festival Plaza", "mission", "lottery shop", "haunted house" };
            string[] res9 = { "+", "++", "+++" };
            CB_LuckyResult.Items.Clear();
            CB_LuckyResult.Items.Add("none");
            for (int i = 0; i < res8.Length; i++)
            {
                for (int j = 0; j < res9.Length; j++)
                {
                    CB_LuckyResult.Items.Add($"{res9[j]} {res8[i]}");
                }
            }

            NUD_Rank.Value = SAV.FestaRank;
            LoadRankLabel(SAV.FestaRank);
            NUD_Messages = new[] { NUD_MyMessageMeet, NUD_MyMessagePart, NUD_MyMessageMoved, NUD_MyMessageDissapointed };
            for (int i = 0; i < NUD_Messages.Length; i++)
            {
                NUD_Messages[i].Value = SAV.GetFestaMessage(i);
            }

            LB_FacilityIndex.SelectedIndex   = 0;
            CB_FacilityMessage.SelectedIndex = 0;
            editing = false;

            entry = 0;
            LoadFacility();
        }
Ejemplo n.º 20
0
        public SAV_SimpleTrainer()
        {
            Loading = true;
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.curlanguage);

            cba = new[] { CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_6, CHK_7, CHK_8 };
            TB_OTName.MaxLength = SAV.OTLength;
            B_MaxCash.Click    += (sender, e) => MT_Money.Text = SAV.MaxMoney.ToString();
            B_MaxCoins.Click   += (sender, e) => MT_Coins.Text = SAV.MaxCoins.ToString();
            MT_Money.Mask       = "00000000000".Substring(0, SAV.MaxMoney.ToString().Length);
            MT_Coins.Mask       = "00000000000".Substring(0, SAV.MaxCoins.ToString().Length);

            CB_Gender.Items.Clear();
            CB_Gender.Items.AddRange(Main.gendersymbols.Take(2).ToArray()); // m/f depending on unicode selection

            L_SID.Visible     = MT_SID.Visible = SAV.Generation > 2;
            L_Coins.Visible   = B_MaxCoins.Visible = MT_Coins.Visible = SAV.Generation < 3;
            CB_Gender.Visible = SAV.Generation > 1;

            L_PikaFriend.Visible = MT_PikaFriend.Visible = SAV.Generation == 1;

            TB_OTName.Text          = SAV.OT;
            CB_Gender.SelectedIndex = SAV.Gender;
            MT_TID.Text             = SAV.TID.ToString("00000");
            MT_SID.Text             = SAV.SID.ToString("00000");
            MT_Money.Text           = SAV.Money.ToString();
            MT_Hours.Text           = SAV.PlayedHours.ToString();
            MT_Minutes.Text         = SAV.PlayedMinutes.ToString();
            MT_Seconds.Text         = SAV.PlayedSeconds.ToString();


            int badgeval = 0;

            if (SAV is SAV1)
            {
                SAV1 sav1 = (SAV1)SAV;
                MT_Coins.Text = sav1.Coin.ToString();
                badgeval      = sav1.Badges;

                L_Started.Visible = L_Fame.Visible = false;
                CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
                CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
                GB_Map.Visible     = false;
                GB_Options.Visible = true;
                CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
                CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo", "Earphone2", "Earphone3" });
                CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });

                CHK_BattleEffects.Checked    = sav1.BattleEffects;
                CB_BattleStyle.SelectedIndex = sav1.BattleStyleSwitch ? 0 : 1;
                CB_SoundType.SelectedIndex   = sav1.Sound;
                CB_TextSpeed.SelectedIndex   = sav1.TextSpeed;

                MT_PikaFriend.Text = sav1.PikaFriendship.ToString();
            }

            if (SAV is SAV2)
            {
                SAV2 sav2 = (SAV2)SAV;
                MT_Coins.Text = sav2.Coin.ToString();

                L_Started.Visible = L_Fame.Visible = false;
                CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
                CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
                GB_Map.Visible     = false;
                GB_Options.Visible = true;
                CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
                CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo" });
                CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });

                CHK_BattleEffects.Checked    = sav2.BattleEffects;
                CB_BattleStyle.SelectedIndex = sav2.BattleStyleSwitch ? 0 : 1;
                CB_SoundType.SelectedIndex   = sav2.Sound > 0 ? 1 : 0;
                CB_TextSpeed.SelectedIndex   = sav2.TextSpeed;
                badgeval = sav2.Badges;
                cba      = new[] { CHK_1, CHK_2, CHK_3, CHK_4, CHK_6, CHK_5, CHK_7, CHK_8, CHK_H1, CHK_H2, CHK_H3, CHK_H4, CHK_H5, CHK_H6, CHK_H7, CHK_H8 };
            }

            if (SAV is SAV3)
            {
                GB_Map.Visible    = false;
                GB_Badges.Visible = false; // todo

                L_Started.Visible = L_Fame.Visible = false;
                CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
                CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
                return;
            }
            if (SAV is SAV3Colosseum || SAV is SAV3XD)
            {
                GB_Map.Visible    = false;
                GB_Badges.Visible = false;
                L_Started.Visible = L_Fame.Visible = false;
                CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
                CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
                return;
            }

            if (SAV is SAV4)
            {
                SAV4 s = (SAV4)SAV;
                NUD_M.Value = s.M;
                NUD_X.Value = s.X;
                NUD_Z.Value = s.Z;
                NUD_Y.Value = s.Y;

                badgeval = s.Badges;
                if (s.Version == GameVersion.HGSS)
                {
                    badgeval |= s.Badges16 << 8;
                    cba       = cba.Concat(new[] { CHK_H1, CHK_H2, CHK_H3, CHK_H4, CHK_H5, CHK_H6, CHK_H7, CHK_H8 }).ToArray();
                }
            }
            else if (SAV is SAV5)
            {
                SAV5 s = (SAV5)SAV;
                NUD_M.Value = s.M;
                NUD_X.Value = s.X;
                NUD_Z.Value = s.Z;
                NUD_Y.Value = s.Y;

                badgeval = s.Badges;
            }

            for (int i = 0; i < cba.Length; i++)
            {
                cba[i].Visible = true;
                cba[i].Checked = (badgeval & 1 << i) != 0;
            }

            CAL_HoFDate.Value            = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame);
            CAL_HoFTime.Value            = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame % 86400);
            CAL_AdventureStartDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart);
            CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart % 86400);

            Loading = false;
        }
Ejemplo n.º 21
0
        public SAV_Database(PKMEditor f1, SAVEditor saveditor)
        {
            InitializeComponent();

            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuDelete });

            SAV       = saveditor.SAV;
            BoxView   = saveditor;
            PKME_Tabs = f1;

            // Preset Filters to only show PKM available for loaded save
            CB_FormatComparator.SelectedIndex = 3; // <=
            pokeGrid1.InitializeGrid(6, 11);
            pokeGrid1.SetBackground(Resources.box_wp_clean);
            PKXBOXES = pokeGrid1.Entries.ToArray();

            // Enable Scrolling when hovered over
            foreach (var slot in PKXBOXES)
            {
                // Enable Click
                slot.MouseClick += (sender, e) =>
                {
                    switch (ModifierKeys)
                    {
                    case Keys.Control: ClickView(sender, e); break;

                    case Keys.Alt: ClickDelete(sender, e); break;

                    case Keys.Shift: ClickSet(sender, e); break;
                    }
                };

                if (Settings.Default.HoverSlotShowText)
                {
                    slot.MouseEnter += ShowHoverTextForSlot;
                }
            }

            Counter       = L_Count.Text;
            Viewed        = L_Viewed.Text;
            L_Viewed.Text = string.Empty; // invisible for now
            PopulateComboBoxes();

            // Assign to datagridview
            foreach (PictureBox p in PKXBOXES)
            {
                p.ContextMenuStrip = mnu;
            }

            // Load Data
            B_Search.Enabled = false;
            L_Count.Text     = "Loading...";
            new Task(LoadDatabase).Start();

            Menu_SearchSettings.DropDown.Closing += (sender, e) =>
            {
                if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
                {
                    e.Cancel = true;
                }
            };
            CB_Format.Items[0] = MsgAny;
            CenterToParent();
        }
Ejemplo n.º 22
0
 private void B_Output_Click(object sender, EventArgs e)
 {
     WinFormsUtil.SaveMGDialog(mg);
 }
Ejemplo n.º 23
0
        private void pbBoxSlot_DragDrop(object sender, DragEventArgs e)
        {
            DragInfo.Destination.Parent = this;
            DragInfo.Destination.Slot   = getSlot(sender);
            DragInfo.Destination.Offset = getPKXOffset(DragInfo.Destination.Slot);
            DragInfo.Destination.Box    = CB_BoxSelect.SelectedIndex;

            // Check for In-Dropped files (PKX,SAV,ETC)
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            if (Directory.Exists(files[0]))
            {
                return;
            }
            if (SAV.getIsSlotLocked(DragInfo.Destination.Box, DragInfo.Destination.Slot))
            {
                DragInfo.Destination.Slot = -1; // Invalidate
                WinFormsUtil.Alert("Unable to set to locked slot.");
                return;
            }
            if (DragInfo.Source.Offset < 0) // file
            {
                if (files.Length <= 0)
                {
                    return;
                }
                string   file = files[0];
                FileInfo fi   = new FileInfo(file);
                if (!PKX.getIsPKM(fi.Length) && !MysteryGift.getIsMysteryGift(fi.Length))
                {
                    return;
                }

                byte[]      data = File.ReadAllBytes(file);
                MysteryGift mg   = MysteryGift.getMysteryGift(data, fi.Extension);
                PKM         temp = mg != null?mg.convertToPKM(SAV) : PKMConverter.getPKMfromBytes(data, prefer: SAV.Generation);

                string c;

                PKM pk = PKMConverter.convertToFormat(temp, SAV.PKMType, out c);
                if (pk == null)
                {
                    WinFormsUtil.Error(c); Console.WriteLine(c); return;
                }

                string[] errata = SAV.IsPKMCompatible(pk);
                if (errata.Length > 0)
                {
                    string concat = string.Join(Environment.NewLine, errata);
                    if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, concat, "Continue?"))
                    {
                        Console.WriteLine(c); Console.WriteLine(concat); return;
                    }
                }

                DragInfo.SetPKM(pk, false);
                getQuickFiller(SlotPictureBoxes[DragInfo.Destination.Slot], pk);
                Console.WriteLine(c);
            }
            else
            {
                PKM pkz = DragInfo.GetPKM(true);
                if (!DragInfo.Source.IsValid)
                {
                }                                                                  // not overwritable, do nothing
                else if (ModifierKeys == Keys.Alt && DragInfo.Destination.IsValid) // overwrite
                {
                    // Clear from slot
                    if (DragInfo.SameBox)
                    {
                        getQuickFiller(SlotPictureBoxes[DragInfo.Source.Slot], SAV.BlankPKM); // picturebox
                    }
                    DragInfo.SetPKM(SAV.BlankPKM, true);
                }
                else if (ModifierKeys != Keys.Control && DragInfo.Destination.IsValid) // move
                {
                    // Load data from destination
                    PKM pk = ((PictureBox)sender).Image != null
                        ? DragInfo.GetPKM(false)
                        : SAV.BlankPKM;

                    // Set destination pokemon image to source picture box
                    if (DragInfo.SameBox)
                    {
                        getQuickFiller(SlotPictureBoxes[DragInfo.Source.Slot], pk);
                    }

                    // Set destination pokemon data to source slot
                    DragInfo.SetPKM(pk, true);
                }
                else if (DragInfo.SameBox) // clone
                {
                    getQuickFiller(SlotPictureBoxes[DragInfo.Source.Slot], pkz);
                }

                // Copy from temp to destination slot.
                DragInfo.SetPKM(pkz, false);
                getQuickFiller(SlotPictureBoxes[DragInfo.Destination.Slot], pkz);

                e.Effect = DragDropEffects.Link;
                Cursor   = DefaultCursor;
            }
            if (DragInfo.Source.IsParty || DragInfo.Destination.IsParty)
            {
                parent.setParty();
            }
            if (DragInfo.Source.Parent == null) // another instance or file
            {
                parent.notifyBoxViewerRefresh();
                DragInfo.Reset();
            }
        }
Ejemplo n.º 24
0
        private void DiffSaves()
        {
            if (!File.Exists(TB_OldSAV.Text))
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 1)); return;
            }
            if (!File.Exists(TB_NewSAV.Text))
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 2)); return;
            }
            if (new FileInfo(TB_OldSAV.Text).Length > 0x100000)
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 1)); return;
            }
            if (new FileInfo(TB_NewSAV.Text).Length > 0x100000)
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 2)); return;
            }

            var s1 = SaveUtil.GetVariantSAV(TB_OldSAV.Text);
            var s2 = SaveUtil.GetVariantSAV(TB_NewSAV.Text);

            if (s1 == null)
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 1)); return;
            }
            if (s2 == null)
            {
                WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 2)); return;
            }

            if (s1.GetType() != s2.GetType())
            {
                WinFormsUtil.Alert(MsgSaveDifferentTypes, $"S1: {s1.GetType().Name}", $"S2: {s2.GetType().Name}"); return;
            }
            if (s1.Version != s2.Version)
            {
                WinFormsUtil.Alert(MsgSaveDifferentVersions, $"S1: {s1.Version}", $"S2: {s2.Version}"); return;
            }

            var tbIsSet = new List <int>();
            var tbUnSet = new List <int>();
            var result  = new List <string>();

            bool[] oldBits  = s1.EventFlags;
            bool[] newBits  = s2.EventFlags;
            var    oldConst = s1.EventConsts;
            var    newConst = s2.EventConsts;

            for (int i = 0; i < oldBits.Length; i++)
            {
                if (oldBits[i] != newBits[i])
                {
                    (newBits[i] ? tbIsSet : tbUnSet).Add(i);
                }
            }
            TB_IsSet.Text = string.Join(", ", tbIsSet.Select(z => $"{z:0000}"));
            TB_UnSet.Text = string.Join(", ", tbUnSet.Select(z => $"{z:0000}"));

            for (int i = 0; i < newConst.Length; i++)
            {
                if (oldConst[i] != newConst[i])
                {
                    result.Add($"{i}: {oldConst[i]}->{newConst[i]}");
                }
            }

            if (result.Count == 0)
            {
                WinFormsUtil.Alert("No Event Constant diff found.");
                return;
            }

            if (DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Copy Event Constant diff to clipboard?"))
            {
                Clipboard.SetText(string.Join(Environment.NewLine, result));
            }
        }
Ejemplo n.º 25
0
        // View Updates
        private void B_Search_Click(object sender, EventArgs e)
        {
            // Populate Search Query Result
            IEnumerable <MysteryGift> res = RawDB;

            int format = MAXFORMAT + 1 - CB_Format.SelectedIndex;

            switch (CB_FormatComparator.SelectedIndex)
            {
            case 0: /* Do nothing */ break;

            case 1: res = res.Where(mg => mg.Format >= format); break;

            case 2: res = res.Where(mg => mg.Format == format); break;

            case 3: res = res.Where(mg => mg.Format <= format); break;
            }

            // Primary Searchables
            int species = WinFormsUtil.GetIndex(CB_Species);
            int item    = WinFormsUtil.GetIndex(CB_HeldItem);

            if (species != -1)
            {
                res = res.Where(pk => pk.Species == species);
            }
            if (item != -1)
            {
                res = res.Where(pk => pk.HeldItem == item);
            }

            // Secondary Searchables
            int move1 = WinFormsUtil.GetIndex(CB_Move1);
            int move2 = WinFormsUtil.GetIndex(CB_Move2);
            int move3 = WinFormsUtil.GetIndex(CB_Move3);
            int move4 = WinFormsUtil.GetIndex(CB_Move4);

            if (move1 != -1)
            {
                res = res.Where(mg => mg.HasMove(move1));
            }
            if (move2 != -1)
            {
                res = res.Where(mg => mg.HasMove(move2));
            }
            if (move3 != -1)
            {
                res = res.Where(mg => mg.HasMove(move3));
            }
            if (move4 != -1)
            {
                res = res.Where(mg => mg.HasMove(move4));
            }
            if (CHK_Shiny.CheckState == CheckState.Checked)
            {
                res = res.Where(pk => pk.IsShiny);
            }
            if (CHK_Shiny.CheckState == CheckState.Unchecked)
            {
                res = res.Where(pk => !pk.IsShiny);
            }
            if (CHK_IsEgg.CheckState == CheckState.Checked)
            {
                res = res.Where(pk => pk.IsEgg);
            }
            if (CHK_IsEgg.CheckState == CheckState.Unchecked)
            {
                res = res.Where(pk => !pk.IsEgg);
            }

            slotSelected = -1; // reset the slot last viewed

            if (RTB_Instructions.Lines.Any(line => line.Length > 0))
            {
                var filters = StringInstruction.GetFilters(RTB_Instructions.Lines).ToArray();
                BatchEditing.ScreenStrings(filters);
                res = res.Where(pkm => BatchEditing.IsFilterMatch(filters, pkm)); // Compare across all filters
            }

            var results = res.ToArray();

            if (results.Length == 0)
            {
                WinFormsUtil.Alert(MsgDBSearchNone);
            }

            SetResults(new List <MysteryGift>(results)); // updates Count Label as well.
            System.Media.SystemSounds.Asterisk.Play();
        }
Ejemplo n.º 26
0
        public SAV_MysteryGiftDB(PKMEditor tabs, SAVEditor sav)
        {
            InitializeComponent();

            ToolStripMenuItem mnuView = new ToolStripMenuItem {
                Name = "mnuView", Text = "View"
            };
            ToolStripMenuItem mnuSaveMG = new ToolStripMenuItem {
                Name = "mnuSaveMG", Text = "Save Gift"
            };
            ToolStripMenuItem mnuSavePK = new ToolStripMenuItem {
                Name = "mnuSavePK", Text = "Save PKM"
            };

            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            ContextMenuStrip mnu = new ContextMenuStrip();

            mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuSaveMG, mnuSavePK });

            SAV       = sav.SAV;
            BoxView   = sav;
            PKME_Tabs = tabs;

            // Preset Filters to only show PKM available for loaded save
            CB_FormatComparator.SelectedIndex = 3; // <=

            PKXBOXES = new[]
            {
                bpkx1, bpkx2, bpkx3, bpkx4, bpkx5, bpkx6,
                bpkx7, bpkx8, bpkx9, bpkx10, bpkx11, bpkx12,
                bpkx13, bpkx14, bpkx15, bpkx16, bpkx17, bpkx18,
                bpkx19, bpkx20, bpkx21, bpkx22, bpkx23, bpkx24,
                bpkx25, bpkx26, bpkx27, bpkx28, bpkx29, bpkx30,

                bpkx31, bpkx32, bpkx33, bpkx34, bpkx35, bpkx36,
                bpkx37, bpkx38, bpkx39, bpkx40, bpkx41, bpkx42,
                bpkx43, bpkx44, bpkx45, bpkx46, bpkx47, bpkx48,
                bpkx49, bpkx50, bpkx51, bpkx52, bpkx53, bpkx54,
                bpkx55, bpkx56, bpkx57, bpkx58, bpkx59, bpkx60,
                bpkx61, bpkx62, bpkx63, bpkx64, bpkx65, bpkx66,
            };

            // Enable Scrolling when hovered over
            foreach (var slot in PKXBOXES)
            {
                // Enable Click
                slot.MouseClick += (sender, e) =>
                {
                    if (ModifierKeys == Keys.Control)
                    {
                        ClickView(sender, e);
                    }
                };
            }

            Counter       = L_Count.Text;
            Viewed        = L_Viewed.Text;
            L_Viewed.Text = string.Empty; // invis for now
            var hover = new ToolTip();

            L_Viewed.MouseEnter += (sender, e) => hover.SetToolTip(L_Viewed, L_Viewed.Text);

            // Assign event handlers
            mnuView.Click   += ClickView;
            mnuSaveMG.Click += ClickSaveMG;
            mnuSavePK.Click += ClickSavePK;

            // Assign to datagridview
            foreach (PictureBox p in PKXBOXES)
            {
                p.ContextMenuStrip = mnu;
            }

            // Load Data
            B_Search.Enabled = false;
            L_Count.Text     = "Loading...";
            new Task(LoadDatabase).Start();

            Menu_SearchSettings.DropDown.Closing += (sender, e) =>
            {
                if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
                {
                    e.Cancel = true;
                }
            };
            CB_Format.Items[0] = MsgAny;
            CenterToParent();
        }
Ejemplo n.º 27
0
 private void B_OK_Click(object sender, EventArgs e)
 {
     Result = (GameVersion)WinFormsUtil.GetIndex(CB_Game);
     Close();
 }
Ejemplo n.º 28
0
        public SAV_MailBox(SaveFile sav)
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            SAV     = (Origin = sav).Clone();
            Gen     = SAV.Generation;
            p       = SAV.PartyData;
            editing = true;

            Messages = new[]
            {
                new[] { NUD_Message00, NUD_Message01, NUD_Message02, NUD_Message03 },
                new[] { NUD_Message10, NUD_Message11, NUD_Message12, NUD_Message13 },
                new[] { NUD_Message20, NUD_Message21, NUD_Message22, NUD_Message23 }
            };
            PKMLabels    = new[] { L_PKM1, L_PKM2, L_PKM3, L_PKM4, L_PKM5, L_PKM6 };
            PKMHeldItems = new[] { L_HeldItem1, L_HeldItem2, L_HeldItem3, L_HeldItem4, L_HeldItem5, L_HeldItem6 };
            PKMNUDs      = new[] { NUD_MailID1, NUD_MailID2, NUD_MailID3, NUD_MailID4, NUD_MailID5, NUD_MailID6 };
            AppearPKMs   = new[] { CB_AppearPKM1, CB_AppearPKM2, CB_AppearPKM3 };
            Miscs        = new[] { NUD_Misc1, NUD_Misc2, NUD_Misc3 };

            NUD_BoxSize.Visible       = L_BoxSize.Visible = Gen == 2;
            GB_MessageTB.Visible      = Gen == 2;
            GB_MessageNUD.Visible     = Gen != 2;
            Messages[0][3].Visible    = Messages[1][3].Visible = Messages[2][3].Visible = Gen == 4 || Gen == 5;
            NUD_AuthorSID.Visible     = Gen != 2;
            Label_OTGender.Visible    = CB_AuthorLang.Visible = CB_AuthorVersion.Visible = Gen == 4 || Gen == 5;
            L_AppearPKM.Visible       = AppearPKMs[0].Visible = Gen != 5;
            AppearPKMs[1].Visible     = AppearPKMs[2].Visible = Gen == 4;
            NUD_MessageEnding.Visible = Gen == 5;
            L_MiscValue.Visible       = NUD_Misc1.Visible = NUD_Misc2.Visible = NUD_Misc3.Visible = Gen == 5;

            for (int i = p.Count; i < 6; i++)
            {
                PKMNUDs[i].Visible = PKMLabels[i].Visible = PKMHeldItems[i].Visible = false;
            }
            if (Gen != 3)
            {
                for (int i = 0; i < PKMNUDs.Length; i++)
                {
                    PKMNUDs[i].Value   = i;
                    PKMNUDs[i].Enabled = false;
                }
            }

            switch (SAV)
            {
            case SAV2 sav2:
                m = new Mail2[6 + 10];
                for (int i = 0; i < m.Length; i++)
                {
                    m[i] = new Mail2(sav2, i);
                }

                NUD_BoxSize.Value = SAV.Data[0x834];
                MailItemID        = new[] { 0x9E, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD };
                PartyBoxCount     = 6;
                break;

            case SAV3 sav3:
                m = new Mail3[6 + 10];
                for (int i = 0; i < m.Length; i++)
                {
                    var ofs  = sav3.GetMailOffset(i);
                    var data = sav.GetData(ofs, Mail3.SIZE);
                    m[i] = new Mail3(data, ofs, sav3.Japanese);
                }

                MailItemID    = Enumerable.Range(0x79, 12).ToArray();
                PartyBoxCount = 6;
                break;

            case SAV4 sav4:
                m = new Mail4[p.Count + 20];
                for (int i = 0; i < p.Count; i++)
                {
                    m[i] = new Mail4(((PK4)p[i]).HeldMailData);
                }
                for (int i = p.Count, j = 0; i < m.Length; i++, j++)
                {
                    int ofs = sav4.GetMailOffset(j);
                    m[i] = new Mail4(sav4.GetMailData(ofs), ofs);
                }
                var l4 = (Mail4)m.Last();
                ResetVer      = l4.AuthorVersion;
                ResetLang     = l4.AuthorLanguage;
                MailItemID    = Enumerable.Range(0x89, 12).ToArray();
                PartyBoxCount = p.Count;
                break;

            case SAV5 sav5:
                m = new Mail5[p.Count + 20];
                for (int i = 0; i < p.Count; i++)
                {
                    m[i] = new Mail5(((PK5)p[i]).GetHeldMailData());
                }
                for (int i = p.Count, j = 0; i < m.Length; i++, j++)
                {
                    int ofs  = SAV5.GetMailOffset(j);
                    var data = sav5.GetMailData(ofs);
                    m[i] = new Mail5(data, ofs);
                }
                var l5 = (Mail5)m.Last();
                ResetVer      = l5.AuthorVersion;
                ResetLang     = l5.AuthorLanguage;
                MailItemID    = Enumerable.Range(0x89, 12).ToArray();
                PartyBoxCount = p.Count;
                break;
            }
            MakePartyList();
            MakePCList();

            if (Gen == 2 || Gen == 3)
            {
                CB_AppearPKM1.Items.Clear();
                CB_AppearPKM1.InitializeBinding();
                CB_AppearPKM1.DataSource = new BindingSource(GameInfo.FilteredSources.Species.ToList(), null);
            }
            else if (Gen == 4 || Gen == 5)
            {
                var species = GameInfo.FilteredSources.Species.ToList();
                foreach (ComboBox a in AppearPKMs)
                {
                    a.Items.Clear();
                    a.InitializeBinding();
                    a.DataSource = new BindingSource(species, null);
                }

                CB_AuthorVersion.Items.Clear();
                CB_AuthorVersion.InitializeBinding();
                CB_AuthorVersion.DataSource = new BindingSource(Gen == 4
                    ? new[] {
                    new ComboItem("Diamond", (int)GameVersion.D),
                    new ComboItem("Pearl", (int)GameVersion.P),
                    new ComboItem("Platinum", (int)GameVersion.Pt),
                    new ComboItem("HeartGold", (int)GameVersion.HG),
                    new ComboItem("SoulSilver", (int)GameVersion.SS),
                }
                    : new[] {
                    new ComboItem("Black", (int)GameVersion.B),
                    new ComboItem("White", (int)GameVersion.W),
                    new ComboItem("Black2", (int)GameVersion.B2),
                    new ComboItem("White2", (int)GameVersion.W2),
                }, null);

                CB_AuthorLang.Items.Clear();
                CB_AuthorLang.InitializeBinding();
                CB_AuthorLang.DataSource = new BindingSource(new[] {
                    // not sure
                    new ComboItem("JPN", 1),
                    new ComboItem("ENG", 2),
                    new ComboItem("FRE", 3),
                    new ComboItem("ITA", 4),
                    new ComboItem("GER", 5),
                    new ComboItem("ESP", 7),
                    new ComboItem("KOR", 8),
                }, null);
            }

            var ItemList = GameInfo.Strings.GetItemStrings(Gen, SAV.Version);

            CB_MailType.Items.Clear();
            CB_MailType.Items.Add(ItemList[0]);
            foreach (int item in MailItemID)
            {
                CB_MailType.Items.Add(ItemList[item]);
            }

            LoadPKM(true);
            entry   = -1;
            editing = false;
            if (LB_PartyHeld.Items.Count > 0)
            {
                LB_PartyHeld.SelectedIndex = 0;
            }
            else if (LB_PCBOX.Items.Count > 0)
            {
                LB_PCBOX.SelectedIndex = 0;
            }
        }
Ejemplo n.º 29
0
        public SAV_Misc4(SAV4 sav)
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            int ofsFlag;

            SAV = (SAV4)(Origin = sav).Clone();

            switch (SAV.Version)
            {
            case GameVersion.D or GameVersion.P or GameVersion.DP:
                ofsFlag              = 0xFDC;
                ofsBP                = 0x65F8;
                ofsUGFlagCount       = 0x3A60;
                L_CurrentMap.Visible = CB_UpgradeMap.Visible = false;
                GB_Prints.Visible    = GB_Prints.Enabled = GB_Hall.Visible = GB_Hall.Enabled = GB_Castle.Visible = GB_Castle.Enabled = false;
                BFF = new[] { new[] { 0, 1, 0x5FCA, 0x04, 0x6601 } };
                break;

            case GameVersion.Pt:
                ofsFlag              = 0xFEC;
                ofsBP                = 0x7234;
                ofsUGFlagCount       = 0x3CE8;
                L_CurrentMap.Visible = CB_UpgradeMap.Visible = false;
                ofsPrints            = 0xE4A;
                BFF = new[] {
                    new[] { 0, 1, 0x68E0, 0x04, 0x723D },
                    new[] { 1, 0, 0x68F4, 0x10, 0x7EF8 },
                    new[] { 0, 0, 0x6924, 0x18, 0x7EFC },
                    new[] { 2, 0, 0x696C, 0x10, 0x7F00 },
                    new[] { 0, 0, 0x699C, 0x04, 0x7F04 },
                };
                ofsHallStat = 0x2820;
                break;

            case GameVersion.HG or GameVersion.SS or GameVersion.HGSS:
                ofsFlag            = 0x10C4;
                ofsBP              = 0x5BB8;
                L_UGFlags.Visible  = NUD_UGFlags.Visible = false;
                GB_Poketch.Visible = false;
                ofsMap             = 0xBAE7;
                ofsPrints          = 0xE7E;
                BFF = new[] {
                    // { BFV, BFT, addr, 1BFTlen, checkBit
                    new[] { 0, 1, 0x5264, 0x04, 0x5BC1 },
                    new[] { 1, 0, 0x5278, 0x10, 0x687C },
                    new[] { 0, 0, 0x52A8, 0x18, 0x6880 },
                    new[] { 2, 0, 0x52F0, 0x10, 0x6884 },
                    new[] { 0, 0, 0x5320, 0x04, 0x6888 },
                };
                ofsHallStat = 0x230C;
                break;

            default: return;
            }
            ofsFly = ofsFlag + 0x136;
            ReadMain();
            ReadBattleFrontier();
            if (SAV is SAV4Sinnoh s)
            {
                TC_Misc.Controls.Remove(TAB_Walker);
                poffinCase4Editor1.Initialize(s);
                TC_Misc.Controls.Remove(Tab_PokeGear);
            }
            else
            {
                pokeGear4Editor1.Initialize((SAV4HGSS)SAV);
                TC_Misc.Controls.Remove(Tab_Poffins);
            }
        }
Ejemplo n.º 30
0
        public SAV_Misc3(SaveFile sav)
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            SAV = (SAV3)(Origin = sav).Clone();

            if (SAV.FRLG || SAV.E)
            {
                ReadJoyful();
            }
            else
            {
                tabControl1.Controls.Remove(TAB_Joyful);
            }

            if (SAV.E)
            {
                ReadFerry();
                ReadBattleFrontier();
            }
            else
            {
                tabControl1.Controls.Remove(TAB_Ferry);
                tabControl1.Controls.Remove(TAB_BF);
            }

            if (SAV.FRLG)
            {
                TB_OTName.Text = StringConverter.GetString3(SAV.Data, SAV.GetBlockOffset(4) + 0xBCC, 8, SAV.Japanese);
                ComboBox[] cba            = { CB_TCM1, CB_TCM2, CB_TCM3, CB_TCM4, CB_TCM5, CB_TCM6 };
                int[]      HoennListMixed =
                {
                    277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300,
                    304, 305, 309, 310, 392, 393, 394, 311, 312, 306, 307, 364, 365, 366, 301, 302, 303, 370, 371, 372, 335, 336, 350, 320, 315, 316,
                    322, 355, 382, 383, 384, 356, 357, 337, 338, 353, 354, 386, 387, 363, 367, 368, 330, 331, 313, 314,
                    339, 340, 321, 351, 352, 308, 332, 333, 334, 344, 345, 358, 359, 380, 379, 348, 349, 323, 324,
                    326, 327, 318, 319, 388, 389, 390, 391, 328, 329, 385, 317, 377, 378, 361, 362, 369, 411, 376, 360,
                    346, 347, 341, 342, 343, 373, 374, 375, 381, 325, 395, 396, 397, 398, 399, 400,
                    401, 402, 403, 407, 408, 404, 405, 406, 409, 410
                };
                var speciesList = GameInfo.SpeciesDataSource.Where(v => v.Value <= SAV.MaxSpeciesID).Select(v => new ComboItem {
                    Text  = v.Text,
                    Value = v.Value < 252 ? v.Value : HoennListMixed[v.Value - 252],
                }).ToList();
                int ofsTCM = SAV.GetBlockOffset(2) + 0x106;
                for (int i = 0; i < cba.Length; i++)
                {
                    cba[i].Items.Clear();
                    cba[i].DisplayMember = "Text";
                    cba[i].ValueMember   = "Value";
                    cba[i].DataSource    = new BindingSource(speciesList, null);
                    cba[i].SelectedValue = (int)BitConverter.ToUInt16(SAV.Data, ofsTCM + (i << 1));
                }
            }
            else
            {
                TB_OTName.Visible = L_TrainerName.Visible = GB_TCM.Visible = false;
            }

            NUD_BP.Value    = Math.Min(NUD_BP.Maximum, SAV.BP);
            NUD_Coins.Value = Math.Min(NUD_Coins.Maximum, SAV.Coin);
        }