From e2201ab6fbb416062af61784d600d4cabed4a6dd Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 7 Apr 2015 00:02:29 -0700 Subject: [PATCH] xytext fix and clarity refactoring --- pk3DS/Subforms/LevelUp.cs | 1 - pk3DS/Subforms/MEE.cs | 73 ++++++++++++++++------------------- pk3DS/Subforms/RSTE.cs | 4 +- pk3DS/Subforms/TrainerRand.cs | 4 +- pk3DS/Subforms/xytext.cs | 22 +++++------ 5 files changed, 51 insertions(+), 53 deletions(-) diff --git a/pk3DS/Subforms/LevelUp.cs b/pk3DS/Subforms/LevelUp.cs index bcce61e..3144f43 100644 --- a/pk3DS/Subforms/LevelUp.cs +++ b/pk3DS/Subforms/LevelUp.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Linq; using System.Media; diff --git a/pk3DS/Subforms/MEE.cs b/pk3DS/Subforms/MEE.cs index 4e86ad8..6c6de31 100644 --- a/pk3DS/Subforms/MEE.cs +++ b/pk3DS/Subforms/MEE.cs @@ -108,25 +108,23 @@ private void changeIndex(object sender, EventArgs e) bool dumping; private void getEntry() { - if (loaded) + if (!loaded) return; + if (Main.oras && entry == 384 && !dumping) // Current Mon is Rayquaza + Util.Alert("Rayquaza is special and uses a different activator for its evolution. If it knows Dragon Ascent, it can Mega Evolve", "Don't edit its evolution table if you want to keep this functionality."); + + byte[] data = File.ReadAllBytes(files[entry]); + + foreach (ComboBox CB in forme_spec) + Personal.setForms(entry, CB, AltForms); + + for (int i = 0; i < 3; i++) { - if (Main.oras && entry == 384 && !dumping) // Current Mon is Rayquaza - Util.Alert("Rayquaza is special and uses a different activator for its evolution. If it knows Dragon Ascent, it can Mega Evolve", "Don't edit its evolution table if you want to keep this functionality."); - - byte[] data = File.ReadAllBytes(files[entry]); - - foreach (ComboBox CB in forme_spec) - Personal.setForms(entry, CB, AltForms); - - for (int i = 0; i < 3; i++) - { - ushort method = BitConverter.ToUInt16(data, 2 + (i * 8)); - ushort form = BitConverter.ToUInt16(data, i * 8); - int item = BitConverter.ToUInt16(data, 4 + i * 8); - checkbox_spec[i].Checked = (method == 1); - forme_spec[i].SelectedIndex = form; - item_spec[i].SelectedValue = item; - } + ushort method = BitConverter.ToUInt16(data, 2 + (i * 8)); + ushort form = BitConverter.ToUInt16(data, i * 8); + int item = BitConverter.ToUInt16(data, 4 + i * 8); + checkbox_spec[i].Checked = (method == 1); + forme_spec[i].SelectedIndex = form; + item_spec[i].SelectedValue = item; } } private void setEntry() @@ -156,27 +154,8 @@ private void setEntry() private void Update_PBs(object sender, EventArgs e) { - if (loaded) - { - for (int i = 0; i < checkbox_spec.Length; i++) - { - CheckBox CB = checkbox_spec[i]; - if (CB.Checked) - { - UpdateImage(picturebox_spec[0][i], entry, 0, (int)(item_spec[i]).SelectedValue, 0); - UpdateImage(picturebox_spec[1][i], entry, (forme_spec[i]).SelectedIndex, (int)(item_spec[i]).SelectedValue, 0); - } - else - { - UpdateImage(picturebox_spec[0][i], 0, 0, (int)(item_spec[i]).SelectedValue, 0); - UpdateImage(picturebox_spec[1][i], 0, 0, (int)(item_spec[i]).SelectedValue, 0); - } - } - } - } - private void Update_PBs(int i) - { - if (loaded) + if (!loaded) return; + for (int i = 0; i < checkbox_spec.Length; i++) { CheckBox CB = checkbox_spec[i]; if (CB.Checked) @@ -191,6 +170,22 @@ private void Update_PBs(int i) } } } + + private void Update_PBs(int i) + { + if (!loaded) return; + CheckBox CB = checkbox_spec[i]; + if (CB.Checked) + { + UpdateImage(picturebox_spec[0][i], entry, 0, (int)(item_spec[i]).SelectedValue, 0); + UpdateImage(picturebox_spec[1][i], entry, (forme_spec[i]).SelectedIndex, (int)(item_spec[i]).SelectedValue, 0); + } + else + { + UpdateImage(picturebox_spec[0][i], 0, 0, (int)(item_spec[i]).SelectedValue, 0); + UpdateImage(picturebox_spec[1][i], 0, 0, (int)(item_spec[i]).SelectedValue, 0); + } + } private void UpdateImage(PictureBox bpkx, int species, int form, int item, int gender) { diff --git a/pk3DS/Subforms/RSTE.cs b/pk3DS/Subforms/RSTE.cs index 154640e..3d6dc91 100644 --- a/pk3DS/Subforms/RSTE.cs +++ b/pk3DS/Subforms/RSTE.cs @@ -509,7 +509,9 @@ private void Setup() CB_Battle_Type.Items.Add("Rotation"); CB_Battle_Type.Items.Add("Horde"); - megaEvos = (Main.oras) ? new[] { 15, 18, 80, 208, 254, 260, 302, 319, 323, 334, 362, 373, 376, 380, 381, 428, 475, 531, 719, 3, 6, 9, 65, 94, 115, 127, 130, 142, 150, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, 445, 448, 460 } : new[] { 3, 6, 9, 65, 94, 115, 127, 130, 142, 150, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, 445, 448, 460 }; + megaEvos = (Main.oras) + ? new[] { 15, 18, 80, 208, 254, 260, 302, 319, 323, 334, 362, 373, 376, 380, 381, 428, 475, 531, 719, 3, 6, 9, 65, 94, 115, 127, 130, 142, 150, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, 445, 448, 460 } + : new[] { 3, 6, 9, 65, 94, 115, 127, 130, 142, 150, 181, 212, 214, 229, 248, 257, 282, 303, 306, 308, 310, 354, 359, 445, 448, 460 }; CB_TrainerID.SelectedIndex = 1; start = false; diff --git a/pk3DS/Subforms/TrainerRand.cs b/pk3DS/Subforms/TrainerRand.cs index 9b24ec1..8143a04 100644 --- a/pk3DS/Subforms/TrainerRand.cs +++ b/pk3DS/Subforms/TrainerRand.cs @@ -48,7 +48,9 @@ private void B_Save_Click(object sender, EventArgs e) if (CHK_StoryMEvos.Checked) { - RSTE.rEnsureMEvo = Main.oras ? (new int[] { 178, 235, 557, 583, 687, 698, 699, 700, 701, 713, 906, 907, 908, 909, 910, 911, 912, 913, 942, 944, 946 }) : (new int[] { 188, 263, 276, 277, 519, 520, 521, 526, 599, 600, 601 }); + RSTE.rEnsureMEvo = Main.oras + ? (new [] { 178, 235, 557, 583, 687, 698, 699, 700, 701, 713, 906, 907, 908, 909, 910, 911, 912, 913, 942, 944, 946 }) + : (new [] { 188, 263, 276, 277, 519, 520, 521, 526, 599, 600, 601 }); } else { diff --git a/pk3DS/Subforms/xytext.cs b/pk3DS/Subforms/xytext.cs index 415450f..fc878aa 100644 --- a/pk3DS/Subforms/xytext.cs +++ b/pk3DS/Subforms/xytext.cs @@ -36,16 +36,16 @@ private void dumpTXT_Click(object sender, EventArgs e) tw.WriteLine("~~~~~~~~~~~~~~~"); tw.WriteLine("Text File : " + i); tw.WriteLine("~~~~~~~~~~~~~~~"); - if (data != null) - foreach (string line in data) - { - tw.WriteLine(newline - ? line.Replace("\\n\\n", " ") - .Replace("\\n", " ") - .Replace("\\c", "") - .Replace("\\r", "") - : line); - } + if (data == null) continue; + foreach (string line in data) + { + tw.WriteLine(newline + ? line.Replace("\\n\\n", " ") + .Replace("\\n", " ") + .Replace("\\c", "") + .Replace("\\r", "") + : line); + } } File.WriteAllBytes(path, ms.ToArray()); } @@ -260,7 +260,7 @@ internal static byte[] getBytesForFile(string[] lines) else if (val == 0x2640) val = 0xE08F; // ♀ // Variables - else if (val == '[' || val == '\\') // Variable + if (val == '[' || val == '\\') // Variable encryptVar(bz, lines[i], ref j, ref key); // Text