2014-11-23 22:23:40 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX
|
|
|
|
|
{
|
|
|
|
|
public partial class SAV_SecretBase : Form
|
|
|
|
|
{
|
2015-09-21 03:34:09 +00:00
|
|
|
|
public SAV_SecretBase()
|
2014-11-23 22:23:40 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Util.TranslateInterface(this, Main.curlanguage);
|
|
|
|
|
abilitylist = Main.abilitylist;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
setupComboBoxes();
|
|
|
|
|
popFavorite();
|
|
|
|
|
popFavorite();
|
|
|
|
|
|
|
|
|
|
LB_Favorite.SelectedIndex = 0;
|
2014-12-14 20:36:44 +00:00
|
|
|
|
// MT_Flags.Text = BitConverter.ToUInt16(sav, 0x24800 + 0x140).ToString(); PSS Stat transmitted
|
2015-10-24 03:13:32 +00:00
|
|
|
|
MT_Flags.Text = BitConverter.ToUInt32(sav, Main.SAV.SecretBase + 0x62C).ToString(); // read counter
|
2014-11-23 22:23:40 +00:00
|
|
|
|
B_SAV2FAV(null, null);
|
|
|
|
|
}
|
2016-02-10 08:33:42 +00:00
|
|
|
|
|
2016-02-11 08:43:44 +00:00
|
|
|
|
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
|
2016-02-10 08:33:42 +00:00
|
|
|
|
private bool editing;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
private bool loading = true;
|
|
|
|
|
|
2016-02-10 08:33:42 +00:00
|
|
|
|
private static string[] abilitylist = { };
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
private void setupComboBoxes()
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
CB_Ball.DisplayMember = "Text";
|
|
|
|
|
CB_Ball.ValueMember = "Value";
|
2015-09-21 03:34:09 +00:00
|
|
|
|
CB_Ball.DataSource = new BindingSource(Main.BallDataSource, null);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
CB_HeldItem.DisplayMember = "Text";
|
|
|
|
|
CB_HeldItem.ValueMember = "Value";
|
2015-09-21 03:34:09 +00:00
|
|
|
|
CB_HeldItem.DataSource = new BindingSource(Main.ItemDataSource, null);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
CB_Species.DisplayMember = "Text";
|
|
|
|
|
CB_Species.ValueMember = "Value";
|
2015-09-21 03:34:09 +00:00
|
|
|
|
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource, null);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
CB_Nature.DisplayMember = "Text";
|
|
|
|
|
CB_Nature.ValueMember = "Value";
|
2015-09-21 03:34:09 +00:00
|
|
|
|
CB_Nature.DataSource = new BindingSource(Main.NatureDataSource, null);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
#region Moves
|
|
|
|
|
{
|
|
|
|
|
CB_Move1.DisplayMember = CB_Move2.DisplayMember = CB_Move3.DisplayMember = CB_Move4.DisplayMember = "Text";
|
|
|
|
|
CB_Move1.ValueMember = CB_Move2.ValueMember = CB_Move3.ValueMember = CB_Move4.ValueMember = "Value";
|
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
CB_Move1.DataSource = new BindingSource(Main.MoveDataSource, null);
|
|
|
|
|
CB_Move2.DataSource = new BindingSource(Main.MoveDataSource, null);
|
|
|
|
|
CB_Move3.DataSource = new BindingSource(Main.MoveDataSource, null);
|
|
|
|
|
CB_Move4.DataSource = new BindingSource(Main.MoveDataSource, null);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Repopulation Functions
|
|
|
|
|
private void popFavorite()
|
|
|
|
|
{
|
|
|
|
|
LB_Favorite.Items.Clear();
|
|
|
|
|
|
2015-10-24 03:13:32 +00:00
|
|
|
|
int playeroff = Main.SAV.SecretBase + 0x326;
|
|
|
|
|
int favoff = Main.SAV.SecretBase + 0x63A;
|
2015-09-21 03:34:09 +00:00
|
|
|
|
string OT = Util.TrimFromZero(Encoding.Unicode.GetString(sav, playeroff + 0x218, 0x1A));
|
2014-11-23 22:23:40 +00:00
|
|
|
|
LB_Favorite.Items.Add("* " + OT);
|
|
|
|
|
for (int i = 0; i < 30; i++)
|
|
|
|
|
{
|
2015-09-21 03:34:09 +00:00
|
|
|
|
string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(sav, favoff + i * 0x3E0 + 0x218, 0x1A));
|
2014-11-23 22:23:40 +00:00
|
|
|
|
if (BaseTrainer.Length < 1 || BaseTrainer[0] == '\0')
|
|
|
|
|
BaseTrainer = "Empty";
|
2015-03-12 04:44:12 +00:00
|
|
|
|
LB_Favorite.Items.Add(i + " " + BaseTrainer);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void B_SAV2FAV(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
loading = true;
|
|
|
|
|
int index = LB_Favorite.SelectedIndex;
|
|
|
|
|
if (index < 0) return;
|
2015-10-24 03:13:32 +00:00
|
|
|
|
int offset = Main.SAV.SecretBase + 0x25A;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
// Base Offset Changing
|
2015-10-24 03:13:32 +00:00
|
|
|
|
if (index == 0) offset = Main.SAV.SecretBase + 0x326;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
else offset += 0x3E0 * index;
|
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
string TrainerName = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x218, 0x1A));
|
2014-11-25 03:53:10 +00:00
|
|
|
|
TB_FOT.Text = TrainerName;
|
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
TB_FT1.Text = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x232 + 0x22 * 0, 0x22));
|
|
|
|
|
TB_FT2.Text = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x232 + 0x22 * 1, 0x22));
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
string saying1 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 0, 0x22));
|
|
|
|
|
string saying2 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 1, 0x22));
|
|
|
|
|
string saying3 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 2, 0x22));
|
|
|
|
|
string saying4 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 3, 0x22));
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
int baseloc = BitConverter.ToInt16(sav, offset);
|
2014-11-25 07:21:08 +00:00
|
|
|
|
NUD_FBaseLocation.Value = baseloc;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2014-11-25 03:53:10 +00:00
|
|
|
|
TB_FSay1.Text = saying1; TB_FSay2.Text = saying2; TB_FSay3.Text = saying3; TB_FSay4.Text = saying4;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
// Gather data for Object Array
|
|
|
|
|
objdata = new byte[25, 12];
|
|
|
|
|
for (int i = 0; i < 25; i++)
|
|
|
|
|
for (int z = 0; z < 12; z++)
|
2015-09-21 03:34:09 +00:00
|
|
|
|
objdata[i, z] = sav[offset + 2 + 12 * i + z];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
NUD_FObject.Value = 1; // Trigger Update
|
|
|
|
|
changeObjectIndex(null, null);
|
|
|
|
|
|
2016-01-06 02:16:58 +00:00
|
|
|
|
GB_PKM.Enabled = index > 0;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
// Trainer Pokemon
|
|
|
|
|
pkmdata = new byte[3, 0x34];
|
|
|
|
|
if (index > 0)
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
for (int z = 0; z < 0x34; z++)
|
2015-09-21 03:34:09 +00:00
|
|
|
|
pkmdata[i, z] = sav[offset + 0x32E + 0x34 * i + z];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
NUD_FPKM.Value = 1;
|
|
|
|
|
changeFavPKM(null, null); // Trigger Update
|
|
|
|
|
|
|
|
|
|
loading = false;
|
|
|
|
|
}
|
|
|
|
|
private byte[,] objdata;
|
|
|
|
|
private byte[,] pkmdata;
|
|
|
|
|
private void B_FAV2SAV(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Write data back to save
|
|
|
|
|
int index = LB_Favorite.SelectedIndex; // store for restoring
|
2014-11-25 07:21:08 +00:00
|
|
|
|
if (!GB_PKM.Enabled && index > 0)
|
2014-12-11 06:50:40 +00:00
|
|
|
|
{ Util.Error("Sorry, no overwriting someone else's base with your own data."); return; }
|
2014-11-25 03:53:10 +00:00
|
|
|
|
if (GB_PKM.Enabled && index == 0)
|
2014-12-11 06:50:40 +00:00
|
|
|
|
{ Util.Error("Sorry, no overwriting of your own base with someone else's."); return; }
|
2014-11-25 03:53:10 +00:00
|
|
|
|
if (LB_Favorite.Items[index].ToString().Substring(LB_Favorite.Items[index].ToString().Length - 5, 5) == "Empty")
|
2014-12-11 06:50:40 +00:00
|
|
|
|
{ Util.Error("Sorry, no overwriting an empty base with someone else's."); return; }
|
2014-11-23 22:23:40 +00:00
|
|
|
|
if (index < 0) return;
|
2015-10-24 03:13:32 +00:00
|
|
|
|
int offset = Main.SAV.SecretBase + 0x25A;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
// Base Offset Changing
|
|
|
|
|
if (index == 0)
|
2015-10-24 03:13:32 +00:00
|
|
|
|
offset = Main.SAV.SecretBase + 0x326;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
else offset += 0x3E0 * index;
|
|
|
|
|
|
|
|
|
|
string TrainerName = TB_FOT.Text;
|
|
|
|
|
byte[] tr = Encoding.Unicode.GetBytes(TrainerName);
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Resize(ref tr, 0x22); Array.Copy(tr, 0, sav, offset + 0x218, 0x1A);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2014-11-25 03:53:10 +00:00
|
|
|
|
string team1 = TB_FT1.Text;
|
|
|
|
|
string team2 = TB_FT2.Text;
|
|
|
|
|
byte[] t1 = Encoding.Unicode.GetBytes(team1);
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Resize(ref t1, 0x22); Array.Copy(t1, 0, sav, offset + 0x232 + 0x22 * 0, 0x22);
|
2014-11-25 03:53:10 +00:00
|
|
|
|
byte[] t2 = Encoding.Unicode.GetBytes(team2);
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Resize(ref t2, 0x22); Array.Copy(t2, 0, sav, offset + 0x232 + 0x22 * 1, 0x22);
|
2014-11-25 03:53:10 +00:00
|
|
|
|
|
2014-11-23 22:23:40 +00:00
|
|
|
|
string saying1 = TB_FSay1.Text;
|
|
|
|
|
string saying2 = TB_FSay2.Text;
|
|
|
|
|
string saying3 = TB_FSay3.Text;
|
|
|
|
|
string saying4 = TB_FSay4.Text;
|
|
|
|
|
byte[] s1 = Encoding.Unicode.GetBytes(saying1);
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Resize(ref s1, 0x22); Array.Copy(s1, 0, sav, offset + 0x276 + 0x22 * 0, 0x22);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
byte[] s2 = Encoding.Unicode.GetBytes(saying2);
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Resize(ref s2, 0x22); Array.Copy(s2, 0, sav, offset + 0x276 + 0x22 * 1, 0x22);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
byte[] s3 = Encoding.Unicode.GetBytes(saying3);
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Resize(ref s3, 0x22); Array.Copy(s3, 0, sav, offset + 0x276 + 0x22 * 2, 0x22);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
byte[] s4 = Encoding.Unicode.GetBytes(saying4);
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Resize(ref s4, 0x22); Array.Copy(s4, 0, sav, offset + 0x276 + 0x22 * 3, 0x22);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2014-11-25 07:21:08 +00:00
|
|
|
|
int baseloc = (int)NUD_FBaseLocation.Value;
|
|
|
|
|
if (baseloc < 3) baseloc = 0; // skip 1/2 baselocs as they are dummied out ingame.
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Array.Copy(BitConverter.GetBytes(baseloc), 0, sav, offset, 2);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
TB_FOT.Text = TrainerName; TB_FSay1.Text = saying1; TB_FSay2.Text = saying2; TB_FSay3.Text = saying3; TB_FSay4.Text = saying4;
|
|
|
|
|
|
|
|
|
|
// Copy back Objects
|
|
|
|
|
for (int i = 0; i < 25; i++)
|
|
|
|
|
for (int z = 0; z < 12; z++)
|
2015-09-21 03:34:09 +00:00
|
|
|
|
sav[offset + 2 + 12 * i + z] = objdata[i, z];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
if (GB_PKM.Enabled) // Copy pkm data back in
|
2015-02-07 02:30:35 +00:00
|
|
|
|
{
|
|
|
|
|
saveFavPKM();
|
2014-11-23 22:23:40 +00:00
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
|
for (int z = 0; z < 0x34; z++)
|
2015-09-21 03:34:09 +00:00
|
|
|
|
sav[offset + 0x32E + 0x34 * i + z] = pkmdata[i, z];
|
2015-02-07 02:30:35 +00:00
|
|
|
|
}
|
2014-11-23 22:23:40 +00:00
|
|
|
|
popFavorite();
|
|
|
|
|
LB_Favorite.SelectedIndex = index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Button Specific
|
|
|
|
|
private void B_Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
private void B_Save_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-01-09 20:39:18 +00:00
|
|
|
|
uint flags = Util.ToUInt32(MT_Flags.Text);
|
2015-10-24 03:13:32 +00:00
|
|
|
|
Array.Copy(BitConverter.GetBytes(flags), 0, sav, Main.SAV.PSSStats + 0x140, 4); // write pss
|
|
|
|
|
Array.Copy(BitConverter.GetBytes(flags), 0, sav, Main.SAV.SecretBase + 0x62C, 4); // write counter
|
|
|
|
|
Array.Copy(sav, Main.SAV.Data, sav.Length);
|
2015-10-24 23:33:44 +00:00
|
|
|
|
Main.SAV.Edited = true;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
private void B_GiveDecor_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 173; i++)
|
|
|
|
|
{
|
2014-11-25 03:53:10 +00:00
|
|
|
|
// int qty = BitConverter.ToUInt16(sav, offset + i * 4);
|
|
|
|
|
// int has = BitConverter.ToUInt16(sav, offset + i * 4 + 2);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2015-10-24 03:13:32 +00:00
|
|
|
|
sav[Main.SAV.SecretBase + i * 4] = 25;
|
|
|
|
|
sav[Main.SAV.SecretBase + i * 4 + 2] = 1;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void changeObjectIndex(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-01-18 01:07:19 +00:00
|
|
|
|
int objindex = (int)NUD_FObject.Value - 1;
|
2014-12-12 05:45:01 +00:00
|
|
|
|
byte[] objinfo = new byte[12];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
for (int i = 0; i < 12; i++)
|
|
|
|
|
objinfo[i] = objdata[objindex, i];
|
|
|
|
|
|
|
|
|
|
// Array with object data acquired. Fill data.
|
|
|
|
|
int val = objinfo[0]; if (val == 0xFF) val = -1;
|
|
|
|
|
byte x = objinfo[2];
|
|
|
|
|
byte y = objinfo[4];
|
|
|
|
|
byte rot = objinfo[6];
|
2015-03-11 01:44:51 +00:00
|
|
|
|
// byte unk1 = objinfo[7];
|
|
|
|
|
// ushort unk2 = BitConverter.ToUInt16(objinfo, 0x8);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
// Set values to display
|
|
|
|
|
editing = true;
|
|
|
|
|
|
|
|
|
|
NUD_FObjType.Value = val;
|
|
|
|
|
NUD_FX.Value = x;
|
|
|
|
|
NUD_FY.Value = y;
|
|
|
|
|
NUD_FRot.Value = rot;
|
|
|
|
|
|
|
|
|
|
editing = false;
|
|
|
|
|
}
|
|
|
|
|
private void changeObjectQuality(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (editing) return;
|
|
|
|
|
|
2016-01-06 02:16:58 +00:00
|
|
|
|
int objindex = (int)NUD_FObject.Value - 1;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2016-01-06 02:16:58 +00:00
|
|
|
|
byte val = (byte)NUD_FObjType.Value;
|
|
|
|
|
byte x = (byte)NUD_FX.Value;
|
|
|
|
|
byte y = (byte)NUD_FY.Value;
|
|
|
|
|
byte rot = (byte)NUD_FRot.Value;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
objdata[objindex, 0] = val;
|
|
|
|
|
objdata[objindex, 2] = x;
|
|
|
|
|
objdata[objindex, 4] = y;
|
|
|
|
|
objdata[objindex, 6] = rot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int currentpkm;
|
|
|
|
|
private void changeFavPKM(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-01-06 02:16:58 +00:00
|
|
|
|
int index = (int)NUD_FPKM.Value;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
saveFavPKM(); // Save existing PKM
|
|
|
|
|
currentpkm = index;
|
|
|
|
|
loadFavPKM();
|
|
|
|
|
}
|
|
|
|
|
private void saveFavPKM()
|
|
|
|
|
{
|
|
|
|
|
if (loading || !GB_PKM.Enabled) return;
|
|
|
|
|
int index = currentpkm;
|
2014-12-12 05:45:01 +00:00
|
|
|
|
byte[] pkm = new byte[0x34];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2016-02-01 07:15:54 +00:00
|
|
|
|
BitConverter.GetBytes(Util.getHEXval(TB_EC.Text)).CopyTo(pkm, 0);
|
|
|
|
|
BitConverter.GetBytes((ushort)Util.getIndex(CB_Species)).CopyTo(pkm, 8);
|
|
|
|
|
BitConverter.GetBytes((ushort)Util.getIndex(CB_HeldItem)).CopyTo(pkm, 0xA);
|
|
|
|
|
pkm[0xC] = (byte)Array.IndexOf(abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
|
|
|
|
|
pkm[0xD] = (byte)(CB_Ability.SelectedIndex << 1);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
pkm[0x14] = (byte)Util.getIndex(CB_Nature);
|
|
|
|
|
|
|
|
|
|
int fegform = 0;
|
2016-02-01 07:15:54 +00:00
|
|
|
|
fegform += PKX.getGender(Label_Gender.Text) << 1;
|
2016-01-22 06:55:20 +00:00
|
|
|
|
fegform += CB_Form.SelectedIndex << 3;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
pkm[0x15] = (byte)fegform;
|
|
|
|
|
|
2016-01-18 01:07:19 +00:00
|
|
|
|
pkm[0x16] = (byte)Math.Min(Convert.ToInt32( TB_HPEV.Text), 252);
|
|
|
|
|
pkm[0x17] = (byte)Math.Min(Convert.ToInt32(TB_ATKEV.Text), 252);
|
|
|
|
|
pkm[0x18] = (byte)Math.Min(Convert.ToInt32(TB_DEFEV.Text), 252);
|
|
|
|
|
pkm[0x19] = (byte)Math.Min(Convert.ToInt32(TB_SPAEV.Text), 252);
|
|
|
|
|
pkm[0x1A] = (byte)Math.Min(Convert.ToInt32(TB_SPDEV.Text), 252);
|
|
|
|
|
pkm[0x1B] = (byte)Math.Min(Convert.ToInt32(TB_SPEEV.Text), 252);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2016-02-01 07:15:54 +00:00
|
|
|
|
BitConverter.GetBytes((ushort)Util.getIndex(CB_Move1)).CopyTo(pkm, 0x1C);
|
|
|
|
|
BitConverter.GetBytes((ushort)Util.getIndex(CB_Move2)).CopyTo(pkm, 0x1E);
|
|
|
|
|
BitConverter.GetBytes((ushort)Util.getIndex(CB_Move3)).CopyTo(pkm, 0x20);
|
|
|
|
|
BitConverter.GetBytes((ushort)Util.getIndex(CB_Move4)).CopyTo(pkm, 0x22);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
pkm[0x24] = (byte)CB_PPu1.SelectedIndex;
|
|
|
|
|
pkm[0x25] = (byte)CB_PPu2.SelectedIndex;
|
|
|
|
|
pkm[0x26] = (byte)CB_PPu3.SelectedIndex;
|
|
|
|
|
pkm[0x27] = (byte)CB_PPu4.SelectedIndex;
|
|
|
|
|
|
|
|
|
|
pkm[0x28] = (byte)(Convert.ToByte(TB_HPIV.Text) & 0x1F);
|
|
|
|
|
pkm[0x29] = (byte)(Convert.ToByte(TB_ATKIV.Text) & 0x1F);
|
|
|
|
|
pkm[0x2A] = (byte)(Convert.ToByte(TB_DEFIV.Text) & 0x1F);
|
|
|
|
|
pkm[0x2B] = (byte)(Convert.ToByte(TB_SPAIV.Text) & 0x1F);
|
|
|
|
|
pkm[0x2C] = (byte)(Convert.ToByte(TB_SPDIV.Text) & 0x1F);
|
|
|
|
|
pkm[0x2D] = (byte)(Convert.ToByte(TB_SPEIV.Text) & 0x1F);
|
2014-11-28 09:44:43 +00:00
|
|
|
|
int shiny = (CHK_Shiny.Checked? 1 : 0) << 6;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
pkm[0x2D] |= (byte)shiny;
|
|
|
|
|
|
|
|
|
|
pkm[0x2E] = Convert.ToByte(TB_Friendship.Text);
|
|
|
|
|
pkm[0x2F] = (byte)Util.getIndex(CB_Ball);
|
|
|
|
|
pkm[0x30] = Convert.ToByte(TB_Level.Text);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 0x34; i++) // Copy data back to storage.
|
|
|
|
|
pkmdata[index - 1, i] = pkm[i];
|
|
|
|
|
}
|
|
|
|
|
private void loadFavPKM()
|
|
|
|
|
{
|
|
|
|
|
int index = currentpkm - 1;
|
2014-12-12 05:45:01 +00:00
|
|
|
|
byte[] fpkm = new byte[0x34];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
for (int i = 0; i < 0x34; i++)
|
|
|
|
|
fpkm[i] = pkmdata[index, i];
|
|
|
|
|
|
|
|
|
|
uint ec = BitConverter.ToUInt32(fpkm, 0);
|
2015-03-11 01:44:51 +00:00
|
|
|
|
// uint unk = BitConverter.ToUInt32(fpkm, 4);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
int spec = BitConverter.ToInt16(fpkm, 8);
|
|
|
|
|
int item = BitConverter.ToInt16(fpkm, 0xA);
|
2015-03-11 01:44:51 +00:00
|
|
|
|
// int abil = fpkm[0xC];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
int abil_no = fpkm[0xD];
|
|
|
|
|
MT_AbilNo.Text = abil_no.ToString();
|
|
|
|
|
// 6 unknown bytes, contest?
|
|
|
|
|
|
|
|
|
|
int nature = fpkm[0x14];
|
|
|
|
|
byte genform = fpkm[0x15];
|
2016-01-06 02:16:58 +00:00
|
|
|
|
genderflag = genform >> 1 & 0x3;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
setGenderLabel();
|
|
|
|
|
|
|
|
|
|
byte HP_EV = fpkm[0x16];
|
|
|
|
|
byte AT_EV = fpkm[0x17];
|
|
|
|
|
byte DE_EV = fpkm[0x18];
|
|
|
|
|
byte SA_EV = fpkm[0x19];
|
|
|
|
|
byte SD_EV = fpkm[0x1A];
|
|
|
|
|
byte SP_EV = fpkm[0x1B];
|
|
|
|
|
|
|
|
|
|
int move1 = BitConverter.ToInt16(fpkm, 0x1C);
|
|
|
|
|
int move2 = BitConverter.ToInt16(fpkm, 0x1E);
|
|
|
|
|
int move3 = BitConverter.ToInt16(fpkm, 0x20);
|
|
|
|
|
int move4 = BitConverter.ToInt16(fpkm, 0x22);
|
|
|
|
|
|
|
|
|
|
byte ppu1 = fpkm[0x24];
|
|
|
|
|
byte ppu2 = fpkm[0x25];
|
|
|
|
|
byte ppu3 = fpkm[0x26];
|
|
|
|
|
byte ppu4 = fpkm[0x27];
|
|
|
|
|
|
|
|
|
|
byte HP_IV = fpkm[0x28];
|
|
|
|
|
byte AT_IV = fpkm[0x29];
|
|
|
|
|
byte DE_IV = fpkm[0x2A];
|
|
|
|
|
byte SA_IV = fpkm[0x2B];
|
|
|
|
|
byte SD_IV = fpkm[0x2C];
|
|
|
|
|
byte SP_IV = fpkm[0x2D];
|
|
|
|
|
|
2016-01-06 02:16:58 +00:00
|
|
|
|
bool isshiny = (SP_IV & 0x40) > 0;
|
2014-11-25 03:53:10 +00:00
|
|
|
|
SP_IV &= 0x1F;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
byte friendship = fpkm[0x2E];
|
|
|
|
|
int ball = fpkm[0x2F];
|
|
|
|
|
byte level = fpkm[0x30];
|
|
|
|
|
|
|
|
|
|
// Put data into fields.
|
|
|
|
|
TB_EC.Text = ec.ToString("X8");
|
|
|
|
|
CB_Species.SelectedValue = spec;
|
|
|
|
|
CB_HeldItem.SelectedValue = item;
|
|
|
|
|
|
|
|
|
|
CB_Nature.SelectedValue = nature;
|
|
|
|
|
CB_Ball.SelectedValue = ball;
|
|
|
|
|
|
|
|
|
|
TB_HPIV.Text = HP_IV.ToString();
|
|
|
|
|
TB_ATKIV.Text = AT_IV.ToString();
|
|
|
|
|
TB_DEFIV.Text = DE_IV.ToString();
|
|
|
|
|
TB_SPAIV.Text = SA_IV.ToString();
|
|
|
|
|
TB_SPDIV.Text = SD_IV.ToString();
|
2014-11-25 03:53:10 +00:00
|
|
|
|
TB_SPEIV.Text = SP_IV.ToString();
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
TB_HPEV.Text = HP_EV.ToString();
|
|
|
|
|
TB_ATKEV.Text = AT_EV.ToString();
|
|
|
|
|
TB_DEFEV.Text = DE_EV.ToString();
|
|
|
|
|
TB_SPAEV.Text = SA_EV.ToString();
|
|
|
|
|
TB_SPDEV.Text = SD_EV.ToString();
|
|
|
|
|
TB_SPEEV.Text = SP_EV.ToString();
|
|
|
|
|
|
|
|
|
|
TB_Friendship.Text = friendship.ToString();
|
|
|
|
|
TB_Level.Text = level.ToString();
|
|
|
|
|
|
|
|
|
|
CB_Move1.SelectedValue = move1;
|
|
|
|
|
CB_Move2.SelectedValue = move2;
|
|
|
|
|
CB_Move3.SelectedValue = move3;
|
|
|
|
|
CB_Move4.SelectedValue = move4;
|
|
|
|
|
CB_PPu1.SelectedIndex = ppu1;
|
|
|
|
|
CB_PPu2.SelectedIndex = ppu2;
|
|
|
|
|
CB_PPu3.SelectedIndex = ppu3;
|
|
|
|
|
CB_PPu4.SelectedIndex = ppu4;
|
|
|
|
|
|
2014-11-28 09:44:43 +00:00
|
|
|
|
CHK_Shiny.Checked = isshiny;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
// Set Form
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Main.setForms(spec, CB_Form);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
int form = genform >> 3;
|
|
|
|
|
CB_Form.SelectedIndex = form;
|
|
|
|
|
|
|
|
|
|
// Set Ability
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Main.setAbilityList(MT_AbilNo, spec, CB_Ability, CB_Form);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateSpecies(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Get Forms for Given Species
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Main.setForms(Util.getIndex(CB_Species), CB_Form);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
|
|
|
|
// Check for Gender Changes
|
|
|
|
|
// Get Gender Threshold
|
2015-11-26 06:20:09 +00:00
|
|
|
|
int gt = PKX.Personal[Util.getIndex(CB_Species)].Gender;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2014-12-12 06:36:39 +00:00
|
|
|
|
if (gt == 255) // Genderless
|
2014-11-23 22:23:40 +00:00
|
|
|
|
genderflag = 2;
|
2014-12-12 06:36:39 +00:00
|
|
|
|
else if (gt == 254) // Female Only
|
2014-11-23 22:23:40 +00:00
|
|
|
|
genderflag = 1;
|
2014-12-12 06:36:39 +00:00
|
|
|
|
else if (gt == 0) // Male Only
|
2014-11-23 22:23:40 +00:00
|
|
|
|
genderflag = 0;
|
|
|
|
|
|
|
|
|
|
setGenderLabel();
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Main.setAbilityList(MT_AbilNo, Util.getIndex(CB_Species), CB_Ability, CB_Form);
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
private void updateForm(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Main.setAbilityList(MT_AbilNo, Util.getIndex(CB_Species), CB_Ability, CB_Form);
|
2014-12-14 07:18:27 +00:00
|
|
|
|
|
2014-11-23 22:23:40 +00:00
|
|
|
|
// If form has a single gender, account for it.
|
2014-12-14 07:18:27 +00:00
|
|
|
|
if (PKX.getGender(CB_Form.Text) < 2)
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Label_Gender.Text = Main.gendersymbols[CB_Form.SelectedIndex];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
2014-12-12 06:36:39 +00:00
|
|
|
|
|
2015-03-11 01:44:51 +00:00
|
|
|
|
private int genderflag;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
private void Label_Gender_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Get Gender Threshold
|
2015-11-26 06:20:09 +00:00
|
|
|
|
int gt = PKX.Personal[Util.getIndex(CB_Species)].Gender;
|
2014-11-23 22:23:40 +00:00
|
|
|
|
|
2014-12-12 06:36:39 +00:00
|
|
|
|
if (gt == 255 || gt == 0 || gt == 254) // Single gender/genderless
|
2014-11-23 22:23:40 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (gt < 256) // If not a single gender(less) species:
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Label_Gender.Text = Main.gendersymbols[PKX.getGender(Label_Gender.Text) ^ 1];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
private void setGenderLabel()
|
|
|
|
|
{
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Label_Gender.Text = Main.gendersymbols[genderflag];
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
2015-02-01 04:40:35 +00:00
|
|
|
|
|
|
|
|
|
private void B_FDelete_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (LB_Favorite.SelectedIndex < 1) { Util.Alert("Cannot delete your Secret Base."); return; }
|
|
|
|
|
int index = LB_Favorite.SelectedIndex - 1;
|
2015-03-11 01:44:51 +00:00
|
|
|
|
|
2015-10-24 03:13:32 +00:00
|
|
|
|
int favoff = Main.SAV.SecretBase + 0x63A;
|
2015-09-21 03:34:09 +00:00
|
|
|
|
string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(sav, favoff + index * 0x3E0 + 0x218, 0x1A));
|
2015-02-01 04:40:35 +00:00
|
|
|
|
if (BaseTrainer.Length < 1 || BaseTrainer[0] == '\0')
|
|
|
|
|
BaseTrainer = "Empty";
|
|
|
|
|
|
2016-02-01 07:15:54 +00:00
|
|
|
|
if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, $"Delete {BaseTrainer}'s base (Entry {index}) from your records?"))
|
2015-03-11 01:44:51 +00:00
|
|
|
|
return;
|
2016-02-01 07:15:54 +00:00
|
|
|
|
|
2015-03-11 01:44:51 +00:00
|
|
|
|
const int max = 29;
|
|
|
|
|
const int size = 0x3E0;
|
2015-09-21 03:34:09 +00:00
|
|
|
|
int offset = favoff + index * size;
|
2015-03-11 01:44:51 +00:00
|
|
|
|
if (index != max) Array.Copy(sav, offset + size, sav, offset, size * (max - index));
|
|
|
|
|
// Ensure Last Entry is Cleared
|
|
|
|
|
Array.Copy(new byte[size], 0, sav, size * max, size);
|
|
|
|
|
popFavorite();
|
2015-02-01 04:40:35 +00:00
|
|
|
|
}
|
2014-11-23 22:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|