diff --git a/PKHeX.Core/PersonalInfo/Interfaces/IPersonalTable.cs b/PKHeX.Core/PersonalInfo/Interfaces/IPersonalTable.cs
index 7ba3d2be1..5003c05b1 100644
--- a/PKHeX.Core/PersonalInfo/Interfaces/IPersonalTable.cs
+++ b/PKHeX.Core/PersonalInfo/Interfaces/IPersonalTable.cs
@@ -41,7 +41,19 @@ public interface IPersonalTable
/// Entry for the input criteria
PersonalInfo GetFormEntry(int species, int form);
+ ///
+ /// Checks if the is within the bounds of the table.
+ ///
+ ///
+ /// True if present in game
bool IsSpeciesInGame(int species);
+
+ ///
+ /// Checks if the and is within the bounds of the table.
+ ///
+ ///
+ ///
+ /// True if present in game
bool IsPresentInGame(int species, int form);
}
@@ -51,65 +63,3 @@ public interface IPersonalTable where T : IPersonalInfo
T this[int species, int form] { get; }
T GetFormEntry(int species, int form);
}
-
-public static class PersonalTableExtensions
-{
- ///
- /// Gets form names for every species.
- ///
- /// Table to use
- /// Raw string resource (Species) for the corresponding table.
- /// Max Species ID ()
- /// Array of species containing an array of form names for that species.
- public static string[][] GetFormList(this IPersonalTable table, string[] species, int MaxSpecies)
- {
- string[][] FormList = new string[MaxSpecies + 1][];
- for (int i = 0; i < FormList.Length; i++)
- {
- int FormCount = table[i].FormCount;
- FormList[i] = new string[FormCount];
- if (FormCount <= 0)
- continue;
-
- FormList[i][0] = species[i];
- for (int j = 1; j < FormCount; j++)
- FormList[i][j] = $"{species[i]} {j}";
- }
-
- return FormList;
- }
-
- ///
- /// Gets an arranged list of Form names and indexes for use with the individual values.
- ///
- /// Table to use
- /// Raw string resource (Forms) for the corresponding table.
- /// Raw string resource (Species) for the corresponding table.
- /// Max Species ID ()
- /// Pointers for base form IDs
- /// Pointers for table indexes for each form
- /// Sanitized list of species names, and outputs indexes for various lookup purposes.
- public static string[] GetPersonalEntryList(this IPersonalTable table, string[][] forms, string[] species, int MaxSpecies, out int[] baseForm, out int[] formVal)
- {
- string[] result = new string[table.Count];
- baseForm = new int[result.Length];
- formVal = new int[result.Length];
- for (int i = 0; i <= MaxSpecies; i++)
- {
- result[i] = species[i];
- if (forms[i].Length == 0)
- continue;
- int basePtr = table[i].FormStatsIndex;
- if (basePtr <= 0)
- continue;
- for (int j = 1; j < forms[i].Length; j++)
- {
- int ptr = basePtr + j - 1;
- baseForm[ptr] = i;
- formVal[ptr] = j;
- result[ptr] = forms[i][j];
- }
- }
- return result;
- }
-}
diff --git a/PKHeX.WinForms/Subforms/KChart.cs b/PKHeX.WinForms/Subforms/KChart.cs
index 0f82d6b7d..fe1b10b05 100644
--- a/PKHeX.WinForms/Subforms/KChart.cs
+++ b/PKHeX.WinForms/Subforms/KChart.cs
@@ -12,10 +12,7 @@ namespace PKHeX.WinForms;
public partial class KChart : Form
{
private readonly SaveFile SAV;
- private readonly string[] species = GameInfo.Strings.specieslist;
- private readonly string[] abilities = GameInfo.Strings.abilitylist;
- private readonly int[] baseForm;
- private readonly int[] formVal;
+ private readonly string[] abilities;
public KChart(SaveFile sav)
{
@@ -24,60 +21,69 @@ public KChart(SaveFile sav)
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
SAV = sav;
- IPersonalTable pt = SAV.Personal;
- Array.Resize(ref species, pt.Count);
-
- var forms = pt.GetFormList(species, SAV.MaxSpeciesID);
- species = pt.GetPersonalEntryList(forms, species, SAV.MaxSpeciesID, out baseForm, out formVal);
+ var pt = SAV.Personal;
+ var strings = GameInfo.Strings;
+ var species = strings.specieslist;
+ abilities = strings.abilitylist;
DGV.Rows.Clear();
- for (int i = 1; i < species.Length; i++)
- PopEntry(i);
+ for (int s = 1; s <= pt.MaxSpeciesID; s++)
+ {
+ var fc = pt[s, 0].FormCount;
+ var formNames = fc <= 1
+ ? Array.Empty()
+ : FormConverter.GetFormList(s, strings.Types, strings.forms, Main.GenderSymbols, SAV.Context);
+
+ for (int f = 0; f < fc; f++)
+ {
+ var name = f == 0 ? species[s] : $"{species[s]}-{(f < formNames.Length ? formNames[f] : f.ToString())}";
+ PopEntry(s, f, name);
+ }
+ }
DGV.DoubleBuffered(true);
DGV.Sort(DGV.Columns[0], ListSortDirection.Ascending);
}
- private void PopEntry(int index)
+ private void PopEntry(int species, int form, string name)
{
- var p = SAV.Personal[index];
+ var p = SAV.Personal.GetFormEntry(species, form);
if (p.HP == 0)
return;
- int s = index > SAV.MaxSpeciesID ? baseForm[index] : index;
- var f = index <= SAV.MaxSpeciesID ? 0 : formVal[index];
-
var row = new DataGridViewRow();
row.CreateCells(DGV);
-
- int r = 0;
+ var cells = row.Cells;
+ int c = 0;
+
var bst = p.GetBaseStatTotal();
- row.Cells[r++].Value = s.ToString("000") + (f > 0 ? $"-{f:00}" : "");
- row.Cells[r++].Value = SpriteUtil.GetSprite(s, f, 0, 0, 0, false, Shiny.Never, SAV.Generation);
- row.Cells[r++].Value = species[index];
- row.Cells[r++].Value = GetIsNative(p, s);
- row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStatTotal(bst);
- row.Cells[r++].Value = bst.ToString("000");
- row.Cells[r++].Value = p.CatchRate.ToString("000");
- row.Cells[r++].Value = TypeSpriteUtil.GetTypeSprite(p.Type1, SAV.Generation);
- row.Cells[r++].Value = p.Type1 == p.Type2 ? SpriteUtil.Spriter.Transparent : TypeSpriteUtil.GetTypeSprite(p.Type2, SAV.Generation);
- row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.HP);
- row.Cells[r++].Value = p.HP.ToString("000");
- row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.ATK);
- row.Cells[r++].Value = p.ATK.ToString("000");
- row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.DEF);
- row.Cells[r++].Value = p.DEF.ToString("000");
- row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.SPA);
- row.Cells[r++].Value = p.SPA.ToString("000");
- row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.SPD);
- row.Cells[r++].Value = p.SPD.ToString("000");
- row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.SPE);
- row.Cells[r++].Value = p.SPE.ToString("000");
+ cells[c++].Value = species.ToString("000") + (form > 0 ? $"-{form:00}" : "");
+ cells[c++].Value = SpriteUtil.GetSprite(species, form, 0, 0, 0, false, Shiny.Never, SAV.Generation);
+ cells[c++].Value = name;
+ cells[c++].Value = GetIsNative(p, species);
+ cells[c].Style.BackColor = ColorUtil.ColorBaseStatTotal(bst);
+ cells[c++].Value = bst.ToString("000");
+ cells[c++].Value = p.CatchRate.ToString("000");
+ cells[c++].Value = TypeSpriteUtil.GetTypeSprite(p.Type1, SAV.Generation);
+ cells[c++].Value = p.Type1 == p.Type2 ? SpriteUtil.Spriter.Transparent : TypeSpriteUtil.GetTypeSprite(p.Type2, SAV.Generation);
+ cells[c].Style.BackColor = ColorUtil.ColorBaseStat(p.HP);
+ cells[c++].Value = p.HP.ToString("000");
+ cells[c].Style.BackColor = ColorUtil.ColorBaseStat(p.ATK);
+ cells[c++].Value = p.ATK.ToString("000");
+ cells[c].Style.BackColor = ColorUtil.ColorBaseStat(p.DEF);
+ cells[c++].Value = p.DEF.ToString("000");
+ cells[c].Style.BackColor = ColorUtil.ColorBaseStat(p.SPA);
+ cells[c++].Value = p.SPA.ToString("000");
+ cells[c].Style.BackColor = ColorUtil.ColorBaseStat(p.SPD);
+ cells[c++].Value = p.SPD.ToString("000");
+ cells[c].Style.BackColor = ColorUtil.ColorBaseStat(p.SPE);
+ cells[c++].Value = p.SPE.ToString("000");
var abils = p.Abilities;
- row.Cells[r++].Value = GetAbility(abils, 0);
- row.Cells[r++].Value = GetAbility(abils, 1);
- row.Cells[r].Value = GetAbility(abils, 2);
+ cells[c++].Value = GetAbility(abils, 0);
+ cells[c++].Value = GetAbility(abils, 1);
+ cells[c].Value = GetAbility(abils, 2);
+
row.Height = SpriteUtil.Spriter.Height + 1;
DGV.Rows.Add(row);
}