From 0a22a9cab5be1fe06b2bb69e9e5ad672dd9ca4c8 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 31 Jan 2016 20:44:30 -0800 Subject: [PATCH] Switch PP textboxes to masked Removes some unnecessary code. --- PKX/f1-Main.Designer.cs | 105 +++++++++++++++++++++------------------- PKX/f1-Main.cs | 24 ++------- PKX/f1-Main.resx | 12 ++--- 3 files changed, 64 insertions(+), 77 deletions(-) diff --git a/PKX/f1-Main.Designer.cs b/PKX/f1-Main.Designer.cs index b5ff9157e..9311eda05 100644 --- a/PKX/f1-Main.Designer.cs +++ b/PKX/f1-Main.Designer.cs @@ -156,12 +156,12 @@ public void InitializeComponent() this.CB_RelearnMove2 = new System.Windows.Forms.ComboBox(); this.CB_RelearnMove1 = new System.Windows.Forms.ComboBox(); this.GB_CurrentMoves = new System.Windows.Forms.GroupBox(); + this.TB_PP4 = new System.Windows.Forms.MaskedTextBox(); + this.TB_PP3 = new System.Windows.Forms.MaskedTextBox(); + this.TB_PP2 = new System.Windows.Forms.MaskedTextBox(); + this.TB_PP1 = new System.Windows.Forms.MaskedTextBox(); this.Label_CurPP = new System.Windows.Forms.Label(); this.Label_PPups = new System.Windows.Forms.Label(); - this.TB_PP4 = new System.Windows.Forms.TextBox(); - this.TB_PP3 = new System.Windows.Forms.TextBox(); - this.TB_PP2 = new System.Windows.Forms.TextBox(); - this.TB_PP1 = new System.Windows.Forms.TextBox(); this.CB_PPu4 = new System.Windows.Forms.ComboBox(); this.CB_PPu3 = new System.Windows.Forms.ComboBox(); this.CB_PPu2 = new System.Windows.Forms.ComboBox(); @@ -1935,12 +1935,12 @@ public void InitializeComponent() // // GB_CurrentMoves // - this.GB_CurrentMoves.Controls.Add(this.Label_CurPP); - this.GB_CurrentMoves.Controls.Add(this.Label_PPups); this.GB_CurrentMoves.Controls.Add(this.TB_PP4); this.GB_CurrentMoves.Controls.Add(this.TB_PP3); this.GB_CurrentMoves.Controls.Add(this.TB_PP2); this.GB_CurrentMoves.Controls.Add(this.TB_PP1); + this.GB_CurrentMoves.Controls.Add(this.Label_CurPP); + this.GB_CurrentMoves.Controls.Add(this.Label_PPups); this.GB_CurrentMoves.Controls.Add(this.CB_PPu4); this.GB_CurrentMoves.Controls.Add(this.CB_PPu3); this.GB_CurrentMoves.Controls.Add(this.CB_PPu2); @@ -1956,6 +1956,46 @@ public void InitializeComponent() this.GB_CurrentMoves.TabStop = false; this.GB_CurrentMoves.Text = "Current Moves"; // + // TB_PP4 + // + this.TB_PP4.Location = new System.Drawing.Point(135, 93); + this.TB_PP4.Mask = "000"; + this.TB_PP4.Name = "TB_PP4"; + this.TB_PP4.PromptChar = ' '; + this.TB_PP4.Size = new System.Drawing.Size(31, 20); + this.TB_PP4.TabIndex = 16; + this.TB_PP4.TextChanged += new System.EventHandler(this.update255_MTB); + // + // TB_PP3 + // + this.TB_PP3.Location = new System.Drawing.Point(135, 71); + this.TB_PP3.Mask = "000"; + this.TB_PP3.Name = "TB_PP3"; + this.TB_PP3.PromptChar = ' '; + this.TB_PP3.Size = new System.Drawing.Size(31, 20); + this.TB_PP3.TabIndex = 15; + this.TB_PP3.TextChanged += new System.EventHandler(this.update255_MTB); + // + // TB_PP2 + // + this.TB_PP2.Location = new System.Drawing.Point(135, 49); + this.TB_PP2.Mask = "000"; + this.TB_PP2.Name = "TB_PP2"; + this.TB_PP2.PromptChar = ' '; + this.TB_PP2.Size = new System.Drawing.Size(31, 20); + this.TB_PP2.TabIndex = 14; + this.TB_PP2.TextChanged += new System.EventHandler(this.update255_MTB); + // + // TB_PP1 + // + this.TB_PP1.Location = new System.Drawing.Point(135, 27); + this.TB_PP1.Mask = "000"; + this.TB_PP1.Name = "TB_PP1"; + this.TB_PP1.PromptChar = ' '; + this.TB_PP1.Size = new System.Drawing.Size(31, 20); + this.TB_PP1.TabIndex = 13; + this.TB_PP1.TextChanged += new System.EventHandler(this.update255_MTB); + // // Label_CurPP // this.Label_CurPP.Location = new System.Drawing.Point(133, 12); @@ -1975,43 +2015,6 @@ public void InitializeComponent() this.Label_PPups.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.Label_PPups.Click += new System.EventHandler(this.clickPPUps); // - // TB_PP4 - // - this.TB_PP4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.TB_PP4.Location = new System.Drawing.Point(135, 93); - this.TB_PP4.MaxLength = 2; - this.TB_PP4.Name = "TB_PP4"; - this.TB_PP4.Size = new System.Drawing.Size(31, 20); - this.TB_PP4.TabIndex = 11; - // - // TB_PP3 - // - this.TB_PP3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.TB_PP3.Location = new System.Drawing.Point(135, 71); - this.TB_PP3.MaxLength = 2; - this.TB_PP3.Name = "TB_PP3"; - this.TB_PP3.Size = new System.Drawing.Size(31, 20); - this.TB_PP3.TabIndex = 8; - // - // TB_PP2 - // - this.TB_PP2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.TB_PP2.Location = new System.Drawing.Point(135, 49); - this.TB_PP2.MaxLength = 2; - this.TB_PP2.Name = "TB_PP2"; - this.TB_PP2.Size = new System.Drawing.Size(31, 20); - this.TB_PP2.TabIndex = 5; - // - // TB_PP1 - // - this.TB_PP1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.TB_PP1.Location = new System.Drawing.Point(135, 27); - this.TB_PP1.MaxLength = 2; - this.TB_PP1.Name = "TB_PP1"; - this.TB_PP1.Size = new System.Drawing.Size(31, 20); - this.TB_PP1.TabIndex = 2; - this.TB_PP1.TextChanged += new System.EventHandler(this.update255_TB); - // // CB_PPu4 // this.CB_PPu4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -2840,7 +2843,7 @@ public void InitializeComponent() this.Menu_Language.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.CB_MainLanguage}); this.Menu_Language.Name = "Menu_Language"; - this.Menu_Language.Size = new System.Drawing.Size(152, 22); + this.Menu_Language.Size = new System.Drawing.Size(139, 22); this.Menu_Language.Text = "Language"; // // CB_MainLanguage @@ -2856,7 +2859,7 @@ public void InitializeComponent() this.Menu_ModifyDex, this.Menu_ModifyPK6}); this.Menu_Modify.Name = "Menu_Modify"; - this.Menu_Modify.Size = new System.Drawing.Size(152, 22); + this.Menu_Modify.Size = new System.Drawing.Size(139, 22); this.Menu_Modify.Text = "Set to SAV"; // // Menu_ModifyDex @@ -2885,7 +2888,7 @@ public void InitializeComponent() this.Menu_Unicode.CheckOnClick = true; this.Menu_Unicode.CheckState = System.Windows.Forms.CheckState.Checked; this.Menu_Unicode.Name = "Menu_Unicode"; - this.Menu_Unicode.Size = new System.Drawing.Size(152, 22); + this.Menu_Unicode.Size = new System.Drawing.Size(139, 22); this.Menu_Unicode.Text = "Unicode"; this.Menu_Unicode.Click += new System.EventHandler(this.mainMenuUnicode); // @@ -2894,7 +2897,7 @@ public void InitializeComponent() this.Menu_About.Name = "Menu_About"; this.Menu_About.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P))); this.Menu_About.ShowShortcutKeys = false; - this.Menu_About.Size = new System.Drawing.Size(152, 22); + this.Menu_About.Size = new System.Drawing.Size(139, 22); this.Menu_About.Text = "About &PKHeX"; this.Menu_About.Click += new System.EventHandler(this.mainMenuAbout); // @@ -4635,10 +4638,6 @@ public void InitializeComponent() private System.Windows.Forms.PictureBox PB_Mark2; private System.Windows.Forms.PictureBox PB_Mark1; private System.Windows.Forms.PictureBox Label_IsShiny; - private System.Windows.Forms.TextBox TB_PP4; - private System.Windows.Forms.TextBox TB_PP3; - private System.Windows.Forms.TextBox TB_PP2; - private System.Windows.Forms.TextBox TB_PP1; private System.Windows.Forms.Panel PAN_Party; private System.Windows.Forms.Panel PAN_BattleBox; private System.Windows.Forms.Button B_OpenSuperTraining; @@ -4709,6 +4708,10 @@ public void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem Menu_DumpBoxes; private System.Windows.Forms.ToolStripMenuItem Menu_ExportBAK; private System.Windows.Forms.ToolStripMenuItem Menu_ExportMAIN; + private System.Windows.Forms.MaskedTextBox TB_PP1; + private System.Windows.Forms.MaskedTextBox TB_PP2; + private System.Windows.Forms.MaskedTextBox TB_PP3; + private System.Windows.Forms.MaskedTextBox TB_PP4; } } diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 2a584773a..886ffc4e3 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -1439,15 +1439,15 @@ private void updateEXPLevel(object sender, EventArgs e) { if (changingFields) return; + changingFields = true; if (sender == TB_EXP) { - changingFields = true; // Change the Level uint EXP = Util.ToUInt32(TB_EXP.Text); int Species = Util.getIndex(CB_Species); - int Level = EXP == 0 ? 1 : PKX.getLevel(Species, EXP); + int Level = PKX.getLevel(Species, EXP); if (Level == 100) - EXP = PKX.getEXP(Level, Species); + EXP = PKX.getEXP(100, Species); TB_Level.Text = Level.ToString(); if (!MT_Level.Visible) @@ -1457,7 +1457,6 @@ private void updateEXPLevel(object sender, EventArgs e) } else { - changingFields = true; // Change the XP int Level = Util.ToInt32((MT_Level.Focused ? MT_Level : TB_Level).Text); if (Level > 100) TB_Level.Text = "100"; @@ -1630,23 +1629,8 @@ private void updateHackedStatText(object sender, EventArgs e) } private void update255_MTB(object sender, EventArgs e) { - MaskedTextBox mtb = sender as MaskedTextBox; - try - { - if (Util.ToInt32((sender as MaskedTextBox).Text) > byte.MaxValue) + if (Util.ToInt32((sender as MaskedTextBox).Text) > byte.MaxValue) (sender as MaskedTextBox).Text = "255"; - } - catch { mtb.Text = "0"; } - } - private void update255_TB(object sender, EventArgs e) - { - TextBox tb = sender as TextBox; - try - { - if (Util.ToInt32((sender as TextBox).Text) > byte.MaxValue) - (sender as TextBox).Text = "255"; - } - catch { tb.Text = "0"; } } private void updateForm(object sender, EventArgs e) { diff --git a/PKX/f1-Main.resx b/PKX/f1-Main.resx index c930f6406..618275562 100644 --- a/PKX/f1-Main.resx +++ b/PKX/f1-Main.resx @@ -480,12 +480,6 @@ True - - True - - - True - True @@ -498,6 +492,12 @@ True + + True + + + True + True