Add dex size record editing via pokedex editor

Closes #2186
This commit is contained in:
Kurt 2018-11-29 21:40:20 -08:00
parent 660b7cc399
commit f6508bec5b
4 changed files with 605 additions and 27 deletions

View File

@ -30,7 +30,7 @@ public Zukan7b(SaveFile sav, int dex, int langflag)
public override void SetDex(PKM pkm)
{
if (!TryGetIndex(pkm.AltForm, pkm.Species, out _))
if (!TryGetSizeEntryIndex(pkm.Species, pkm.AltForm, out _))
return;
SetSizeData((PB7)pkm);
base.SetDex(pkm);
@ -45,72 +45,101 @@ protected override void SetDex(int species, int bit, int form, int gender, bool
private static bool IsBuddy(int species, int form) => (species == 25 && form == 8) || (species == 133 && form == 1);
public const int DefaultEntryValue = 0x7F;
public bool GetSizeData(DexSizeType group, int species, int form, out int height, out int weight)
{
height = weight = DefaultEntryValue;
if (TryGetSizeEntryIndex(species, form, out var index))
return GetSizeData(group, index, out height, out weight);
return false;
}
public bool GetSizeData(DexSizeType group, int index, out int height, out int weight)
{
var ofs = GetDexSizeOffset(group, index);
height = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
weight = BitConverter.ToUInt16(SAV.Data, ofs + 2);
return !IsEntryUnset(height, weight);
}
private static bool IsEntryUnset(int height, int weight) => height == DefaultEntryValue && weight == DefaultEntryValue;
private void SetSizeData(PB7 pkm)
{
int species = pkm.Species;
int form = pkm.AltForm;
if (!TryGetIndex(form, species, out int index))
if (!TryGetSizeEntryIndex(species, form, out int index))
return;
if (Math.Round(pkm.HeightAbsolute) < pkm.PersonalInfo.Height) // possible minimum height
{
int ofs = GetDexSizeOffset(0, index);
int ofs = GetDexSizeOffset(DexSizeType.MinHeight, index);
var minHeight = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
var calcHeight = PB7.GetHeightAbsolute(pkm.PersonalInfo, minHeight);
if (Math.Round(pkm.HeightAbsolute) < Math.Round(calcHeight) || BitConverter.ToUInt32(SAV.Data, ofs) == 0x007F00FE) // unset
UpdateSizeIndex(pkm, 0);
SetSizeData(pkm, DexSizeType.MinHeight);
}
else if (Math.Round(pkm.HeightAbsolute) > pkm.PersonalInfo.Height) // possible maximum height
{
int ofs = GetDexSizeOffset(1, index);
int ofs = GetDexSizeOffset(DexSizeType.MaxHeight, index);
var maxHeight = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
var calcHeight = PB7.GetHeightAbsolute(pkm.PersonalInfo, maxHeight);
if (Math.Round(pkm.HeightAbsolute) > Math.Round(calcHeight) || BitConverter.ToUInt32(SAV.Data, ofs) == 0x007F00FE) // unset
UpdateSizeIndex(pkm, 1);
SetSizeData(pkm, DexSizeType.MaxHeight);
}
if (Math.Round(pkm.WeightAbsolute) < pkm.PersonalInfo.Weight) // possible minimum weight
{
int ofs = GetDexSizeOffset(2, index);
int ofs = GetDexSizeOffset(DexSizeType.MinWeight, index);
var minWeight = BitConverter.ToUInt16(SAV.Data, ofs + 2);
var minHeight = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
var calcWeight = PB7.GetWeightAbsolute(pkm.PersonalInfo, minHeight, minWeight);
if (Math.Round(pkm.WeightAbsolute) < Math.Round(calcWeight) || BitConverter.ToUInt32(SAV.Data, ofs) == 0x007F00FE) // unset
UpdateSizeIndex(pkm, 2);
SetSizeData(pkm, DexSizeType.MinWeight);
}
else if (Math.Round(pkm.WeightAbsolute) > pkm.PersonalInfo.Weight) // possible maximum weight
{
int ofs = GetDexSizeOffset(3, index);
int ofs = GetDexSizeOffset(DexSizeType.MaxWeight, index);
var maxWeight = BitConverter.ToUInt16(SAV.Data, ofs + 2);
var maxHeight = BitConverter.ToUInt16(SAV.Data, ofs) >> 1;
var calcWeight = PB7.GetWeightAbsolute(pkm.PersonalInfo, maxHeight, maxWeight);
if (Math.Round(pkm.WeightAbsolute) > Math.Round(calcWeight) || BitConverter.ToUInt32(SAV.Data, ofs) == 0x007F00FE) // unset
UpdateSizeIndex(pkm, 3);
SetSizeData(pkm, DexSizeType.MaxWeight);
}
}
private int GetDexSizeOffset(int group, int index) => 0x3978 + (index * 6) + (group * 0x45C); // blockofs + 0xF78 + ([186*6]*n) + x*6
private int GetDexSizeOffset(DexSizeType group, int index) => 0x3978 + (index * 6) + ((int)group * 0x45C); // blockofs + 0xF78 + ([186*6]*n) + x*6
private void UpdateSizeIndex(PB7 pkm, int group)
private void SetSizeData(PB7 pkm, DexSizeType group)
{
var tree = EvolutionTree.GetEvolutionTree(pkm, 7);
int species = pkm.Species;
int form = pkm.AltForm;
int height = pkm.HeightScalar;
int weight = pkm.WeightScalar;
// update for all species in potential lineage
var allspec = tree.GetEvolutionsAndPreEvolutions(species, form);
foreach (var s in allspec)
{
if (!TryGetIndex(form, s, out var index))
continue; // shouldn't hit this
var ofs = GetDexSizeOffset(group, index);
BitConverter.GetBytes((ushort)(pkm.HeightScalar << 1)).CopyTo(SAV.Data, ofs);
BitConverter.GetBytes((ushort)(pkm.WeightScalar)).CopyTo(SAV.Data, ofs + 2);
}
SetSizeData(group, s, form, height, weight);
}
private static bool TryGetIndex(int form, int species, out int index)
public void SetSizeData(DexSizeType group, int species, int form, int height, int weight)
{
if (TryGetSizeEntryIndex(species, form, out var index))
SetSizeData(group, index, height, weight);
}
public void SetSizeData(DexSizeType group, int index, int height, int weight)
{
var ofs = GetDexSizeOffset(group, index);
BitConverter.GetBytes((ushort)(height << 1)).CopyTo(SAV.Data, ofs);
BitConverter.GetBytes((ushort)(weight)).CopyTo(SAV.Data, ofs + 2);
}
public static bool TryGetSizeEntryIndex(int species, int form, out int index)
{
index = -1;
if (form == 0 && species <= 151)
@ -130,7 +159,7 @@ private static bool TryGetIndex(int form, int species, out int index)
return false;
}
public static readonly ushort[] SizeDexInfoTable =
private static readonly ushort[] SizeDexInfoTable =
{
// spec, form, index
808, 0, 151,
@ -188,4 +217,12 @@ protected override bool GetSaneFormsToIterate(int species, out int formStart, ou
}
}
}
public enum DexSizeType
{
MinHeight,
MaxHeight,
MinWeight,
MaxWeight,
}
}

