Ejemplo n.º 1
0
        public void HandleMovePKM(PictureBox pb, bool encrypt)
        {
            // Create a temporary PKM file to perform a drag drop operation.

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

            // Prepare Data
            DragInfo.Source = GetViewParent(pb).GetSlotData(pb);
            DragInfo.Source.OriginalData = SAV.GetData(DragInfo.Source.Offset, SAV.SIZE_STORED);

            // Make a new file name based off the PID
            string newfile = CreateDragDropPKM(pb, encrypt, out bool external);

            DragInfo.Reset();
            SetCursor(SE.GetDefaultCursor, pb);

            // 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?
            int delay = external ? 500 : 0;

            DeleteAsync(newfile, delay);
            if (DragInfo.Source.IsParty || DragInfo.Destination.IsParty)
            {
                SE.SetParty();
            }
        }
Ejemplo n.º 2
0
        public void SetEncounterCount(int index, ushort value)
        {
            var ofs  = PokeDex + 0x686 + (index * 2);
            var data = BitConverter.GetBytes(value);

            SAV.SetData(data, ofs);
        }
Ejemplo n.º 3
0
 private string CreateDragDropPKM(PictureBox pb, bool encrypt, out bool external)
 {
     byte[] dragdata = SAV.DecryptPKM(DragInfo.Source.OriginalData);
     Array.Resize(ref dragdata, SAV.SIZE_STORED);
     PKM    pkx      = SAV.GetPKM(dragdata);
     string fn       = pkx.FileName; fn = fn.Substring(0, fn.LastIndexOf('.'));
     string filename = $"{fn}{(encrypt ? $".ek{pkx.Format}" : $".{pkx.Extension}")}";
Ejemplo n.º 4
0
        private void getSlotFiller(int offset, PictureBox pb)
        {
            if (SAV.getData(offset, SAV.SIZE_STORED).SequenceEqual(new byte[SAV.SIZE_STORED]))
            {
                // 00s present in slot.
                pb.Image     = null;
                pb.BackColor = Color.Transparent;
                return;
            }
            PKM p = SAV.getStoredSlot(offset);

            if (!p.Valid) // Invalid
            {
                // Bad Egg present in slot.
                pb.Image     = null;
                pb.BackColor = Color.Red;
                return;
            }

            int slot = getSlot(pb);

            pb.Image     = p.Sprite(SAV, CB_BoxSelect.SelectedIndex, slot, parent.Menu_FlagIllegal.Checked);
            pb.BackColor = Color.Transparent;
            pb.Visible   = true;
        }
Ejemplo n.º 5
0
        public void SetBoxName(int box, string value)
        {
            var data   = SAV.SetString(value, strlen, strlen, 0);
            var offset = GetBoxNameOffset(box);

            SAV.SetData(Data, data, offset);
        }
Ejemplo n.º 6
0
        private void getSlotFiller(int offset, PictureBox pb)
        {
            if (SAV.getData(offset, SAV.SIZE_STORED).SequenceEqual(new byte[SAV.SIZE_STORED]))
            {
                // 00s present in slot.
                pb.Image     = null;
                pb.BackColor = Color.Transparent;
                return;
            }
            PKM p = SAV.getStoredSlot(offset);

            if (!p.Valid) // Invalid
            {
                // Bad Egg present in slot.
                pb.Image     = null;
                pb.BackColor = Color.Red;
                return;
            }
            // Something stored in slot. Only display if species is valid.
            var  sprite = p.Species != 0 ? p.Sprite : null;
            int  slot   = getSlot(pb);
            bool locked = slot < 30 && SAV.getIsSlotLocked(CB_BoxSelect.SelectedIndex, slot);
            bool team   = slot < 30 && SAV.getIsTeamSet(CB_BoxSelect.SelectedIndex, slot);

            if (locked)
            {
                sprite = Util.LayerImage(sprite, Properties.Resources.locked, 26, 0, 1);
            }
            else if (team)
            {
                sprite = Util.LayerImage(sprite, Properties.Resources.team, 21, 0, 1);
            }
            pb.Image     = sprite;
            pb.BackColor = Color.Transparent;
        }
Ejemplo n.º 7
0
        public void MouseMove(object sender, MouseEventArgs e)
        {
            if (!CanStartDrag)
            {
                return;
            }

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

            if (pb.Image == null)
            {
                return;
            }
            var view = WinFormsUtil.FindFirstControlOfType <ISlotViewer <PictureBox> >(pb);
            var src  = view.GetSlotData(pb);

            if (!src.Editable || SAV.IsSlotLocked(src.Box, src.Slot))
            {
                return;
            }
            bool encrypt = Control.ModifierKeys == Keys.Control;

            HandleMovePKM(pb, encrypt);
        }
Ejemplo n.º 8
0
        public SAV_BoxLayout(int box)
        {
            InitializeComponent();
            Util.TranslateInterface(this, Main.curlanguage);
            editing = true;

            // Repopulate Wallpaper names
            CB_BG.Items.Clear();
            foreach (string wallpaper in Main.GameStrings.wallpapernames)
            {
                CB_BG.Items.Add(wallpaper);
            }

            // Go
            LB_BoxSelect.Items.Clear();
            for (int i = 0; i < SAV.BoxCount; i++)
            {
                LB_BoxSelect.Items.Add(SAV.getBoxName(i));
            }

            // Flags
            byte[] flags = SAV.BoxFlags;
            if (flags != null)
            {
                flagArr = new NumericUpDown[flags.Length];
                for (int i = 0; i < flags.Length; i++)
                {
                    flagArr[i] = new NumericUpDown
                    {
                        Minimum     = 0,
                        Maximum     = 255,
                        Width       = CB_Unlocked.Width - 5,
                        Hexadecimal = true,
                        Value       = flags[i]
                    };
                    FLP_Flags.Controls.Add(flagArr[i]);
                }
            }
            else
            {
                FLP_Flags.Visible = false;
            }

            // Unlocked
            if (SAV.BoxesUnlocked > 0)
            {
                CB_Unlocked.Items.Clear();
                for (int i = 0; i < SAV.BoxCount; i++)
                {
                    CB_Unlocked.Items.Add(i + 1);
                }
                CB_Unlocked.SelectedIndex = SAV.BoxesUnlocked;
            }
            else
            {
                FLP_Unlocked.Visible = L_Unlocked.Visible = CB_Unlocked.Visible = false;
            }
            LB_BoxSelect.SelectedIndex = box;
        }
Ejemplo n.º 9
0
        public SAV_BoxViewer(Main p)
        {
            InitializeComponent();
            parent = p;
            CenterToParent();

            AllowDrop  = true;
            DragEnter += tabMain_DragEnter;
            DragDrop  += (sender, e) =>
            {
                Cursor = DefaultCursor;
                System.Media.SystemSounds.Asterisk.Play();
            };

            SlotPictureBoxes = 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,
            };
            foreach (PictureBox pb in SlotPictureBoxes)
            {
                pb.AllowDrop          = true;
                pb.GiveFeedback      += (sender, e) => { e.UseDefaultCursors = false; };
                pb.MouseUp           += pbBoxSlot_MouseUp;
                pb.MouseDown         += pbBoxSlot_MouseDown;
                pb.MouseMove         += pbBoxSlot_MouseMove;
                pb.DragDrop          += pbBoxSlot_DragDrop;
                pb.DragEnter         += pbBoxSlot_DragEnter;
                pb.QueryContinueDrag += pbBoxSlot_QueryContinueDrag;
                pb.MouseEnter        += pbBoxSlot_MouseEnter;
                pb.MouseLeave        += pbBoxSlot_MouseLeave;
            }
            for (int i = SAV.BoxSlotCount; i < SlotPictureBoxes.Length; i++)
            {
                SlotPictureBoxes[i].Visible = false;
            }

            try
            {
                CB_BoxSelect.Items.Clear();
                for (int i = 0; i < SAV.BoxCount; i++)
                {
                    CB_BoxSelect.Items.Add(SAV.getBoxName(i));
                }
            }
            catch
            {
                CB_BoxSelect.Items.Clear();
                for (int i = 1; i <= SAV.BoxCount; i++)
                {
                    CB_BoxSelect.Items.Add($"BOX {i}");
                }
            }
            CB_BoxSelect.SelectedIndex = 0;
        }
