Updated happy birthday mod to have all translation issues fixed. Ready for release but I need to add in the secret sauce.

This commit is contained in:
JoshuaNavarro 2019-12-02 20:54:30 -08:00
parent 612bb94cbd
commit f4060c8c88
3 changed files with 39 additions and 25 deletions

View File

@ -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<Dictionary<string, string>>(path, this.defaultBirthdayWishes);
this.birthdayWishes = this.defaultBirthdayWishes;
}

View File

@ -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<ModConfig>(HappyBirthday.Config);
return;
}
}
}
/// <summary>Gets the proper file extension for the current translation.</summary>
/// <param name="language">The translation language name.</param>
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
/// <param name="FileName"></param>
/// <param name="language"></param>
/// <returns></returns>
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"))

View File

@ -78,8 +78,6 @@ namespace Omegasis.HappyBirthday
{
Instance = this;
//helper.Content.AssetLoaders.Add(new PossibleGifts());
Config = helper.ReadConfig<ModConfig>();
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<long, PlayerData>();
}
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<long, PlayerData>();
}
/// <summary>Get whether this instance can edit the given asset.</summary>
@ -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<string> texts = new List<string>();
@ -746,5 +740,11 @@ namespace Omegasis.HappyBirthday
}
}
}
private void hmm()
{
Game1.player.currentLocation.currentEvent = new Event();
}
}
}