public Form1()
{
#region Pop open a splash screen while we load up.
Thread SplashSCR = new Thread(() => new SplashScreen(this).ShowDialog());
SplashSCR.Start();
#endregion
#region Initialize Form
InitializeComponent();
defaultControlWhite = CB_Species.BackColor;
defaultControlText = Label_Species.ForeColor;
CB_ExtraBytes.SelectedIndex = 0;
// Resize Main Window to PKX Editing Mode
largeWidth = Width;
shortWidth = (Width * (30500 / 620)) / 100 + 1;
Width = shortWidth;
// Initialize Boxes
byte[] ezeros = PKX.encryptArray(new byte[232]);
for (int i = 0; i < 30 * 31; i++)
Array.Copy(ezeros, 0, savefile, SaveGame.Box + i * 0xE8, 0xE8);
#endregion
#region Language Detection before loading
// Set up Language Selection
foreach (var cbItem in main_langlist)
CB_MainLanguage.Items.Add(cbItem);
// Try and detect the language
int[] main_langnum = {1, 2, 3, 4, 5, 7, 8, 9};
main_langnum = main_langnum.Concat(Enumerable.Range(10, lang_val.Length).Select(i => i).ToArray()).ToArray();
string filename = Path.GetFileNameWithoutExtension(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
string lastTwoChars = filename.Substring(filename.Length - 2);
int lang = Array.IndexOf(lang_val, lastTwoChars);
CB_MainLanguage.SelectedIndex = lang >= 0 ? main_langnum[lang] - 1 : ((lastTwoChars == "jp") ? 1 : 0);
#region HaX
HaX = (filename.IndexOf("HaX", StringComparison.Ordinal) >= 0);
{
CHK_HackedStats.Enabled = CHK_HackedStats.Visible =
DEV_Ability.Enabled = DEV_Ability.Visible =
MT_Level.Enabled = MT_Level.Visible =
TB_AbilityNumber.Visible =
MT_Form.Enabled = MT_Form.Visible = HaX;
TB_Level.Visible =
CB_Ability.Visible = !HaX;
}
#endregion
Status = "Language set up";
#endregion
#region Localize & Populate
InitializeFields(); Status = "Fields set up";
CB_Language.SelectedIndex = (lang >= 0 && lang < 7) ? main_langnum[lang] : 1;
#endregion
#region Add ContextMenus to the PictureBoxes (PKX slots)
ContextMenuStrip mnu = new ContextMenuStrip();
ToolStripMenuItem mnuView = new ToolStripMenuItem("View");
ToolStripMenuItem mnuSet = new ToolStripMenuItem("Set");
ToolStripMenuItem mnuDelete = new ToolStripMenuItem("Delete");
// Assign event handlers
mnuView.Click += clickView;
mnuSet.Click += clickSet;
mnuDelete.Click += clickDelete;
// Add to main context menu
mnu.Items.AddRange(new ToolStripItem[] { mnuView, mnuSet, mnuDelete });
// Assign to datagridview for Box Pokemon and Party Pokemon
foreach (PictureBox pb in PAN_Box.Controls)
pb.ContextMenuStrip = mnu;
foreach (PictureBox pb in PAN_Party.Controls)
pb.ContextMenuStrip = mnu;
// Add ContextMenus to the PictureBoxes that are read only
PictureBox[] pba2 = {
bbpkx1,bbpkx2,bbpkx3,bbpkx4,bbpkx5,bbpkx6,
dcpkx1, dcpkx2, gtspkx, fusedpkx, subepkx1, subepkx2, subepkx3
};
ContextMenuStrip mnu2 = new ContextMenuStrip();
ToolStripMenuItem mnu2View = new ToolStripMenuItem("View");
// Assign event handlers
mnu2View.Click += clickView;
// Add to main context menu
mnu2.Items.AddRange(new ToolStripItem[] { mnu2View });
// Assign to datagridview
foreach (PictureBox p in pba2)
p.ContextMenuStrip = mnu2;
#endregion
#region Enable Drag and Drop on the form & tab control.
AllowDrop = true;
DragEnter += tabMain_DragEnter;
DragDrop += tabMain_DragDrop;
// Enable Drag and Drop on each tab.
tabMain.AllowDrop = true;
tabMain.DragEnter += tabMain_DragEnter;
tabMain.DragDrop += tabMain_DragDrop;
foreach (TabPage tab in tabMain.Controls)
{
tab.AllowDrop = true;
tab.DragEnter += tabMain_DragEnter;
tab.DragDrop += tabMain_DragDrop;
}
// ToolTips for Drag&Drop
ToolTip dragoutTip1 = new ToolTip();
dragoutTip1.SetToolTip(dragout, "PK6 QuickSave");
// Box Drag & Drop
foreach (PictureBox pb in PAN_Box.Controls)
pb.AllowDrop = true;
// Box to Tabs D&D
dragout.AllowDrop = true;
#endregion
#region Finish Up
// Load the arguments
Status = "Checking load args.";
string[] args = Environment.GetCommandLineArgs();
pathSDF = Util.GetSDFLocation();
path3DS = Util.get3DSLocation();
if (args.Length > 1)
openQuick(args[1]);
else if (path3DS != null && File.Exists(Path.Combine(Path.GetDirectoryName(path3DS), "SaveDataBackup", "main")))
openQuick(Path.Combine(Path.GetDirectoryName(path3DS), "SaveDataBackup", "main"));
else if (pathSDF != null)
openQuick(Path.Combine(pathSDF, "main"));
else if (File.Exists(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root" + Path.DirectorySeparatorChar + "main"))))
openQuick(Util.NormalizePath(Path.Combine(Util.GetTempFolder(), "root" + Path.DirectorySeparatorChar + "main")));
GB_OT.Click += clickGT;
GB_nOT.Click += clickGT;
GB_Daycare.Click += switchDaycare;
GB_RelearnMoves.Click += clickMoves;
Status = "Setting game font.";
TB_Nickname.Font = PKX.getPKXFont(11);
TB_OT.Font = (Font)TB_Nickname.Font.Clone();
TB_OTt2.Font = (Font)TB_Nickname.Font.Clone();
Status = "Initialized!";
CB_Species.SelectedIndex = 1;
init = true;
// Splash Screen closes on its own.
BringToFront();
WindowState = FormWindowState.Minimized;
Show();
WindowState = FormWindowState.Normal;
if (HaX) Util.Alert("Illegal mode activated.", "Please behave.");
#endregion
}