Ejemplo n.º 10
0
        public void setPKXBoxes()
        {
            int boxoffset = SAV.getBoxOffset(CB_BoxSelect.SelectedIndex);
            int boxbgval  = SAV.getBoxWallpaper(CB_BoxSelect.SelectedIndex);

            PAN_Box.BackgroundImage = SAV.WallpaperImage(boxbgval);

            for (int i = 0; i < SAV.BoxSlotCount; i++)
            {
                getSlotFiller(boxoffset + SAV.SIZE_STORED * i, SlotPictureBoxes[i]);
            }
        }
Ejemplo n.º 11
0
        private void getQuickFiller(PictureBox pb, PKM pk)
        {
            var  sprite = pk.Species != 0 ? pk.Sprite : null;
            int  slot   = getSlot(pb);
            bool locked = slot < 30 && SAV.getIsSlotLocked(CB_BoxSelect.SelectedIndex, slot);

            if (locked)
            {
                sprite = Util.LayerImage(sprite, Properties.Resources.locked, 5, 0, 1);
            }
            pb.Image = sprite;
            if (pb.BackColor == Color.Red)
            {
                pb.BackColor = Color.Transparent;
            }
        }
Ejemplo n.º 12
0
        public void SaveBattleTeams()
        {
            for (int i = 0; i < TeamCount * 6; i++)
            {
                int index = TeamSlots[i];
                if (index < 0)
                {
                    BitConverter.GetBytes((short)index).CopyTo(Data, Offset + (i * 2));
                    continue;
                }

                SAV.GetBoxSlotFromIndex(index, out var box, out var slot);
                int val = (box << 8) | slot;
                BitConverter.GetBytes((short)val).CopyTo(Data, Offset + (i * 2));
            }
        }
