2014-07-31 22:06:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX
|
|
|
|
|
{
|
|
|
|
|
public partial class SAV_SuperTrain : Form
|
|
|
|
|
{
|
2016-01-24 18:19:30 +00:00
|
|
|
|
public SAV_SuperTrain()
|
2014-07-31 22:06:48 +00:00
|
|
|
|
{
|
2015-10-24 03:13:32 +00:00
|
|
|
|
sav = (byte[])Main.SAV.Data.Clone();
|
2015-09-21 03:34:09 +00:00
|
|
|
|
trba = Main.trainingbags;
|
2014-07-31 22:06:48 +00:00
|
|
|
|
trba[0] = "---";
|
2015-10-24 03:13:32 +00:00
|
|
|
|
offsetTime = Main.SAV.SuperTrain + 0x08;
|
|
|
|
|
offsetSpec = Main.SAV.SuperTrain + 0x188;
|
|
|
|
|
offsetVal = Main.SAV.SuperTrain + 0x18A;
|
2014-07-31 22:06:48 +00:00
|
|
|
|
InitializeComponent();
|
2015-09-21 03:34:09 +00:00
|
|
|
|
Util.TranslateInterface(this, Main.curlanguage);
|
|
|
|
|
string[] stages = Main.trainingstage;
|
2014-07-31 22:06:48 +00:00
|
|
|
|
listBox1.Items.Clear();
|
|
|
|
|
for (int i = 0; i < 30; i++)
|
|
|
|
|
listBox1.Items.Add((i + 1).ToString("00") + " - " + stages[i + 2]);
|
2014-11-22 07:23:48 +00:00
|
|
|
|
|
2014-07-31 22:06:48 +00:00
|
|
|
|
setup();
|
|
|
|
|
}
|
2016-01-24 18:19:30 +00:00
|
|
|
|
|
2015-09-21 03:34:09 +00:00
|
|
|
|
public byte[] sav;
|
2016-01-17 21:27:24 +00:00
|
|
|
|
private readonly string[] trba = {
|
2014-07-31 22:06:48 +00:00
|
|
|
|
"Empty",
|
|
|
|
|
"HP Bag S","HP Bag M","HP Bag L",
|
|
|
|
|
"ATK Bag S","ATK Bag M","ATK Bag L",
|
|
|
|
|
"DEF Bag S","DEF Bag M","DEF Bag L",
|
|
|
|
|
"SpA Bag S","SpA Bag M","SpA Bag L",
|
|
|
|
|
"SpD Bag S","SpD Bag M","SpD Bag L",
|
|
|
|
|
"Speed Bag S","Speed Bag M","Speed Bag L",
|
|
|
|
|
"Strength Bag","Toughen Up Bag","Swiftness Bag",
|
|
|
|
|
"Big-Shot Bag","Double-Up Bag","Team Flare Bag",
|
2014-11-22 07:23:48 +00:00
|
|
|
|
"Reset Bag","Soothing Bag",
|
2014-07-31 22:06:48 +00:00
|
|
|
|
};
|
2016-01-17 21:27:24 +00:00
|
|
|
|
private readonly int offsetVal;
|
|
|
|
|
private readonly int offsetTime;
|
|
|
|
|
private readonly int offsetSpec;
|
2014-07-31 22:06:48 +00:00
|
|
|
|
private void setup()
|
|
|
|
|
{
|
|
|
|
|
dataGridView1.Rows.Clear();
|
|
|
|
|
dataGridView1.Columns.Clear();
|
|
|
|
|
{
|
|
|
|
|
CB_Species.DisplayMember = "Text";
|
|
|
|
|
CB_Species.ValueMember = "Value";
|
2016-01-24 18:19:30 +00:00
|
|
|
|
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource, null);
|
2014-07-31 22:06:48 +00:00
|
|
|
|
|
|
|
|
|
CB_S2.DisplayMember = "Text";
|
|
|
|
|
CB_S2.ValueMember = "Value";
|
2016-01-24 18:19:30 +00:00
|
|
|
|
CB_S2.DataSource = new BindingSource(Main.SpeciesDataSource, null);
|
2014-07-31 22:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
listBox1.SelectedIndex = 0;
|
|
|
|
|
fillTrainingBags();
|
|
|
|
|
|
|
|
|
|
CB_S2.SelectedValue = (int)BitConverter.ToUInt16(sav, offsetSpec + 4 * 30);
|
|
|
|
|
TB_Time1.Text = BitConverter.ToSingle(sav, offsetTime + 4 * 30).ToString();
|
|
|
|
|
TB_Time2.Text = BitConverter.ToSingle(sav, offsetTime + 4 * 31).ToString();
|
|
|
|
|
}
|
|
|
|
|
private void fillTrainingBags()
|
|
|
|
|
{
|
|
|
|
|
DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
|
|
|
|
|
{
|
|
|
|
|
dgvIndex.HeaderText = "Slot";
|
|
|
|
|
dgvIndex.DisplayIndex = 0;
|
|
|
|
|
dgvIndex.Width = 25;
|
|
|
|
|
dgvIndex.ReadOnly = true;
|
|
|
|
|
dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
|
|
|
|
}
|
2015-03-11 01:44:51 +00:00
|
|
|
|
DataGridViewComboBoxColumn dgvBag = new DataGridViewComboBoxColumn
|
2014-07-31 22:06:48 +00:00
|
|
|
|
{
|
2015-03-11 01:44:51 +00:00
|
|
|
|
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
|
|
|
|
|
};
|
|
|
|
|
{
|
|
|
|
|
foreach (string t in trba)
|
|
|
|
|
if (t.Length > 0)
|
|
|
|
|
dgvBag.Items.Add(t);
|
2014-11-22 07:23:48 +00:00
|
|
|
|
|
2014-07-31 22:06:48 +00:00
|
|
|
|
dgvBag.DisplayIndex = 1;
|
|
|
|
|
dgvBag.Width = 135;
|
|
|
|
|
dgvBag.FlatStyle = FlatStyle.Flat;
|
|
|
|
|
}
|
|
|
|
|
dataGridView1.Columns.Add(dgvIndex);
|
|
|
|
|
dataGridView1.Columns.Add(dgvBag);
|
|
|
|
|
|
|
|
|
|
dataGridView1.Rows.Add(12);
|
2015-10-24 03:13:32 +00:00
|
|
|
|
int offset = Main.SAV.SuperTrain + 0x308;
|
2014-07-31 22:06:48 +00:00
|
|
|
|
for (int i = 0; i < 12; i++)
|
|
|
|
|
{
|
|
|
|
|
dataGridView1.Rows[i].Cells[0].Value = (i + 1).ToString();
|
|
|
|
|
dataGridView1.Rows[i].Cells[1].Value = trba[sav[offset + i]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void dropclick(object sender, DataGridViewCellEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2015-03-11 01:44:51 +00:00
|
|
|
|
if (e.ColumnIndex != 1) return;
|
|
|
|
|
ComboBox comboBox = (ComboBox)dataGridView1.EditingControl;
|
|
|
|
|
comboBox.DroppedDown = true;
|
2014-07-31 22:06:48 +00:00
|
|
|
|
}
|
2015-03-11 01:44:51 +00:00
|
|
|
|
catch { }
|
2014-07-31 22:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
private void changeListRecordSelection(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int index = listBox1.SelectedIndex;
|
2016-01-22 06:38:26 +00:00
|
|
|
|
if (index < 0) return;
|
2014-07-31 22:06:48 +00:00
|
|
|
|
TB_Time.Text = BitConverter.ToSingle(sav, offsetTime + 4 * index).ToString();
|
|
|
|
|
TB_Unk.Text = BitConverter.ToUInt16(sav, offsetVal + 4 * index).ToString();
|
|
|
|
|
CB_Species.SelectedValue = (int)BitConverter.ToUInt16(sav, offsetSpec + 4 * index);
|
|
|
|
|
}
|
|
|
|
|
private void B_Save_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Copy Bags
|
2014-12-12 05:45:01 +00:00
|
|
|
|
byte[] bagarray = new byte[12];
|
2014-07-31 22:06:48 +00:00
|
|
|
|
int emptyslots = 0;
|
|
|
|
|
for (int i = 0; i < 12; i++)
|
|
|
|
|
{
|
|
|
|
|
string bag = dataGridView1.Rows[i].Cells[1].Value.ToString();
|
|
|
|
|
if (Array.IndexOf(trba, bag) == 0)
|
|
|
|
|
{
|
|
|
|
|
emptyslots++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
bagarray[i - emptyslots] = (byte)Array.IndexOf(trba, bag);
|
|
|
|
|
}
|
2016-01-22 06:38:26 +00:00
|
|
|
|
try { BitConverter.GetBytes(float.Parse(TB_Time1.Text)).CopyTo(sav, offsetTime + 4 * 30); } catch { }
|
|
|
|
|
try { BitConverter.GetBytes(float.Parse(TB_Time2.Text)).CopyTo(sav, offsetTime + 4 * 31); } catch { }
|
|
|
|
|
BitConverter.GetBytes((ushort)Util.getIndex(CB_S2)).CopyTo(sav, offsetSpec + 4 * 30);
|
|
|
|
|
bagarray.CopyTo(sav, Main.SAV.SuperTrain + 0x308);
|
2015-10-24 03:13:32 +00:00
|
|
|
|
Array.Copy(sav, Main.SAV.Data, Main.SAV.Data.Length);
|
2015-10-24 23:33:44 +00:00
|
|
|
|
Main.SAV.Edited = true;
|
2015-03-12 04:44:12 +00:00
|
|
|
|
Close();
|
2014-07-31 22:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
private void B_Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-03-11 01:44:51 +00:00
|
|
|
|
Close();
|
2014-07-31 22:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
private void changeRecordSpecies(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int index = listBox1.SelectedIndex;
|
|
|
|
|
if (index < 0) return;
|
2016-01-22 06:38:26 +00:00
|
|
|
|
BitConverter.GetBytes(Util.getIndex(CB_Species)).CopyTo(sav, offsetSpec + 4 * index);
|
2014-07-31 22:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
private void changeRecordVal(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int index = listBox1.SelectedIndex;
|
|
|
|
|
if (index < 0) return;
|
2016-01-22 06:38:26 +00:00
|
|
|
|
try { BitConverter.GetBytes(ushort.Parse(TB_Unk.Text)).CopyTo(sav, offsetVal + 4 * index); } catch { }
|
2014-07-31 22:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
private void changeRecordTime(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int index = listBox1.SelectedIndex;
|
|
|
|
|
if (index < 0) return;
|
2016-01-22 06:38:26 +00:00
|
|
|
|
try { BitConverter.GetBytes(float.Parse(TB_Time.Text)).CopyTo(sav, offsetTime + 4 * index); } catch { }
|
2014-07-31 22:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|