2016-11-12 18:19:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
2017-01-08 07:54:09 +00:00
|
|
|
|
using PKHeX.Core;
|
2017-05-12 04:34:18 +00:00
|
|
|
|
using PKHeX.WinForms.Properties;
|
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-05-23 04:55:05 +00:00
|
|
|
|
private readonly bool alolanOnly;
|
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
|
|
|
|
{
|
2017-05-23 04:55:05 +00:00
|
|
|
|
SAV = sav;
|
|
|
|
|
alolanOnly = SAV.Generation == 7 && DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Alolan Dex only?");
|
2016-11-12 18:19:17 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2017-05-23 04:55:05 +00:00
|
|
|
|
Array.Resize(ref species, SAV.Personal.TableLength);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
var AltForms = SAV.Personal.GetFormList(species, SAV.MaxSpeciesID);
|
|
|
|
|
species = SAV.Personal.GetPersonalEntryList(AltForms, 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
|
|
|
|
|
|
|
|
|
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];
|
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
|
|
|
|
bool alolan = s > 721 || Legal.PastGenAlolanNatives.Contains(s);
|
|
|
|
|
|
|
|
|
|
if (alolanOnly && !alolan)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var row = new DataGridViewRow();
|
|
|
|
|
row.CreateCells(DGV);
|
|
|
|
|
|
|
|
|
|
int r = 0;
|
|
|
|
|
row.Cells[r++].Value = s.ToString("000") + (f > 0 ? "-"+f.ToString("00") :"");
|
2017-06-18 01:37:19 +00:00
|
|
|
|
row.Cells[r++].Value = PKMUtil.GetSprite(s, f, 0, 0, false, false, SAV.Generation);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = species[index];
|
|
|
|
|
row.Cells[r++].Value = s > 721 || Legal.PastGenAlolanNatives.Contains(s);
|
2018-03-18 18:22:20 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = MapColor((int)((Math.Max(p.BST - 175, 0)) / 3f));
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.BST.ToString("000");
|
2018-03-25 20:53:48 +00:00
|
|
|
|
row.Cells[r++].Value = PKMUtil.GetTypeSprite(p.Type1, SAV.Generation);
|
|
|
|
|
row.Cells[r++].Value = p.Type1 == p.Type2 ? Resources.slotTrans : PKMUtil.GetTypeSprite(p.Type2, SAV.Generation);
|
2017-06-18 01:37:19 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = MapColor(p.HP);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.HP.ToString("000");
|
2017-06-18 01:37:19 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = MapColor(p.ATK);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.ATK.ToString("000");
|
2017-06-18 01:37:19 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = MapColor(p.DEF);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.DEF.ToString("000");
|
2017-06-18 01:37:19 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = MapColor(p.SPA);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.SPA.ToString("000");
|
2017-06-18 01:37:19 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = MapColor(p.SPD);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.SPD.ToString("000");
|
2017-06-18 01:37:19 +00:00
|
|
|
|
row.Cells[r].Style.BackColor = MapColor(p.SPE);
|
2016-11-12 18:19:17 +00:00
|
|
|
|
row.Cells[r++].Value = p.SPE.ToString("000");
|
|
|
|
|
row.Cells[r++].Value = abilities[p.Abilities[0]];
|
|
|
|
|
row.Cells[r++].Value = abilities[p.Abilities[1]];
|
2018-03-18 18:22:20 +00:00
|
|
|
|
row.Cells[r].Value = abilities[p.Abilities.Length <= 2 ? 0 : p.Abilities[2]];
|
2016-11-12 18:19:17 +00:00
|
|
|
|
DGV.Rows.Add(row);
|
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static Color MapColor(int v)
|
2016-11-12 18:19:17 +00:00
|
|
|
|
{
|
|
|
|
|
const float maxval = 180; // shift the green cap down
|
|
|
|
|
float x = 100f * v / maxval;
|
|
|
|
|
if (x > 100)
|
|
|
|
|
x = 100;
|
|
|
|
|
double red = 255f * (x > 50 ? 1 - 2 * (x - 50) / 100.0 : 1.0);
|
|
|
|
|
double green = 255f * (x > 50 ? 1.0 : 2 * x / 100.0);
|
|
|
|
|
|
|
|
|
|
return Blend(Color.FromArgb((int)red, (int)green, 0), Color.White, 0.4);
|
|
|
|
|
}
|
2017-06-18 01:37:19 +00:00
|
|
|
|
private static Color Blend(Color color, Color backColor, double amount)
|
2016-11-12 18:19:17 +00:00
|
|
|
|
{
|
|
|
|
|
byte r = (byte)(color.R * amount + backColor.R * (1 - amount));
|
|
|
|
|
byte g = (byte)(color.G * amount + backColor.G * (1 - amount));
|
|
|
|
|
byte b = (byte)(color.B * amount + backColor.B * (1 - amount));
|
|
|
|
|
return Color.FromArgb(r, g, b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|