View File

@ -69,17 +69,45 @@ private void InitializeComponent()
this.mnuForm1 = new System.Windows.Forms.ToolStripMenuItem();
this.mnuFormAll = new System.Windows.Forms.ToolStripMenuItem();
this.LB_Forms = new System.Windows.Forms.ListBox();
this.GB_SizeRecords = new System.Windows.Forms.GroupBox();
this.CHK_RMaxWeight = new System.Windows.Forms.CheckBox();
this.CHK_RMinWeight = new System.Windows.Forms.CheckBox();
this.CHK_RMaxHeight = new System.Windows.Forms.CheckBox();
this.CHK_RMinHeight = new System.Windows.Forms.CheckBox();
this.L_RWeight = new System.Windows.Forms.Label();
this.L_RHeight = new System.Windows.Forms.Label();
this.L_RWeightMax = new System.Windows.Forms.Label();
this.L_RHeightMax = new System.Windows.Forms.Label();
this.L_RWeightMin = new System.Windows.Forms.Label();
this.L_RHeightMin = new System.Windows.Forms.Label();
this.NUD_RWeightMax = new System.Windows.Forms.NumericUpDown();
this.NUD_RWeightMin = new System.Windows.Forms.NumericUpDown();
this.NUD_RHeightMaxWeight = new System.Windows.Forms.NumericUpDown();
this.NUD_RHeightMinWeight = new System.Windows.Forms.NumericUpDown();
this.NUD_RWeightMaxHeight = new System.Windows.Forms.NumericUpDown();
this.NUD_RWeightMinHeight = new System.Windows.Forms.NumericUpDown();
this.NUD_RHeightMax = new System.Windows.Forms.NumericUpDown();
this.NUD_RHeightMin = new System.Windows.Forms.NumericUpDown();
this.GB_Language.SuspendLayout();
this.GB_Encountered.SuspendLayout();
this.GB_Owned.SuspendLayout();
this.GB_Displayed.SuspendLayout();
this.modifyMenu.SuspendLayout();
this.GB_SizeRecords.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_RWeightMax)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RWeightMin)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RHeightMaxWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RHeightMinWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RWeightMaxHeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RWeightMinHeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RHeightMax)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RHeightMin)).BeginInit();
this.SuspendLayout();
//
// B_Cancel
//
this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.B_Cancel.Location = new System.Drawing.Point(244, 261);
this.B_Cancel.Location = new System.Drawing.Point(244, 393);
this.B_Cancel.Name = "B_Cancel";
this.B_Cancel.Size = new System.Drawing.Size(80, 23);
this.B_Cancel.TabIndex = 0;
@ -92,7 +120,7 @@ private void InitializeComponent()
this.LB_Species.FormattingEnabled = true;
this.LB_Species.Location = new System.Drawing.Point(12, 40);
this.LB_Species.Name = "LB_Species";
this.LB_Species.Size = new System.Drawing.Size(160, 173);
this.LB_Species.Size = new System.Drawing.Size(160, 316);
this.LB_Species.TabIndex = 2;
this.LB_Species.SelectedIndexChanged += new System.EventHandler(this.ChangeLBSpecies);
//
@ -301,7 +329,7 @@ private void InitializeComponent()
// B_Save
//
this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.B_Save.Location = new System.Drawing.Point(330, 261);
this.B_Save.Location = new System.Drawing.Point(330, 393);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(80, 23);
this.B_Save.TabIndex = 24;
@ -457,17 +485,279 @@ private void InitializeComponent()
// LB_Forms
//
this.LB_Forms.FormattingEnabled = true;
this.LB_Forms.Location = new System.Drawing.Point(12, 222);
this.LB_Forms.Location = new System.Drawing.Point(12, 362);
this.LB_Forms.Name = "LB_Forms";
this.LB_Forms.Size = new System.Drawing.Size(160, 56);
this.LB_Forms.TabIndex = 33;
this.LB_Forms.SelectedIndexChanged += new System.EventHandler(this.ChangeLBForms);
//
// GB_SizeRecords
//
this.GB_SizeRecords.Controls.Add(this.CHK_RMaxWeight);
this.GB_SizeRecords.Controls.Add(this.CHK_RMinWeight);
this.GB_SizeRecords.Controls.Add(this.CHK_RMaxHeight);
this.GB_SizeRecords.Controls.Add(this.CHK_RMinHeight);
this.GB_SizeRecords.Controls.Add(this.L_RWeight);
this.GB_SizeRecords.Controls.Add(this.L_RHeight);
this.GB_SizeRecords.Controls.Add(this.L_RWeightMax);
this.GB_SizeRecords.Controls.Add(this.L_RHeightMax);
this.GB_SizeRecords.Controls.Add(this.L_RWeightMin);
this.GB_SizeRecords.Controls.Add(this.L_RHeightMin);
this.GB_SizeRecords.Controls.Add(this.NUD_RWeightMax);
this.GB_SizeRecords.Controls.Add(this.NUD_RWeightMin);
this.GB_SizeRecords.Controls.Add(this.NUD_RHeightMaxWeight);
this.GB_SizeRecords.Controls.Add(this.NUD_RHeightMinWeight);
this.GB_SizeRecords.Controls.Add(this.NUD_RWeightMaxHeight);
this.GB_SizeRecords.Controls.Add(this.NUD_RWeightMinHeight);
this.GB_SizeRecords.Controls.Add(this.NUD_RHeightMax);
this.GB_SizeRecords.Controls.Add(this.NUD_RHeightMin);
this.GB_SizeRecords.Location = new System.Drawing.Point(178, 261);
this.GB_SizeRecords.Name = "GB_SizeRecords";
this.GB_SizeRecords.Size = new System.Drawing.Size(230, 126);
this.GB_SizeRecords.TabIndex = 52;
this.GB_SizeRecords.TabStop = false;
this.GB_SizeRecords.Text = "Records";
//
// CHK_RMaxWeight
//
this.CHK_RMaxWeight.AutoSize = true;
this.CHK_RMaxWeight.Location = new System.Drawing.Point(174, 99);
this.CHK_RMaxWeight.Name = "CHK_RMaxWeight";
this.CHK_RMaxWeight.Size = new System.Drawing.Size(51, 17);
this.CHK_RMaxWeight.TabIndex = 69;
this.CHK_RMaxWeight.Text = "Used";
this.CHK_RMaxWeight.UseVisualStyleBackColor = true;
this.CHK_RMaxWeight.CheckedChanged += new System.EventHandler(this.CHK_RUsed_CheckedChanged);
//
// CHK_RMinWeight
//
this.CHK_RMinWeight.AutoSize = true;
this.CHK_RMinWeight.Location = new System.Drawing.Point(174, 79);
this.CHK_RMinWeight.Name = "CHK_RMinWeight";
this.CHK_RMinWeight.Size = new System.Drawing.Size(51, 17);
this.CHK_RMinWeight.TabIndex = 68;
this.CHK_RMinWeight.Text = "Used";
this.CHK_RMinWeight.UseVisualStyleBackColor = true;
this.CHK_RMinWeight.CheckedChanged += new System.EventHandler(this.CHK_RUsed_CheckedChanged);
//
// CHK_RMaxHeight
//
this.CHK_RMaxHeight.AutoSize = true;
this.CHK_RMaxHeight.Location = new System.Drawing.Point(174, 59);
this.CHK_RMaxHeight.Name = "CHK_RMaxHeight";
this.CHK_RMaxHeight.Size = new System.Drawing.Size(51, 17);
this.CHK_RMaxHeight.TabIndex = 67;
this.CHK_RMaxHeight.Text = "Used";
this.CHK_RMaxHeight.UseVisualStyleBackColor = true;
this.CHK_RMaxHeight.CheckedChanged += new System.EventHandler(this.CHK_RUsed_CheckedChanged);
//
// CHK_RMinHeight
//
this.CHK_RMinHeight.AutoSize = true;
this.CHK_RMinHeight.Location = new System.Drawing.Point(174, 41);
this.CHK_RMinHeight.Name = "CHK_RMinHeight";
this.CHK_RMinHeight.Size = new System.Drawing.Size(51, 17);
this.CHK_RMinHeight.TabIndex = 66;
this.CHK_RMinHeight.Text = "Used";
this.CHK_RMinHeight.UseVisualStyleBackColor = true;
this.CHK_RMinHeight.CheckedChanged += new System.EventHandler(this.CHK_RUsed_CheckedChanged);
//
// L_RWeight
//
this.L_RWeight.Location = new System.Drawing.Point(105, 15);
this.L_RWeight.Name = "L_RWeight";
this.L_RWeight.Size = new System.Drawing.Size(73, 20);
this.L_RWeight.TabIndex = 65;
this.L_RWeight.Text = "Weight";
this.L_RWeight.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// L_RHeight
//
this.L_RHeight.Location = new System.Drawing.Point(20, 15);
this.L_RHeight.Name = "L_RHeight";
this.L_RHeight.Size = new System.Drawing.Size(74, 20);
this.L_RHeight.TabIndex = 64;
this.L_RHeight.Text = "Height";
this.L_RHeight.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// L_RWeightMax
//
this.L_RWeightMax.Location = new System.Drawing.Point(92, 96);
this.L_RWeightMax.Name = "L_RWeightMax";
this.L_RWeightMax.Size = new System.Drawing.Size(30, 20);
this.L_RWeightMax.TabIndex = 63;
this.L_RWeightMax.Text = "Max";
this.L_RWeightMax.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_RHeightMax
//
this.L_RHeightMax.Location = new System.Drawing.Point(7, 56);
this.L_RHeightMax.Name = "L_RHeightMax";
this.L_RHeightMax.Size = new System.Drawing.Size(30, 20);
this.L_RHeightMax.TabIndex = 62;
this.L_RHeightMax.Text = "Max";
this.L_RHeightMax.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_RWeightMin
//
this.L_RWeightMin.Location = new System.Drawing.Point(92, 76);
this.L_RWeightMin.Name = "L_RWeightMin";
this.L_RWeightMin.Size = new System.Drawing.Size(30, 20);
this.L_RWeightMin.TabIndex = 61;
this.L_RWeightMin.Text = "Min";
this.L_RWeightMin.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// L_RHeightMin
//
this.L_RHeightMin.Location = new System.Drawing.Point(7, 36);
this.L_RHeightMin.Name = "L_RHeightMin";
this.L_RHeightMin.Size = new System.Drawing.Size(30, 20);
this.L_RHeightMin.TabIndex = 60;
this.L_RHeightMin.Text = "Min";
this.L_RHeightMin.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NUD_RWeightMax
//
this.NUD_RWeightMax.Location = new System.Drawing.Point(128, 98);
this.NUD_RWeightMax.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_RWeightMax.Name = "NUD_RWeightMax";
this.NUD_RWeightMax.Size = new System.Drawing.Size(40, 20);
this.NUD_RWeightMax.TabIndex = 59;
this.NUD_RWeightMax.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// NUD_RWeightMin
//
this.NUD_RWeightMin.Location = new System.Drawing.Point(128, 78);
this.NUD_RWeightMin.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_RWeightMin.Name = "NUD_RWeightMin";
this.NUD_RWeightMin.Size = new System.Drawing.Size(40, 20);
this.NUD_RWeightMin.TabIndex = 58;
this.NUD_RWeightMin.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// NUD_RHeightMaxWeight
//
this.NUD_RHeightMaxWeight.Location = new System.Drawing.Point(128, 58);
this.NUD_RHeightMaxWeight.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_RHeightMaxWeight.Name = "NUD_RHeightMaxWeight";
this.NUD_RHeightMaxWeight.Size = new System.Drawing.Size(40, 20);
this.NUD_RHeightMaxWeight.TabIndex = 57;
this.NUD_RHeightMaxWeight.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// NUD_RHeightMinWeight
//
this.NUD_RHeightMinWeight.Location = new System.Drawing.Point(128, 38);
this.NUD_RHeightMinWeight.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_RHeightMinWeight.Name = "NUD_RHeightMinWeight";
this.NUD_RHeightMinWeight.Size = new System.Drawing.Size(40, 20);
this.NUD_RHeightMinWeight.TabIndex = 56;
this.NUD_RHeightMinWeight.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// NUD_RWeightMaxHeight
//
this.NUD_RWeightMaxHeight.Location = new System.Drawing.Point(43, 98);
this.NUD_RWeightMaxHeight.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_RWeightMaxHeight.Name = "NUD_RWeightMaxHeight";
this.NUD_RWeightMaxHeight.Size = new System.Drawing.Size(40, 20);
this.NUD_RWeightMaxHeight.TabIndex = 55;
this.NUD_RWeightMaxHeight.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// NUD_RWeightMinHeight
//
this.NUD_RWeightMinHeight.Location = new System.Drawing.Point(43, 78);
this.NUD_RWeightMinHeight.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_RWeightMinHeight.Name = "NUD_RWeightMinHeight";
this.NUD_RWeightMinHeight.Size = new System.Drawing.Size(40, 20);
this.NUD_RWeightMinHeight.TabIndex = 54;
this.NUD_RWeightMinHeight.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// NUD_RHeightMax
//
this.NUD_RHeightMax.Location = new System.Drawing.Point(43, 58);
this.NUD_RHeightMax.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_RHeightMax.Name = "NUD_RHeightMax";
this.NUD_RHeightMax.Size = new System.Drawing.Size(40, 20);
this.NUD_RHeightMax.TabIndex = 53;
this.NUD_RHeightMax.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// NUD_RHeightMin
//
this.NUD_RHeightMin.Location = new System.Drawing.Point(43, 38);
this.NUD_RHeightMin.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.NUD_RHeightMin.Name = "NUD_RHeightMin";
this.NUD_RHeightMin.Size = new System.Drawing.Size(40, 20);
this.NUD_RHeightMin.TabIndex = 52;
this.NUD_RHeightMin.Value = new decimal(new int[] {
255,
0,
0,
0});
//
// SAV_PokedexGG
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(417, 291);
this.ClientSize = new System.Drawing.Size(417, 423);
this.Controls.Add(this.GB_SizeRecords);
this.Controls.Add(this.LB_Forms);
this.Controls.Add(this.GB_Displayed);
this.Controls.Add(this.GB_Owned);
@ -496,6 +786,16 @@ private void InitializeComponent()
this.GB_Displayed.ResumeLayout(false);
this.GB_Displayed.PerformLayout();
this.modifyMenu.ResumeLayout(false);
this.GB_SizeRecords.ResumeLayout(false);
this.GB_SizeRecords.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_RWeightMax)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RWeightMin)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RHeightMaxWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RHeightMinWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RWeightMaxHeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RWeightMinHeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RHeightMax)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUD_RHeightMin)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -542,5 +842,24 @@ private void InitializeComponent()
private System.Windows.Forms.CheckBox CHK_L8;
private System.Windows.Forms.CheckBox CHK_L9;
private System.Windows.Forms.ListBox LB_Forms;
private System.Windows.Forms.GroupBox GB_SizeRecords;
private System.Windows.Forms.CheckBox CHK_RMaxWeight;
private System.Windows.Forms.CheckBox CHK_RMinWeight;
private System.Windows.Forms.CheckBox CHK_RMaxHeight;
private System.Windows.Forms.CheckBox CHK_RMinHeight;
private System.Windows.Forms.Label L_RWeight;
private System.Windows.Forms.Label L_RHeight;
private System.Windows.Forms.Label L_RWeightMax;
private System.Windows.Forms.Label L_RHeightMax;
private System.Windows.Forms.Label L_RWeightMin;
private System.Windows.Forms.Label L_RHeightMin;
private System.Windows.Forms.NumericUpDown NUD_RWeightMax;
private System.Windows.Forms.NumericUpDown NUD_RWeightMin;
private System.Windows.Forms.NumericUpDown NUD_RHeightMaxWeight;
private System.Windows.Forms.NumericUpDown NUD_RHeightMinWeight;
private System.Windows.Forms.NumericUpDown NUD_RWeightMaxHeight;
private System.Windows.Forms.NumericUpDown NUD_RWeightMinHeight;
private System.Windows.Forms.NumericUpDown NUD_RHeightMax;
private System.Windows.Forms.NumericUpDown NUD_RHeightMin;
}
}

