From 7b00e6cfd08b71fff0b2a4c3d9c010ff3123504a Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 13 Nov 2018 19:24:08 -0800 Subject: [PATCH] Add size/cp editor control Years from now this may have to be split (sizes arent related to CP) --- .../Controls/PKM Editor/SizeCP.Designer.cs | 246 ++++++++++++++++++ PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs | 87 +++++++ .../Controls/PKM Editor/SizeCP.resx | 120 +++++++++ 3 files changed, 453 insertions(+) create mode 100644 PKHeX.WinForms/Controls/PKM Editor/SizeCP.Designer.cs create mode 100644 PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs create mode 100644 PKHeX.WinForms/Controls/PKM Editor/SizeCP.resx diff --git a/PKHeX.WinForms/Controls/PKM Editor/SizeCP.Designer.cs b/PKHeX.WinForms/Controls/PKM Editor/SizeCP.Designer.cs new file mode 100644 index 000000000..71bf6c9f1 --- /dev/null +++ b/PKHeX.WinForms/Controls/PKM Editor/SizeCP.Designer.cs @@ -0,0 +1,246 @@ +namespace PKHeX.WinForms.Controls +{ + partial class SizeCP + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.FLP_CP = new System.Windows.Forms.FlowLayoutPanel(); + this.MT_CP = new System.Windows.Forms.MaskedTextBox(); + this.CHK_Auto = new System.Windows.Forms.CheckBox(); + this.L_CP = new System.Windows.Forms.Label(); + this.L_Height = new System.Windows.Forms.Label(); + this.L_Weight = new System.Windows.Forms.Label(); + this.NUD_HeightScalar = new System.Windows.Forms.NumericUpDown(); + this.TB_HeightAbs = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.FLP_Weight = new System.Windows.Forms.FlowLayoutPanel(); + this.NUD_WeightScalar = new System.Windows.Forms.NumericUpDown(); + this.TB_WeightAbs = new System.Windows.Forms.TextBox(); + this.FLP_Height = new System.Windows.Forms.FlowLayoutPanel(); + this.FLP_CP.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_HeightScalar)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); + this.FLP_Weight.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_WeightScalar)).BeginInit(); + this.FLP_Height.SuspendLayout(); + this.SuspendLayout(); + // + // FLP_CP + // + this.FLP_CP.Controls.Add(this.MT_CP); + this.FLP_CP.Controls.Add(this.CHK_Auto); + this.FLP_CP.Location = new System.Drawing.Point(63, 0); + this.FLP_CP.Margin = new System.Windows.Forms.Padding(0); + this.FLP_CP.Name = "FLP_CP"; + this.FLP_CP.Size = new System.Drawing.Size(140, 23); + this.FLP_CP.TabIndex = 1; + // + // MT_CP + // + this.MT_CP.Location = new System.Drawing.Point(0, 0); + this.MT_CP.Margin = new System.Windows.Forms.Padding(0); + this.MT_CP.Mask = "00000"; + this.MT_CP.Name = "MT_CP"; + this.MT_CP.Size = new System.Drawing.Size(36, 20); + this.MT_CP.TabIndex = 3; + this.MT_CP.TextChanged += new System.EventHandler(this.MT_CP_TextChanged); + // + // CHK_Auto + // + this.CHK_Auto.AutoSize = true; + this.CHK_Auto.Checked = true; + this.CHK_Auto.CheckState = System.Windows.Forms.CheckState.Checked; + this.CHK_Auto.Location = new System.Drawing.Point(39, 3); + this.CHK_Auto.Name = "CHK_Auto"; + this.CHK_Auto.Size = new System.Drawing.Size(48, 17); + this.CHK_Auto.TabIndex = 4; + this.CHK_Auto.Text = "Auto"; + this.CHK_Auto.UseVisualStyleBackColor = true; + this.CHK_Auto.CheckedChanged += new System.EventHandler(this.UpdateFlagState); + // + // L_CP + // + this.L_CP.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.L_CP.Location = new System.Drawing.Point(3, 0); + this.L_CP.Name = "L_CP"; + this.L_CP.Size = new System.Drawing.Size(57, 20); + this.L_CP.TabIndex = 0; + this.L_CP.Text = "CP:"; + this.L_CP.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_Height + // + this.L_Height.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.L_Height.Location = new System.Drawing.Point(3, 23); + this.L_Height.Name = "L_Height"; + this.L_Height.Size = new System.Drawing.Size(57, 20); + this.L_Height.TabIndex = 1; + this.L_Height.Text = "Height:"; + this.L_Height.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_Weight + // + this.L_Weight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.L_Weight.Location = new System.Drawing.Point(3, 46); + this.L_Weight.Name = "L_Weight"; + this.L_Weight.Size = new System.Drawing.Size(57, 20); + this.L_Weight.TabIndex = 2; + this.L_Weight.Text = "Weight:"; + this.L_Weight.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // NUD_HeightScalar + // + this.NUD_HeightScalar.Location = new System.Drawing.Point(0, 0); + this.NUD_HeightScalar.Margin = new System.Windows.Forms.Padding(0); + this.NUD_HeightScalar.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.NUD_HeightScalar.Name = "NUD_HeightScalar"; + this.NUD_HeightScalar.Size = new System.Drawing.Size(40, 20); + this.NUD_HeightScalar.TabIndex = 5; + this.NUD_HeightScalar.Value = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.NUD_HeightScalar.ValueChanged += new System.EventHandler(this.NUD_HeightScalar_ValueChanged); + // + // TB_HeightAbs + // + this.TB_HeightAbs.Location = new System.Drawing.Point(40, 0); + this.TB_HeightAbs.Margin = new System.Windows.Forms.Padding(0); + this.TB_HeightAbs.Name = "TB_HeightAbs"; + this.TB_HeightAbs.Size = new System.Drawing.Size(100, 20); + this.TB_HeightAbs.TabIndex = 7; + this.TB_HeightAbs.TextChanged += new System.EventHandler(this.TB_HeightAbs_TextChanged); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 31F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 69F)); + this.tableLayoutPanel1.Controls.Add(this.FLP_Weight, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.FLP_CP, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.L_Weight, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.FLP_Height, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.L_Height, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.L_CP, 0, 0); + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.Size = new System.Drawing.Size(204, 68); + this.tableLayoutPanel1.TabIndex = 2; + // + // FLP_Weight + // + this.FLP_Weight.Controls.Add(this.NUD_WeightScalar); + this.FLP_Weight.Controls.Add(this.TB_WeightAbs); + this.FLP_Weight.Location = new System.Drawing.Point(63, 46); + this.FLP_Weight.Margin = new System.Windows.Forms.Padding(0); + this.FLP_Weight.Name = "FLP_Weight"; + this.FLP_Weight.Size = new System.Drawing.Size(140, 21); + this.FLP_Weight.TabIndex = 4; + // + // NUD_WeightScalar + // + this.NUD_WeightScalar.Location = new System.Drawing.Point(0, 0); + this.NUD_WeightScalar.Margin = new System.Windows.Forms.Padding(0); + this.NUD_WeightScalar.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.NUD_WeightScalar.Name = "NUD_WeightScalar"; + this.NUD_WeightScalar.Size = new System.Drawing.Size(40, 20); + this.NUD_WeightScalar.TabIndex = 5; + this.NUD_WeightScalar.Value = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.NUD_WeightScalar.ValueChanged += new System.EventHandler(this.NUD_WeightScalar_ValueChanged); + // + // TB_WeightAbs + // + this.TB_WeightAbs.Location = new System.Drawing.Point(40, 0); + this.TB_WeightAbs.Margin = new System.Windows.Forms.Padding(0); + this.TB_WeightAbs.Name = "TB_WeightAbs"; + this.TB_WeightAbs.Size = new System.Drawing.Size(100, 20); + this.TB_WeightAbs.TabIndex = 7; + this.TB_WeightAbs.TextChanged += new System.EventHandler(this.TB_WeightAbs_TextChanged); + // + // FLP_Height + // + this.FLP_Height.Controls.Add(this.NUD_HeightScalar); + this.FLP_Height.Controls.Add(this.TB_HeightAbs); + this.FLP_Height.Location = new System.Drawing.Point(63, 23); + this.FLP_Height.Margin = new System.Windows.Forms.Padding(0); + this.FLP_Height.Name = "FLP_Height"; + this.FLP_Height.Size = new System.Drawing.Size(140, 21); + this.FLP_Height.TabIndex = 3; + // + // SizeCP + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "SizeCP"; + this.Size = new System.Drawing.Size(204, 68); + this.FLP_CP.ResumeLayout(false); + this.FLP_CP.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_HeightScalar)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.FLP_Weight.ResumeLayout(false); + this.FLP_Weight.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_WeightScalar)).EndInit(); + this.FLP_Height.ResumeLayout(false); + this.FLP_Height.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + private System.Windows.Forms.FlowLayoutPanel FLP_CP; + private System.Windows.Forms.MaskedTextBox MT_CP; + private System.Windows.Forms.CheckBox CHK_Auto; + private System.Windows.Forms.Label L_CP; + private System.Windows.Forms.Label L_Height; + private System.Windows.Forms.Label L_Weight; + private System.Windows.Forms.NumericUpDown NUD_HeightScalar; + private System.Windows.Forms.TextBox TB_HeightAbs; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.FlowLayoutPanel FLP_Weight; + private System.Windows.Forms.NumericUpDown NUD_WeightScalar; + private System.Windows.Forms.TextBox TB_WeightAbs; + private System.Windows.Forms.FlowLayoutPanel FLP_Height; + } +} diff --git a/PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs b/PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs new file mode 100644 index 000000000..bcee15a37 --- /dev/null +++ b/PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs @@ -0,0 +1,87 @@ +using System; +using System.Globalization; +using System.Windows.Forms; +using PKHeX.Core; + +namespace PKHeX.WinForms.Controls +{ + public partial class SizeCP : UserControl + { + private PB7 pkm; + private bool Loading; + public SizeCP() => InitializeComponent(); + + public void LoadPKM(PKM pk) + { + pkm = pk as PB7; + if (pkm == null) + return; + + if (CHK_Auto.Checked) + pkm.ResetCalculatedValues(); + LoadStoredValues(); + } + + private void LoadStoredValues() + { + Loading = true; + MT_CP.Text = Math.Min(10000, pkm.Stat_CP).ToString(); + + NUD_HeightScalar.Value = pkm.HeightScalar; + TB_HeightAbs.Text = pkm.HeightAbsolute.ToString(); + + NUD_WeightScalar.Value = pkm.WeightScalar; + TB_WeightAbs.Text = pkm.WeightAbsolute.ToString(); + Loading = false; + } + + private void UpdateFlagState(object sender, EventArgs e) + { + if (!CHK_Auto.Checked) + return; + + pkm.ResetCalculatedValues(); + LoadStoredValues(); + } + + private void MT_CP_TextChanged(object sender, EventArgs e) + { + if (int.TryParse(MT_CP.Text, out var cp)) + pkm.Stat_CP = Math.Min(10000, cp); + } + + private void NUD_HeightScalar_ValueChanged(object sender, EventArgs e) + { + pkm.HeightScalar = (byte) NUD_HeightScalar.Value; + if (!CHK_Auto.Checked || Loading) + return; + pkm.ResetHeight(); + TB_HeightAbs.Text = pkm.HeightAbsolute.ToString(); + } + + private void NUD_WeightScalar_ValueChanged(object sender, EventArgs e) + { + pkm.WeightScalar = (byte) NUD_WeightScalar.Value; + if (!CHK_Auto.Checked || Loading) + return; + pkm.ResetWeight(); + TB_WeightAbs.Text = pkm.WeightAbsolute.ToString("F8"); + } + + private void TB_HeightAbs_TextChanged(object sender, EventArgs e) + { + if (CHK_Auto.Checked) + pkm.ResetHeight(); + else if (float.TryParse(TB_HeightAbs.Text, out var result)) + pkm.HeightAbsolute = result; + } + + private void TB_WeightAbs_TextChanged(object sender, EventArgs e) + { + if (CHK_Auto.Checked) + pkm.ResetWeight(); + else if (float.TryParse(TB_WeightAbs.Text, out var result)) + pkm.WeightAbsolute = result; + } + } +} diff --git a/PKHeX.WinForms/Controls/PKM Editor/SizeCP.resx b/PKHeX.WinForms/Controls/PKM Editor/SizeCP.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/PKHeX.WinForms/Controls/PKM Editor/SizeCP.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file