mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Rework apricorn/bean editors to be text entry
Combobox for count is an antipattern, just parse like all the other quantity datagrids
This commit is contained in:
parent
dc3d8e7cec
commit
adda0af96e
3 changed files with 24 additions and 35 deletions
|
@ -33,31 +33,24 @@ namespace PKHeX.WinForms
|
|||
dgvApricorn.ReadOnly = true;
|
||||
dgvApricorn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
}
|
||||
DataGridViewComboBoxColumn dgvCount = new()
|
||||
DataGridViewTextBoxColumn dgvCount = new()
|
||||
{
|
||||
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing,
|
||||
DisplayIndex = 0,
|
||||
Width = 135,
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
ValueType = typeof(int),
|
||||
DisplayIndex = 1,
|
||||
Width = 45,
|
||||
};
|
||||
{
|
||||
for (var i = 0; i <= 99; i++)
|
||||
dgvCount.Items.Add(i);
|
||||
|
||||
dgvCount.DisplayIndex = 1;
|
||||
dgvCount.Width = 45;
|
||||
dgvCount.FlatStyle = FlatStyle.Flat;
|
||||
}
|
||||
dgv.Columns.Add(dgvApricorn);
|
||||
dgv.Columns.Add(dgvCount);
|
||||
|
||||
dgv.Rows.Add(Count);
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
dgv.Rows[i].Cells[0].Value = itemlist[i];
|
||||
dgv.Rows[i].Cells[1].Value = SAV.GetApricornCount(i);
|
||||
}
|
||||
LoadCount();
|
||||
}
|
||||
|
||||
private void LoadCount()
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
dgv.Rows[i].Cells[1].Value = SAV.GetApricornCount(i).ToString();
|
||||
}
|
||||
|
||||
private void B_Cancel_Click(object sender, EventArgs e)
|
||||
|
@ -69,20 +62,24 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
SAV.SetApricornCount(i, 99);
|
||||
Setup();
|
||||
LoadCount();
|
||||
}
|
||||
|
||||
private void B_None_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
SAV.SetApricornCount(i, 0);
|
||||
Setup();
|
||||
LoadCount();
|
||||
}
|
||||
|
||||
private void B_Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
SAV.SetApricornCount(i, (int)dgv.Rows[i].Cells[1].Value);
|
||||
{
|
||||
var cells = dgv.Rows[i].Cells;
|
||||
var count = int.TryParse(cells[1].Value?.ToString() ?? "0", out var val) ? val : 0;
|
||||
SAV.SetApricornCount(i, Math.Min(byte.MaxValue, count));
|
||||
}
|
||||
Origin.CopyChangesFrom(SAV);
|
||||
Close();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
this.dgv.ShowEditingIcon = false;
|
||||
this.dgv.Size = new System.Drawing.Size(200, 186);
|
||||
this.dgv.TabIndex = 11;
|
||||
this.dgv.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(SAV_Pokebean.DropClick);
|
||||
//
|
||||
// B_Save
|
||||
//
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace PKHeX.WinForms
|
|||
for (int i = 0; i < beans.Length; i++)
|
||||
{
|
||||
dgv.Rows[i].Cells[0].Value = BeanPouch.BeanIndexNames[i];
|
||||
dgv.Rows[i].Cells[1].Value = beans[i];
|
||||
dgv.Rows[i].Cells[1].Value = beans[i].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,27 +45,16 @@ namespace PKHeX.WinForms
|
|||
ReadOnly = true,
|
||||
DefaultCellStyle = {Alignment = DataGridViewContentAlignment.MiddleCenter},
|
||||
};
|
||||
var dgvCount = new DataGridViewComboBoxColumn
|
||||
var dgvCount = new DataGridViewTextBoxColumn
|
||||
{
|
||||
DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing,
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
ValueType = typeof(int),
|
||||
DisplayIndex = 1,
|
||||
Width = 45,
|
||||
};
|
||||
for (var i = 0; i < 256; i++)
|
||||
dgvCount.Items.Add(i);
|
||||
|
||||
dgv.Columns.Add(dgvBean);
|
||||
dgv.Columns.Add(dgvCount);
|
||||
}
|
||||
|
||||
private static void DropClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex != 1) return;
|
||||
((ComboBox)((DataGridView) sender).EditingControl).DroppedDown = true;
|
||||
}
|
||||
|
||||
private void B_Cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
|
@ -89,7 +78,11 @@ namespace PKHeX.WinForms
|
|||
{
|
||||
var beans = Pouch.Beans;
|
||||
for (int i = 0; i < beans.Length; i++)
|
||||
beans[i] = (byte)dgv.Rows[i].Cells[1].Value;
|
||||
{
|
||||
var cells = dgv.Rows[i].Cells;
|
||||
var count = int.TryParse(cells[1].Value?.ToString() ?? "0", out var val) ? val : 0;
|
||||
beans[i] = (byte)Math.Min(byte.MaxValue, count);
|
||||
}
|
||||
Origin.CopyChangesFrom(SAV);
|
||||
Close();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue