Use string method instead of control based

This commit is contained in:
Kurt 2016-01-09 12:39:18 -08:00
parent f9fa461955
commit bd5a1c7db3
10 changed files with 52 additions and 61 deletions

View file

@ -76,7 +76,7 @@ namespace PKHeX
{
// Add the new code to the textbox.
if (!loaddata()) return;
uint writeoffset = Util.getHEXval(TB_Write);
uint writeoffset = Util.getHEXval(TB_Write.Text);
for (int i = 0; i < newdata.Length / 4; i++)
{

View file

@ -2159,7 +2159,6 @@
// CHK_Diamond
//
this.CHK_Diamond.AutoSize = true;
this.CHK_Diamond.Font = new System.Drawing.Font("Cambria", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.CHK_Diamond.Location = new System.Drawing.Point(205, 228);
this.CHK_Diamond.Name = "CHK_Diamond";
this.CHK_Diamond.Size = new System.Drawing.Size(15, 14);
@ -2170,7 +2169,6 @@
//
// CHK_Star
//
this.CHK_Star.AutoSize = true;
this.CHK_Star.Location = new System.Drawing.Point(205, 213);
this.CHK_Star.Name = "CHK_Star";
this.CHK_Star.Size = new System.Drawing.Size(38, 17);
@ -2181,7 +2179,6 @@
//
// CHK_Heart
//
this.CHK_Heart.AutoSize = true;
this.CHK_Heart.Location = new System.Drawing.Point(205, 199);
this.CHK_Heart.Name = "CHK_Heart";
this.CHK_Heart.Size = new System.Drawing.Size(37, 17);
@ -2192,7 +2189,6 @@
//
// CHK_Square
//
this.CHK_Square.AutoSize = true;
this.CHK_Square.Location = new System.Drawing.Point(29, 227);
this.CHK_Square.Name = "CHK_Square";
this.CHK_Square.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
@ -2262,7 +2258,6 @@
//
// CHK_Triangle
//
this.CHK_Triangle.AutoSize = true;
this.CHK_Triangle.Location = new System.Drawing.Point(29, 213);
this.CHK_Triangle.Name = "CHK_Triangle";
this.CHK_Triangle.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
@ -2274,8 +2269,6 @@
//
// CHK_Circle
//
this.CHK_Circle.AutoSize = true;
this.CHK_Circle.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.CHK_Circle.Location = new System.Drawing.Point(27, 193);
this.CHK_Circle.Name = "CHK_Circle";
this.CHK_Circle.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
@ -2599,8 +2592,6 @@
//
// Label_Diamond
//
this.Label_Diamond.AutoSize = true;
this.Label_Diamond.Font = new System.Drawing.Font("Century", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Label_Diamond.Location = new System.Drawing.Point(215, 224);
this.Label_Diamond.Name = "Label_Diamond";
this.Label_Diamond.Size = new System.Drawing.Size(26, 20);
@ -2637,7 +2628,7 @@
this.Menu_Open.Name = "Menu_Open";
this.Menu_Open.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
this.Menu_Open.ShowShortcutKeys = false;
this.Menu_Open.Size = new System.Drawing.Size(152, 22);
this.Menu_Open.Size = new System.Drawing.Size(140, 22);
this.Menu_Open.Text = "&Open...";
this.Menu_Open.Click += new System.EventHandler(this.mainMenuOpen);
//
@ -2646,7 +2637,7 @@
this.Menu_Save.Name = "Menu_Save";
this.Menu_Save.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.Menu_Save.ShowShortcutKeys = false;
this.Menu_Save.Size = new System.Drawing.Size(152, 22);
this.Menu_Save.Size = new System.Drawing.Size(140, 22);
this.Menu_Save.Text = "&Save PK6...";
this.Menu_Save.Click += new System.EventHandler(this.mainMenuSave);
//
@ -2659,7 +2650,7 @@
this.Menu_ExportTransfer});
this.Menu_ExportSAV.Enabled = false;
this.Menu_ExportSAV.Name = "Menu_ExportSAV";
this.Menu_ExportSAV.Size = new System.Drawing.Size(152, 22);
this.Menu_ExportSAV.Size = new System.Drawing.Size(140, 22);
this.Menu_ExportSAV.Text = "&Export SAV...";
//
// Menu_ExportMAIN
@ -2699,7 +2690,7 @@
this.Menu_Exit.Name = "Menu_Exit";
this.Menu_Exit.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q)));
this.Menu_Exit.ShowShortcutKeys = false;
this.Menu_Exit.Size = new System.Drawing.Size(152, 22);
this.Menu_Exit.Size = new System.Drawing.Size(140, 22);
this.Menu_Exit.Text = "&Quit";
this.Menu_Exit.Click += new System.EventHandler(this.mainMenuExit);
//
@ -2866,7 +2857,7 @@
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(139, 22);
this.Menu_Language.Size = new System.Drawing.Size(152, 22);
this.Menu_Language.Text = "Language";
//
// CB_MainLanguage
@ -2882,7 +2873,7 @@
this.Menu_ModifyDex,
this.Menu_ModifyPK6});
this.Menu_Modify.Name = "Menu_Modify";
this.Menu_Modify.Size = new System.Drawing.Size(139, 22);
this.Menu_Modify.Size = new System.Drawing.Size(152, 22);
this.Menu_Modify.Text = "Set to SAV";
//
// Menu_ModifyDex
@ -2908,7 +2899,7 @@
// Menu_Unicode
//
this.Menu_Unicode.Name = "Menu_Unicode";
this.Menu_Unicode.Size = new System.Drawing.Size(139, 22);
this.Menu_Unicode.Size = new System.Drawing.Size(152, 22);
this.Menu_Unicode.Text = "Toggle Font";
this.Menu_Unicode.Click += new System.EventHandler(this.mainMenuUnicode);
//
@ -2917,7 +2908,7 @@
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(139, 22);
this.Menu_About.Size = new System.Drawing.Size(152, 22);
this.Menu_About.Text = "About &PKHeX";
this.Menu_About.Click += new System.EventHandler(this.mainMenuAbout);
//

View file

@ -144,7 +144,7 @@ namespace PKHeX
public static Color defaultControlWhite;
public static Color defaultControlText;
public static int colorizedbox = 32;
public static Image mixedHighlight = Util.LayerImage(Properties.Resources.slotSet, Properties.Resources.slotView, 0, 0, 0.5);
public static Image mixedHighlight = Util.ChangeOpacity(Properties.Resources.slotSet, 0.5);
public static Image colorizedcolor;
public static int colorizedslot;
public static string eggname = "";
@ -1299,7 +1299,7 @@ namespace PKHeX
// PKX Data Calculation Functions //
private void setIsShiny()
{
bool isShiny = PKX.getIsShiny(Util.getHEXval(TB_PID), Util.ToUInt32(TB_TID.Text), Util.ToUInt32(TB_SID.Text));
bool isShiny = PKX.getIsShiny(Util.getHEXval(TB_PID.Text), Util.ToUInt32(TB_TID.Text), Util.ToUInt32(TB_SID.Text));
// Set the Controls
BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny;
@ -1410,7 +1410,7 @@ namespace PKHeX
{
var arrayEV = new[] {TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPAEV, TB_SPDEV, TB_SPEEV};
arrayEV[index].Text = (e.Button == MouseButtons.Left
? Math.Min(Math.Max(510 - Util.ToInt32(TB_EVTotal) + Util.ToInt32(arrayEV[index]), 0), 252)
? Math.Min(Math.Max(510 - Util.ToInt32(TB_EVTotal.Text) + Util.ToInt32(arrayEV[index].Text), 0), 252)
: 0).ToString();
}
else
@ -1427,7 +1427,7 @@ namespace PKHeX
private void clickEV(object sender, EventArgs e)
{
if (ModifierKeys == Keys.Control) // EV
(sender as MaskedTextBox).Text = Math.Min(Math.Max(510 - Util.ToInt32(TB_EVTotal) + Util.ToInt32((sender as MaskedTextBox)), 0), 252).ToString();
(sender as MaskedTextBox).Text = Math.Min(Math.Max(510 - Util.ToInt32(TB_EVTotal.Text) + Util.ToInt32((sender as MaskedTextBox).Text), 0), 252).ToString();
else if (ModifierKeys == Keys.Alt)
(sender as MaskedTextBox).Text = 0.ToString();
}
@ -1502,7 +1502,7 @@ namespace PKHeX
{
changingFields = true;
// Change the Level
uint EXP = Util.ToUInt32(TB_EXP);
uint EXP = Util.ToUInt32(TB_EXP.Text);
int Species = Util.getIndex(CB_Species);
int Level = EXP == 0 ? 1 : PKX.getLevel(Species, EXP);
if (Level == 100)
@ -1561,12 +1561,12 @@ namespace PKHeX
changingFields = true;
// Update IVs
pk6.IV_HP = Util.ToInt32(TB_HPIV);
pk6.IV_ATK = Util.ToInt32(TB_ATKIV);
pk6.IV_DEF = Util.ToInt32(TB_DEFIV);
pk6.IV_SPE = Util.ToInt32(TB_SPEIV);
pk6.IV_SPA = Util.ToInt32(TB_SPAIV);
pk6.IV_SPD = Util.ToInt32(TB_SPDIV);
pk6.IV_HP = Util.ToInt32(TB_HPIV.Text);
pk6.IV_ATK = Util.ToInt32(TB_ATKIV.Text);
pk6.IV_DEF = Util.ToInt32(TB_DEFIV.Text);
pk6.IV_SPE = Util.ToInt32(TB_SPEIV.Text);
pk6.IV_SPA = Util.ToInt32(TB_SPAIV.Text);
pk6.IV_SPD = Util.ToInt32(TB_SPDIV.Text);
CB_HPType.SelectedValue = pk6.HPType;
changingFields = false;
@ -1833,7 +1833,7 @@ namespace PKHeX
else if (gt == 0) // Male Only
genderflag = 0;
else // get gender from old PID correlation
genderflag = (Util.getHEXval(TB_PID) & 0xFF) <= gt ? 1 : 0;
genderflag = (Util.getHEXval(TB_PID.Text) & 0xFF) <= gt ? 1 : 0;
int Gender = genderflag;
Label_Gender.Text = gendersymbols[Gender];
@ -2052,12 +2052,12 @@ namespace PKHeX
}
private void updateShinyPID(object sender, EventArgs e)
{
uint PID = Util.getHEXval(TB_PID);
uint PID = Util.getHEXval(TB_PID.Text);
uint UID = PID >> 16;
uint LID = PID & 0xFFFF;
uint PSV = UID ^ LID;
uint TID = Util.ToUInt32(TB_TID);
uint SID = Util.ToUInt32(TB_SID);
uint TID = Util.ToUInt32(TB_TID.Text);
uint SID = Util.ToUInt32(TB_SID.Text);
uint TSV = TID ^ SID;
uint XOR = TSV ^ PSV;
@ -2079,14 +2079,14 @@ namespace PKHeX
Tip1.SetToolTip(TB_TID, "TSV: " + TSV.ToString("0000"));
Tip2.SetToolTip(TB_SID, "TSV: " + TSV.ToString("0000"));
var PSV = PKX.getPSV(Util.getHEXval(TB_PID));
var PSV = PKX.getPSV(Util.getHEXval(TB_PID.Text));
Tip3.SetToolTip(TB_PID, "PSV: " + PSV.ToString("0000"));
}
private void update_ID(object sender, EventArgs e)
{
// Trim out nonhex characters
TB_PID.Text = Util.getHEXval(TB_PID).ToString("X8");
TB_EC.Text = Util.getHEXval(TB_EC).ToString("X8");
TB_PID.Text = Util.getHEXval(TB_PID.Text).ToString("X8");
TB_EC.Text = Util.getHEXval(TB_EC.Text).ToString("X8");
// Max TID/SID is 65535
if (Util.ToUInt32(TB_TID.Text) > ushort.MaxValue) TB_TID.Text = "65535";
@ -2241,8 +2241,8 @@ namespace PKHeX
// Repopulate PK6 with Edited Stuff
if (Util.getIndex(CB_GameOrigin) < 24)
{
uint EC = Util.getHEXval(TB_EC);
uint PID = Util.getHEXval(TB_PID);
uint EC = Util.getHEXval(TB_EC.Text);
uint PID = Util.getHEXval(TB_PID.Text);
uint SID = Util.ToUInt32(TB_TID.Text);
uint TID = Util.ToUInt32(TB_TID.Text);
uint LID = PID & 0xFFFF;
@ -2263,7 +2263,7 @@ namespace PKHeX
TB_EC.Text = PID.ToString("X8");
}
pk6.EncryptionConstant = Util.getHEXval(TB_EC);
pk6.EncryptionConstant = Util.getHEXval(TB_EC.Text);
pk6.Checksum = 0; // 0 CHK for now
// Block A
@ -2275,7 +2275,7 @@ namespace PKHeX
pk6.Ability = (byte)Array.IndexOf(abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk6.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
// pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag)
pk6.PID = Util.getHEXval(TB_PID);
pk6.PID = Util.getHEXval(TB_PID.Text);
pk6.Nature = (byte)Util.getIndex(CB_Nature);
pk6.FatefulEncounter = CHK_Fateful.Checked;
pk6.Gender = PKX.getGender(Label_Gender.Text);

View file

@ -22,11 +22,11 @@ namespace PKHeX
if (arguments[i] == null) continue;
vartypes[i - 5] = arguments[i] + ":";
}
args[0] = arguments.Length > 0 ? arguments[0] : "Disabled";
args[1] = arguments.Length > 1 ? arguments[1] : "Never left";
args[2] = arguments.Length > 2 ? arguments[2] : "OT";
args[3] = arguments.Length > 3 ? arguments[3] : "Past Gen";
args[4] = arguments.Length > 4 ? arguments[4] : "Memories with";
args[0] = arguments.Length > 0 ? arguments[0] ?? "Disabled" : "Disabled";
args[1] = arguments.Length > 1 ? arguments[1] ?? "Never left" : "Never left";
args[2] = arguments.Length > 2 ? arguments[2] ?? "OT" : "OT";
args[3] = arguments.Length > 3 ? arguments[3] ?? "Past Gen": "Past Gen";
args[4] = arguments.Length > 4 ? arguments[4] ?? "Memories with" : "Memories with";
ComboBox[] cba = { CB_Country0, CB_Country1, CB_Country2, CB_Country3, CB_Country4, };
foreach (ComboBox comboBox in cba)
{
@ -142,12 +142,12 @@ namespace PKHeX
Main.pk6.Geo5_Country = Util.getIndex(CB_Country4);
// Save 0-255 stats
Main.pk6.HT_Friendship = Util.ToInt32(M_CT_Friendship);
Main.pk6.HT_Affection = Util.ToInt32(M_CT_Affection);
Main.pk6.OT_Friendship = Util.ToInt32(M_OT_Friendship);
Main.pk6.OT_Affection = Util.ToInt32(M_OT_Affection);
Main.pk6.Fullness = (byte)Util.ToInt32(M_Fullness);
Main.pk6.Enjoyment = (byte)Util.ToInt32(M_Enjoyment);
Main.pk6.HT_Friendship = Util.ToInt32(M_CT_Friendship.Text);
Main.pk6.HT_Affection = Util.ToInt32(M_CT_Affection.Text);
Main.pk6.OT_Friendship = Util.ToInt32(M_OT_Friendship.Text);
Main.pk6.OT_Affection = Util.ToInt32(M_OT_Affection.Text);
Main.pk6.Fullness = (byte)Util.ToInt32(M_Fullness.Text);
Main.pk6.Enjoyment = (byte)Util.ToInt32(M_Enjoyment.Text);
// Save Memories
Main.pk6.HT_Memory = Util.getIndex(CB_CTMemory);

View file

@ -50,7 +50,7 @@ namespace PKHeX
Array.Copy(BitConverter.GetBytes(Constants[i]), 0, Main.SAV.Data, Main.SAV.EventConst + 2 * i, 2);
// Copy back Volcanic Ash counter
Array.Copy(BitConverter.GetBytes(Util.ToUInt32(MT_Ash)), 0, Main.SAV.Data, Main.SAV.EventAsh, 2);
Array.Copy(BitConverter.GetBytes(Util.ToUInt32(MT_Ash.Text)), 0, Main.SAV.Data, Main.SAV.EventAsh, 2);
Close();
}
@ -225,7 +225,7 @@ namespace PKHeX
private void changeConstantIndex(object sender, EventArgs e)
{
if (entry > -1) // Set Entry
Constants[entry] = (ushort)(Math.Min(Util.ToUInt32(MT_Stat), 0xFFFF));
Constants[entry] = (ushort)(Math.Min(Util.ToUInt32(MT_Stat.Text), 0xFFFF));
entry = CB_Stats.SelectedIndex; // Get Entry
MT_Stat.Text = Constants[entry].ToString();

View file

@ -193,7 +193,7 @@ namespace PKHeX
private void changeConstantIndex(object sender, EventArgs e)
{
if (entry > -1) // Set Entry
Constants[entry] = (ushort)(Math.Min(Util.ToUInt32(MT_Stat), 0xFFFF));
Constants[entry] = (ushort)(Math.Min(Util.ToUInt32(MT_Stat.Text), 0xFFFF));
entry = CB_Stats.SelectedIndex; // Get Entry
MT_Stat.Text = Constants[entry].ToString();

View file

@ -208,7 +208,7 @@ namespace PKHeX
}
// Store Spinda Spot
uint PID = Util.getHEXval(TB_Spinda);
uint PID = Util.getHEXval(TB_Spinda.Text);
Array.Copy(BitConverter.GetBytes(PID), 0, sav, Main.SAV.Spinda, 4);
}
@ -268,7 +268,7 @@ namespace PKHeX
CHK_P7.Checked = true;
}
int dexNav = Util.ToInt32(MT_Count);
int dexNav = Util.ToInt32(MT_Count.Text);
if (dexNav == 0)
MT_Count.Text = 1.ToString();
}
@ -306,7 +306,7 @@ namespace PKHeX
private void changeEncounteredCount(object sender, EventArgs e)
{
if (!editing)
BitConverter.GetBytes((ushort)Math.Min(0xFFFF, Util.ToUInt32(MT_Count))).CopyTo(sav, Main.SAV.EncounterCount + (Util.getIndex(CB_Species) - 1) * 2);
BitConverter.GetBytes((ushort)Math.Min(0xFFFF, Util.ToUInt32(MT_Count.Text))).CopyTo(sav, Main.SAV.EncounterCount + (Util.getIndex(CB_Species) - 1) * 2);
}
}
}

