diff --git a/ShiftOS.WinForms/LanguageSelector.Designer.cs b/ShiftOS.WinForms/LanguageSelector.Designer.cs deleted file mode 100644 index 508b5df..0000000 --- a/ShiftOS.WinForms/LanguageSelector.Designer.cs +++ /dev/null @@ -1,94 +0,0 @@ -using ShiftOS.Engine; - -namespace ShiftOS.WinForms -{ - partial class LanguageSelector - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // comboBox1 - // - this.comboBox1.Cursor = System.Windows.Forms.Cursors.Default; - this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(Localization.GetAllLanguages()); - this.comboBox1.Location = new System.Drawing.Point(13, 13); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(167, 21); - this.comboBox1.TabIndex = 0; - this.comboBox1.SelectedItem = this.comboBox1.Items[0]; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(12, 40); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 1; - this.button1.Text = "Run"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // button2 - // - this.button2.Location = new System.Drawing.Point(105, 40); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 2; - this.button2.Text = "Quit"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // LanguageSelector - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(192, 74); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); - this.Controls.Add(this.comboBox1); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "LanguageSelector"; - this.ShowIcon = false; - this.Text = "Choose A Language"; - this.ResumeLayout(false); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.closing); - - } - - #endregion - - private System.Windows.Forms.ComboBox comboBox1; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Button button2; - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/LanguageSelector.cs b/ShiftOS.WinForms/LanguageSelector.cs deleted file mode 100644 index c9a5ac1..0000000 --- a/ShiftOS.WinForms/LanguageSelector.cs +++ /dev/null @@ -1,44 +0,0 @@ -using ShiftOS.Engine; -using ShiftOS.WinForms.Applications; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace ShiftOS.WinForms -{ - public partial class LanguageSelector : Form - { - public string languageID; - public bool rdy = false; - - public LanguageSelector() - { - InitializeComponent(); - } - - private void button1_Click(object sender, EventArgs e) - { - Localization.SetLanguageID((string)comboBox1.SelectedItem); - - rdy = true; - - this.Close(); - } - - private void button2_Click(object sender, EventArgs e) - { - Environment.Exit(0); - } - - private void closing(object sender, FormClosingEventArgs e) - { - if (!rdy) Environment.Exit(0); - } - } -} diff --git a/ShiftOS.WinForms/LanguageSelector.resx b/ShiftOS.WinForms/LanguageSelector.resx deleted file mode 100644 index 1af7de1..0000000 --- a/ShiftOS.WinForms/LanguageSelector.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index b5f371e..348360f 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -58,14 +58,6 @@ namespace ShiftOS.WinForms Environment.Exit(0); }; - var langselect = new LanguageSelector(); - langselect.ShowDialog(); - - while (!langselect.rdy) - { - - }; - TutorialManager.RegisterTutorial(new Oobe()); TerminalBackend.TerminalRequested += () => diff --git a/ShiftOS.WinForms/Resources/languages.txt b/ShiftOS.WinForms/Resources/languages.txt index ca34308..a452137 100644 --- a/ShiftOS.WinForms/Resources/languages.txt +++ b/ShiftOS.WinForms/Resources/languages.txt @@ -1,4 +1,4 @@ [ "english" - "deutsch - in beta" + "deutsch" ] \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/strings_de.txt b/ShiftOS.WinForms/Resources/strings_de.txt index 5abfd32..59631de 100644 --- a/ShiftOS.WinForms/Resources/strings_de.txt +++ b/ShiftOS.WinForms/Resources/strings_de.txt @@ -159,6 +159,8 @@ Wenn eine Systemdatei von dem Virenscanner erkannt wird, wird sie ersetzt.", "{COMMAND_SOS_SHUTDOWN_DESCRIPTION}":"Saves and shuts down ShiftOS", "{COMMAND_SOS_STATUS_USAGE}":"%ns.%cmd", "{COMMAND_SOS_STATUS_DESCRIPTION}":"Displays how many codepoints you have", + "{COMMAND_SOS_LANG_USAGE}":"%ns.%cmd{[language:\"english\"]}", + "{COMMAND_SOS_LANG_DESCRIPTION}":"Sprache ändern.", "{COMMAND_DEV_CRASH_USAGE}":"%ns.%cmd", "{COMMAND_DEV_CRASH_DESCRIPTION}":"Shuts down ShiftOS forcefully", "{COMMAND_DEV_UNLOCKEVERYTHING_USAGE}":"%ns.%cmd", @@ -217,6 +219,7 @@ Wenn eine Systemdatei von dem Virenscanner erkannt wird, wird sie ersetzt.", "{OBSOLETE_SYS_SHUTDOWN}":"sys.shutdown is obsolete", "{PY_EXCEPTION}":"There was an error running python code.", "{LUA_ERROR}":"There was an error running lua code.", + "{LANGUAGE_CHANGED}":"The language has been changed. Please restart ShiftOS for changes to take full effect.", "{TERMINAL_NAME}":"Terminal", "{ARTPAD_NAME}":"Artpad", diff --git a/ShiftOS.WinForms/Resources/strings_en.txt b/ShiftOS.WinForms/Resources/strings_en.txt index 54c9b54..34d034a 100644 --- a/ShiftOS.WinForms/Resources/strings_en.txt +++ b/ShiftOS.WinForms/Resources/strings_en.txt @@ -158,12 +158,14 @@ If a system file is deleted by the virus scanner, it will be replaced.", "{COMMAND_SOS_SHUTDOWN_DESCRIPTION}":"Saves and shuts down ShiftOS", "{COMMAND_SOS_STATUS_USAGE}":"%ns.%cmd", "{COMMAND_SOS_STATUS_DESCRIPTION}":"Displays how many codepoints you have", + "{COMMAND_SOS_LANG_USAGE}":"%ns.%cmd{[language:\"deutsch\"]}", + "{COMMAND_SOS_LANG_DESCRIPTION}":"Change the language.", "{COMMAND_DEV_CRASH_USAGE}":"%ns.%cmd", "{COMMAND_DEV_CRASH_DESCRIPTION}":"Shuts down ShiftOS forcefully", "{COMMAND_DEV_UNLOCKEVERYTHING_USAGE}":"%ns.%cmd", "{COMMAND_DEV_UNLOCKEVERYTHING_DESCRIPTION}":"Unlocks all shiftorium upgrades", "{COMMAND_DEV_FREECP_USAGE}":"%ns.%cmd{[amount:1000]}", - "{COMMAND_DEV_FREECP_DESCRIPTION}":"Gives [ammount] codepoints", + "{COMMAND_DEV_FREECP_DESCRIPTION}":"Gives [amount] codepoints", "{COMMAND_TRM_CLEAR_USAGE}":"%ns.%cmd", "{COMMAND_TRM_CLEAR_DESCRIPTION}":"Clears the terminal", "{COMMAND_SHIFTORIUM_BUY_USAGE}":"%ns.%cmd{upgrade:}", @@ -217,6 +219,7 @@ If a system file is deleted by the virus scanner, it will be replaced.", "{OBSOLETE_SYS_SHUTDOWN}":"sys.shutdown is obsolete", "{PY_EXCEPTION}":"There was an error running python code.", "{LUA_ERROR}":"There was an error running lua code.", + "{LANGUAGE_CHANGED}":"The language has been changed. Please restart ShiftOS for changes to take full effect.", "{TERMINAL_NAME}":"Terminal", "{ARTPAD_NAME}":"Artpad", diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index d7b3478..d865c62 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -258,12 +258,6 @@ - - Form - - - LanguageSelector.cs - Form @@ -389,9 +383,6 @@ FakeSetupScreen.cs - - LanguageSelector.cs - Oobe.cs diff --git a/ShiftOS.WinForms/WFLanguageProvider.cs b/ShiftOS.WinForms/WFLanguageProvider.cs index b6b652b..c11b6dc 100644 --- a/ShiftOS.WinForms/WFLanguageProvider.cs +++ b/ShiftOS.WinForms/WFLanguageProvider.cs @@ -42,13 +42,20 @@ namespace ShiftOS.WinForms public string GetCurrentTranscript() { - switch (SaveSystem.CurrentSave.Language) + try { - case "deutsch - in beta": - return Properties.Resources.strings_de; - default: - return getDefault(); - + switch (SaveSystem.CurrentSave.Language) + { + case "deutsch": + return Properties.Resources.strings_de; + default: + return getDefault(); + + } + } + catch (NullReferenceException) + { + return getDefault(); } } @@ -56,7 +63,7 @@ namespace ShiftOS.WinForms { switch (SaveSystem.CurrentSave.Language) { - case "deutsch - in beta": + case "deutsch": return Paths.GetPath("deutsch.local"); default: return Paths.GetPath("english.local"); diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 9f85a25..fedff19 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -357,6 +357,35 @@ namespace ShiftOS.Engine return true; } + [Command("lang", usage = "{{COMMAND_SOS_LANG_USAGE}}", description = "{{COMMAND_SOS_LANG_DESCRIPTION}}")] + [RequiresArgument("language")] + public static bool SetLanguage(Dictionary userArgs) + { + try + { + string lang = ""; + + if (userArgs.ContainsKey("language")) + lang = (string)userArgs["language"]; + else + throw new Exception("You must specify a valid 'language' value."); + + if (Localization.GetAllLanguages().Contains(lang)) + { + SaveSystem.CurrentSave.Language = lang; + SaveSystem.SaveGame(); + Console.WriteLine("{LANGUAGE_CHANGED}"); + return true; + } + + throw new Exception($"Couldn't find language with ID: {lang}"); + } + catch + { + return false; + } + } + [Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")] public static bool Help() { diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index a9d24b8..c1a6bd6 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -67,6 +67,12 @@ namespace ShiftOS.Engine var path = "english.local"; Utils.WriteAllText(Paths.GetPath(path), lines); } + else if (SaveSystem.CurrentSave == null) + { + var lines = Properties.Resources.strings_en; + var path = "english.local"; + Utils.WriteAllText(Paths.GetPath(path), lines); + } else { _provider.WriteTranscript(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 5188bf1..9ff3111 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -70,7 +70,6 @@ namespace ShiftOS.Engine root.permissions = Permissions.All; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } - CurrentSave.Language = Localization.GetLanguageID(); if (Utils.Mounts.Count == 0) Utils.Mount(System.IO.File.ReadAllText(Paths.SaveFile)); @@ -176,6 +175,8 @@ namespace ShiftOS.Engine } + Localization.SetupTHETRUEDefaultLocals(); + Shiftorium.Init(); while (CurrentSave.StoryPosition < 1)