PKHeX/PKHeX.WinForms/Subforms/Save Editors/SAV_SimplePokedex.cs
Kurt b81a1e1e29 Refactoring
Increase abstraction for arbitrary slot get/set operations, and fracture
SAV4 behavior for each game type.

Adds: Undo/Redo of party slot changes
Fixes: Fixed Gen5 daycare slot 2 reading, and EXP reading
Fixes: Some slot color glitchiness
Fixed: Box layout editor now hides the flag label if no flags are
present
Fixed: Gen7 box flags are now shown (unknown purpose lol)
Changed: savefile objects are generally smaller (removed a few shared
offset fields)
2019-09-02 19:30:58 -07:00

91 lines
2.8 KiB
C#

using System;
using System.Windows.Forms;
using PKHeX.Core;
namespace PKHeX.WinForms
{
public partial class SAV_SimplePokedex : Form
{
private readonly SaveFile Origin;
private readonly SaveFile SAV;
public SAV_SimplePokedex(SaveFile sav)
{
InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
SAV = (Origin = sav).Clone();
seen = new bool[SAV.MaxSpeciesID];
caught = new bool[SAV.MaxSpeciesID];
string[] spec = Util.GetSpeciesList(Main.CurrentLanguage);
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;
}
private readonly bool[] seen;
private readonly bool[] caught;
private readonly bool initialized;
private void B_Save_Click(object sender, EventArgs e)
{
for (int i = 0; i < seen.Length; i++)
{
int species = i + 1;
SAV.SetSeen(species, seen[i]);
SAV.SetCaught(species, caught[i]);
}
Origin.CopyChangesFrom(SAV);
Close();
}
private void B_Cancel_Click(object sender, EventArgs e)
{
Close();
}
private void B_SeenAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
CLB_Seen.SetItemChecked(i, true);
}
private void B_SeenNone_Click(object sender, EventArgs e)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
CLB_Seen.SetItemChecked(i, false);
}
private void B_CaughtAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
CLB_Caught.SetItemChecked(i, true);
}
private void B_CaughtNone_Click(object sender, EventArgs e)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
CLB_Caught.SetItemChecked(i, false);
}
private void CLB_Seen_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (!initialized) return;
seen[e.Index] = e.NewValue == CheckState.Checked;
}
private void CLB_Caught_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (!initialized) return;
caught[e.Index] = e.NewValue == CheckState.Checked;
}
}
}