From c070f8d07811bbce337b4e79c0aa5151805c3a8e Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sat, 10 May 2014 13:15:23 +0200 Subject: [PATCH] Fix wrong initial language selection --- Vocaluxe/Base/CConfig.cs | 8 +++++--- Vocaluxe/Base/CLanguage.cs | 9 +++++++-- Vocaluxe/Program.cs | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index cc523c70..d6265f3c 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -134,7 +134,7 @@ namespace Vocaluxe.Base public static ETimerMode TimerMode = ETimerMode.TR_CONFIG_TIMERMODE_REMAINING; public static int NumPlayer = 2; public static EOffOn Tabs = EOffOn.TR_CONFIG_OFF; - public static string Language = "English"; + public static string Language = CSettings.FallbackLanguage; public static ELyricsPosition LyricsPosition = ELyricsPosition.TR_CONFIG_LYRICSPOSITION_BOTTOM; public static readonly string[] Players = new string[CSettings.MaxNumPlayer]; @@ -302,9 +302,11 @@ namespace Vocaluxe.Base bool langExists = CLanguage.SetLanguage(Language); - //TODO: What should we do, if English not exists? if (langExists == false) - Language = "English"; + { + Language = CSettings.FallbackLanguage; + CLanguage.SetLanguage(Language); + } //Read players from config for (i = 1; i <= CSettings.MaxNumPlayer; i++) diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index 343aabc0..c3828223 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -41,7 +41,7 @@ namespace Vocaluxe.Base static class CLanguage { private static List _Languages; - private static int _CurrentLanguage; + private static int _CurrentLanguage = -1; private static int _FallbackLanguage; public static int LanguageId @@ -69,7 +69,7 @@ namespace Vocaluxe.Base return languages; } - public static void Init() + public static bool Init() { _Languages = new List(); @@ -78,6 +78,7 @@ namespace Vocaluxe.Base foreach (string file in files) _LoadLanguageFile(file); + return _CurrentLanguage >= 0 && _FallbackLanguage >= 0; } public static bool SetLanguage(string language) @@ -225,7 +226,11 @@ namespace Vocaluxe.Base lang.Name = value; if (lang.Name == CSettings.FallbackLanguage) + { _FallbackLanguage = _Languages.Count; + if (_CurrentLanguage < 0) + _CurrentLanguage = _FallbackLanguage; + } lang.PartyModeTexts = new List(); diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index b7e0d20c..de49bff9 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -91,7 +91,8 @@ namespace Vocaluxe // Init Language CLog.StartBenchmark("Init Language"); - CLanguage.Init(); + if (!CLanguage.Init()) + throw new CLoadingException("Language"); CLog.StopBenchmark("Init Language"); Application.DoEvents();