diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 9f3628302..b11062eb0 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -47,8 +47,6 @@ public Main() }).Start(); CB_ExtraBytes.SelectedIndex = 0; - SaveFile.SetUpdateDex = Menu_ModifyDex.Checked; - SaveFile.SetUpdatePKM = Menu_ModifyPKM.Checked; getFieldsfromPKM = populateFieldsPK6; getPKMfromFields = preparePK6; @@ -111,6 +109,13 @@ public Main() if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) e.Cancel = true; }; + Menu_Options.DropDown.Closing += (sender, e) => + { + if (!Menu_Unicode.Selected) + return; + if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) + e.Cancel = true; + }; // Box to Tabs D&D dragout.AllowDrop = true; @@ -124,13 +129,32 @@ public Main() #region Localize & Populate Fields string[] args = Environment.GetCommandLineArgs(); string filename = args.Length > 0 ? Path.GetFileNameWithoutExtension(args[0])?.ToLower() : ""; - HaX = filename.IndexOf("hax", StringComparison.Ordinal) >= 0; + HaX = filename?.IndexOf("hax", StringComparison.Ordinal) >= 0; - // Try and detect the language - string lastTwoChars = filename.Length > 2 ? filename.Substring(filename.Length - 2) : ""; - if (lastTwoChars == "jp") lastTwoChars = "ja"; - int lang = Array.IndexOf(lang_val, lastTwoChars); - CB_MainLanguage.SelectedIndex = lang < 0 ? 1 : lang; + bool showChangelog = false; + // Load User Settings + { + unicode = Menu_Unicode.Checked = Properties.Settings.Default.Unicode; + SaveFile.SetUpdateDex = Menu_ModifyDex.Checked = Properties.Settings.Default.SetUpdateDex; + SaveFile.SetUpdatePKM = Menu_ModifyPKM.Checked = Properties.Settings.Default.SetUpdatePKM; + + // Select Language + string l = Properties.Settings.Default.Language; + if (l.Length != 2) l = "en"; + int lang = Array.IndexOf(lang_val, l); + CB_MainLanguage.SelectedIndex = lang < 0 ? 1 : lang; + + // Version Check + if (Properties.Settings.Default.Version.Length > 0) // already run on system + { + int lastrev; int.TryParse(Properties.Settings.Default.Version, out lastrev); + int currrev; int.TryParse(Properties.Resources.ProgramVersion, out currrev); + + showChangelog = lastrev < currrev; + } + Properties.Settings.Default.Version = Properties.Resources.ProgramVersion; + Properties.Settings.Default.Save(); + } InitializeFields(); formInitialized = true; @@ -166,6 +190,9 @@ public Main() Show(); WindowState = FormWindowState.Normal; if (HaX) Util.Alert("Illegal mode activated.", "Please behave."); + + if (showChangelog) + new About().ShowDialog(); #endregion } @@ -348,16 +375,19 @@ private void mainMenuMysteryDM(object sender, EventArgs e) } private void mainMenuUnicode(object sender, EventArgs e) { - unicode = Menu_Unicode.Checked; + Properties.Settings.Default.Unicode = unicode = Menu_Unicode.Checked; + Properties.Settings.Default.Save(); updateUnicode(); } private void mainMenuModifyDex(object sender, EventArgs e) { - SaveFile.SetUpdateDex = Menu_ModifyDex.Checked; + Properties.Settings.Default.SetUpdateDex = SaveFile.SetUpdateDex = Menu_ModifyDex.Checked; + Properties.Settings.Default.Save(); } private void mainMenuModifyPKM(object sender, EventArgs e) { - SaveFile.SetUpdatePKM = Menu_ModifyPKM.Checked; + Properties.Settings.Default.SetUpdatePKM = SaveFile.SetUpdatePKM = Menu_ModifyPKM.Checked; + Properties.Settings.Default.Save(); } private void mainMenuBoxLoad(object sender, EventArgs e) { @@ -1177,14 +1207,18 @@ private void changeMainLanguage(object sender, EventArgs e) Menu_Options.DropDown.Close(); InitializeStrings(); InitializeLanguage(); - Util.TranslateInterface(this, lang_val[CB_MainLanguage.SelectedIndex]); // Translate the UI to language. + string ProgramTitle = Text; + Util.TranslateInterface(this, curlanguage); // Translate the UI to language. + Text = ProgramTitle; // Recenter PKM SubEditors FLP_PKMEditors.Location = new Point((Tab_OTMisc.Width - FLP_PKMEditors.Width)/2, FLP_PKMEditors.Location.Y); populateFields(pk); // put data back in form fieldsInitialized |= alreadyInit; // Set the culture (makes it easy to pass language to other forms) - Thread.CurrentThread.CurrentCulture = new CultureInfo(lang_val[CB_MainLanguage.SelectedIndex]); + Properties.Settings.Default.Language = curlanguage; + Properties.Settings.Default.Save(); + Thread.CurrentThread.CurrentCulture = new CultureInfo(curlanguage); Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; } private void InitializeStrings() diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index 34fe02e77..2e9666a7c 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -183,6 +183,7 @@ + Form diff --git a/PKHeX/Properties/Settings.Designer.cs b/PKHeX/Properties/Settings.Designer.cs index c01c8ff7a..3364bdbf3 100644 --- a/PKHeX/Properties/Settings.Designer.cs +++ b/PKHeX/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17929 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ namespace PKHeX.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -22,5 +22,65 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio return defaultInstance; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string Language { + get { + return ((string)(this["Language"])); + } + set { + this["Language"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string Version { + get { + return ((string)(this["Version"])); + } + set { + this["Version"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool Unicode { + get { + return ((bool)(this["Unicode"])); + } + set { + this["Unicode"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool SetUpdateDex { + get { + return ((bool)(this["SetUpdateDex"])); + } + set { + this["SetUpdateDex"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool SetUpdatePKM { + get { + return ((bool)(this["SetUpdatePKM"])); + } + set { + this["SetUpdatePKM"] = value; + } + } } } diff --git a/PKHeX/Properties/Settings.settings b/PKHeX/Properties/Settings.settings index 8e615f25f..7a3cc02f5 100644 --- a/PKHeX/Properties/Settings.settings +++ b/PKHeX/Properties/Settings.settings @@ -1,5 +1,21 @@  - + - + + + + + + + + + True + + + True + + + True + + \ No newline at end of file diff --git a/PKHeX/Settings.cs b/PKHeX/Settings.cs new file mode 100644 index 000000000..6a176816c --- /dev/null +++ b/PKHeX/Settings.cs @@ -0,0 +1,28 @@ +namespace PKHeX.Properties { + + + // This class allows you to handle specific events on the settings class: + // The SettingChanging event is raised before a setting's value is changed. + // The PropertyChanged event is raised after a setting's value is changed. + // The SettingsLoaded event is raised after the setting values are loaded. + // The SettingsSaving event is raised before the setting values are saved. + internal sealed partial class Settings { + + public Settings() { + // // To add event handlers for saving and changing settings, uncomment the lines below: + // + // this.SettingChanging += this.SettingChangingEventHandler; + // + // this.SettingsSaving += this.SettingsSavingEventHandler; + // + } + + private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { + // Add code to handle the SettingChangingEvent event here. + } + + private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { + // Add code to handle the SettingsSaving event here. + } + } +} diff --git a/PKHeX/app.config b/PKHeX/app.config index b5dac54d7..11ccf9c44 100644 --- a/PKHeX/app.config +++ b/PKHeX/app.config @@ -1,8 +1,30 @@ + +
+ + + + + + + + + + + True + + + True + + + True + + +