2014-07-28 01:30:54 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX
|
|
|
|
|
{
|
2014-11-26 03:55:46 +00:00
|
|
|
|
public partial class SAV_PokedexORAS : Form
|
2014-07-28 01:30:54 +00:00
|
|
|
|
{
|
2015-09-21 03:34:09 +00:00
|
|
|
|
public SAV_PokedexORAS()
|
2014-07-28 01:30:54 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2015-10-06 04:56:51 +00:00
|
|
|
|
CP = new[] { CHK_P1, CHK_P2, CHK_P3, CHK_P4, CHK_P5, CHK_P6, CHK_P7, CHK_P8, CHK_P9, };
|
|
|
|
|
CL = new[] { CHK_L1, CHK_L2, CHK_L3, CHK_L4, CHK_L5, CHK_L6, CHK_L7, };
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Util.TranslateInterface(this, Main.curlanguage);
|
|
|
|
|
sav = (byte[])Main.savefile.Clone();
|
|
|
|
|
|
2014-07-28 01:30:54 +00:00
|
|
|
|
Setup();
|
|
|
|
|
editing = false;
|
2014-08-10 03:56:03 +00:00
|
|
|
|
LB_Species.SelectedIndex = 0;
|
2015-09-21 03:34:09 +00:00
|
|
|
|
TB_Spinda.Text = BitConverter.ToUInt32(sav, Main.SaveGame.Spinda).ToString("X8");
|
2014-07-28 01:30:54 +00:00
|
|
|
|
}
|
2015-10-06 04:56:51 +00:00
|
|
|
|
|
|
|
|
|
private CheckBox[] CP, CL;
|
2015-09-21 03:34:09 +00:00
|
|
|
|
public byte[] sav;
|
2014-11-29 07:46:36 +00:00
|
|
|
|
public bool[,] specbools = new bool[9, 0x60 * 8];
|
2014-07-28 01:30:54 +00:00
|
|
|
|
public bool[,] langbools = new bool[7, 0x60 * 8];
|
2014-08-12 23:37:41 +00:00
|
|
|
|
bool editing = true;
|
2014-07-28 01:30:54 +00:00
|
|
|
|
private void Setup()
|
|
|
|
|
{
|
|
|
|
|
// Clear Listbox and ComboBox
|
2015-03-11 01:44:51 +00:00
|
|
|
|
LB_Species.Items.Clear();
|
|
|
|
|
CB_Species.Items.Clear();
|
2014-07-28 01:30:54 +00:00
|
|
|
|
|
|
|
|
|
// Fill List
|
2014-08-10 03:56:03 +00:00
|
|
|
|
#region Species
|
|
|
|
|
{
|
2015-09-21 03:34:09 +00:00
|
|
|
|
var species_list = Util.getCBList(Main.specieslist, null);
|
2014-08-10 03:56:03 +00:00
|
|
|
|
species_list.RemoveAt(0); // Remove 0th Entry
|
|
|
|
|
CB_Species.DisplayMember = "Text";
|
|
|
|
|
CB_Species.ValueMember = "Value";
|
|
|
|
|
CB_Species.DataSource = species_list;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
2014-07-28 01:30:54 +00:00
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
for (int i = 1; i < Main.specieslist.Length; i++)
|
|
|
|
|
LB_Species.Items.Add(i.ToString("000") + " - " + Main.specieslist[i]);
|
2014-07-28 01:30:54 +00:00
|
|
|
|
|
2015-06-10 06:36:03 +00:00
|
|
|
|
getBools();
|
2014-07-28 01:30:54 +00:00
|
|
|
|
}
|
|
|
|
|
private void changeCBSpecies(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-03-12 04:44:12 +00:00
|
|
|
|
if (editing) return;
|
2015-10-06 04:56:51 +00:00
|
|
|
|
setBools();
|
2015-03-12 04:44:12 +00:00
|
|
|
|
|
|
|
|
|
editing = true;
|
2015-10-06 04:56:51 +00:00
|
|
|
|
species = (int)CB_Species.SelectedValue;
|
|
|
|
|
LB_Species.SelectedIndex = species - 1; // Since we don't allow index0 in combobox, everything is shifted by 1
|
2015-03-12 04:44:12 +00:00
|
|
|
|
LB_Species.TopIndex = LB_Species.SelectedIndex;
|
|
|
|
|
loadchks();
|
|
|
|
|
editing = false;
|
2014-07-28 01:30:54 +00:00
|
|
|
|
}
|
|
|
|
|
private void changeLBSpecies(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-03-11 01:44:51 +00:00
|
|
|
|
if (editing) return;
|
2015-10-06 04:56:51 +00:00
|
|
|
|
setBools();
|
|
|
|
|
|
2015-03-11 01:44:51 +00:00
|
|
|
|
editing = true;
|
2015-10-06 04:56:51 +00:00
|
|
|
|
species = LB_Species.SelectedIndex + 1;
|
|
|
|
|
CB_Species.SelectedValue = species;
|
2015-03-11 01:44:51 +00:00
|
|
|
|
loadchks();
|
|
|
|
|
editing = false;
|
2014-07-28 01:30:54 +00:00
|
|
|
|
}
|
|
|
|
|
private void loadchks()
|
|
|
|
|
{
|
|
|
|
|
// Load Bools for the data
|
2015-10-06 04:56:51 +00:00
|
|
|
|
int pk = species;
|
|
|
|
|
|
|
|
|
|
L_Spinda.Visible = TB_Spinda.Visible = pk == 327;
|
2014-08-10 03:56:03 +00:00
|
|
|
|
|
2014-07-28 01:30:54 +00:00
|
|
|
|
// Load Partitions
|
2014-11-29 07:46:36 +00:00
|
|
|
|
for (int i = 0; i < 9; i++)
|
2014-07-28 01:30:54 +00:00
|
|
|
|
CP[i].Checked = specbools[i, pk-1];
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
CL[i].Checked = langbools[i, pk-1];
|
2014-08-17 22:39:27 +00:00
|
|
|
|
{
|
|
|
|
|
CHK_P1.Enabled = true;
|
|
|
|
|
|
2014-08-31 20:32:04 +00:00
|
|
|
|
int index = LB_Species.SelectedIndex + 1;
|
2014-12-12 06:36:39 +00:00
|
|
|
|
PKX.PersonalParser.Personal MonData = PKX.PersonalGetter.GetPersonal(index);
|
|
|
|
|
int gt = MonData.GenderRatio;
|
2014-08-31 20:32:04 +00:00
|
|
|
|
|
2014-12-12 06:36:39 +00:00
|
|
|
|
CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = (gt != 254); // Not Female-Only
|
|
|
|
|
CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = (gt != 0) && (gt != 255); // Not Male-Only and Not Genderless
|
2014-08-17 22:39:27 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 7; i++)
|
|
|
|
|
CL[i].Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-26 03:55:46 +00:00
|
|
|
|
// Load Encountered Count
|
|
|
|
|
editing = true;
|
2015-09-21 03:34:09 +00:00
|
|
|
|
MT_Count.Text = BitConverter.ToUInt16(sav, Main.SaveGame.EncounterCount + (pk - 1) * 2).ToString();
|
2014-11-26 03:55:46 +00:00
|
|
|
|
editing = false;
|
2014-07-28 01:30:54 +00:00
|
|
|
|
}
|
|
|
|
|
private void removedropCB(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
((ComboBox)sender).DroppedDown = false;
|
|
|
|
|
}
|
2015-10-07 00:19:15 +00:00
|
|
|
|
private void changeDisplayed(object sender, EventArgs e)
|
2014-08-10 03:56:03 +00:00
|
|
|
|
{
|
2015-10-06 04:56:51 +00:00
|
|
|
|
if (!(sender as CheckBox).Checked)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CHK_P6.Checked = (sender as CheckBox == CHK_P6);
|
|
|
|
|
CHK_P7.Checked = (sender as CheckBox == CHK_P7);
|
|
|
|
|
CHK_P8.Checked = (sender as CheckBox == CHK_P8);
|
|
|
|
|
CHK_P9.Checked = (sender as CheckBox == CHK_P9);
|
2015-10-07 00:19:15 +00:00
|
|
|
|
|
|
|
|
|
if (CHK_P6.Checked) CHK_P2.Checked = true;
|
|
|
|
|
if (CHK_P7.Checked) CHK_P3.Checked = true;
|
|
|
|
|
if (CHK_P8.Checked) CHK_P4.Checked = true;
|
|
|
|
|
if (CHK_P9.Checked) CHK_P5.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
private void changeEncountered(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked))
|
|
|
|
|
CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false;
|
|
|
|
|
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
|
|
|
|
|
{
|
|
|
|
|
if (sender as CheckBox == CHK_P2 && CHK_P2.Checked)
|
|
|
|
|
CHK_P6.Checked = true;
|
|
|
|
|
else if (sender as CheckBox == CHK_P3 && CHK_P3.Checked)
|
|
|
|
|
CHK_P7.Checked = true;
|
|
|
|
|
else if (sender as CheckBox == CHK_P4 && CHK_P4.Checked)
|
|
|
|
|
CHK_P8.Checked = true;
|
|
|
|
|
else if (sender as CheckBox == CHK_P5 && CHK_P5.Checked)
|
|
|
|
|
CHK_P9.Checked = true;
|
|
|
|
|
}
|
2014-08-10 03:56:03 +00:00
|
|
|
|
}
|
2015-10-06 04:56:51 +00:00
|
|
|
|
|
|
|
|
|
private int species = -1;
|
|
|
|
|
private void setBools()
|
2014-08-10 03:56:03 +00:00
|
|
|
|
{
|
2015-10-06 04:56:51 +00:00
|
|
|
|
if (species < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-08-10 03:56:03 +00:00
|
|
|
|
specbools[0, (species - 1)] = CHK_P1.Checked;
|
|
|
|
|
specbools[1, (species - 1)] = CHK_P2.Checked;
|
|
|
|
|
specbools[2, (species - 1)] = CHK_P3.Checked;
|
|
|
|
|
specbools[3, (species - 1)] = CHK_P4.Checked;
|
|
|
|
|
specbools[4, (species - 1)] = CHK_P5.Checked;
|
|
|
|
|
specbools[5, (species - 1)] = CHK_P6.Checked;
|
|
|
|
|
specbools[6, (species - 1)] = CHK_P7.Checked;
|
|
|
|
|
specbools[7, (species - 1)] = CHK_P8.Checked;
|
|
|
|
|
specbools[8, (species - 1)] = CHK_P9.Checked;
|
2015-10-06 04:56:51 +00:00
|
|
|
|
|
|
|
|
|
langbools[0, (species - 1)] = CHK_L1.Checked;
|
|
|
|
|
langbools[1, (species - 1)] = CHK_L2.Checked;
|
|
|
|
|
langbools[2, (species - 1)] = CHK_L3.Checked;
|
|
|
|
|
langbools[3, (species - 1)] = CHK_L4.Checked;
|
|
|
|
|
langbools[4, (species - 1)] = CHK_L5.Checked;
|
|
|
|
|
langbools[5, (species - 1)] = CHK_L6.Checked;
|
|
|
|
|
langbools[6, (species - 1)] = CHK_L7.Checked;
|
2014-08-10 03:56:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-12 23:37:41 +00:00
|
|
|
|
private void B_Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-03-11 01:44:51 +00:00
|
|
|
|
Close();
|
2014-08-12 23:37:41 +00:00
|
|
|
|
}
|
2014-08-10 03:56:03 +00:00
|
|
|
|
private void B_Save_Click(object sender, EventArgs e)
|
2014-09-05 05:58:49 +00:00
|
|
|
|
{
|
|
|
|
|
saveChanges();
|
|
|
|
|
|
|
|
|
|
// Return back to the parent savefile
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Copy(sav, Main.savefile, sav.Length);
|
2015-03-11 01:44:51 +00:00
|
|
|
|
Close();
|
2014-09-05 05:58:49 +00:00
|
|
|
|
}
|
|
|
|
|
private void saveChanges()
|
2014-08-10 03:56:03 +00:00
|
|
|
|
{
|
|
|
|
|
// Save back the Species Bools
|
|
|
|
|
// Return to Byte Array
|
2014-11-29 07:46:36 +00:00
|
|
|
|
for (int p = 0; p < 9; p++)
|
2014-08-10 03:56:03 +00:00
|
|
|
|
{
|
|
|
|
|
byte[] sdata = new byte[0x60];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 0x60 * 8; i++)
|
|
|
|
|
if (specbools[p, i])
|
|
|
|
|
sdata[i / 8] |= (byte)(1 << i % 8);
|
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Copy(sdata, 0, sav, Main.SaveGame.PokeDex + 0x8 + 0x60 * p, 0x60);
|
2014-08-10 03:56:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build new bool array for the Languages
|
|
|
|
|
{
|
2014-11-26 03:55:46 +00:00
|
|
|
|
bool[] languagedata = new bool[0x27C * 8];
|
|
|
|
|
for (int i = 0; i < 722; i++)
|
2014-08-10 03:56:03 +00:00
|
|
|
|
for (int l = 0; l < 7; l++)
|
|
|
|
|
languagedata[i * 7 + l] = langbools[l, i];
|
|
|
|
|
|
|
|
|
|
// Return to Byte Array
|
|
|
|
|
byte[] ldata = new byte[languagedata.Length / 8];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < languagedata.Length; i++)
|
|
|
|
|
if (languagedata[i])
|
|
|
|
|
ldata[i / 8] |= (byte)(1 << i % 8);
|
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Copy(ldata, 0, sav, Main.SaveGame.PokeDexLanguageFlags, 0x27C);
|
2014-08-10 03:56:03 +00:00
|
|
|
|
}
|
2014-11-30 04:12:37 +00:00
|
|
|
|
|
2014-08-31 21:10:06 +00:00
|
|
|
|
// Store Spinda Spot
|
2015-03-12 04:44:12 +00:00
|
|
|
|
uint PID = Util.getHEXval(TB_Spinda);
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Copy(BitConverter.GetBytes(PID), 0, sav, Main.SaveGame.Spinda, 4);
|
2014-08-10 03:56:03 +00:00
|
|
|
|
}
|
2014-08-17 18:30:46 +00:00
|
|
|
|
|
2015-06-10 06:36:03 +00:00
|
|
|
|
private void getBools()
|
|
|
|
|
{
|
|
|
|
|
// Fill Bit arrays
|
|
|
|
|
for (int i = 0; i < 9; i++)
|
|
|
|
|
{
|
|
|
|
|
byte[] data = new byte[0x60];
|
2015-09-21 03:34:09 +00:00
|
|
|
|
int offset = Main.SaveGame.PokeDex + 0x8 + 0x60 * i;
|
2015-06-10 06:36:03 +00:00
|
|
|
|
Array.Copy(sav, offset, data, 0, 0x60);
|
|
|
|
|
BitArray BitRegion = new BitArray(data);
|
|
|
|
|
for (int b = 0; b < (0x60 * 8); b++)
|
|
|
|
|
specbools[i, b] = BitRegion[b];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fill Language arrays
|
|
|
|
|
byte[] langdata = new byte[0x280];
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Copy(sav, Main.SaveGame.PokeDexLanguageFlags, langdata, 0, 0x280);
|
2015-06-10 06:36:03 +00:00
|
|
|
|
BitArray LangRegion = new BitArray(langdata);
|
|
|
|
|
for (int b = 0; b < (721); b++) // 721 Species
|
|
|
|
|
for (int i = 0; i < 7; i++) // 7 Languages
|
|
|
|
|
langbools[i, b] = LangRegion[7 * b + i];
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-17 18:30:46 +00:00
|
|
|
|
private void B_GiveAll_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-08-31 21:10:06 +00:00
|
|
|
|
if (LB_Species.SelectedIndex > 0x2D0) return;
|
2014-08-17 22:39:27 +00:00
|
|
|
|
if (CHK_L1.Enabled)
|
|
|
|
|
{
|
|
|
|
|
CHK_L1.Checked =
|
|
|
|
|
CHK_L2.Checked =
|
|
|
|
|
CHK_L3.Checked =
|
|
|
|
|
CHK_L4.Checked =
|
|
|
|
|
CHK_L5.Checked =
|
|
|
|
|
CHK_L6.Checked =
|
2015-03-11 01:44:51 +00:00
|
|
|
|
CHK_L7.Checked = ModifierKeys != Keys.Control;
|
2014-08-17 22:39:27 +00:00
|
|
|
|
}
|
|
|
|
|
if (CHK_P1.Enabled)
|
|
|
|
|
{
|
2015-03-11 01:44:51 +00:00
|
|
|
|
CHK_P1.Checked = ModifierKeys != Keys.Control;
|
2014-08-17 22:39:27 +00:00
|
|
|
|
}
|
2014-08-31 20:32:04 +00:00
|
|
|
|
int index = LB_Species.SelectedIndex+1;
|
|
|
|
|
|
2014-12-12 06:36:39 +00:00
|
|
|
|
PKX.PersonalParser.Personal MonData = PKX.PersonalGetter.GetPersonal(index);
|
|
|
|
|
int gt = MonData.GenderRatio;
|
2014-08-31 20:32:04 +00:00
|
|
|
|
|
2015-10-06 04:56:51 +00:00
|
|
|
|
CHK_P2.Checked = CHK_P4.Checked = (gt != 254) && ModifierKeys != Keys.Control;
|
|
|
|
|
CHK_P3.Checked = CHK_P5.Checked = (gt != 0) && (gt != 255) && ModifierKeys != Keys.Control;
|
|
|
|
|
|
|
|
|
|
if (ModifierKeys == Keys.Control)
|
|
|
|
|
foreach (var chk in new[]{CHK_P6, CHK_P7, CHK_P8, CHK_P9})
|
|
|
|
|
chk.Checked = false;
|
2015-10-07 00:19:15 +00:00
|
|
|
|
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
|
2015-10-06 04:56:51 +00:00
|
|
|
|
{
|
|
|
|
|
if (gt != 254)
|
|
|
|
|
CHK_P6.Checked = true;
|
|
|
|
|
else
|
|
|
|
|
CHK_P7.Checked = true;
|
|
|
|
|
}
|
2014-08-17 18:30:46 +00:00
|
|
|
|
}
|
|
|
|
|
private void B_FillDex_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-10-15 11:23:41 +00:00
|
|
|
|
// Write Checkboxes manually (Gender stuff done automatically by form)
|
|
|
|
|
for (int i = 0; i < CB_Species.Items.Count; i++)
|
2014-09-05 05:58:49 +00:00
|
|
|
|
{
|
2015-10-15 11:23:41 +00:00
|
|
|
|
CB_Species.SelectedIndex = i;
|
|
|
|
|
B_GiveAll.PerformClick();
|
2014-09-05 05:58:49 +00:00
|
|
|
|
}
|
2014-11-29 07:46:36 +00:00
|
|
|
|
|
2015-10-15 11:23:41 +00:00
|
|
|
|
// Switch to byte editing
|
|
|
|
|
setBools();
|
|
|
|
|
saveChanges();
|
2014-11-29 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
// Encounter Count Writing (999*all species)
|
|
|
|
|
for (int i = 0; i < 0x2D1; i++)
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Copy(BitConverter.GetBytes(999), 0, sav, Main.SaveGame.EncounterCount + i * 2, 2);
|
2015-10-15 11:23:41 +00:00
|
|
|
|
|
2014-11-29 07:46:36 +00:00
|
|
|
|
// Forms Bool Writing
|
2015-10-06 04:56:51 +00:00
|
|
|
|
for (int i = 0; i < 0x98; i++)
|
|
|
|
|
sav[Main.SaveGame.PokeDex + 0x368 + i] = 0xFF;
|
2015-10-15 11:23:41 +00:00
|
|
|
|
|
|
|
|
|
// Turn off Italian Petlil
|
|
|
|
|
sav[Main.SaveGame.PokeDexLanguageFlags + 0x1DF] &= 0xFE;
|
2015-06-10 06:36:03 +00:00
|
|
|
|
|
|
|
|
|
// Fetch the dex bools
|
|
|
|
|
getBools();
|
2014-08-17 18:30:46 +00:00
|
|
|
|
|
2015-06-10 06:36:03 +00:00
|
|
|
|
// Reload the current entry
|
|
|
|
|
loadchks();
|
2014-08-17 18:30:46 +00:00
|
|
|
|
}
|
2014-11-26 03:55:46 +00:00
|
|
|
|
|
|
|
|
|
private void changeEncounteredCount(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!editing)
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Copy(BitConverter.GetBytes(Math.Min(0xFFFF, Util.ToUInt32(MT_Count))), 0, sav, Main.SaveGame.EncounterCount + (Util.getIndex(CB_Species) - 1) * 2, 2);
|
2014-11-26 03:55:46 +00:00
|
|
|
|
}
|
2014-07-28 01:30:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|