public void hardReset(SaveFile SAV = null) { SaveFile CURRSAV = new SAVEditor().SAV; if (SAV != null) { CURRSAV = SAV; } else { CurrentSAV = new PKHeX.WinForms.Controls.SAVEditor(); CurrentSAV.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); CurrentSAV.Location = new System.Drawing.Point(292, 26); CurrentSAV.Name = "C_SAV"; CurrentSAV.Size = new System.Drawing.Size(310, 326); CurrentSAV.TabIndex = 104; CURRSAV = CurrentSAV.SAV; } if (CURRSAV.USUM || CURRSAV.SM) { if (TryLoadPKM(new ConstData().resetpk7, "", "pk7", CURRSAV)) { return; } } else if (CURRSAV.ORAS || CURRSAV.XY) { if (TryLoadPKM(new ConstData().resetpk6, "", "pk6", CURRSAV)) { return; } } }
public BoxMenuStrip(SAVEditor SAV) { sav = SAV; foreach (Level z in Enum.GetValues(typeof(Level))) { var ctrl = new ToolStripMenuItem { Name = $"mnu_{z}", Text = z.ToString(), Image = GetImage(z) }; Items.Add(ctrl); } AddItem(Level.Delete, GetItem("All", "Clear", () => Clear(), Resources.nocheck)); AddItem(Level.Delete, GetItem("Eggs", "Eggs", () => Clear(pk => ModifierKeys == Keys.Control != pk.IsEgg), Resources.about), s => s.Generation >= 2); AddItem(Level.Delete, GetItem("PastGen", "Past Generation", () => Clear(pk => pk.GenNumber != sav.SAV.Generation), Resources.bak), s => s.Generation >= 4); AddItem(Level.Delete, GetItem("Foreign", "Foreign", () => Clear(pk => !sav.SAV.IsOriginalHandler(pk, pk.Format > 2)), Resources.users)); AddItem(Level.Delete, GetItem("Untrained", "Untrained", () => Clear(pk => pk.EVTotal == 0), Resources.gift)); AddItem(Level.Delete, GetItem("Itemless", "No Held Item", () => Clear(pk => pk.HeldItem == 0), Resources.main), s => s.Generation >= 2); AddItem(Level.Delete, GetItem("Illegal", "Illegal", () => Clear(pk => ModifierKeys == Keys.Control != !new LegalityAnalysis(pk).Valid), Resources.export)); AddItem(Level.SortBox, GetItem("Species", "Pokédex No.", () => Sort(PKMSorting.OrderBySpecies), Resources.numlohi)); AddItem(Level.SortBox, GetItem("SpeciesRev", "Pokédex No. (Reverse)", () => Sort(PKMSorting.OrderByDescendingSpecies), Resources.numhilo)); AddItem(Level.SortBox, GetItem("Level", "Level (Low to High)", () => Sort(PKMSorting.OrderByLevel), Resources.vallohi)); AddItem(Level.SortBox, GetItem("LevelRev", "Level (High to Low)", () => Sort(PKMSorting.OrderByDescendingLevel), Resources.valhilo)); AddItem(Level.SortBox, GetItem("Date", "Met Date", () => Sort(PKMSorting.OrderByDateObtained), Resources.date), s => s.Generation >= 4); AddItem(Level.SortBox, GetItem("Name", "Species Name", () => Sort(list => list.OrderBySpeciesName(GameInfo.Strings.Species)), Resources.alphaAZ)); AddItem(Level.SortBox, GetItem("Shiny", "Shiny", () => Sort(list => list.OrderByCustom(pk => !pk.IsShiny)), Resources.showdown)); AddItem(Level.SortBox, GetItem("Random", "Random", () => Sort(list => list.OrderByCustom(_ => Util.Rand32())), Resources.wand)); AddItem(Level.SortBoxAdvanced, GetItem("Usage", "Usage", () => Sort(PKMSorting.OrderByUsage), Resources.heart), s => s.Generation >= 3); AddItem(Level.SortBoxAdvanced, GetItem("Potential", "IV Potential", () => Sort(list => list.OrderByCustom(pk => pk.MaxIV * 6 - pk.IVTotal)), Resources.numhilo)); AddItem(Level.SortBoxAdvanced, GetItem("Training", "EV Training", () => Sort(list => list.OrderByCustom(pk => pk.MaxEV * 6 - pk.EVTotal)), Resources.showdown)); AddItem(Level.SortBoxAdvanced, GetItem("Owner", "Ownership", () => Sort(list => list.OrderByOwnership(sav.SAV)), Resources.users)); AddItem(Level.SortBoxAdvanced, GetItem("Type", "Type", () => Sort(list => list.OrderByCustom(pk => pk.PersonalInfo.Type1, pk => pk.PersonalInfo.Type2)), Resources.main)); AddItem(Level.SortBoxAdvanced, GetItem("Version", "Version", () => Sort(list => list.OrderByCustom(pk => pk.GenNumber, pk => pk.Version)), Resources.numlohi), s => s.Generation >= 3); AddItem(Level.SortBoxAdvanced, GetItem("BST", "Base Stat Total", () => Sort(list => list.OrderByCustom(pk => pk.PersonalInfo.BST)), Resources.vallohi)); AddItem(Level.SortBoxAdvanced, GetItem("Legal", "Legal", () => Sort(list => list.OrderByCustom(pk => !new LegalityAnalysis(pk).Valid)), Resources.export)); AddItem(Level.Modify, GetItem("HatchEggs", "Hatch Eggs", () => Modify(z => z.ForceHatchPKM()), Resources.about), s => s.Generation >= 2); AddItem(Level.Modify, GetItem("MaxFriendship", "Max Friendship", () => Modify(z => z.MaximizeFriendship()), Resources.heart)); AddItem(Level.Modify, GetItem("MaxLevel", "Max Level", () => Modify(z => z.MaximizeLevel()), Resources.showdown)); AddItem(Level.Modify, GetItem("ResetMoves", "Reset Moves", () => Modify(z => z.SetMoves(z.GetMoveSet())), Resources.date), s => s.Generation >= 3); AddItem(Level.Modify, GetItem("RandomMoves", "Randomize Moves", () => Modify(z => z.SetMoves(z.GetMoveSet(true))), Resources.wand)); AddItem(Level.Modify, GetItem("HyperTrain", "Hyper Train", () => Modify(z => z.SetSuggestedHyperTrainingData()), Resources.vallohi), s => s.Generation >= 7); AddItem(Level.Modify, GetItem("RemoveNicknames", "Remove Nicknames", () => Modify(z => z.SetDefaultNickname()), Resources.alphaAZ)); AddItem(Level.Modify, GetItem("RemoveItem", "Delete Held Item", () => Modify(z => z.HeldItem = 0), Resources.gift), s => s.Generation >= 2); }
public BoxMenuStrip(SAVEditor SAV) { Manipulator = new BoxManipulatorWF(SAV); sav = SAV; var Levels = BoxManipUtil.ManipCategories; var LevelNames = BoxManipUtil.ManipCategoryNames; for (int i = 0; i < Levels.Length; i++) { var level = Levels[i]; var sprite = TopLevelImages[i]; var name = LevelNames[i]; var parent = new ToolStripMenuItem { Name = $"mnu_{name}", Text = name, Image = sprite }; foreach (var item in level) { AddItem(SAV, parent, item); } Items.Add(parent); } }
public BoxMenuStrip(SAVEditor sav) { Manipulator = new BoxManipulatorWF(sav); SAV = sav; var categories = BoxManipUtil.ManipCategories; var names = BoxManipUtil.ManipCategoryNames; for (int i = 0; i < categories.Length; i++) { var category = categories[i]; var sprite = TopLevelImages[i]; var name = names[i]; var parent = new ToolStripMenuItem { Name = $"mnu_{name}", Text = name, Image = sprite }; foreach (var item in category) { AddItem(sav, parent, item); } Items.Add(parent); } }
/// <summary> /// Function to extract trainerdata values from trainerdata.json /// </summary> /// <param name="C_SAV">Current Save Editor</param> /// <param name="Game">optional Game value in case of mode being game</param> /// <returns></returns> public string[] parseTrainerJSON(SAVEditor C_SAV, int Game = -1) { if (!System.IO.File.Exists(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\trainerdata.json")) { return(parseTrainerData(C_SAV)); // Default trainerdata.txt handling } string jsonstring = System.IO.File.ReadAllText(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\trainerdata.json", System.Text.Encoding.UTF8); if (Game == -1) { Game = C_SAV.SAV.Game; } if (!checkIfGameExists(jsonstring, Game, out string finaljson)) { return(parseTrainerData(C_SAV, finaljson == "auto")); } string TID = getValueFromKey("TID", finaljson); string SID = getValueFromKey("SID", finaljson); string OT = getValueFromKey("OT", finaljson); string Gender = getValueFromKey("Gender", finaljson); string Country = getValueFromKey("Country", finaljson); string SubRegion = getValueFromKey("SubRegion", finaljson); string ConsoleRegion = getValueFromKey("3DSRegion", finaljson); if (TID.Length == 6 && SID.Length == 4) { if (new List <int> { 33, 32, 31, 30 }.IndexOf(Game) == -1) { WinFormsUtil.Alert("Force Converting G7TID/G7SID to TID/SID"); } int[] tidsid = ConvertTIDSID7toTIDSID(int.Parse(TID), int.Parse(SID)); TID = tidsid[0].ToString(); SID = tidsid[1].ToString(); } return(new string[] { TID, SID, OT, Gender, Country, SubRegion, ConsoleRegion }); }
/// <summary> /// Parser for auto and preset trainerdata.txt files /// </summary> /// <param name="C_SAV">SAVEditor of the current save file</param> /// <returns></returns> public string[] parseTrainerData(SAVEditor C_SAV, bool auto = false) { // Defaults string TID = "23456"; string SID = "34567"; string OT = "Archit"; string Gender = "M"; string Country = "Canada"; string SubRegion = "Alberta"; string ConsoleRegion = "Americas (NA/SA)"; if (!System.IO.File.Exists(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\trainerdata.txt")) { return(new string[] { TID, SID, OT, Gender, Country, SubRegion, ConsoleRegion }); // Default No trainerdata.txt handling } string[] trainerdataLines = System.IO.File.ReadAllText(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\trainerdata.txt", System.Text.Encoding.UTF8) .Split(new string[] { Environment.NewLine }, StringSplitOptions.None); List <string> lstlines = trainerdataLines.OfType <string>().ToList(); int count = lstlines.Count; for (int i = 0; i < count; i++) { string item = lstlines[0]; if (item.TrimEnd() == "" || item.TrimEnd() == "auto") { continue; } string key = item.Split(':')[0].TrimEnd(); string value = item.Split(':')[1].TrimEnd(); lstlines.RemoveAt(0); if (key == "TID") { TID = value; } else if (key == "SID") { SID = value; } else if (key == "OT") { OT = value; } else if (key == "Gender") { Gender = value; } else if (key == "Country") { Country = value; } else if (key == "SubRegion") { SubRegion = value; } else if (key == "3DSRegion") { ConsoleRegion = value; } else { continue; } } // Automatic loading if (trainerdataLines[0] == "auto" || auto) { try { int ct = PKMConverter.Country; int sr = PKMConverter.Region; int cr = PKMConverter.ConsoleRegion; if (C_SAV.SAV.Gender == 1) { Gender = "F"; } return(new string[] { C_SAV.SAV.TID.ToString("00000"), C_SAV.SAV.SID.ToString("00000"), C_SAV.SAV.OT, Gender, ct.ToString(), sr.ToString(), cr.ToString() }); } catch { return(new string[] { TID, SID, OT, Gender, Country, SubRegion, ConsoleRegion }); } } if (TID.Length == 6 && SID.Length == 4) { int[] tidsid = ConvertTIDSID7toTIDSID(int.Parse(TID), int.Parse(SID)); TID = tidsid[0].ToString(); SID = tidsid[1].ToString(); } return(new string[] { TID, SID, OT, Gender, Country, SubRegion, ConsoleRegion }); }
public SlotChangeManager(SAVEditor se) { SE = se; Reset(); }
public BoxManipulatorWF(SAVEditor editor) { Editor = editor; }
public SlotChangeManager(SAVEditor se) => SE = se;
public SlotChangeManager(SAVEditor se) { HoverWorker = new BitmapAnimator(Resources.slotHover); SE = se; }
public string[] parseTrainerData(SAVEditor C_SAV) { // Defaults string TID = "23456"; string SID = "34567"; string OT = "Archit"; string Gender = "M"; string Country = ""; string SubRegion = ""; string ConsoleRegion = ""; if (!System.IO.File.Exists(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\trainerdata.txt")) { return(new string[] { TID, SID, OT, Gender, Country, SubRegion, ConsoleRegion }); // Default No trainerdata.txt handling } string[] trainerdataLines = System.IO.File.ReadAllText(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\trainerdata.txt", System.Text.Encoding.UTF8) .Split(new string[] { Environment.NewLine }, StringSplitOptions.None); List <string> lstlines = trainerdataLines.OfType <string>().ToList(); int count = lstlines.Count; for (int i = 0; i < count; i++) { string item = lstlines[0]; if (item.TrimEnd() == "" || item.TrimEnd() == "auto") { continue; } string key = item.Split(':')[0].TrimEnd(); string value = item.Split(':')[1].TrimEnd(); lstlines.RemoveAt(0); if (key == "TID") { TID = value; } else if (key == "SID") { SID = value; } else if (key == "OT") { OT = value; } else if (key == "Gender") { Gender = value; } else if (key == "Country") { Country = value; } else if (key == "SubRegion") { SubRegion = value; } else if (key == "3DSRegion") { ConsoleRegion = value; } else { continue; } } // Automatic loading if (trainerdataLines[0] == "auto") { try { if (C_SAV.SAV.Gender == 1) { Gender = "F"; } return(new string[] { C_SAV.SAV.TID.ToString("00000"), C_SAV.SAV.SID.ToString("00000"), C_SAV.SAV.OT, Gender, CB_Country.GetItemText(CB_Country.Items[C_SAV.SAV.Country]), CB_SubRegion.GetItemText(CB_SubRegion.Items[C_SAV.SAV.SubRegion]), CB_3DSReg.GetItemText(CB_3DSReg.Items[C_SAV.SAV.ConsoleRegion]) }); } catch { return(new string[] { TID, SID, OT, Gender, Country, SubRegion, ConsoleRegion }); } } return(new string[] { TID, SID, OT, Gender, Country, SubRegion, ConsoleRegion }); }
public static ContextMenuStrip GetSortStrip(this SAVEditor sav) { var sortMenu = new ContextMenuStrip(); foreach (Level z in Enum.GetValues(typeof(Level))) { var ctrl = new ToolStripMenuItem { Name = $"mnu_{z}", Text = z.ToString(), Image = GetImage(z) }; sortMenu.Items.Add(ctrl); } Image GetImage(Level l) { switch (l) { case Level.Delete: return(Resources.nocheck); case Level.SortBox: return(Resources.swapBox); case Level.SortBoxAdvanced: return(Resources.settings); case Level.Modify: return(Resources.wand); default: return(null); } } AddItem(Level.Delete, GetItem("All", "Clear", () => Clear(), Resources.nocheck)); AddItem(Level.Delete, GetItem("Eggs", "Eggs", () => Clear(pk => Control.ModifierKeys == Keys.Control != pk.IsEgg), Resources.about)); AddItem(Level.Delete, GetItem("PastGen", "Past Generation", () => Clear(pk => pk.GenNumber != sav.SAV.Generation), Resources.bak)); AddItem(Level.Delete, GetItem("Foreign", "Foreign", () => Clear(pk => !sav.SAV.IsOriginalHandler(pk, pk.Format > 2)), Resources.users)); AddItem(Level.Delete, GetItem("Untrained", "Untrained", () => Clear(pk => pk.EVTotal == 0), Resources.gift)); AddItem(Level.Delete, GetItem("Itemless", "No Held Item", () => Clear(pk => pk.HeldItem == 0), Resources.main)); AddItem(Level.Delete, GetItem("Illegal", "Illegal", () => Clear(pk => Control.ModifierKeys == Keys.Control != !new LegalityAnalysis(pk).Valid), Resources.export)); AddItem(Level.SortBox, GetItem("Species", "Pokédex No.", () => Sort(PKMSorting.OrderBySpecies), Resources.numlohi)); AddItem(Level.SortBox, GetItem("SpeciesRev", "Pokédex No. (Reverse)", () => Sort(PKMSorting.OrderByDescendingSpecies), Resources.numhilo)); AddItem(Level.SortBox, GetItem("Level", "Level (Low to High)", () => Sort(PKMSorting.OrderByLevel), Resources.vallohi)); AddItem(Level.SortBox, GetItem("LevelRev", "Level (High to Low)", () => Sort(PKMSorting.OrderByDescendingLevel), Resources.valhilo)); AddItem(Level.SortBox, GetItem("Date", "Met Date", () => Sort(PKMSorting.OrderByDateObtained), Resources.date)); AddItem(Level.SortBox, GetItem("Name", "Species Name", () => Sort(list => list.OrderBySpeciesName(GameInfo.Strings.Species)), Resources.alphaAZ)); AddItem(Level.SortBox, GetItem("Shiny", "Shiny", () => Sort(list => list.OrderByCustom(pk => !pk.IsShiny)), Resources.showdown)); AddItem(Level.SortBox, GetItem("Random", "Random", () => Sort(list => list.OrderByCustom(_ => Util.Rand32())), Resources.wand)); AddItem(Level.SortBoxAdvanced, GetItem("Usage", "Usage", () => Sort(PKMSorting.OrderByUsage), Resources.heart)); AddItem(Level.SortBoxAdvanced, GetItem("Potential", "IV Potential", () => Sort(list => list.OrderByCustom(pk => pk.MaxIV * 6 - pk.IVTotal)), Resources.numhilo)); AddItem(Level.SortBoxAdvanced, GetItem("Training", "EV Training", () => Sort(list => list.OrderByCustom(pk => pk.MaxEV * 6 - pk.EVTotal)), Resources.showdown)); AddItem(Level.SortBoxAdvanced, GetItem("Owner", "Ownership", () => Sort(list => list.OrderByOwnership(sav.SAV)), Resources.users)); AddItem(Level.SortBoxAdvanced, GetItem("Type", "Type", () => Sort(list => list.OrderByCustom(pk => pk.PersonalInfo.Type1, pk => pk.PersonalInfo.Type2)), Resources.main)); AddItem(Level.SortBoxAdvanced, GetItem("Version", "Version", () => Sort(list => list.OrderByCustom(pk => pk.GenNumber, pk => pk.Version)), Resources.numlohi)); AddItem(Level.SortBoxAdvanced, GetItem("BST", "Base Stat Total", () => Sort(list => list.OrderByCustom(pk => pk.PersonalInfo.BST)), Resources.vallohi)); AddItem(Level.SortBoxAdvanced, GetItem("Legal", "Legal", () => Sort(list => list.OrderByCustom(pk => !new LegalityAnalysis(pk).Valid)), Resources.export)); AddItem(Level.Modify, GetItem("HatchEggs", "Hatch Eggs", () => Modify(z => z.ForceHatchPKM()), Resources.about)); AddItem(Level.Modify, GetItem("MaxFriendship", "Max Friendship", () => Modify(z => z.MaximizeFriendship()), Resources.heart)); AddItem(Level.Modify, GetItem("MaxLevel", "Max Level", () => Modify(z => z.MaximizeLevel()), Resources.showdown)); AddItem(Level.Modify, GetItem("RemoveItem", "Delete Held Item", () => Modify(z => z.HeldItem = 0), Resources.gift)); void AddItem(Level v, ToolStripItem t) { var item = (ToolStripMenuItem)sortMenu.Items[(int)v]; t.Name = $"{item.Name}{t.Name}"; item.DropDownItems.Add(t); } void Clear(Func <PKM, bool> criteria = null) { if (Control.ModifierKeys.HasFlag(Keys.Shift)) { sav.ClearAll(criteria); } else { sav.ClearCurrent(criteria); } } void Sort(Func <IEnumerable <PKM>, IEnumerable <PKM> > sorter) { bool reverse = Control.ModifierKeys.HasFlag(Keys.Control); if (Control.ModifierKeys.HasFlag(Keys.Shift)) { sav.SortAll(sorter, reverse); } else { sav.SortCurrent(sorter, reverse); } } void Modify(Action <PKM> action) { if (Control.ModifierKeys.HasFlag(Keys.Shift)) { sav.ModifyAll(action); } else { sav.ModifyCurrent(action); } } return(sortMenu); }