Ejemplo n.º 13
0
        private void BeginHoverSlot(PictureBox pb)
        {
            var view = WinFormsUtil.FindFirstControlOfType <ISlotViewer <PictureBox> >(pb);
            var data = view.GetSlotData(pb);
            var pk   = SAV.GetStoredSlot(data.Offset);

            HoveredSlot = pb;

            if (Settings.Default.HoverSlotShowText)
            {
                ShowSimulatorSetTooltip(pb, pk);
            }
            if (Settings.Default.HoverSlotPlayCry)
            {
                PlayCry(pk);
            }
        }
Ejemplo n.º 14
0
        public void DragDrop(object sender, DragEventArgs e)
        {
            PictureBox pb   = (PictureBox)sender;
            var        view = WinFormsUtil.FindFirstControlOfType <ISlotViewer <PictureBox> >(pb);
            var        src  = view.GetSlotData(pb);

            if (!src.Editable || SAV.IsSlotLocked(src.Box, src.Slot))
            {
                SystemSounds.Asterisk.Play();
                e.Effect = DragDropEffects.Copy;
                DragInfo.Reset();
                return;
            }

            bool overwrite = Control.ModifierKeys == Keys.Alt;
            bool clone     = Control.ModifierKeys == Keys.Control;

            DragInfo.Destination = src;
            HandleDropPKM(sender, e, overwrite, clone);
        }
Ejemplo n.º 15
0
        public SAV_SimplePokedex()
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.curlanguage);
            seen   = new bool[SAV.MaxSpeciesID];
            caught = new bool[SAV.MaxSpeciesID];

            string[] spec = Util.getSpeciesList(Main.curlanguage);
            for (int i = 0; i < seen.Length; i++)
            {
                int species = i + 1;
                seen[i]   = SAV.getSeen(species);
                caught[i] = SAV.getCaught(species);
                CLB_Seen.Items.Add(spec[species]);
                CLB_Caught.Items.Add(spec[species]);
                CLB_Seen.SetItemChecked(i, seen[i]);
                CLB_Caught.SetItemChecked(i, caught[i]);
            }
            initialized = true;
        }
