Ejemplo n.º 1
0
        private static void ClickDelete(object sender, EventArgs e)
        {
            SlotChangeManager m = GetSenderInfo(ref sender, out SlotChange info);

            if (m == null)
            {
                return;
            }

            if ((sender as PictureBox)?.Image == null)
            {
                System.Media.SystemSounds.Asterisk.Play(); return;
            }

            var sav = m.SE.SAV;

            if (info.IsParty && sav.IsPartyAllEggs(info.Slot - 30) && !m.SE.HaX)
            {
                WinFormsUtil.Alert("Can't delete this slot."); return;
            }
            if (sav.IsSlotLocked(info.Box, info.Slot))
            {
                WinFormsUtil.Alert("Can't delete locked slot."); return;
            }

            if (info.Slot >= 30 && info.Slot < 36) // Party
            {
                m.SetPKM(sav.BlankPKM, info, true, Resources.slotDel);
                return;
            }
            if (info.Slot < 30 || m.SE.HaX)
            {
                if (info.Slot < 30)
                {
                    m.SE.UndoStack.Push(new SlotChange
                    {
                        Box    = info.Box,
                        Slot   = info.Slot,
                        Offset = info.Offset,
                        PKM    = sav.GetStoredSlot(info.Offset)
                    });
                    m.SE.Menu_Undo.Enabled = true;
                }
                m.SetPKM(sav.BlankPKM, info, true, Resources.slotDel);
            }
            else
            {
                return;
            }

            m.SE.RedoStack.Clear(); m.SE.Menu_Redo.Enabled = false;
        }
Ejemplo n.º 2
0
        private void ClickDelete(object sender, EventArgs e)
        {
            SlotChangeManager m = GetSenderInfo(ref sender, out SlotChange info);

            if (m == null)
            {
                return;
            }

            if ((sender as PictureBox)?.Image == null)
            {
                System.Media.SystemSounds.Asterisk.Play(); return;
            }

            var sav = m.SE.SAV;

            if (info.IsParty && sav.IsPartyAllEggs(info.Slot) && !m.SE.HaX)
            {
                WinFormsUtil.Alert(MsgSaveSlotEmpty); return;
            }
            if (sav.IsSlotLocked(info.Box, info.Slot))
            {
                WinFormsUtil.Alert(MsgSaveSlotLocked); return;
            }

            m.HoverCancel();

            if (info.Type == StorageSlotType.Party) // Party
            {
                m.SetPKM(sav.BlankPKM, info, true, Resources.slotDel);
                return;
            }
            if (info.Type == StorageSlotType.Box || m.SE.HaX)
            {
                if (info.Type == StorageSlotType.Box)
                {
                    m.SE.UndoStack.Push(new SlotChange(info, sav));
                    m.SE.Menu_Undo.Enabled = true;
                }
                m.SetPKM(sav.BlankPKM, info, true, Resources.slotDel);
            }
            else
            {
                return;
            }

            m.SE.RedoStack.Clear(); m.SE.Menu_Redo.Enabled = false;
        }
Ejemplo n.º 3
0
        private void ClickSet(object sender, EventArgs e)
        {
            SlotChangeManager m = GetSenderInfo(ref sender, out SlotChange info);

            if (m == null)
            {
                return;
            }

            var editor = m.SE.PKME_Tabs;
            var sav    = m.SE.SAV;

            if (info.IsParty && editor.IsEmptyOrEgg && sav.IsPartyAllEggs(info.Slot) && !m.SE.HaX)
            {
                WinFormsUtil.Alert(MsgSaveSlotEmpty); return;
            }
            if (m.SE.SAV.IsSlotLocked(info.Box, info.Slot))
            {
                WinFormsUtil.Alert(MsgSaveSlotLocked); return;
            }

            if (!editor.VerifiedPKM())
            {
                return;
            }

            PKM pk = editor.PreparePKM();

            string[] errata = sav.IsPKMCompatible(pk);
            if (errata.Length > 0 && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, string.Join(Environment.NewLine, errata), MsgContinue))
            {
                return;
            }

            if (info.Type == StorageSlotType.Party) // Party
            {
                // If info.Slot isn't overwriting existing PKM, make it write to the lowest empty PKM info.Slot
                if (sav.PartyCount < info.Slot + 1)
                {
                    var pb   = (PictureBox)WinFormsUtil.GetUnderlyingControl(sender);
                    var view = WinFormsUtil.FindFirstControlOfType <ISlotViewer <PictureBox> >(pb);
                    info = view.GetSlotData(view.SlotPictureBoxes[sav.PartyCount]);
                }
                m.SetPKM(pk, info, true, Resources.slotSet);
            }
            else if (info.Type == StorageSlotType.Box || m.SE.HaX)
            {
                if (info.Type == StorageSlotType.Box)
                {
                    m.SE.UndoStack.Push(new SlotChange(info, sav));
                    m.SE.Menu_Undo.Enabled = true;
                }

                m.SetPKM(pk, info, true, Resources.slotSet);
            }
            else
            {
                return;
            }

            editor.LastData = pk.Data;
            m.SE.RedoStack.Clear(); m.SE.Menu_Redo.Enabled = false;
        }
Ejemplo n.º 4
0
        // Command to set in box (for multiple imports)
        public void ClickSet(object sender, int slot)
        {
            SlotChangeManager m = GetSenderInfo(ref sender, out SlotChange info, slot);

            if (m == null)
            {
                return;
            }

            var editor = m.SE.PKME_Tabs;
            var sav    = m.SE.SAV;

            if (info.IsParty && editor.IsEmptyOrEgg && sav.IsPartyAllEggs(info.Slot - 30) && !m.SE.HaX)
            {
                WinFormsUtil.Alert("Can't have empty/egg party."); return;
            }
            if (m.SE.SAV.IsSlotLocked(info.Box, info.Slot))
            {
                WinFormsUtil.Alert("Can't set to locked slot."); return;
            }

            PKM pk = editor.PreparePKM();

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

            if (info.Slot >= 30)
            {
                info.Box = -1;
            }
            if (info.Slot >= 30 && info.Slot < 36) // Party
            {
                // If info.Slot isn't overwriting existing PKM, make it write to the lowest empty PKM info.Slot
                if (sav.PartyCount < info.Slot + 1 - 30)
                {
                    info.Slot   = sav.PartyCount + 30;
                    info.Offset = m.SE.GetPKMOffset(info.Slot);
                }
                m.SetPKM(pk, info, true, Resources.slotSet);
            }
            else if (info.Slot < 30 || m.SE.HaX)
            {
                if (info.Slot < 30)
                {
                    m.SE.UndoStack.Push(new SlotChange
                    {
                        Box    = info.Box,
                        Slot   = info.Slot,
                        Offset = info.Offset,
                        PKM    = sav.GetStoredSlot(info.Offset)
                    });
                    m.SE.Menu_Undo.Enabled = true;
                }

                m.SetPKM(pk, info, true, Resources.slotSet);
            }

            editor.LastData = pk.Data;
            m.SE.RedoStack.Clear(); m.SE.Menu_Redo.Enabled = false;
        }