View file

@ -228,7 +228,7 @@ namespace PKHeX
}
// Store Spinda Spot
uint PID = Util.getHEXval(TB_Spinda);
uint PID = Util.getHEXval(TB_Spinda.Text);
Array.Copy(BitConverter.GetBytes(PID), 0, sav, Main.SAV.Spinda, 4);
}

View file

@ -148,7 +148,7 @@ namespace PKHeX
puffarray[i - emptyslots] = (byte)Array.IndexOf(pfa, puff);
}
Main.SAV.Puffs = puffarray;
Main.SAV.PuffCount = Util.ToInt32(MT_CNT);
Main.SAV.PuffCount = Util.ToInt32(MT_CNT.Text);
Main.SAV.Edited = true;
Close();
}

View file

@ -202,7 +202,7 @@ namespace PKHeX
}
private void B_Save_Click(object sender, EventArgs e)
{
uint flags = Util.ToUInt32(MT_Flags);
uint flags = Util.ToUInt32(MT_Flags.Text);
Array.Copy(BitConverter.GetBytes(flags), 0, sav, Main.SAV.PSSStats + 0x140, 4); // write pss
Array.Copy(BitConverter.GetBytes(flags), 0, sav, Main.SAV.SecretBase + 0x62C, 4); // write counter
Array.Copy(sav, Main.SAV.Data, sav.Length);
@ -277,7 +277,7 @@ namespace PKHeX
int index = currentpkm;
byte[] pkm = new byte[0x34];
Array.Copy(BitConverter.GetBytes(Util.getHEXval(TB_EC)), 0, pkm, 0, 4); // EC
Array.Copy(BitConverter.GetBytes(Util.getHEXval(TB_EC.Text)), 0, pkm, 0, 4); // EC
Array.Copy(BitConverter.GetBytes(Util.getIndex(CB_Species)), 0, pkm, 8, 2);
Array.Copy(BitConverter.GetBytes(Util.getIndex(CB_HeldItem)), 0, pkm, 0xA, 2);
pkm[0xC] = (byte)Array.IndexOf(abilitylist, (CB_Ability.Text).Remove((CB_Ability.Text).Length - 4)); // Ability