View File

@ -36,6 +36,10 @@ public SAV_PokedexGG(SaveFile sav)
foreach (var n in names)
LB_Species.Items.Add(n);
RecordUsed = new[] { CHK_RMinHeight, CHK_RMaxHeight, CHK_RMinWeight, CHK_RMaxWeight };
RecordHeight = new[] { NUD_RHeightMin, NUD_RHeightMax, NUD_RWeightMinHeight, NUD_RWeightMaxHeight};
RecordWeight = new[] { NUD_RHeightMinWeight, NUD_RHeightMaxWeight, NUD_RWeightMin, NUD_RWeightMax};
editing = false;
LB_Species.SelectedIndex = 0;
CB_Species.KeyDown += WinFormsUtil.RemoveDropCB;
@ -47,6 +51,9 @@ public SAV_PokedexGG(SaveFile sav)
private int species = -1;
private readonly CheckBox[] CP, CL;
private readonly CheckBox[] RecordUsed;
private readonly NumericUpDown[] RecordHeight, RecordWeight;
private void ChangeCBSpecies(object sender, EventArgs e)
{
if (editing) return;
@ -217,6 +224,9 @@ private void GetEntry()
CL[i].Enabled = species <= SAV.MaxSpeciesID;
CL[i].Checked = CL[i].Enabled && Dex.GetLanguageFlag(pk, i);
}
LoadRecord(species, Math.Max(0, LB_Forms.SelectedIndex));
editing = false;
}
@ -240,6 +250,53 @@ private void SetEntry()
for (int i = 0; i < 9; i++)
Dex.SetLanguageFlag(pk, i, CL[i].Checked);
SetRecord(species, Math.Max(0, LB_Forms.SelectedIndex));
}
private void LoadRecord(int spec, int form)
{
bool hasRecord = Zukan7b.TryGetSizeEntryIndex(spec, form, out var index);
GB_SizeRecords.Visible = hasRecord;
if (!hasRecord)
return;
void set(DexSizeType type, NumericUpDown nudH, NumericUpDown nudW, CheckBox ck)
{
nudH.Enabled = nudW.Enabled = ck.Checked = Dex.GetSizeData(type, index, out int h, out int w);
nudH.Value = h;
nudW.Value = w;
}
set(DexSizeType.MinHeight, NUD_RHeightMin, NUD_RHeightMinWeight, CHK_RMinHeight);
set(DexSizeType.MaxHeight, NUD_RHeightMax, NUD_RHeightMaxWeight, CHK_RMaxHeight);
set(DexSizeType.MinWeight, NUD_RWeightMinHeight, NUD_RWeightMin, CHK_RMinWeight);
set(DexSizeType.MaxWeight, NUD_RWeightMaxHeight, NUD_RWeightMax, CHK_RMaxWeight);
}
private void SetRecord(int spec, int form)
{
bool hasRecord = Zukan7b.TryGetSizeEntryIndex(spec, form, out var index);
if (!hasRecord)
return;
int get(NumericUpDown nud, CheckBox ck) => !ck.Checked ? Zukan7b.DefaultEntryValue : (int) Math.Max(0, Math.Min(255, nud.Value));
Dex.SetSizeData(DexSizeType.MinHeight, index, get(NUD_RHeightMin, CHK_RMinHeight), get(NUD_RHeightMinWeight, CHK_RMinHeight));
Dex.SetSizeData(DexSizeType.MaxHeight, index, get(NUD_RHeightMax, CHK_RMaxHeight), get(NUD_RHeightMaxWeight, CHK_RMaxHeight));
Dex.SetSizeData(DexSizeType.MinWeight, index, get(NUD_RWeightMinHeight, CHK_RMinWeight), get(NUD_RWeightMin, CHK_RMinWeight));
Dex.SetSizeData(DexSizeType.MaxWeight, index, get(NUD_RWeightMaxHeight, CHK_RMaxWeight), get(NUD_RWeightMax, CHK_RMaxWeight));
}
private void CHK_RUsed_CheckedChanged(object sender, EventArgs e)
{
var ck = (CheckBox) sender;
int index = Array.IndexOf(RecordUsed, ck);
var h = RecordHeight[index];
var w = RecordWeight[index];
h.Enabled = w.Enabled = ck.Checked;
if (!editing && !ck.Checked)
h.Value = w.Value = Zukan7b.DefaultEntryValue;
}
private void B_Cancel_Click(object sender, EventArgs e)
@ -328,6 +385,9 @@ private void ClearAll(object sender)
// remove seen/displayed
CHK_P2.Checked = CHK_P4.Checked = CHK_P3.Checked = CHK_P5.Checked = false;
CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false;
foreach (var ck in RecordUsed)
ck.Checked = false;
}
}
@ -343,6 +403,9 @@ private void SetAll(object sender, int lang)
if (sender != mnuSeenAll)
SetCaught(sender, gt, lang, false);
if (sender != mnuSeenAll)
SetRecords();
if (spec == 25 || spec == 133)
continue; // ignore starter (setdex doesn't set buddy bit; totem raticate is not emitted below).
@ -358,6 +421,21 @@ private void SetAll(object sender, int lang)
}
}
private void SetRecords()
{
if (!GB_SizeRecords.Enabled)
return;
for (var r = 0; r < RecordUsed.Length; r++)
{
var ck = RecordUsed[r];
if (ck.Checked)
continue;
ck.Checked = true;
RecordHeight[r].Value = r % 2 == 0 ? 0 : 255;
RecordWeight[r].Value = r % 2 == 0 ? 0 : 255;
}
}
private static IEnumerable<int> GetLegalSpecies()
{
foreach (var z in Enumerable.Range(1, 151))

View File

@ -117,9 +117,153 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="B_Cancel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LB_Species.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_P2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_P3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_P4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_P5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_P6.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_P7.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_P8.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_P9.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L7.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L6.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L5.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L4.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_goto.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CB_Species.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_GiveAll.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_Save.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_Modify.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="GB_Language.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L9.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_L8.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="GB_Encountered.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="GB_Owned.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="GB_Displayed.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="modifyMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="LB_Forms.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="GB_SizeRecords.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_RMaxWeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_RMinWeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_RMaxHeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="CHK_RMinHeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_RWeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_RHeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_RWeightMax.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_RHeightMax.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_RWeightMin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="L_RHeightMin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NUD_RWeightMax.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NUD_RWeightMin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NUD_RHeightMaxWeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NUD_RHeightMinWeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NUD_RWeightMaxHeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NUD_RWeightMinHeight.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NUD_RHeightMax.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NUD_RHeightMin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>