diff --git a/GeneralMods/HappyBirthday/BirthdayMessages.cs b/GeneralMods/HappyBirthday/BirthdayMessages.cs index 689cdce2..312a4d19 100644 --- a/GeneralMods/HappyBirthday/BirthdayMessages.cs +++ b/GeneralMods/HappyBirthday/BirthdayMessages.cs @@ -126,6 +126,7 @@ namespace Omegasis.HappyBirthday this.spouseEnglishGeneratedMessages.Add("Leah", this.generateSpouseMessage); this.spouseEnglishGeneratedMessages.Add("Maru", this.generateSpouseMessage); this.spouseEnglishGeneratedMessages.Add("Penny", this.generateSpouseMessage); + HappyBirthday.Config.translationInfo.setTranslationFromLanguageCode(Game1.content.GetCurrentLanguage()); this.createBirthdayGreetings(); this.loadTranslationStrings(); } @@ -266,7 +267,7 @@ namespace Omegasis.HappyBirthday //Handle normal birthday wishes. if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, path))) { - HappyBirthday.ModMonitor.Log("Creating Villager Birthday Messages", StardewModdingAPI.LogLevel.Alert); + //HappyBirthday.ModMonitor.Log("Creating Villager Birthday Messages", StardewModdingAPI.LogLevel.Alert); HappyBirthday.ModHelper.Data.WriteJsonFile>(path, this.defaultBirthdayWishes); this.birthdayWishes = this.defaultBirthdayWishes; } diff --git a/GeneralMods/HappyBirthday/Framework/TranslationInfo.cs b/GeneralMods/HappyBirthday/Framework/TranslationInfo.cs index 3525e7f6..792c51a0 100644 --- a/GeneralMods/HappyBirthday/Framework/TranslationInfo.cs +++ b/GeneralMods/HappyBirthday/Framework/TranslationInfo.cs @@ -90,6 +90,19 @@ namespace Omegasis.HappyBirthday.Framework return this.TranslationCodes[this.CurrentTranslation]; } + public void setTranslationFromLanguageCode(LocalizedContentManager.LanguageCode code) + { + foreach (var v in this.TranslationCodes) + { + if (v.Value.Equals(code)) + { + this.CurrentTranslation = v.Key; + HappyBirthday.ModHelper.WriteConfig(HappyBirthday.Config); + return; + } + } + } + /// Gets the proper file extension for the current translation. /// The translation language name. public string getFileExtentionForTranslation(LanguageName language, FileType File) @@ -100,7 +113,7 @@ namespace Omegasis.HappyBirthday.Framework { return this.getFileExtensionForFileType(File); } - return this.TranslationFileExtensions[language]+this.getFileExtensionForFileType(File); + return this.TranslationFileExtensions[language] + this.getFileExtensionForFileType(File); } catch (Exception err) { @@ -112,7 +125,7 @@ namespace Omegasis.HappyBirthday.Framework } public string getFileExtensionForFileType(FileType Type) { - if(Type== FileType.JSON) + if (Type == FileType.JSON) { return ".json"; } @@ -127,7 +140,7 @@ namespace Omegasis.HappyBirthday.Framework { try { - string s=this.TranslationFileExtensions[language]; + string s = this.TranslationFileExtensions[language]; return s; } catch (Exception err) @@ -146,15 +159,15 @@ namespace Omegasis.HappyBirthday.Framework /// /// /// - public string getJSONForTranslation(string FileName,LanguageName language) + public string getJSONForTranslation(string FileName, LanguageName language) { - if(language!= LanguageName.English) + if (language != LanguageName.English) { return FileName + "." + this.getFileExtentionForTranslation(language, FileType.JSON); } else { - return FileName + this.getFileExtentionForTranslation(language, FileType.JSON); + return FileName + this.getFileExtentionForTranslation(language, FileType.JSON); } } @@ -199,7 +212,7 @@ namespace Omegasis.HappyBirthday.Framework return HappyBirthday.Instance.messages.translatedStrings[Language][Key]; } - catch(Exception err) + catch (Exception err) { return ""; } @@ -210,13 +223,13 @@ namespace Omegasis.HappyBirthday.Framework if (Key.Equals("Birthday")) { - string s= Game1.content.LoadString("Strings\\UI:Billboard_Birthday"); + string s = Game1.content.LoadString("Strings\\UI:Billboard_Birthday"); s = s.Split(' ')[0]; return s; } if (Key.Equals("Spring") || Key.Equals("spring")) { - string file= Path.Combine("Strings", "StringsFromCSFiles"); + string file = Path.Combine("Strings", "StringsFromCSFiles"); return HappyBirthday.Config.translationInfo.LoadStringFromXNBFile(file, "Utility.cs.5680", HappyBirthday.Config.translationInfo.CurrentTranslation); } if (Key.Equals("Summer") || Key.Equals("summer")) diff --git a/GeneralMods/HappyBirthday/HappyBirthday.cs b/GeneralMods/HappyBirthday/HappyBirthday.cs index 0186feee..c988934f 100644 --- a/GeneralMods/HappyBirthday/HappyBirthday.cs +++ b/GeneralMods/HappyBirthday/HappyBirthday.cs @@ -78,8 +78,6 @@ namespace Omegasis.HappyBirthday { Instance = this; - - //helper.Content.AssetLoaders.Add(new PossibleGifts()); Config = helper.ReadConfig(); helper.Events.GameLoop.DayStarted += this.OnDayStarted; @@ -88,25 +86,23 @@ namespace Omegasis.HappyBirthday helper.Events.GameLoop.Saving += this.OnSaving; helper.Events.Input.ButtonPressed += this.OnButtonPressed; helper.Events.Display.MenuChanged += this.OnMenuChanged; - - - helper.Events.Display.RenderedActiveMenu += this.OnRenderedActiveMenu; helper.Events.Display.RenderedHud += this.OnRenderedHud; - //MultiplayerSupport.initializeMultiplayerSupport(); + helper.Events.Multiplayer.ModMessageReceived += this.Multiplayer_ModMessageReceived; + helper.Events.Multiplayer.PeerDisconnected += this.Multiplayer_PeerDisconnected; + helper.Events.GameLoop.GameLaunched += this.GameLoop_GameLaunched; ModHelper = this.Helper; ModMonitor = this.Monitor; + this.othersBirthdays = new Dictionary(); + + } + + private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e) + { this.messages = new BirthdayMessages(); this.giftManager = new GiftManager(); this.isDailyQuestBoard = false; - - ModHelper.Events.Multiplayer.ModMessageReceived += this.Multiplayer_ModMessageReceived; - - ModHelper.Events.Multiplayer.PeerDisconnected += this.Multiplayer_PeerDisconnected; - - this.othersBirthdays = new Dictionary(); - } /// Get whether this instance can edit the given asset. @@ -181,8 +177,6 @@ namespace Omegasis.HappyBirthday if (this.isDailyQuestBoard || billboard.calendarDays == null) return; - //Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 230 + (index - 1) / 7 * 32 * 4), 1f, 4f, 2, Game1.player); - string hoverText = ""; List texts = new List(); @@ -746,5 +740,11 @@ namespace Omegasis.HappyBirthday } } } + + + private void hmm() + { + Game1.player.currentLocation.currentEvent = new Event(); + } } }