mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-11 07:04:16 +00:00
Round of refactoring and improvements
This commit is contained in:
parent
742a41e7f3
commit
a99ddf11bf
14 changed files with 1425 additions and 1538 deletions
|
@ -140,7 +140,7 @@ namespace PKHeX
|
|||
for (int i = 0; i < newdata.Length / 4; i++)
|
||||
{
|
||||
RTB_Code.AppendText((writeoffset + i * 4 + 0x20000000).ToString("X8") + " ");
|
||||
RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + "\n");
|
||||
RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + System.Environment.NewLine);
|
||||
}
|
||||
|
||||
// Mat's Code - Unfinished
|
||||
|
@ -150,7 +150,7 @@ namespace PKHeX
|
|||
|
||||
// RTB_Code.AppendText("00000001 "); // 01 00 00 00
|
||||
// RTB_Code.AppendText((writeoffset + i * 4).ToString("X8") + " ");
|
||||
// RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + "\n");
|
||||
// RTB_Code.AppendText(BitConverter.ToUInt32(newdata,i*4).ToString("X8") + System.Environment.NewLine);
|
||||
//}
|
||||
}
|
||||
private void B_Clear_Click(object sender, EventArgs e)
|
||||
|
@ -169,12 +169,12 @@ namespace PKHeX
|
|||
|
||||
if (ncf.Length != length + 4)
|
||||
{
|
||||
MessageBox.Show("Not a valid code file.", "Error");
|
||||
Util.Error("Not a valid code file.");
|
||||
return;
|
||||
}
|
||||
if (RTB_Code.Text.Length > 0)
|
||||
{
|
||||
DialogResult ld = MessageBox.Show("Replace current code?","Alert",MessageBoxButtons.YesNo);
|
||||
DialogResult ld = Util.Prompt(MessageBoxButtons.YesNo, "Replace current code?");
|
||||
if (ld == DialogResult.Yes)
|
||||
RTB_Code.Clear();
|
||||
else if (ld != DialogResult.No)
|
||||
|
@ -184,7 +184,7 @@ namespace PKHeX
|
|||
{
|
||||
RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 0 * 4).ToString("X8") + " ");
|
||||
RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 1 * 4).ToString("X8") + " ");
|
||||
RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 2 * 4).ToString("X8") + "\n");
|
||||
RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 2 * 4).ToString("X8") + System.Environment.NewLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,21 +225,17 @@ namespace PKHeX
|
|||
private void B_Copy_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (RTB_Code.Text.Length > 0)
|
||||
{
|
||||
Clipboard.SetText(RTB_Code.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
B_Diff.PerformClick();
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(RTB_Code.Text);
|
||||
MessageBox.Show("Code generated and copied to clipboard!\n\nNext time click [Create Diff] first.", "Alert");
|
||||
Util.Alert("Code generated and copied to clipboard!", "Next time click [Create Diff] first.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("No code created!\n\nClick [Create Diff], then make sure that data appears in the Text Box below.\nIf no code appears, then you didn't save your changes.\n\nBe sure to Set the Pokemon you edited back into a Box/Party slot!", "Alert");
|
||||
}
|
||||
{ Util.Alert("No code created!", "Click [Create Diff], then make sure that data appears in the Text Box below. If no code appears, then you didn't save your changes.", "Be sure to Set the Pokemon you edited back into a Box/Party slot!"); }
|
||||
}
|
||||
}
|
||||
private void B_Diff_Click(object sender, EventArgs e)
|
||||
|
@ -265,11 +261,11 @@ namespace PKHeX
|
|||
if (BitConverter.ToUInt32(cybersav, i) != BitConverter.ToUInt32(newcyber, i))
|
||||
{
|
||||
result += ((0x20000000 + i).ToString("X8") + " ");
|
||||
result += (BitConverter.ToUInt32(newcyber, i).ToString("X8") + "\n");
|
||||
result += (BitConverter.ToUInt32(newcyber, i).ToString("X8") + System.Environment.NewLine);
|
||||
|
||||
lines++;
|
||||
if ((lines % 128 == 0) && CHK_Break.Checked)
|
||||
{ result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); }
|
||||
{ result += ("\n--- Segment " + (lines / 128 + 1).ToString() + " ---" + System.Environment.NewLine + System.Environment.NewLine); }
|
||||
if (lines > 10000) goto toomany;
|
||||
}
|
||||
}
|
||||
|
@ -284,11 +280,11 @@ namespace PKHeX
|
|||
for (int z = 0; z < newdata.Length; z += 4)
|
||||
{
|
||||
result += ((0x20000000 + i + z).ToString("X8") + " ");
|
||||
result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + "\n");
|
||||
result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + System.Environment.NewLine);
|
||||
|
||||
lines++;
|
||||
if ((lines % 128 == 0) && CHK_Break.Checked)
|
||||
{ result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); }
|
||||
{ result += ("\n--- Segment " + (lines / 128 + 1).ToString() + " ---" + System.Environment.NewLine + System.Environment.NewLine); }
|
||||
if (lines > 10000) goto toomany;
|
||||
}
|
||||
}
|
||||
|
@ -298,11 +294,11 @@ namespace PKHeX
|
|||
if (cybersav[0x14818] != newcyber[0x14818])
|
||||
{
|
||||
result += ((0x00000000 + 0x14818).ToString("X8") + " ");
|
||||
result += (newcyber[0x14818].ToString("X8") + "\n");
|
||||
result += (newcyber[0x14818].ToString("X8") + System.Environment.NewLine);
|
||||
|
||||
lines++;
|
||||
if ((lines % 128 == 0) && CHK_Break.Checked)
|
||||
{ result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); }
|
||||
{ result += (System.Environment.NewLine + "--- Segment " + (lines / 128 + 1).ToString() + " ---" + System.Environment.NewLine + System.Environment.NewLine); }
|
||||
if (lines > 10000) goto toomany;
|
||||
}
|
||||
|
||||
|
@ -316,11 +312,11 @@ namespace PKHeX
|
|||
for (int z = 0; z < newdata.Length; z += 4)
|
||||
{
|
||||
result += ((0x20000000 + i + z).ToString("X8") + " ");
|
||||
result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + "\n");
|
||||
result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + System.Environment.NewLine);
|
||||
|
||||
lines++;
|
||||
if ((lines % 128 == 0) && CHK_Break.Checked)
|
||||
{ result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); }
|
||||
{ result += (System.Environment.NewLine + "--- Segment " + (lines / 128 + 1).ToString() + " ---" + System.Environment.NewLine + System.Environment.NewLine); }
|
||||
if (lines > 10000) goto toomany;
|
||||
}
|
||||
}
|
||||
|
@ -328,13 +324,13 @@ namespace PKHeX
|
|||
|
||||
if ((lines / 128 > 0) && CHK_Break.Checked)
|
||||
{
|
||||
MessageBox.Show((1 + (lines / 128)).ToString() + " Code Segments\n\nLines: " + lines.ToString(), "Alert");
|
||||
Util.Alert(String.Format("{0} Code Segments.", (1 + (lines / 128)).ToString()), String.Format("{0} Lines.", lines.ToString()));
|
||||
}
|
||||
RTB_Code.Text = result; return;
|
||||
|
||||
toomany:
|
||||
{
|
||||
MessageBox.Show("Too many differences. Export your save instead.", "Alert");
|
||||
Util.Alert("Too many differences detected.", "Export your save instead.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,9 +351,7 @@ namespace PKHeX
|
|||
if (RTB_Code.Lines[i].Length > 0)
|
||||
{
|
||||
if (RTB_Code.Lines[i].Length <= 2 * 8 && RTB_Code.Lines[i].Length > 2 * 8 + 2)
|
||||
{
|
||||
MessageBox.Show("Invalid code pasted (Type)", "Error"); return;
|
||||
}
|
||||
{ Util.Error("Invalid code pasted (Type)"); return; }
|
||||
else
|
||||
{
|
||||
try
|
||||
|
@ -368,10 +362,8 @@ namespace PKHeX
|
|||
Array.Resize(ref data, data.Length + 4);
|
||||
Array.Copy(BitConverter.GetBytes(UInt32.Parse(rip[1], NumberStyles.HexNumber)), 0, data, data.Length - 4, 4);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Invalid code pasted (Content)", "Error"); return;
|
||||
}
|
||||
catch (Exception x)
|
||||
{ Util.Error("Invalid code pasted (Content):", x.ToString()); return; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -389,7 +381,7 @@ namespace PKHeX
|
|||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid code pasted (Length)", "Error"); return;
|
||||
Util.Error("Invalid code pasted (Length)"); return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1082
Misc/PKX.cs
1082
Misc/PKX.cs
File diff suppressed because it is too large
Load diff
148
Misc/Util.cs
148
Misc/Util.cs
|
@ -5,8 +5,8 @@ using System.Globalization;
|
|||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Reflection;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PKHeX
|
||||
{
|
||||
|
@ -73,6 +73,8 @@ namespace PKHeX
|
|||
B = 255;
|
||||
return Color.FromArgb(Math.Abs(A), Math.Abs(R), Math.Abs(G), Math.Abs(B));
|
||||
}
|
||||
|
||||
// Strings and Paths
|
||||
internal static FileInfo GetNewestFile(DirectoryInfo directory)
|
||||
{
|
||||
return directory.GetFiles()
|
||||
|
@ -80,24 +82,16 @@ namespace PKHeX
|
|||
.OrderByDescending(f => (f == null ? DateTime.MinValue : f.LastWriteTime))
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
//Adding a Normalize Path function using a variant of this answer from stack overflow
|
||||
//http://stackoverflow.com/questions/1266674/how-can-one-get-an-absolute-or-normalized-file-path-in-net/21058121#21058121
|
||||
internal static string NormalizePath(string path)
|
||||
{
|
||||
return Path.GetFullPath(new Uri(path).LocalPath)
|
||||
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
}
|
||||
internal static string GetTempFolder() // From 3DSSE's decompiled source.
|
||||
internal static string GetTempFolder()
|
||||
{
|
||||
string tempPath = Path.GetTempPath();
|
||||
string str2 = "SE3DS";
|
||||
str2 = "3DSSE";
|
||||
tempPath = Path.Combine(tempPath, str2);
|
||||
// Directory.CreateDirectory(tempPath);
|
||||
return (tempPath);
|
||||
return Path.Combine(Path.GetTempPath(), "3DSSE");
|
||||
}
|
||||
internal static string GetCacheFolder() // edited
|
||||
internal static string GetCacheFolder()
|
||||
{
|
||||
return Path.Combine(GetBackupLocation(), "cache");
|
||||
}
|
||||
|
@ -133,17 +127,14 @@ namespace PKHeX
|
|||
{
|
||||
try
|
||||
{
|
||||
// start by checking if the 3DS file path exists or not.
|
||||
// Start by checking if the 3DS file path exists or not.
|
||||
string path_SDF = null;
|
||||
string[] DriveList = Environment.GetLogicalDrives();
|
||||
for (int i = 1; i < DriveList.Length; i++)
|
||||
for (int i = 1; i < DriveList.Length; i++) // Skip first drive (some users still have floppy drives and would chew up time!)
|
||||
{
|
||||
string potentialPath_SDF = NormalizePath(Path.Combine(DriveList[i], "filer" + Path.DirectorySeparatorChar + "UserSaveData"));
|
||||
if (Directory.Exists(potentialPath_SDF))
|
||||
{
|
||||
path_SDF = potentialPath_SDF;
|
||||
break;
|
||||
}
|
||||
{ path_SDF = potentialPath_SDF; break; }
|
||||
}
|
||||
if (path_SDF == null)
|
||||
return null;
|
||||
|
@ -159,12 +150,8 @@ namespace PKHeX
|
|||
if (File.Exists(Path.Combine(folders[i], "000011c5" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "000011c5"); // AS
|
||||
if (File.Exists(Path.Combine(folders[i], "0000055d" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "0000055d"); // X
|
||||
if (File.Exists(Path.Combine(folders[i], "0000055e" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "0000055e"); // Y
|
||||
|
||||
// I don't know
|
||||
if (File.Exists(Path.Combine(folders[i], "00055d00" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "00055d00"); // X
|
||||
if (File.Exists(Path.Combine(folders[i], "00055e00" + Path.DirectorySeparatorChar + "main"))) return Path.Combine(folders[i], "00055e00"); // Y
|
||||
}
|
||||
return null;
|
||||
return null; // Fallthrough
|
||||
}
|
||||
}
|
||||
catch { return null; }
|
||||
|
@ -193,12 +180,14 @@ namespace PKHeX
|
|||
return stringdata;
|
||||
}
|
||||
|
||||
// Randomization
|
||||
internal static Random rand = new Random();
|
||||
internal static uint rnd32()
|
||||
{
|
||||
return (uint)(rand.Next(1 << 30)) << 2 | (uint)(rand.Next(1 << 2));
|
||||
}
|
||||
|
||||
// Data Retrieval
|
||||
internal static int ToInt32(TextBox tb)
|
||||
{
|
||||
string value = tb.Text;
|
||||
|
@ -283,18 +272,113 @@ namespace PKHeX
|
|||
return s;
|
||||
}
|
||||
|
||||
internal static MaskedTextBox[] shuffle(MaskedTextBox[] charArray)
|
||||
// Data Manipulation
|
||||
internal static void Shuffle<T>(T[] array)
|
||||
{
|
||||
MaskedTextBox[] shuffledArray = new MaskedTextBox[charArray.Length];
|
||||
int rndNo;
|
||||
|
||||
for (int i = charArray.Length; i >= 1; i--)
|
||||
int n = array.Length;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
rndNo = rand.Next(1, i + 1) - 1;
|
||||
shuffledArray[i - 1] = charArray[rndNo];
|
||||
charArray[rndNo] = charArray[i - 1];
|
||||
int r = i + (int)(rand.NextDouble() * (n - i));
|
||||
T t = array[r];
|
||||
array[r] = array[i];
|
||||
array[i] = t;
|
||||
}
|
||||
return shuffledArray;
|
||||
}
|
||||
|
||||
// Form Manipulation
|
||||
internal static void TranslateInterface(string FORM_NAME, string lang, Control.ControlCollection Controls, MenuStrip menu = null)
|
||||
{
|
||||
// Fetch a File
|
||||
// Check to see if a the translation file exists in the same folder as the executable
|
||||
string externalLangPath = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "lang_" + lang + ".txt";
|
||||
string[] rawlist;
|
||||
if (File.Exists(externalLangPath))
|
||||
rawlist = File.ReadAllLines(externalLangPath);
|
||||
else
|
||||
{
|
||||
object txt;
|
||||
txt = Properties.Resources.ResourceManager.GetObject("lang_" + lang); // Fetch File, \n to list.
|
||||
if (txt == null) return; // Translation file does not exist as a resource; abort this function and don't translate UI.
|
||||
string[] stringSeparators = new string[] { "\r\n" }; // Resource files are notepad compatible
|
||||
rawlist = ((string)txt).Split(stringSeparators, StringSplitOptions.None);
|
||||
rawlist = rawlist.Select(i => i.Trim()).ToArray(); // Remove trailing spaces
|
||||
}
|
||||
|
||||
string[] stringdata = new string[rawlist.Length];
|
||||
int itemsToRename = 0;
|
||||
int start = Array.IndexOf(rawlist, "! " + FORM_NAME);
|
||||
if (start < 0) return; // No Translation loaded for this Form.
|
||||
for (int i = start; i < rawlist.Length; i++)
|
||||
{
|
||||
// Find our starting point
|
||||
if (rawlist[i] == "! " + FORM_NAME) // Start our data
|
||||
{
|
||||
// Copy our Control Names and Text to a new array for later processing.
|
||||
for (int j = i + 1; j < rawlist.Length; j++)
|
||||
{
|
||||
if (rawlist[j].Length == 0)
|
||||
continue; // Skip Over Empty Lines, errhandled
|
||||
if (rawlist[j][0].ToString() != "-") // If line is not a comment line...
|
||||
{
|
||||
if (rawlist[j][0].ToString() == "!") // Stop if we have reached the end of translation
|
||||
break; // exit inner loop
|
||||
stringdata[itemsToRename] = rawlist[j]; // Add the entry to process later.
|
||||
itemsToRename++;
|
||||
}
|
||||
}
|
||||
break; // exit outer loop
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we have our items to rename in: Control = Text format, let's execute the changes!
|
||||
|
||||
for (int i = 0; i < itemsToRename; i++)
|
||||
{
|
||||
string[] SplitString = Regex.Split(stringdata[i], " = ");
|
||||
if (SplitString.Length < 2)
|
||||
continue; // Error in Input, errhandled
|
||||
string ctrl = SplitString[0]; // Control to change the text of...
|
||||
string text = SplitString[1]; // Text to set Control.Text to...
|
||||
Control[] controllist = Controls.Find(ctrl, true);
|
||||
if (controllist.Length == 0) // If Control isn't found...
|
||||
{
|
||||
// Menu Items can't be found with Controls.Find as they aren't Controls
|
||||
ToolStripDropDownItem TSI = (ToolStripDropDownItem)menu.Items[ctrl];
|
||||
if (TSI != null)
|
||||
{
|
||||
// We'll rename the main and child in a row.
|
||||
string[] ToolItems = Regex.Split(SplitString[1], " ; ");
|
||||
TSI.Text = ToolItems[0]; // Set parent's text first
|
||||
if (TSI.DropDownItems.Count != ToolItems.Length - 1)
|
||||
continue; // Error in Input, errhandled
|
||||
for (int ti = 1; ti <= TSI.DropDownItems.Count; ti++)
|
||||
TSI.DropDownItems[ti - 1].Text = ToolItems[ti]; // Set child text
|
||||
}
|
||||
// If not found, it is not something to rename and is thus skipped.
|
||||
}
|
||||
else // Set the input control's text.
|
||||
controllist[0].Text = text;
|
||||
}
|
||||
}
|
||||
|
||||
// Message Displays
|
||||
internal static DialogResult Error(params string[] lines)
|
||||
{
|
||||
System.Media.SystemSounds.Exclamation.Play();
|
||||
string msg = String.Join(System.Environment.NewLine + System.Environment.NewLine, lines);
|
||||
return (DialogResult)MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
internal static DialogResult Alert(params string[] lines)
|
||||
{
|
||||
System.Media.SystemSounds.Asterisk.Play();
|
||||
string msg = String.Join(System.Environment.NewLine + System.Environment.NewLine, lines);
|
||||
return (DialogResult)MessageBox.Show(msg, "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
internal static DialogResult Prompt(MessageBoxButtons btn, params string[] lines)
|
||||
{
|
||||
System.Media.SystemSounds.Question.Play();
|
||||
string msg = String.Join(System.Environment.NewLine + System.Environment.NewLine, lines);
|
||||
return (DialogResult)MessageBox.Show(msg, "Prompt", btn, MessageBoxIcon.Asterisk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
8
PKX/f1-Main.Designer.cs
generated
8
PKX/f1-Main.Designer.cs
generated
|
@ -535,7 +535,7 @@
|
|||
this.TB_PID.Size = new System.Drawing.Size(60, 20);
|
||||
this.TB_PID.TabIndex = 60;
|
||||
this.TB_PID.Text = "12345678";
|
||||
this.TB_PID.TextChanged += new System.EventHandler(this.updateTIDSID);
|
||||
this.TB_PID.TextChanged += new System.EventHandler(this.update_ID);
|
||||
this.TB_PID.MouseHover += new System.EventHandler(this.getTSV);
|
||||
//
|
||||
// CHK_Nicknamed
|
||||
|
@ -2154,7 +2154,7 @@
|
|||
this.TB_EC.Size = new System.Drawing.Size(60, 20);
|
||||
this.TB_EC.TabIndex = 61;
|
||||
this.TB_EC.Text = "12345678";
|
||||
this.TB_EC.TextChanged += new System.EventHandler(this.updateTIDSID);
|
||||
this.TB_EC.TextChanged += new System.EventHandler(this.update_ID);
|
||||
//
|
||||
// GB_nOT
|
||||
//
|
||||
|
@ -2486,7 +2486,7 @@
|
|||
this.TB_SID.Size = new System.Drawing.Size(40, 20);
|
||||
this.TB_SID.TabIndex = 2;
|
||||
this.TB_SID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.TB_SID.TextChanged += new System.EventHandler(this.updateTIDSID);
|
||||
this.TB_SID.TextChanged += new System.EventHandler(this.update_ID);
|
||||
this.TB_SID.MouseHover += new System.EventHandler(this.getTSV);
|
||||
//
|
||||
// TB_TID
|
||||
|
@ -2498,7 +2498,7 @@
|
|||
this.TB_TID.Size = new System.Drawing.Size(40, 20);
|
||||
this.TB_TID.TabIndex = 1;
|
||||
this.TB_TID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.TB_TID.TextChanged += new System.EventHandler(this.updateTIDSID);
|
||||
this.TB_TID.TextChanged += new System.EventHandler(this.update_ID);
|
||||
this.TB_TID.MouseHover += new System.EventHandler(this.getTSV);
|
||||
//
|
||||
// Label_OT
|
||||
|
|
1417
PKX/f1-Main.cs
1417
PKX/f1-Main.cs
File diff suppressed because it is too large
Load diff
|
@ -24,8 +24,8 @@ namespace PKHeX
|
|||
public MemoryAmie(Form1 frm1)
|
||||
{
|
||||
InitializeComponent();
|
||||
Util.TranslateInterface(this.Name, Form1.curlanguage, this.Controls);
|
||||
m_parent = frm1;
|
||||
TranslateInterface("MemoryAmie");
|
||||
string[] arguments = Regex.Split(L_Arguments.Text, " ; ");
|
||||
|
||||
for (int i = 5; i < Math.Min(arguments.Length,vartypes.Length+5); i++)
|
||||
|
@ -45,14 +45,10 @@ namespace PKHeX
|
|||
h = m_parent.buff;
|
||||
|
||||
// Set the current friendship from main window
|
||||
if (m_parent.buff[0x93] == 0)
|
||||
{
|
||||
if (m_parent.buff[0x93] == 0)
|
||||
m_parent.buff[0xCA] = (byte)Convert.ToUInt16(m_parent.TB_Friendship.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_parent.buff[0xA2] = (byte)Convert.ToUInt16(m_parent.TB_Friendship.Text);
|
||||
}
|
||||
|
||||
getCountries();
|
||||
getLangStrings();
|
||||
|
@ -62,72 +58,6 @@ namespace PKHeX
|
|||
public string[] feeling;
|
||||
public string[] quality;
|
||||
|
||||
// Conversion
|
||||
public void TranslateInterface(string FORM_NAME)
|
||||
{
|
||||
string curlanguage = Form1.curlanguage;
|
||||
// Fetch a File
|
||||
// Check to see if a the translation file exists in the same folder as the executable
|
||||
string externalLangPath = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + "lang_" + curlanguage + ".txt";
|
||||
string[] rawlist;
|
||||
if (File.Exists(externalLangPath))
|
||||
{
|
||||
rawlist = File.ReadAllLines(externalLangPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
object txt;
|
||||
txt = Properties.Resources.ResourceManager.GetObject("lang_" + curlanguage); // Fetch File, \n to list.
|
||||
if (txt == null) return; // Translation file does not exist as a resource; abort this function and don't translate UI.
|
||||
string[] stringSeparators = new string[] { "\r\n" };
|
||||
rawlist = ((string)txt).Split(stringSeparators, StringSplitOptions.None);
|
||||
}
|
||||
|
||||
string[] stringdata = new string[rawlist.Length];
|
||||
int itemsToRename = 0;
|
||||
for (int i = 0; i < rawlist.Length; i++)
|
||||
{
|
||||
// Find our starting point
|
||||
if (rawlist[i] == "! " + FORM_NAME) // Start our data
|
||||
{
|
||||
// Copy our Control Names and Text to a new array for later processing.
|
||||
for (int j = i + 1; j < rawlist.Length; j++)
|
||||
{
|
||||
if (rawlist[j].Length == 0)
|
||||
continue; // Skip Over Empty Lines, errhandled
|
||||
if (rawlist[j][0].ToString() != "-") // If line is not a comment line...
|
||||
{
|
||||
if (rawlist[j][0].ToString() == "!") // Stop if we have reached the end of translation
|
||||
break; // exit inner loop
|
||||
stringdata[itemsToRename] = rawlist[j]; // Add the entry to process later.
|
||||
itemsToRename++;
|
||||
}
|
||||
}
|
||||
break; // exit outer loop
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we have our items to rename in: Control = Text format, let's execute the changes!
|
||||
|
||||
for (int i = 0; i < itemsToRename; i++)
|
||||
{
|
||||
string[] SplitString = Regex.Split(stringdata[i], " = ");
|
||||
if (SplitString.Length < 2)
|
||||
continue; // Error in Input, errhandled
|
||||
string ctrl = SplitString[0]; // Control to change the text of...
|
||||
string text = SplitString[1]; // Text to set Control.Text to...
|
||||
Control[] controllist = Controls.Find(ctrl, true);
|
||||
if (controllist.Length == 0) // If Control isn't found...
|
||||
{
|
||||
// If not found, it is not something to rename and is thus skipped.
|
||||
}
|
||||
else // Set the input control's text.
|
||||
{
|
||||
controllist[0].Text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load/Save Actions
|
||||
private void loadFields()
|
||||
{
|
||||
|
@ -153,7 +83,7 @@ namespace PKHeX
|
|||
|
||||
CB_Handler.Items.Clear();
|
||||
CB_Handler.Items.AddRange(new object[] { m_parent.TB_OT.Text + " ("+ot+")"});
|
||||
if ((m_parent.TB_OTt2.Text != "") && (m_parent.TB_OTt2.Text != "\0\0\0\0\0\0\0\0\0\0\0\0"))
|
||||
if (Util.TrimFromZero(m_parent.TB_OTt2.Text) != "")
|
||||
{
|
||||
CB_Handler.Items.AddRange(new object[] { m_parent.TB_OTt2.Text });
|
||||
CB_Handler.Enabled = true;
|
||||
|
@ -214,9 +144,7 @@ namespace PKHeX
|
|||
GB_M_CT.Text = notleft + " " + ot + " - " + disabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
GB_M_CT.Text = withOT + " " + m_parent.TB_OTt2.Text;
|
||||
}
|
||||
}
|
||||
RTB_OT.Visible = CB_OTQual.Enabled = CB_OTMemory.Enabled = CB_OTFeel.Enabled = CB_OTVar.Enabled = M_OT_Affection.Enabled = enable;
|
||||
}
|
||||
|
@ -244,9 +172,7 @@ namespace PKHeX
|
|||
m_parent.buff[0xA9] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cb2v(CB_CTVar, 0xA8);
|
||||
}
|
||||
|
||||
// If memory doesn't contain a feeling/quality
|
||||
if (!CB_CTFeel.Enabled)
|
||||
|
@ -268,9 +194,7 @@ namespace PKHeX
|
|||
m_parent.buff[0xCF] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cb2v(CB_OTVar, 0xCE);
|
||||
}
|
||||
|
||||
// If memory doesn't contain a feeling/quality
|
||||
if (!CB_OTFeel.Enabled)
|
||||
|
@ -479,28 +403,13 @@ namespace PKHeX
|
|||
};
|
||||
#endregion
|
||||
|
||||
var c0_list = new BindingSource(country_list, null);
|
||||
var c1_list = new BindingSource(country_list, null);
|
||||
var c2_list = new BindingSource(country_list, null);
|
||||
var c3_list = new BindingSource(country_list, null);
|
||||
var c4_list = new BindingSource(country_list, null);
|
||||
|
||||
|
||||
CB_Country0.DataSource = c0_list;
|
||||
CB_Country0.DisplayMember = "Text";
|
||||
CB_Country0.ValueMember = "Value";
|
||||
CB_Country1.DataSource = c1_list;
|
||||
CB_Country1.DisplayMember = "Text";
|
||||
CB_Country1.ValueMember = "Value";
|
||||
CB_Country2.DataSource = c2_list;
|
||||
CB_Country2.DisplayMember = "Text";
|
||||
CB_Country2.ValueMember = "Value";
|
||||
CB_Country3.DataSource = c3_list;
|
||||
CB_Country3.DisplayMember = "Text";
|
||||
CB_Country3.ValueMember = "Value";
|
||||
CB_Country4.DataSource = c4_list;
|
||||
CB_Country4.DisplayMember = "Text";
|
||||
CB_Country4.ValueMember = "Value";
|
||||
ComboBox[] cba = new ComboBox[] { CB_Country0, CB_Country1, CB_Country2, CB_Country3, CB_Country4, };
|
||||
for (int i = 0; i < cba.Length; i++)
|
||||
{
|
||||
cba[i].DataSource = new BindingSource(country_list, null);
|
||||
cba[i].DisplayMember = "Text";
|
||||
cba[i].ValueMember = "Value";
|
||||
}
|
||||
}
|
||||
private void getLangStrings()
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace PKHeX
|
|||
m_parent.setPKXBoxes();
|
||||
}
|
||||
else
|
||||
MessageBox.Show("Box data loaded is too big!", "Error");
|
||||
Util.Error("Box data loaded is too big!");
|
||||
}
|
||||
}
|
||||
private void B_ExportBox_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace PKHeX
|
|||
Array.Copy(data, 0x1A0FC - 0x5400, eventflags, 0, 0x180);
|
||||
}
|
||||
else
|
||||
{ MessageBox.Show("Invalid SAV Size", "Error"); return; }
|
||||
{ Util.Error("Invalid SAV Size", String.Format("File Size: {0} (bytes)"), fi.Length.ToString(), "File Loaded: " + path); return; }
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
|
|
@ -169,9 +169,7 @@ namespace PKHeX
|
|||
Array.Copy(data, 0x1A0FC - 0x5400, eventflags, 0, 0x180);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid SAV Size", "Error"); return;
|
||||
}
|
||||
{ Util.Error("Invalid SAV Size"); return; }
|
||||
}
|
||||
else return;
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ namespace PKHeX
|
|||
uint vnd = BitConverter.ToUInt32(data, offset + 0x1B0);
|
||||
uint vn = vnd & 0xFF;
|
||||
TB_VN.Text = vn.ToString("000");
|
||||
s = "Entry #" + vn + "\r\n";
|
||||
s = "Entry #" + vn + Environment.NewLine;
|
||||
uint date = (vnd >> 14) & 0x1FFFF;
|
||||
uint year = (date & 0xFF) + 2000;
|
||||
uint month = (date >> 8) & 0xF;
|
||||
|
@ -233,7 +233,7 @@ namespace PKHeX
|
|||
((Control)editor_spec[i]).Enabled = true;
|
||||
}
|
||||
|
||||
s += "Date: " + year.ToString() + "/" + month.ToString() + "/" + day.ToString() + "\r\n\r\n";
|
||||
s += "Date: " + year.ToString() + "/" + month.ToString() + "/" + day.ToString() + "" + Environment.NewLine + Environment.NewLine;
|
||||
CAL_MetDate.Value = new DateTime((int)year, (int)month, (int)day);
|
||||
int moncount = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
|
@ -266,16 +266,16 @@ namespace PKHeX
|
|||
string shinystr = (shiny == 1) ? "Yes" : "No";
|
||||
|
||||
s += "Name: " + nickname;
|
||||
s += " (" + Form1.specieslist[species] + " - " + genderstr + ")\r\n";
|
||||
s += "Level: " + level.ToString() + "\r\n";
|
||||
s += "Shiny: " + shinystr + "\r\n";
|
||||
s += "Held Item: " + Form1.itemlist[helditem] + "\r\n";
|
||||
s += "Move 1: " + Form1.movelist[move1] + "\r\n";
|
||||
s += "Move 2: " + Form1.movelist[move2] + "\r\n";
|
||||
s += "Move 3: " + Form1.movelist[move3] + "\r\n";
|
||||
s += "Move 4: " + Form1.movelist[move4] + "\r\n";
|
||||
s += "OT: " + OTname + " (" + TID.ToString() + "/" + SID.ToString() + ")\r\n";
|
||||
s += "\r\n";
|
||||
s += " (" + Form1.specieslist[species] + " - " + genderstr + ")" + Environment.NewLine;
|
||||
s += "Level: " + level.ToString() + Environment.NewLine;
|
||||
s += "Shiny: " + shinystr + Environment.NewLine;
|
||||
s += "Held Item: " + Form1.itemlist[helditem] + Environment.NewLine;
|
||||
s += "Move 1: " + Form1.movelist[move1] + Environment.NewLine;
|
||||
s += "Move 2: " + Form1.movelist[move2] + Environment.NewLine;
|
||||
s += "Move 3: " + Form1.movelist[move3] + Environment.NewLine;
|
||||
s += "Move 4: " + Form1.movelist[move4] + Environment.NewLine;
|
||||
s += "OT: " + OTname + " (" + TID.ToString() + "/" + SID.ToString() + ")" + Environment.NewLine;
|
||||
s += Environment.NewLine;
|
||||
|
||||
offset += 0x48;
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ namespace PKHeX
|
|||
try { itemname = Form1.itemlist[itemvalue]; }
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Unknown item detected.\r\n\r\nItem ID: " + itemvalue + "\r\n" + "Item is after: " + itemname, "Error");
|
||||
Util.Error("Unknown item detected.", "Item ID: " + itemvalue, "Item is after: " + itemname);
|
||||
continue;
|
||||
}
|
||||
int itemarrayval = Array.IndexOf(itemarr,itemname);
|
||||
|
@ -282,7 +282,7 @@ namespace PKHeX
|
|||
{
|
||||
dataGridView1.Rows[i].Cells[0].Value = itemarr[0];
|
||||
dataGridView1.Rows[i].Cells[1].Value = 0;
|
||||
MessageBox.Show(itemname + " removed.\n\nIf you exit the Item Editor by saving changes,\nthe item will no longer be in the pouch.", "Alert");
|
||||
Util.Alert(itemname + " removed from item pouch.", "If you exit the Item Editor by saving changes, the item will no longer be in the pouch.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace PKHeX
|
|||
ToolTip1.SetToolTip(this.B_Sort, "Hold CTRL to reverse sort.");
|
||||
|
||||
ToolTip ToolTip2 = new ToolTip();
|
||||
ToolTip2.SetToolTip(this.B_All, "Hold CTRL to give Deluxe\r\ninstead of Supreme.");
|
||||
ToolTip2.SetToolTip(this.B_All, "Hold CTRL to give Deluxe instead of Supreme.");
|
||||
}
|
||||
Form1 m_parent;
|
||||
public byte[] sav = new Byte[0x100000];
|
||||
|
|
|
@ -285,11 +285,11 @@ namespace PKHeX
|
|||
// Write data back to save
|
||||
int index = LB_Favorite.SelectedIndex; // store for restoring
|
||||
if (!GB_PKM.Enabled && index > 0)
|
||||
{ MessageBox.Show("Sorry, no overwriting someone else's base with your own data.", "Error"); return; }
|
||||
{ Util.Error("Sorry, no overwriting someone else's base with your own data."); return; }
|
||||
if (GB_PKM.Enabled && index == 0)
|
||||
{ MessageBox.Show("Sorry, no overwriting of your own base with someone else's.","Error"); return; }
|
||||
{ Util.Error("Sorry, no overwriting of your own base with someone else's."); return; }
|
||||
if (LB_Favorite.Items[index].ToString().Substring(LB_Favorite.Items[index].ToString().Length - 5, 5) == "Empty")
|
||||
{ MessageBox.Show("Sorry, no overwriting an empty base with someone else's.", "Error"); return; }
|
||||
{ Util.Error("Sorry, no overwriting an empty base with someone else's."); return; }
|
||||
if (index < 0) return;
|
||||
int offset = fav_offset + 0x5400 + 0x25A;
|
||||
|
||||
|
|
|
@ -54,49 +54,60 @@ namespace PKHeX
|
|||
}
|
||||
private void loadwcdata()
|
||||
{
|
||||
// Load up the data according to the wiki!
|
||||
int cardID = BitConverter.ToUInt16(wondercard_data, 0);
|
||||
if (cardID == 0)
|
||||
try
|
||||
{
|
||||
RTB.Text = "Empty Slot. No data!";
|
||||
return;
|
||||
}
|
||||
string cardname = Encoding.Unicode.GetString(wondercard_data, 0x2, 0x48);
|
||||
int cardtype = wondercard_data[0x51];
|
||||
RTB.Clear();
|
||||
RTB.AppendText("Card #: " + cardID.ToString("0000") + "\r\n" + cardname + "\r\n");
|
||||
// Load up the data according to the wiki!
|
||||
int cardID = BitConverter.ToUInt16(wondercard_data, 0);
|
||||
if (cardID == 0)
|
||||
{
|
||||
RTB.Text = "Empty Slot. No data!";
|
||||
return;
|
||||
}
|
||||
string cardname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0x2, 0x48));
|
||||
int cardtype = wondercard_data[0x51];
|
||||
string s = "";
|
||||
s += "Card #: " + cardID.ToString("0000") + System.Environment.NewLine + cardname + System.Environment.NewLine + System.Environment.NewLine;
|
||||
|
||||
if (cardtype == 1) // Item
|
||||
{
|
||||
int item = BitConverter.ToUInt16(wondercard_data, 0x68);
|
||||
int qty = BitConverter.ToUInt16(wondercard_data, 0x70);
|
||||
if (cardtype == 1) // Item
|
||||
{
|
||||
int item = BitConverter.ToUInt16(wondercard_data, 0x68);
|
||||
int qty = BitConverter.ToUInt16(wondercard_data, 0x70);
|
||||
|
||||
RTB.AppendText("\r\nItem: " + Form1.itemlist[item] + "\r\n" + "Quantity: " + qty.ToString());
|
||||
}
|
||||
else if (cardtype == 0) // PKM
|
||||
{
|
||||
int species = BitConverter.ToUInt16(wondercard_data, 0x82);
|
||||
int helditem = BitConverter.ToUInt16(wondercard_data, 0x78);
|
||||
int move1 = BitConverter.ToUInt16(wondercard_data, 0x7A);
|
||||
int move2 = BitConverter.ToUInt16(wondercard_data, 0x7C);
|
||||
int move3 = BitConverter.ToUInt16(wondercard_data, 0x7E);
|
||||
int move4 = BitConverter.ToUInt16(wondercard_data, 0x80);
|
||||
int TID = BitConverter.ToUInt16(wondercard_data, 0x68);
|
||||
int SID = BitConverter.ToUInt16(wondercard_data, 0x6A);
|
||||
s += "Item: " + Form1.itemlist[item] + System.Environment.NewLine + "Quantity: " + qty.ToString();
|
||||
}
|
||||
else if (cardtype == 0) // PKM
|
||||
{
|
||||
int species = BitConverter.ToUInt16(wondercard_data, 0x82);
|
||||
int helditem = BitConverter.ToUInt16(wondercard_data, 0x78);
|
||||
int move1 = BitConverter.ToUInt16(wondercard_data, 0x7A);
|
||||
int move2 = BitConverter.ToUInt16(wondercard_data, 0x7C);
|
||||
int move3 = BitConverter.ToUInt16(wondercard_data, 0x7E);
|
||||
int move4 = BitConverter.ToUInt16(wondercard_data, 0x80);
|
||||
int TID = BitConverter.ToUInt16(wondercard_data, 0x68);
|
||||
int SID = BitConverter.ToUInt16(wondercard_data, 0x6A);
|
||||
|
||||
string OTname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0xB6, 22));
|
||||
RTB.Text +=
|
||||
"\r\nSpecies: " + Form1.specieslist[species] + "\r\n"
|
||||
+ "Item: " + Form1.itemlist[helditem] + "\r\n"
|
||||
+ "Move 1: " + Form1.movelist[move1] + "\r\n"
|
||||
+ "Move 2: " + Form1.movelist[move2] + "\r\n"
|
||||
+ "Move 3: " + Form1.movelist[move3] + "\r\n"
|
||||
+ "Move 4: " + Form1.movelist[move4] + "\r\n"
|
||||
+ "OT: " + OTname + "\r\n"
|
||||
+ "ID: " + TID.ToString() + "/" + SID.ToString();
|
||||
string OTname = Util.TrimFromZero(Encoding.Unicode.GetString(wondercard_data, 0xB6, 22));
|
||||
s +=
|
||||
"Species: " + Form1.specieslist[species] + System.Environment.NewLine
|
||||
+ "Item: " + Form1.itemlist[helditem] + System.Environment.NewLine
|
||||
+ "Move 1: " + Form1.movelist[move1] + System.Environment.NewLine
|
||||
+ "Move 2: " + Form1.movelist[move2] + System.Environment.NewLine
|
||||
+ "Move 3: " + Form1.movelist[move3] + System.Environment.NewLine
|
||||
+ "Move 4: " + Form1.movelist[move4] + System.Environment.NewLine
|
||||
+ "OT: " + OTname + System.Environment.NewLine
|
||||
+ "ID: " + TID.ToString() + "/" + SID.ToString();
|
||||
}
|
||||
else
|
||||
s = "Unsupported Wondercard Type!";
|
||||
RTB.Text = s;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Util.Error("Loading of data failed... is this really a Wondercard?");
|
||||
Array.Copy(new Byte[0x108], wondercard_data, 0x108);
|
||||
RTB.Clear();
|
||||
return;
|
||||
}
|
||||
else
|
||||
RTB.Text = "Unsupported Wondercard Type!";
|
||||
}
|
||||
private void populateReceived()
|
||||
{
|
||||
|
@ -115,12 +126,12 @@ namespace PKHeX
|
|||
if (importwc6.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string path = importwc6.FileName;
|
||||
byte[] newwc6 = File.ReadAllBytes(path);
|
||||
if (newwc6.Length > 0x108)
|
||||
if (new FileInfo(path).Length > 0x108)
|
||||
{
|
||||
MessageBox.Show("Not a valid wondercard length.", "Error");
|
||||
Util.Error("File is not a Wondercard:", path);
|
||||
return;
|
||||
}
|
||||
byte[] newwc6 = File.ReadAllBytes(path);
|
||||
Array.Copy(newwc6, wondercard_data, newwc6.Length);
|
||||
loadwcdata();
|
||||
}
|
||||
|
@ -215,6 +226,7 @@ namespace PKHeX
|
|||
Close();
|
||||
}
|
||||
|
||||
// Delete WC Flag
|
||||
private void B_DeleteReceived_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (LB_Received.SelectedIndex > -1)
|
||||
|
@ -222,6 +234,7 @@ namespace PKHeX
|
|||
LB_Received.Items.Remove(LB_Received.Items[LB_Received.SelectedIndex]);
|
||||
}
|
||||
|
||||
// Drag & Drop Wondercards
|
||||
private void tabMain_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
|
||||
|
@ -230,13 +243,13 @@ namespace PKHeX
|
|||
{
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
string path = files[0]; // open first D&D
|
||||
|
||||
byte[] newwc6 = File.ReadAllBytes(path);
|
||||
if (newwc6.Length > 0x108)
|
||||
|
||||
if (new FileInfo(path).Length > 0x108)
|
||||
{
|
||||
MessageBox.Show("Not a valid wondercard length.", "Error");
|
||||
Util.Error("File is not a Wondercard:", path);
|
||||
return;
|
||||
}
|
||||
byte[] newwc6 = File.ReadAllBytes(path);
|
||||
Array.Copy(newwc6, wondercard_data, newwc6.Length);
|
||||
loadwcdata();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue