private void ClickSet(object sender, EventArgs e) { var 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.EditsComplete) { return; } PKM pk = editor.PreparePKM(); var errata = sav.IsPKMCompatible(pk); if (errata.Count > 0 && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, string.Join(Environment.NewLine, errata), MsgContinue)) { return; } m.HoverCancel(); 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; }
// 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; }
private void GiveAllItems(object sender, EventArgs e) { // Get Current Pouch int pouch = CurrentPouch; if (pouch < 0) { return; } var p = Pouches[pouch]; ushort[] legalitems = (ushort[])p.LegalItems.Clone(); bool resize = legalitems.Length > p.Items.Length; if (resize) { var dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Pouch is too small for all items.", "Yes: Give by Item ID" + Environment.NewLine + "No: Random assortment"); if (dr == DialogResult.Cancel) { return; } if (dr == DialogResult.No) { Util.Shuffle(legalitems); } Array.Resize(ref legalitems, p.Items.Length); } DataGridView dgv = Controls.Find(DGVPrefix + p.Type, true).FirstOrDefault() as DataGridView; SetBag(dgv, p); int Count = (int)NUD_Count.Value; for (int i = 0; i < legalitems.Length; i++) { ushort item = legalitems[i]; var itemname = itemlist[item]; int c = Count; // Override for HMs if (IsItemCount1(item, SAV)) { c = 1; } int l = 0; dgv.Rows[i].Cells[l++].Value = itemname; dgv.Rows[i].Cells[l++].Value = c; var t = p.Items.FirstOrDefault(m => m.Index == item); if (HasFreeSpace) { dgv.Rows[i].Cells[l++].Value = t?.FreeSpace ?? false; } if (HasNew) { dgv.Rows[i].Cells[l].Value = t?.New ?? CHK_NEW.Checked; } } System.Media.SystemSounds.Asterisk.Play(); }
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 = Pouches.FirstOrDefault(z => z.Type == InventoryType.KeyItems); if (p == null) { throw new ArgumentException(nameof(InventoryType)); } // 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; }