Ejemplo n.º 16
0
        private string CreateDragDropPKM(PictureBox pb, bool encrypt, out bool external)
        {
            byte[] dragdata = SAV.DecryptPKM(DragInfo.Source.OriginalData);
            Array.Resize(ref dragdata, SAV.SIZE_STORED);

            // Make File
            PKM    pk      = SAV.GetPKM(dragdata);
            string newfile = FileUtil.GetPKMTempFileName(pk, encrypt);

            try
            {
                TryMakeDragDropPKM(pb, encrypt, pk, newfile, out external);
            }
            catch (Exception x)
            {
                WinFormsUtil.Error("Drag & Drop Error", x);
                external = false;
            }

            return(newfile);
        }
Ejemplo n.º 17
0
        private void BeginHoverSlot(PictureBox pb)
        {
            var view = WinFormsUtil.FindFirstControlOfType <ISlotViewer <PictureBox> >(pb);
            var data = view.GetSlotData(pb);
            var pk   = SAV.GetStoredSlot(data.Offset);

            HoveredSlot = pb;

            OriginalBackground = pb.BackgroundImage;

            Bitmap hover;

            if (GlowHover)
            {
                HoverWorker?.Stop();

                var GlowBase = GetGlowSprite(pk);
                hover       = ImageUtil.LayerImage(GlowBase, Resources.slotHover, 0, 0);
                HoverWorker = new BitmapAnimator(GlowBase, Resources.slotHover)
                {
                    GlowFromColor = GlowInitial, GlowToColor = GlowFinal
                };
                HoverWorker.Start(pb, OriginalBackground);
            }
            else
            {
                hover = Resources.slotHover;
            }

            pb.BackgroundImage = CurrentBackground = OriginalBackground == null ? hover : ImageUtil.LayerImage(OriginalBackground, hover, 0, 0);

            if (Settings.Default.HoverSlotShowText)
            {
                ShowSimulatorSetTooltip(pb, pk);
            }
            if (Settings.Default.HoverSlotPlayCry)
            {
                PlayCry(pk);
            }
        }
Ejemplo n.º 18
0
        private void getSlotFiller(int offset, PictureBox pb)
        {
            if (SAV.getData(offset, SAV.SIZE_STORED).SequenceEqual(new byte[SAV.SIZE_STORED]))
            {
                // 00s present in slot.
                pb.Image     = null;
                pb.BackColor = Color.Transparent;
                return;
            }
            PKM p = SAV.getStoredSlot(offset);

            if (!p.Valid) // Invalid
            {
                // Bad Egg present in slot.
                pb.Image     = null;
                pb.BackColor = Color.Red;
                return;
            }
            // Something stored in slot. Only display if species is valid.
            pb.Image     = p.Species == 0 ? null : p.Sprite;
            pb.BackColor = Color.Transparent;
        }
Ejemplo n.º 19
0
        private void ReloadDaycareSlots()
        {
            var s1 = SAV.GetDaycareSlotOffset(CurrentDaycare, 0);

            if (s1 < 0)
            {
                return;
            }
            Slots.Add(new StorageSlotOffset {
                IsPartyFormat = false, Offset = s1, Type = StorageSlotType.Daycare
            });
            var s2 = SAV.GetDaycareSlotOffset(CurrentDaycare, 1);

            if (s2 < 0)
            {
                return;
            }
            Slots.Add(new StorageSlotOffset {
                IsPartyFormat = false, Offset = s2, Type = StorageSlotType.Daycare
            });
            Capacity = Slots.Count;
        }
Ejemplo n.º 20
0
        private string CreateDragDropPKM(PictureBox pb, bool encrypt, out bool external)
        {
            byte[] dragdata = SAV.DecryptPKM(DragInfo.Source.OriginalData);
            Array.Resize(ref dragdata, SAV.SIZE_STORED);
            PKM    pkx      = SAV.GetPKM(dragdata);
            string fn       = pkx.FileName; fn = fn.Substring(0, fn.LastIndexOf('.'));
            string filename = fn + (encrypt ? $".ek{pkx.Format}" : $".{pkx.Extension}");

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

            try
            {
                TryMakeDragDropPKM(pb, encrypt, pkx, newfile, out external);
            }
            catch (Exception x)
            {
                WinFormsUtil.Error("Drag & Drop Error", x);
                external = false;
            }

            return(newfile);
        }
Ejemplo n.º 21
0
 public string GetBoxName(int box)
 {
     return(SAV.GetString(Data, GetBoxNameOffset(box), SAV6.LongStringLength));
 }
Ejemplo n.º 22
0
 // Copied Methods from Main.cs (slightly modified)
 private int getPKXOffset(int slot)
 {
     return(SAV.getBoxOffset(CB_BoxSelect.SelectedIndex) + slot * SAV.SIZE_STORED);
 }
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 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.º 25
0
        public SAV_BoxLayout(int box)
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.curlanguage);
            editing = true;

            // Repopulate Wallpaper names
            CB_BG.Items.Clear();

            switch (SAV.Generation)
            {
            case 3:
                if (SAV.GameCube)
                {
                    goto default;
                }
                CB_BG.Items.AddRange(GameInfo.Strings.wallpapernames.Take(16).ToArray());
                break;

            case 4:
            case 5:
            case 6:
                CB_BG.Items.AddRange(GameInfo.Strings.wallpapernames);
                break;

            case 7:
                CB_BG.Items.AddRange(GameInfo.Strings.wallpapernames.Take(16).ToArray());
                break;

            default:
                WinFormsUtil.Error("Box layout is not supported for this game.", "Please close the window.");
                break;
            }

            // Go
            LB_BoxSelect.Items.Clear();
            for (int i = 0; i < SAV.BoxCount; i++)
            {
                LB_BoxSelect.Items.Add(SAV.getBoxName(i));
            }

            // Flags
            byte[] flags = SAV.BoxFlags;
            if (flags != null)
            {
                flagArr = new NumericUpDown[flags.Length];
                for (int i = 0; i < flags.Length; i++)
                {
                    flagArr[i] = new NumericUpDown
                    {
                        Minimum     = 0,
                        Maximum     = 255,
                        Width       = CB_Unlocked.Width - 5,
                        Hexadecimal = true,
                        Value       = flags[i]
                    };
                    FLP_Flags.Controls.Add(flagArr[i]);
                }
            }
            else
            {
                FLP_Flags.Visible = false;
            }

            // Unlocked
            if (SAV.BoxesUnlocked > 0)
            {
                CB_Unlocked.Items.Clear();
                for (int i = 0; i <= SAV.BoxCount; i++)
                {
                    CB_Unlocked.Items.Add(i);
                }
                CB_Unlocked.SelectedIndex = Math.Min(SAV.BoxCount, SAV.BoxesUnlocked);
            }
            else
            {
                FLP_Unlocked.Visible = L_Unlocked.Visible = CB_Unlocked.Visible = false;
            }
            LB_BoxSelect.SelectedIndex = box;
        }
Ejemplo n.º 26
0
 public void SetBoxName(int box, string value) => SAV.SetString(GetBoxNameSpan(box), value.AsSpan(), StringMaxLength, StringConverterOption.ClearZero);
Ejemplo n.º 27
0
 public string GetBoxName(int box) => SAV.GetString(GetBoxNameSpan(box));
Ejemplo n.º 28
0
 protected virtual void SetFlag(int ofs, int bitIndex, bool value = true) => SAV.SetFlag(PokeDex + ofs + (bitIndex >> 3), bitIndex, value);
Ejemplo n.º 29
0
 protected virtual bool GetFlag(int ofs, int bitIndex) => SAV.GetFlag(PokeDex + ofs + (bitIndex >> 3), bitIndex);
Ejemplo n.º 30
0
        private void openQuick(string path)
        {
            byte[] data = File.ReadAllBytes(path);
            if (data.Length != SAV.SIZE)
            {
                Error("Invalid file size!",
                    String.Format("File size was 0x{0} bytes.", data.Length.ToString("X")));
                return;
            }

            sav = new SAV(data);

            NUD_Rupees.Value = sav.Rupees;
            TB_PlayerName.Text = sav.PlayerName;
            offset = -1;
            CB_Info.SelectedIndex = 0;
            getItem();
            GB_Save.Enabled = Menu_Save.Enabled = Menu_Tools.Enabled = true;
        }
Ejemplo n.º 31
0
 protected override int GetOffset(int index) => SAV.GetBoxSlotOffset(index);