2016-11-12 18:19:17 +00:00
|
|
|
|
using System;
|
2020-09-06 17:53:13 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-11-12 18:19:17 +00:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Windows.Forms;
|
2017-01-08 07:54:09 +00:00
|
|
|
|
using PKHeX.Core;
|
2019-09-29 16:47:06 +00:00
|
|
|
|
using PKHeX.Drawing;
|
2021-11-27 23:48:08 +00:00
|
|
|
|
using PKHeX.Drawing.Misc;
|
|
|
|
|
using PKHeX.Drawing.PokeSprite;
|
2016-11-12 18:19:17 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.WinForms
|
2016-11-12 18:19:17 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class KChart : Form
|
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
private readonly SaveFile SAV;
|
2017-01-08 07:54:09 +00:00
|
|
|
|
private readonly string[] species = GameInfo.Strings.specieslist;
|
|
|
|
|
private readonly string[] abilities = GameInfo.Strings.abilitylist;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private readonly int[] baseForm;
|
|
|
|
|
private readonly int[] formVal;
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
public KChart(SaveFile sav)
|
2016-11-12 18:19:17 +00:00
|
|
|
|
{
|
2018-04-03 03:36:13 +00:00
|
|
|
|
InitializeComponent();
|
2019-11-16 01:34:18 +00:00
|
|
|
|
Icon = Properties.Resources.Icon;
|
2018-04-03 03:36:13 +00:00
|
|
|
|
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
|
2017-05-23 04:55:05 +00:00
|
|
|
|
SAV = sav;
|
2016-11-12 18:19:17 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
Array.Resize(ref species, SAV.Personal.TableLength);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
|
2020-12-11 04:42:30 +00:00
|
|
|
|
var forms = SAV.Personal.GetFormList(species, SAV.MaxSpeciesID);
|
|
|
|
|
species = SAV.Personal.GetPersonalEntryList(forms, species, SAV.MaxSpeciesID, out baseForm, out formVal);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
|
|
|
|
|
DGV.Rows.Clear();
|
|
|
|
|
for (int i = 1; i < species.Length; i++)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
PopEntry(i);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
DGV.DoubleBuffered(true);
|
|
|
|
|
|
2016-11-12 18:19:17 +00:00
|
|
|
|
DGV.Sort(DGV.Columns[0], ListSortDirection.Ascending);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private void PopEntry(int index)
|
2016-11-12 18:19:17 +00:00
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
var p = SAV.Personal[index];
|
2019-11-16 01:34:18 +00:00
|
|
|
|
if (p.HP == 0)
|
|
|
|
|
return;
|
2016-11-12 18:19:17 +00:00
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
int s = index > SAV.MaxSpeciesID ? baseForm[index] : index;
|
|
|
|
|
var f = index <= SAV.MaxSpeciesID ? 0 : formVal[index];
|
2016-11-12 18:19:17 +00:00
|
|
|
|
|
|
|
|
|
var row = new DataGridViewRow();
|
|
|
|
|
row.CreateCells(DGV);
|
|
|
|
|
|
|
|
|
|
int r = 0;
|
2022-02-05 01:36:51 +00:00
|
|
|
|
row.Cells[r++].Value = s.ToString("000") + (f > 0 ? $"-{f:00}" : "");
|
2020-03-04 04:22:57 +00:00
|
|
|
|
row.Cells[r++].Value = SpriteUtil.GetSprite(s, f, 0, 0, 0, false, false, SAV.Generation);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = species[index];
|
2019-11-16 01:34:18 +00:00
|
|
|
|
row.Cells[r++].Value = GetIsNative(p, s);
|
2021-12-10 08:15:04 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStatTotal(p.BST);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.BST.ToString("000");
|
2020-08-15 23:13:15 +00:00
|
|
|
|
row.Cells[r++].Value = p.CatchRate.ToString("000");
|
2021-11-27 23:48:08 +00:00
|
|
|
|
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);
|
2021-12-10 08:15:04 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.HP);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.HP.ToString("000");
|
2021-12-10 08:15:04 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.ATK);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.ATK.ToString("000");
|
2021-12-10 08:15:04 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.DEF);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.DEF.ToString("000");
|
2021-12-10 08:15:04 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.SPA);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.SPA.ToString("000");
|
2021-12-10 08:15:04 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.SPD);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.SPD.ToString("000");
|
2021-12-10 08:15:04 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = ColorUtil.ColorBaseStat(p.SPE);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.SPE.ToString("000");
|
2020-09-06 17:53:13 +00:00
|
|
|
|
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);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
row.Height = SpriteUtil.Spriter.Height + 1;
|
2016-11-12 18:19:17 +00:00
|
|
|
|
DGV.Rows.Add(row);
|
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
|
2020-09-06 17:53:13 +00:00
|
|
|
|
private string GetAbility(IReadOnlyList<int> abilityIDs, int index)
|
|
|
|
|
{
|
2020-11-06 19:20:52 +00:00
|
|
|
|
if ((uint)index >= abilityIDs.Count)
|
2020-09-06 17:53:13 +00:00
|
|
|
|
return abilities[0];
|
|
|
|
|
return abilities[abilityIDs[index]];
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-02 01:08:49 +00:00
|
|
|
|
private static bool GetIsNative(PersonalInfo personalInfo, int s) => personalInfo switch
|
2019-11-16 01:34:18 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
PersonalInfoSM => s > 721 || Legal.PastGenAlolanNatives.Contains(s),
|
|
|
|
|
PersonalInfoSWSH ss => ss.IsInDex,
|
2022-02-05 01:36:51 +00:00
|
|
|
|
PersonalInfoBDSP bs => bs.IsInDex,
|
2021-01-02 01:08:49 +00:00
|
|
|
|
_ => true,
|
|
|
|
|
};
|
2016-11-12 18:19:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|