diff --git a/GeneralMods/Vocalization/Vocalization/Framework/AudioCues.cs b/GeneralMods/Vocalization/Vocalization/Framework/AudioCues.cs index 76f01e18..95a42c60 100644 --- a/GeneralMods/Vocalization/Vocalization/Framework/AudioCues.cs +++ b/GeneralMods/Vocalization/Vocalization/Framework/AudioCues.cs @@ -11,22 +11,19 @@ namespace Vocalization.Framework public static Dictionary> DictionaryReferences = new Dictionary>(); - public static string generateKey(string translationPath, string SpeakerName, string fileName, string dialogueKey) + public static string generateKey(LanguageName language, string SpeakerName, string fileName, string dialogueKey) { - return Vocalization.config.translationInfo.getTranslationNameFromPath(translationPath) + Seperator + SpeakerName + Seperator + fileName + Seperator + dialogueKey; + return Vocalization.config.translationInfo.getTranslationName(language) + Seperator + SpeakerName + Seperator + fileName + Seperator + dialogueKey; } - public static SortedDictionary getWavFileReferences(string translation) + public static SortedDictionary getWavFileReferences(LanguageName language) { - return DictionaryReferences[Vocalization.config.translationInfo.getTranslationNameFromPath(translation)]; + return DictionaryReferences[Vocalization.config.translationInfo.getTranslationName(language)]; } public static void initialize() { - if (!Directory.Exists(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues"))) - { - Directory.CreateDirectory(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues")); - } + Directory.CreateDirectory(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues")); loadAudioCues(); } @@ -45,20 +42,19 @@ namespace Vocalization.Framework public static void loadAudioCues() { - foreach (string v in Vocalization.config.translationInfo.LanguageNames) + foreach (LanguageName language in Vocalization.config.translationInfo.LanguageNames) { - var loaded = Vocalization.ModHelper.ReadJsonFile>(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues", "AudioCues" + Seperator + v + ".json")); - if (loaded == null) loaded = new SortedDictionary(); - DictionaryReferences.Add(v, loaded); + var loaded = + Vocalization.ModHelper.ReadJsonFile>(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues", "AudioCues" + Seperator + language + ".json")) + ?? new SortedDictionary(); + DictionaryReferences.Add(Vocalization.config.translationInfo.getTranslationName(language), loaded); } } public static void saveAudioCues() { foreach (var v in DictionaryReferences) - { Vocalization.ModHelper.WriteJsonFile>(Path.Combine(Vocalization.ModHelper.DirectoryPath, "AudioCues", "AudioCues" + Seperator + v.Key + ".json"), v.Value); - } } } } diff --git a/GeneralMods/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs b/GeneralMods/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs index a1b91933..26c7150d 100644 --- a/GeneralMods/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs +++ b/GeneralMods/Vocalization/Vocalization/Framework/CharacterVoiceCue.cs @@ -172,13 +172,16 @@ namespace Vocalization.Framework } /// Change all of the files to the ones that are appropriate for that translation version. - public void initializeForTranslation(string translation) + /// The translation language name. + public void initializeForTranslation(LanguageName language) { + string extension = Vocalization.config.translationInfo.getFileExtentionForTranslation(language); + for (int i = 0; i < this.dataFileNames.Count; i++) { Vocalization.ModMonitor.Log(this.dataFileNames.ElementAt(i)); string s = this.dataFileNames.ElementAt(i); - s = this.dataFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation)); + s = this.dataFileNames.ElementAt(i).Replace(".xnb", extension); this.dataFileNames[i] = s; Vocalization.ModMonitor.Log(this.dataFileNames.ElementAt(i)); } @@ -187,7 +190,7 @@ namespace Vocalization.Framework { Vocalization.ModMonitor.Log(this.dialogueFileNames.ElementAt(i)); string s = this.dialogueFileNames.ElementAt(i); - s = this.dialogueFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation)); + s = this.dialogueFileNames.ElementAt(i).Replace(".xnb", extension); this.dialogueFileNames[i] = s; Vocalization.ModMonitor.Log(this.dialogueFileNames.ElementAt(i)); } @@ -196,7 +199,7 @@ namespace Vocalization.Framework { Vocalization.ModMonitor.Log(this.stringsFileNames.ElementAt(i)); string s = this.stringsFileNames.ElementAt(i); - s = this.stringsFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation)); + s = this.stringsFileNames.ElementAt(i).Replace(".xnb", extension); this.stringsFileNames[i] = s; Vocalization.ModMonitor.Log(this.stringsFileNames.ElementAt(i)); } @@ -205,7 +208,7 @@ namespace Vocalization.Framework { Vocalization.ModMonitor.Log(this.festivalFileNames.ElementAt(i)); string s = this.festivalFileNames.ElementAt(i); - s = this.festivalFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation)); + s = this.festivalFileNames.ElementAt(i).Replace(".xnb", extension); this.festivalFileNames[i] = s; Vocalization.ModMonitor.Log(this.festivalFileNames.ElementAt(i)); } @@ -214,7 +217,7 @@ namespace Vocalization.Framework { Vocalization.ModMonitor.Log(this.eventFileNames.ElementAt(i)); string s = this.eventFileNames.ElementAt(i); - s = this.eventFileNames.ElementAt(i).Replace(".xnb", Vocalization.config.translationInfo.getFileExtentionForTranslation(translation)); + s = this.eventFileNames.ElementAt(i).Replace(".xnb", extension); this.eventFileNames[i] = s; Vocalization.ModMonitor.Log(this.eventFileNames.ElementAt(i)); } diff --git a/GeneralMods/Vocalization/Vocalization/Framework/LanguageName.cs b/GeneralMods/Vocalization/Vocalization/Framework/LanguageName.cs new file mode 100644 index 00000000..c78d42a5 --- /dev/null +++ b/GeneralMods/Vocalization/Vocalization/Framework/LanguageName.cs @@ -0,0 +1,14 @@ +namespace Vocalization.Framework +{ + /// The supported language names. + public enum LanguageName + { + English, + Spanish, + Chinese, + Japanese, + Russian, + German, + Portuguese + } +} diff --git a/GeneralMods/Vocalization/Vocalization/Framework/Menus/VocalizationMenu.cs b/GeneralMods/Vocalization/Vocalization/Framework/Menus/VocalizationMenu.cs index 7c24f117..ae25f24c 100644 --- a/GeneralMods/Vocalization/Vocalization/Framework/Menus/VocalizationMenu.cs +++ b/GeneralMods/Vocalization/Vocalization/Framework/Menus/VocalizationMenu.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -39,13 +40,13 @@ namespace Vocalization.Framework.Menus Rectangle sourceRect = new Rectangle(0, 0, 4, 16); this.sliderButton = new SliderButton("Slider", "Volume", new Rectangle(this.xPositionOnScreen + 100, this.yPositionOnScreen + 220, 4, 16), buttonTexture, bar, sourceRect, 2f, new SliderInformation(SliderStyle.Horizontal, (int)(Vocalization.config.voiceVolume * 100), 1), new StardustCore.Animations.Animation(sourceRect), Color.White, Color.Black, new StardustCore.UIUtilities.MenuComponents.Delegates.Functionality.ButtonFunctionality(null, null, null), false, null, true); - Button english = new Button("EnglishButton", "English", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 0, 174, 39), 1f); - Button spanish = new Button("SpanishButton", "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 2, 174, 39), 1f); - Button portuguese = new Button("PortugueseButton", "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 4, 174, 39), 1f); - Button russian = new Button("RussianButton", "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 6, 174, 39), 1f); - Button chinese = new Button("ChineseButton", "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 8, 174, 39), 1f); - Button japanese = new Button("JapaneseButton", "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 10, 174, 39), 1f); - Button german = new Button("GermanButton", "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 12, 174, 39), 1f); + Button english = new Button(LanguageName.English.ToString(), "English", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 0, 174, 39), 1f); + Button spanish = new Button(LanguageName.Spanish.ToString(), "Spanish", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 2, 174, 39), 1f); + Button portuguese = new Button(LanguageName.Portuguese.ToString(), "Brazillian Portuguese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 4, 174, 39), 1f); + Button russian = new Button(LanguageName.Russian.ToString(), "Russian", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 6, 174, 39), 1f); + Button chinese = new Button(LanguageName.Chinese.ToString(), "Chinese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 8, 174, 39), 1f); + Button japanese = new Button(LanguageName.Japanese.ToString(), "Japanese", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 10, 174, 39), 1f); + Button german = new Button(LanguageName.German.ToString(), "German", new Rectangle(0, 0, 174, 39), new Texture2DExtended(Vocalization.ModHelper, Path.Combine("LooseSprites", "LanguageButtons.xnb"), StardewModdingAPI.ContentSource.GameContent), new Rectangle(0, 39 * 12, 174, 39), 1f); List