mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-28 15:00:36 +00:00
f296154d30
Merging declaration and assignment outside of form constructor. Alert user if they tried to set Eon Ticket to X/Y.
147 lines
4.8 KiB
C#
147 lines
4.8 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace PKHeX
|
|
{
|
|
public partial class SAV_Pokepuff : Form
|
|
{
|
|
public SAV_Pokepuff()
|
|
{
|
|
InitializeComponent();
|
|
Util.TranslateInterface(this, Main.curlanguage);
|
|
|
|
pfa = Main.puffs;
|
|
pfa[0] = "---";
|
|
Setup();
|
|
|
|
new ToolTip().SetToolTip(B_Sort, "Hold CTRL to reverse sort.");
|
|
new ToolTip().SetToolTip(B_All, "Hold CTRL to give Deluxe instead of Supreme.");
|
|
}
|
|
|
|
private readonly byte[] sav = (byte[])Main.SAV.Data.Clone();
|
|
private readonly string[] pfa;
|
|
private void Setup()
|
|
{
|
|
dgv.Rows.Clear();
|
|
dgv.Columns.Clear();
|
|
|
|
DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
|
|
{
|
|
dgvIndex.HeaderText = "Slot";
|
|
dgvIndex.DisplayIndex = 0;
|
|
dgvIndex.Width = 45;
|
|
dgvIndex.ReadOnly = true;
|
|
dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
|
}
|
|
DataGridViewComboBoxColumn dgvPuff = new DataGridViewComboBoxColumn
|
|
{
|
|
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing
|
|
};
|
|
{
|
|
foreach (string t in pfa)
|
|
dgvPuff.Items.Add(t);
|
|
|
|
dgvPuff.DisplayIndex = 1;
|
|
dgvPuff.Width = 135;
|
|
dgvPuff.FlatStyle = FlatStyle.Flat;
|
|
}
|
|
dgv.Columns.Add(dgvIndex);
|
|
dgv.Columns.Add(dgvPuff);
|
|
|
|
dgv.Rows.Add(100);
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
dgv.Rows[i].Cells[0].Value = (i + 1).ToString();
|
|
dgv.Rows[i].Cells[1].Value = pfa[sav[Main.SAV.Puff + i]];
|
|
}
|
|
MT_CNT.Text = Main.SAV.PuffCount.ToString();
|
|
}
|
|
private void dropclick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
if (e.ColumnIndex != 1) return;
|
|
((ComboBox)(sender as DataGridView).EditingControl).DroppedDown = true;
|
|
}
|
|
|
|
private void B_Cancel_Click(object sender, EventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
private void B_All_Click(object sender, EventArgs e)
|
|
{
|
|
int basepuff = 20;
|
|
int basemod = 6;
|
|
if (ModifierKeys == Keys.Control)
|
|
{
|
|
basepuff = 1;
|
|
basemod = 0x19;
|
|
}
|
|
byte[] newpuffs = new byte[100];
|
|
for (int i = 0; i < 100; i++)
|
|
newpuffs[i] = (byte)(Util.rnd32()%basemod + basepuff);
|
|
|
|
Array.Copy(newpuffs, 0, sav, Main.SAV.Puff, 100);
|
|
Setup();
|
|
}
|
|
private void B_None_Click(object sender, EventArgs e)
|
|
{
|
|
byte[] newpuffs = new byte[100];
|
|
newpuffs[0] = 1;
|
|
newpuffs[1] = 2;
|
|
newpuffs[2] = 3;
|
|
newpuffs[3] = 4;
|
|
newpuffs[4] = 5;
|
|
Array.Copy(newpuffs, 0, sav, Main.SAV.Puff, 100);
|
|
Setup();
|
|
}
|
|
private void B_Sort_Click(object sender, EventArgs e)
|
|
{
|
|
byte[] puffarray = new byte[100];
|
|
if (ModifierKeys == Keys.Control)
|
|
{
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
string puff = dgv.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 = dgv.Rows[i].Cells[1].Value.ToString();
|
|
byte puffval = (byte)Array.IndexOf(pfa, puff);
|
|
if (puffval == 0) continue;
|
|
puffarray[count] = puffval;
|
|
count++;
|
|
}
|
|
Array.Resize(ref puffarray, count);
|
|
Array.Sort(puffarray);
|
|
Array.Resize(ref puffarray, 100);
|
|
}
|
|
Array.Copy(puffarray, 0, sav, Main.SAV.Puff, 100);
|
|
Setup();
|
|
}
|
|
private void B_Save_Click(object sender, EventArgs e)
|
|
{
|
|
byte[] puffarray = new byte[100];
|
|
int emptyslots = 0;
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
string puff = dgv.Rows[i].Cells[1].Value.ToString();
|
|
if (Array.IndexOf(pfa, puff) == 0)
|
|
{
|
|
emptyslots++;
|
|
continue;
|
|
}
|
|
puffarray[i - emptyslots] = (byte)Array.IndexOf(pfa, puff);
|
|
}
|
|
Main.SAV.Puffs = puffarray;
|
|
Main.SAV.PuffCount = Util.ToInt32(MT_CNT.Text);
|
|
Main.SAV.Edited = true;
|
|
Close();
|
|
}
|
|
}
|
|
}
|