PKHeX/PKHeX.WinForms/Subforms/Save Editors/Gen1/SAV_EventReset1.cs
Kurt 3c232505e5
Refactoring: Narrow some value types (Species, Move, Form) (#3575)
In this pull request I've changed a ton of method signatures to reflect the more-narrow types of Species, Move# and Form; additionally, I've narrowed other large collections that stored lists of species / permitted values, and reworked them to be more performant with the latest API spaghetti that PKHeX provides. Roamer met locations, usually in a range of [max-min]<64, can be quickly checked using a bitflag operation on a UInt64. Other collections (like "Is this from Colosseum or XD") were eliminated -- shadow state is not transferred COLO<->XD, so having a Shadow ID or matching the met location from a gift/wild encounter is a sufficient check for "originated in XD".
2022-08-26 23:43:36 -07:00

52 lines
1.5 KiB
C#

using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using PKHeX.Core;
namespace PKHeX.WinForms;
public partial class SAV_EventReset1 : Form
{
private readonly G1OverworldSpawner Overworld;
private void SAV_EventReset1_FormClosing(object sender, FormClosingEventArgs e) => Overworld.Save();
public SAV_EventReset1(SaveFile sav)
{
InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
Overworld = new G1OverworldSpawner((SAV1)sav);
InitializeButtons();
}
private void InitializeButtons()
{
var pairs = Overworld.GetFlagPairs().OrderBy(z => z.Name);
foreach (var pair in pairs)
{
var split = pair.Name.Split('_');
var specName = split[0][G1OverworldSpawner.FlagPropertyPrefix.Length..];
// convert species name to current localization language
var species = SpeciesName.GetSpeciesID(specName);
var pkmname = GameInfo.Strings.specieslist[species];
if (split.Length != 1)
pkmname += $" {split[1]}";
var b = new Button
{
Text = pkmname, Enabled = pair.IsHidden,
Size = new Size((Width / 2) - 25, 22),
};
b.Click += (s, e) =>
{
pair.Reset();
b.Enabled = false;
WinFormsUtil.Alert("Reset!");
};
FLP_List.Controls.Add(b);
}
}
}