2014-06-28 21:22:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX
|
|
|
|
|
{
|
|
|
|
|
public partial class SAV_Pokepuff : Form
|
|
|
|
|
{
|
2014-10-11 07:22:22 +00:00
|
|
|
|
public SAV_Pokepuff(Form1 frm1)
|
2014-06-28 21:22:05 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2014-12-20 04:19:41 +00:00
|
|
|
|
Util.TranslateInterface(this, Form1.curlanguage);
|
2014-10-11 07:22:22 +00:00
|
|
|
|
m_parent = frm1;
|
2014-06-28 21:22:05 +00:00
|
|
|
|
Array.Copy(m_parent.savefile, sav, 0x100000);
|
2014-10-10 02:59:57 +00:00
|
|
|
|
pfa = Form1.puffs;
|
2014-06-28 21:22:05 +00:00
|
|
|
|
savindex = m_parent.savindex;
|
2014-07-31 22:06:48 +00:00
|
|
|
|
pfa[0] = "---";
|
2015-02-01 04:40:35 +00:00
|
|
|
|
Setup();
|
2014-06-28 21:22:05 +00:00
|
|
|
|
|
2015-03-11 01:44:51 +00:00
|
|
|
|
new ToolTip().SetToolTip(B_Sort, "Hold CTRL to reverse sort.");
|
|
|
|
|
new ToolTip().SetToolTip(B_All, "Hold CTRL to give Deluxe instead of Supreme.");
|
2014-06-28 21:22:05 +00:00
|
|
|
|
}
|
|
|
|
|
Form1 m_parent;
|
2014-12-12 05:45:01 +00:00
|
|
|
|
public byte[] sav = new byte[0x100000];
|
2014-06-28 21:22:05 +00:00
|
|
|
|
public int savindex;
|
|
|
|
|
public bool editing = false;
|
|
|
|
|
private string[] pfa = {
|
|
|
|
|
"Empty",
|
|
|
|
|
"Basic Sweet","Basic Mint","Basic Citrus","Basic Mocha","Basic Spice",
|
|
|
|
|
"Frosted Sweet","Frosted Mint","Frosted Citrus","Frosted Mocha","Frosted Spice",
|
|
|
|
|
"Fancy Sweet","Fancy Mint","Fancy Citrus","Fancy Mocha","Fancy Spice",
|
|
|
|
|
"Deluxe Sweet","Deluxe Mint","Deluxe Citrus","Deluxe Mocha","Deluxe Spice",
|
|
|
|
|
"Supreme Wish","Supreme Honor","Supreme Spring","Supreme Summer","Supreme Fall","Supreme Winter",
|
|
|
|
|
};
|
2015-02-01 04:40:35 +00:00
|
|
|
|
private void Setup()
|
2014-06-28 21:22:05 +00:00
|
|
|
|
{
|
|
|
|
|
dataGridView1.Rows.Clear();
|
|
|
|
|
dataGridView1.Columns.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
|
|
|
|
|
{
|
|
|
|
|
dgvIndex.HeaderText = "Slot";
|
|
|
|
|
dgvIndex.DisplayIndex = 0;
|
|
|
|
|
dgvIndex.Width = 45;
|
|
|
|
|
dgvIndex.ReadOnly = true;
|
|
|
|
|
dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
|
|
|
|
}
|
2015-03-11 01:44:51 +00:00
|
|
|
|
DataGridViewComboBoxColumn dgvPuff = new DataGridViewComboBoxColumn
|
2014-06-28 21:22:05 +00:00
|
|
|
|
{
|
2015-03-11 01:44:51 +00:00
|
|
|
|
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
|
|
|
|
|
};
|
|
|
|
|
{
|
|
|
|
|
foreach (string t in pfa)
|
|
|
|
|
dgvPuff.Items.Add(t);
|
|
|
|
|
|
2014-06-28 21:22:05 +00:00
|
|
|
|
dgvPuff.DisplayIndex = 1;
|
|
|
|
|
dgvPuff.Width = 135;
|
|
|
|
|
dgvPuff.FlatStyle = FlatStyle.Flat;
|
|
|
|
|
}
|
|
|
|
|
dataGridView1.Columns.Add(dgvIndex);
|
|
|
|
|
dataGridView1.Columns.Add(dgvPuff);
|
|
|
|
|
|
|
|
|
|
dataGridView1.Rows.Add(100);
|
|
|
|
|
int offset = 0x5400 + 0x7F000 * savindex;
|
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
|
{
|
|
|
|
|
dataGridView1.Rows[i].Cells[0].Value = (i + 1).ToString();
|
|
|
|
|
dataGridView1.Rows[i].Cells[1].Value = pfa[sav[offset+i]];
|
|
|
|
|
}
|
|
|
|
|
MT_CNT.Text = BitConverter.ToUInt32(sav, offset + 100).ToString("0");
|
|
|
|
|
}
|
|
|
|
|
private void dropclick(object sender, DataGridViewCellEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.ColumnIndex == 1)
|
|
|
|
|
{
|
|
|
|
|
ComboBox comboBox = (ComboBox)dataGridView1.EditingControl;
|
|
|
|
|
comboBox.DroppedDown = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void B_Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
private void B_All_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-11-28 04:47:50 +00:00
|
|
|
|
int basepuff = 20;
|
2014-06-28 21:22:05 +00:00
|
|
|
|
int basemod = 6;
|
|
|
|
|
if (ModifierKeys == Keys.Control)
|
|
|
|
|
{
|
2014-11-28 04:47:50 +00:00
|
|
|
|
basepuff = 1;
|
|
|
|
|
basemod = 0x19;
|
2014-06-28 21:22:05 +00:00
|
|
|
|
}
|
2014-12-12 05:45:01 +00:00
|
|
|
|
byte[] newpuffs = new byte[100];
|
2014-06-28 21:22:05 +00:00
|
|
|
|
for (int i = 0; i < 100; i++)
|
2014-10-11 07:22:22 +00:00
|
|
|
|
newpuffs[i] = (byte)(Util.rnd32() % basemod + basepuff);
|
2015-02-01 04:40:35 +00:00
|
|
|
|
|
2014-06-28 21:22:05 +00:00
|
|
|
|
Array.Copy(newpuffs, 0, sav, 0x5400 + savindex * 0x7F000, 100);
|
2015-02-01 04:40:35 +00:00
|
|
|
|
Setup();
|
2014-06-28 21:22:05 +00:00
|
|
|
|
}
|
|
|
|
|
private void B_None_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-12-12 05:45:01 +00:00
|
|
|
|
byte[] newpuffs = new byte[100];
|
2014-06-28 21:22:05 +00:00
|
|
|
|
newpuffs[0] = 1;
|
|
|
|
|
newpuffs[1] = 2;
|
|
|
|
|
newpuffs[2] = 3;
|
|
|
|
|
newpuffs[3] = 4;
|
|
|
|
|
newpuffs[4] = 5;
|
|
|
|
|
Array.Copy(newpuffs, 0, sav, 0x5400 + savindex * 0x7F000, 100);
|
2015-02-01 04:40:35 +00:00
|
|
|
|
Setup();
|
2014-06-28 21:22:05 +00:00
|
|
|
|
}
|
|
|
|
|
private void B_Sort_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-12-12 05:45:01 +00:00
|
|
|
|
byte[] puffarray = new byte[100];
|
2014-06-28 21:22:05 +00:00
|
|
|
|
if (ModifierKeys == Keys.Control)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
|
{
|
|
|
|
|
string puff = dataGridView1.Rows[i].Cells[1].Value.ToString();
|
|
|
|
|
puffarray[i] = (byte)Array.IndexOf(pfa, puff);
|
|
|
|
|
}
|
|
|
|
|
Array.Sort(puffarray);
|
|
|
|
|
Array.Reverse(puffarray);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
|
{
|
|
|
|
|
string puff = dataGridView1.Rows[i].Cells[1].Value.ToString();
|
|
|
|
|
byte puffval = (byte)Array.IndexOf(pfa, puff);
|
2015-03-11 01:44:51 +00:00
|
|
|
|
if (puffval == 0) continue;
|
|
|
|
|
puffarray[count] = puffval;
|
|
|
|
|
count++;
|
2014-06-28 21:22:05 +00:00
|
|
|
|
}
|
|
|
|
|
Array.Resize(ref puffarray, count);
|
|
|
|
|
Array.Sort(puffarray);
|
|
|
|
|
Array.Resize(ref puffarray, 100);
|
|
|
|
|
}
|
|
|
|
|
Array.Copy(puffarray, 0, sav, 0x5400 + savindex * 0x7F000, 100);
|
2015-02-01 04:40:35 +00:00
|
|
|
|
Setup();
|
2014-06-28 21:22:05 +00:00
|
|
|
|
}
|
|
|
|
|
private void B_Save_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-12-12 05:45:01 +00:00
|
|
|
|
byte[] puffarray = new byte[100];
|
2014-06-28 21:22:05 +00:00
|
|
|
|
int emptyslots = 0;
|
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
|
{
|
|
|
|
|
string puff = dataGridView1.Rows[i].Cells[1].Value.ToString();
|
|
|
|
|
if (Array.IndexOf(pfa, puff) == 0)
|
|
|
|
|
{
|
|
|
|
|
emptyslots++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
puffarray[i-emptyslots] = (byte)Array.IndexOf(pfa, puff);
|
|
|
|
|
}
|
|
|
|
|
Array.Copy(puffarray, 0, sav, 0x5400 + savindex * 0x7F000, 100);
|
|
|
|
|
Array.Copy(sav, m_parent.savefile, 0x100000);
|
|
|
|
|
m_parent.savedited = true;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|