Updates to happy birthday to fix some bugs. Also started making spouse messages.
This commit is contained in:
parent
28adb69bbc
commit
3d50d2e38a
|
@ -1,6 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using static StardewValley.LocalizedContentManager;
|
||||
|
||||
namespace Omegasis.HappyBirthday
|
||||
{
|
||||
|
@ -27,6 +32,8 @@ namespace Omegasis.HappyBirthday
|
|||
["Penny"] = "",
|
||||
};
|
||||
|
||||
public Dictionary<string, Func<string,string>> spouseEnglishGeneratedMessages = new Dictionary<string, Func<string,string>>();
|
||||
|
||||
/// <summary>Used to contain birthday wishes should the mod not find any available.</summary>
|
||||
public Dictionary<string, string> defaultBirthdayWishes = new Dictionary<string, string>()
|
||||
{
|
||||
|
@ -67,6 +74,18 @@ namespace Omegasis.HappyBirthday
|
|||
|
||||
public BirthdayMessages()
|
||||
{
|
||||
this.spouseEnglishGeneratedMessages.Add("Alex", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Elliott", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Harvey", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Sam", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Sebastian", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Shane", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Abigail", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Emily", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Haley", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Leah", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Maru", this.generateSpouseMessage);
|
||||
this.spouseEnglishGeneratedMessages.Add("Penny", this.generateSpouseMessage);
|
||||
this.createBirthdayGreetings();
|
||||
this.loadTranslationStrings();
|
||||
}
|
||||
|
@ -142,11 +161,11 @@ namespace Omegasis.HappyBirthday
|
|||
serializer.Formatting = Formatting.Indented;
|
||||
|
||||
//English logic.
|
||||
string defaultPath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation);
|
||||
string defaultPath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "Content", "Dialogue", HappyBirthday.Config.translationInfo.getFileExtentionForDirectory(HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
if (!Directory.Exists(defaultPath)) Directory.CreateDirectory(defaultPath);
|
||||
|
||||
string birthdayFileDict = HappyBirthday.Config.translationInfo.getjsonForTranslation("BirthdayWishes", HappyBirthday.Config.translationInfo.currentTranslation);
|
||||
string path = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, birthdayFileDict);
|
||||
string birthdayFileDict = HappyBirthday.Config.translationInfo.getJSONForTranslation("BirthdayWishes", HappyBirthday.Config.translationInfo.CurrentTranslation);
|
||||
string path = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.getFileExtentionForDirectory(HappyBirthday.Config.translationInfo.CurrentTranslation), birthdayFileDict);
|
||||
|
||||
//Handle normal birthday wishes.
|
||||
if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, path)))
|
||||
|
@ -159,8 +178,8 @@ namespace Omegasis.HappyBirthday
|
|||
this.birthdayWishes = HappyBirthday.ModHelper.Data.ReadJsonFile<Dictionary<string, string>>(path);
|
||||
|
||||
//handle spouse birthday wishes.
|
||||
string spouseBirthdayFileDict = HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", HappyBirthday.Config.translationInfo.currentTranslation);
|
||||
string spousePath = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, spouseBirthdayFileDict);
|
||||
string spouseBirthdayFileDict = HappyBirthday.Config.translationInfo.getJSONForTranslation("SpouseBirthdayWishes", HappyBirthday.Config.translationInfo.CurrentTranslation);
|
||||
string spousePath = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.getFileExtentionForDirectory(HappyBirthday.Config.translationInfo.CurrentTranslation), spouseBirthdayFileDict);
|
||||
if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, spousePath)))
|
||||
{
|
||||
HappyBirthday.ModMonitor.Log("Creating Spouse Messages", StardewModdingAPI.LogLevel.Alert);
|
||||
|
@ -171,16 +190,16 @@ namespace Omegasis.HappyBirthday
|
|||
this.spouseBirthdayWishes = HappyBirthday.ModHelper.Data.ReadJsonFile<Dictionary<string, string>>(spousePath);
|
||||
|
||||
//Non-english logic for creating templates.
|
||||
foreach (var translation in HappyBirthday.Config.translationInfo.translationCodes)
|
||||
foreach (var translation in HappyBirthday.Config.translationInfo.TranslationCodes)
|
||||
{
|
||||
if (translation.Key == "English")
|
||||
if (translation.Key == Framework.TranslationInfo.LanguageName.English)
|
||||
continue;
|
||||
|
||||
string basePath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "Content", "Dialogue", translation.Key);
|
||||
string basePath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "Content", "Dialogue", HappyBirthday.Config.translationInfo.getFileExtentionForDirectory(translation.Key));
|
||||
if (!Directory.Exists(basePath))
|
||||
Directory.CreateDirectory(basePath);
|
||||
string tempBirthdayFile = Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("BirthdayWishes", translation.Key));
|
||||
string tempSpouseBirthdayFile = Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", translation.Key));
|
||||
string tempBirthdayFile = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.getFileExtentionForDirectory(translation.Key), HappyBirthday.Config.translationInfo.getJSONForTranslation("BirthdayWishes", translation.Key));
|
||||
string tempSpouseBirthdayFile = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.getFileExtentionForDirectory(translation.Key), HappyBirthday.Config.translationInfo.getJSONForTranslation("SpouseBirthdayWishes", translation.Key));
|
||||
|
||||
|
||||
Dictionary<string, string> tempBirthdayDict = new Dictionary<string, string>();
|
||||
|
@ -205,7 +224,7 @@ namespace Omegasis.HappyBirthday
|
|||
tempSpouseBirthdayDict = HappyBirthday.ModHelper.Data.ReadJsonFile<Dictionary<string, string>>(tempSpouseBirthdayFile);
|
||||
|
||||
//Set translated birthday info.
|
||||
if (HappyBirthday.Config.translationInfo.currentTranslation == translation.Key)
|
||||
if (HappyBirthday.Config.translationInfo.CurrentTranslation == translation.Key)
|
||||
{
|
||||
this.birthdayWishes = tempBirthdayDict;
|
||||
this.spouseBirthdayWishes = tempSpouseBirthdayDict;
|
||||
|
@ -216,7 +235,7 @@ namespace Omegasis.HappyBirthday
|
|||
|
||||
public static string GetTranslatedString(string key)
|
||||
{
|
||||
StardewValley.LocalizedContentManager.LanguageCode code = HappyBirthday.Config.translationInfo.translationCodes[HappyBirthday.Config.translationInfo.currentTranslation];
|
||||
StardewValley.LocalizedContentManager.LanguageCode code = HappyBirthday.Config.translationInfo.TranslationCodes[HappyBirthday.Config.translationInfo.CurrentTranslation];
|
||||
string value= HappyBirthday.Instance.messages.translatedStrings[code][key];
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
@ -235,15 +254,15 @@ namespace Omegasis.HappyBirthday
|
|||
{
|
||||
|
||||
//Non-english logic for creating templates.
|
||||
foreach (var translation in HappyBirthday.Config.translationInfo.translationCodes)
|
||||
foreach (var translation in HappyBirthday.Config.translationInfo.TranslationCodes)
|
||||
{
|
||||
|
||||
StardewValley.LocalizedContentManager.LanguageCode code = translation.Value;
|
||||
|
||||
string basePath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "Content", "Dialogue", translation.Key);
|
||||
string basePath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "Content", "Dialogue", HappyBirthday.Config.translationInfo.getFileExtentionForDirectory(translation.Key));
|
||||
if (!Directory.Exists(basePath))
|
||||
Directory.CreateDirectory(basePath);
|
||||
string stringsFile = Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("TranslatedStrings", translation.Key));
|
||||
string stringsFile = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.getFileExtentionForDirectory(translation.Key), HappyBirthday.Config.translationInfo.getJSONForTranslation("TranslatedStrings", translation.Key));
|
||||
|
||||
|
||||
if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, stringsFile)))
|
||||
|
@ -256,5 +275,137 @@ namespace Omegasis.HappyBirthday
|
|||
}
|
||||
}
|
||||
|
||||
public string getAffectionateSpouseWord()
|
||||
{
|
||||
|
||||
List<string> words = new List<string>();
|
||||
if (Game1.player.IsMale)
|
||||
{
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4507", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4509", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4511", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4514", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4515", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4512", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4513", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
|
||||
}
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4508", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4510", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4516", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4517", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4518", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4519", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4522", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
words.Add(HappyBirthday.Config.translationInfo.LoadStringFromXNBFile("StringsFromCSFiles", "NPC.cs.4523", HappyBirthday.Config.translationInfo.CurrentTranslation));
|
||||
return words[Game1.random.Next(0, words.Count - 1)];
|
||||
}
|
||||
|
||||
public string getTimeOfDayString()
|
||||
{
|
||||
if (Game1.timeOfDay >= 600 && Game1.timeOfDay < 1200)
|
||||
{
|
||||
return "morning";
|
||||
}
|
||||
else if (Game1.timeOfDay >= 1200 && Game1.timeOfDay < 600)
|
||||
{
|
||||
return "afternoon";
|
||||
}
|
||||
else return "evening";
|
||||
}
|
||||
|
||||
|
||||
public void generateSpouseBirthdayDialogue(string SpeakerName)
|
||||
{
|
||||
this.spouseEnglishGeneratedMessages[SpeakerName].Invoke(SpeakerName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="SpeakerName"></param>
|
||||
/// <returns></returns>
|
||||
private string generateSpouseMessage(string SpeakerName)
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
switch (SpeakerName)
|
||||
{
|
||||
case ("Alex"):
|
||||
b.Append("Hey ");
|
||||
b.Append(this.getAffectionateSpouseWord());
|
||||
b.Append(".");
|
||||
b.Append("I'm so glad that I married you. You make every day feel like winning a sports match. Happy birthday! $h");
|
||||
|
||||
break;
|
||||
case ("Elliott"):
|
||||
b.Append("Good ");
|
||||
b.Append(this.getTimeOfDayString());
|
||||
b.Append(this.getAffectionateSpouseWord());
|
||||
b.Append(".");
|
||||
b.Append("I was just thinking on how you have been a muse for my work. You inspire me every day I spend with you. Happy birthday! $h");
|
||||
|
||||
break;
|
||||
case ("Harvey"):
|
||||
b.Append("Good ");
|
||||
b.Append(this.getTimeOfDayString());
|
||||
b.Append(this.getAffectionateSpouseWord());
|
||||
b.Append(".");
|
||||
b.Append("I was just thinking on how invigorated I've felt since marrying you. When I look at you I feel as I'm positively glowing with joy. Happy birthday! $h");
|
||||
|
||||
break;
|
||||
case ("Sam"):
|
||||
b.Append("Good ");
|
||||
b.Append(this.getTimeOfDayString());
|
||||
b.Append(this.getAffectionateSpouseWord());
|
||||
b.Append(".");
|
||||
b.Append("You know I never saw myself settling down before I met you, but now that I have I feel like I never want to look back. Happy birthday! $h");
|
||||
|
||||
break;
|
||||
case ("Sebastian"):
|
||||
b.Append("I was never a big celebrater of birthdays but with you, today is special. Happy birthday");
|
||||
b.Append(this.getAffectionateSpouseWord());
|
||||
b.Append("$h");
|
||||
b.Append(".");
|
||||
|
||||
break;
|
||||
case ("Shane"):
|
||||
|
||||
|
||||
break;
|
||||
case ("Abigail"):
|
||||
|
||||
|
||||
break;
|
||||
case ("Emily"):
|
||||
|
||||
|
||||
break;
|
||||
case ("Haley"):
|
||||
|
||||
|
||||
break;
|
||||
case ("Leah"):
|
||||
|
||||
|
||||
break;
|
||||
case ("Maru"):
|
||||
|
||||
|
||||
break;
|
||||
case ("Penny"):
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
return b.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using StardewValley;
|
||||
|
||||
namespace Omegasis.HappyBirthday.Framework
|
||||
|
@ -7,65 +8,85 @@ namespace Omegasis.HappyBirthday.Framework
|
|||
/// <summary>A class which deals with handling different translations for Vocalization should other voice teams ever wish to voice act for that language.</summary>
|
||||
public class TranslationInfo
|
||||
{
|
||||
/// <summary>The list of all supported translations by this mod.</summary>
|
||||
public List<string> translations;
|
||||
|
||||
public enum LanguageName
|
||||
{
|
||||
English,
|
||||
Spanish,
|
||||
Chinese,
|
||||
Japanese,
|
||||
Russian,
|
||||
German,
|
||||
Portuguese,
|
||||
Italian,
|
||||
French,
|
||||
Korean,
|
||||
Turkish,
|
||||
Hungarian
|
||||
}
|
||||
/*********
|
||||
** Accessors
|
||||
*********/
|
||||
/// <summary>The language names supported by this mod.</summary>
|
||||
public LanguageName[] LanguageNames { get; } = (from LanguageName language in Enum.GetValues(typeof(LanguageName)) select language).ToArray();
|
||||
|
||||
/// <summary>The current translation mode for the mod, so that it knows what files to load at the beginning of the game.</summary>
|
||||
public string currentTranslation;
|
||||
public LanguageName CurrentTranslation { get; set; } = LanguageName.English;
|
||||
|
||||
/// <summary>Holds the info for what translation has what file extension.</summary>
|
||||
public Dictionary<string, string> translationFileInfo;
|
||||
public Dictionary<LanguageName, string> TranslationFileExtensions { get; } = new Dictionary<LanguageName, string>();
|
||||
|
||||
public Dictionary<string, LocalizedContentManager.LanguageCode> translationCodes;
|
||||
public Dictionary<LanguageName, LocalizedContentManager.LanguageCode> TranslationCodes { get; } = new Dictionary<LanguageName, LocalizedContentManager.LanguageCode>();
|
||||
|
||||
/// <summary>Construct an instance..</summary>
|
||||
|
||||
/*********
|
||||
** Public methods
|
||||
*********/
|
||||
/// <summary>Construct an instance.</summary>
|
||||
public TranslationInfo()
|
||||
{
|
||||
this.translations = new List<string>();
|
||||
|
||||
this.translationFileInfo = new Dictionary<string, string>();
|
||||
this.translationCodes = new Dictionary<string, LocalizedContentManager.LanguageCode>();
|
||||
this.translations.Add("English");
|
||||
this.translations.Add("Spanish");
|
||||
this.translations.Add("Chinese");
|
||||
this.translations.Add("Japanese");
|
||||
this.translations.Add("Russian");
|
||||
this.translations.Add("German");
|
||||
this.translations.Add("Brazillian Portuguese");
|
||||
|
||||
this.currentTranslation = "English";
|
||||
|
||||
this.translationFileInfo.Add("English", ".json");
|
||||
this.translationFileInfo.Add("Spanish", ".es-ES.json");
|
||||
this.translationFileInfo.Add("Chinese", ".zh-CN.json");
|
||||
this.translationFileInfo.Add("Japanese", ".ja-JP.json");
|
||||
this.translationFileInfo.Add("Russian", ".ru-RU.json");
|
||||
this.translationFileInfo.Add("German", ".de-DE.json");
|
||||
this.translationFileInfo.Add("Brazillian Portuguese", ".pt-BR.json");
|
||||
this.TranslationFileExtensions.Add(LanguageName.English, ".xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.Spanish, ".es-ES.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.Chinese, ".zh-CN.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.Japanese, ".ja-JP.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.Russian, ".ru-RU.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.German, ".de-DE.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.Portuguese, ".pt-BR.xnb");
|
||||
//1.3 languages.
|
||||
this.TranslationFileExtensions.Add(LanguageName.Italian, ".it-IT.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.French, ".fr-FR.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.Hungarian, ".hu-HU.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.Turkish, ".tr-TR.xnb");
|
||||
this.TranslationFileExtensions.Add(LanguageName.Korean, ".ko-KR.xnb");
|
||||
|
||||
|
||||
this.translationCodes.Add("English", LocalizedContentManager.LanguageCode.en);
|
||||
this.translationCodes.Add("Spanish", LocalizedContentManager.LanguageCode.es);
|
||||
this.translationCodes.Add("Chinese", LocalizedContentManager.LanguageCode.zh);
|
||||
this.translationCodes.Add("Japanese", LocalizedContentManager.LanguageCode.ja);
|
||||
this.translationCodes.Add("Russian", LocalizedContentManager.LanguageCode.ru);
|
||||
this.translationCodes.Add("German", LocalizedContentManager.LanguageCode.de);
|
||||
this.translationCodes.Add("Brazillian Portuguese", LocalizedContentManager.LanguageCode.pt);
|
||||
|
||||
this.TranslationCodes.Add(LanguageName.English, LocalizedContentManager.LanguageCode.en);
|
||||
this.TranslationCodes.Add(LanguageName.Spanish, LocalizedContentManager.LanguageCode.es);
|
||||
this.TranslationCodes.Add(LanguageName.Chinese, LocalizedContentManager.LanguageCode.zh);
|
||||
this.TranslationCodes.Add(LanguageName.Japanese, LocalizedContentManager.LanguageCode.ja);
|
||||
this.TranslationCodes.Add(LanguageName.Russian, LocalizedContentManager.LanguageCode.ru);
|
||||
this.TranslationCodes.Add(LanguageName.German, LocalizedContentManager.LanguageCode.de);
|
||||
this.TranslationCodes.Add(LanguageName.Portuguese, LocalizedContentManager.LanguageCode.pt);
|
||||
//1.3 languages
|
||||
this.TranslationCodes.Add(LanguageName.Italian, LocalizedContentManager.LanguageCode.it);
|
||||
this.TranslationCodes.Add(LanguageName.French, LocalizedContentManager.LanguageCode.fr);
|
||||
this.TranslationCodes.Add(LanguageName.Hungarian, LocalizedContentManager.LanguageCode.hu);
|
||||
this.TranslationCodes.Add(LanguageName.Turkish, LocalizedContentManager.LanguageCode.tr);
|
||||
this.TranslationCodes.Add(LanguageName.Korean, LocalizedContentManager.LanguageCode.ko);
|
||||
}
|
||||
|
||||
public string getTranslationNameFromPath(string fullPath)
|
||||
/// <summary>Get the language name from a string.</summary>
|
||||
/// <param name="language">The language name.</param>
|
||||
public string getTranslationName(LanguageName language)
|
||||
{
|
||||
return Path.GetFileName(fullPath);
|
||||
return language.ToString();
|
||||
}
|
||||
|
||||
public void changeLocalizedContentManagerFromTranslation(string translation)
|
||||
public void changeLocalizedContentManagerFromTranslation(LanguageName language)
|
||||
{
|
||||
string tra = this.getTranslationNameFromPath(translation);
|
||||
bool f = this.translationCodes.TryGetValue(tra, out LocalizedContentManager.LanguageCode code);
|
||||
if (!f) LocalizedContentManager.CurrentLanguageCode = LocalizedContentManager.LanguageCode.en;
|
||||
else LocalizedContentManager.CurrentLanguageCode = code;
|
||||
return;
|
||||
LocalizedContentManager.CurrentLanguageCode = !this.TranslationCodes.TryGetValue(language, out LocalizedContentManager.LanguageCode code)
|
||||
? LocalizedContentManager.LanguageCode.en
|
||||
: code;
|
||||
}
|
||||
|
||||
public void resetLocalizationCode()
|
||||
|
@ -74,77 +95,75 @@ namespace Omegasis.HappyBirthday.Framework
|
|||
}
|
||||
|
||||
/// <summary>Gets the proper file extension for the current translation.</summary>
|
||||
/// <param name="path"></param>
|
||||
public string getFileExtentionForTranslation(string path)
|
||||
/// <param name="language">The translation language name.</param>
|
||||
public string getFileExtentionForTranslation(LanguageName language)
|
||||
{
|
||||
/*
|
||||
bool f = translationFileInfo.TryGetValue(translation, out string value);
|
||||
if (!f) return ".json";
|
||||
else return value;
|
||||
*/
|
||||
string translation = Path.GetFileName(path);
|
||||
try
|
||||
{
|
||||
return this.translationFileInfo[translation];
|
||||
return this.TranslationFileExtensions[language];
|
||||
}
|
||||
catch
|
||||
catch (Exception err)
|
||||
{
|
||||
HappyBirthday.ModMonitor.Log("WTF SOMETHING IS WRONG!", StardewModdingAPI.LogLevel.Warn);
|
||||
//Vocalization.ModMonitor.Log(err.ToString());
|
||||
//Vocalization.ModMonitor.Log("Attempted to get translation: " + translation);
|
||||
return ".json";
|
||||
|
||||
Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log(err.ToString());
|
||||
Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log($"Attempted to get translation: {language}");
|
||||
return ".xnb";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the proper json for Buildings (aka Blueprints) from the data folder.</summary>
|
||||
public string getBuildingjsonForTranslation(string translation)
|
||||
public string getFileExtentionForDirectory(LanguageName language)
|
||||
{
|
||||
try
|
||||
{
|
||||
string s=this.TranslationFileExtensions[language];
|
||||
s = s.Replace(".xnb", "");
|
||||
s = s.Replace(".","");
|
||||
return s;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
|
||||
Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log(err.ToString());
|
||||
Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log($"Attempted to get translation: {language}");
|
||||
return ".xnb";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets the proper XNB for Buildings (aka Blueprints) from the data folder.</summary>
|
||||
public string getBuildingXNBForTranslation(LanguageName language)
|
||||
{
|
||||
string buildings = "Blueprints";
|
||||
return buildings + this.getFileExtentionForTranslation(translation);
|
||||
return buildings + this.getFileExtentionForTranslation(language);
|
||||
}
|
||||
|
||||
/// <summary>Gets the proper json file for the name passed in. Combines the file name with it's proper translation extension.</summary>
|
||||
/// <param name="jsonFileName"></param>
|
||||
/// <param name="translation"></param>
|
||||
public string getjsonForTranslation(string jsonFileName, string translation)
|
||||
/// <summary>Gets the proper XNB file for the name passed in. Combines the file name with it's proper translation extension.</summary>
|
||||
public string getXNBForTranslation(string xnbFileName, LanguageName language)
|
||||
{
|
||||
return jsonFileName + this.getFileExtentionForTranslation(translation);
|
||||
return xnbFileName + this.getFileExtentionForTranslation(language);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>Loads an json file from StardewValley/Content</summary>
|
||||
/// <param name="jsonFileName"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="translation"></param>
|
||||
public string LoadjsonFile(string jsonFileName, string key, string translation)
|
||||
public string getJSONForTranslation(string FileName,LanguageName language)
|
||||
{
|
||||
string json = jsonFileName + this.getFileExtentionForTranslation(translation);
|
||||
Dictionary<string, string> loadedDict = Game1.content.Load<Dictionary<string, string>>(json);
|
||||
return this.getXNBForTranslation(FileName, language);
|
||||
}
|
||||
|
||||
bool f = loadedDict.TryGetValue(key, out string loaded);
|
||||
if (!f)
|
||||
/// <summary>Loads an XNB file from StardewValley/Content</summary>
|
||||
public string LoadStringFromXNBFile(string xnbFileName, string key, LanguageName language)
|
||||
{
|
||||
//Vocalization.ModMonitor.Log("Big issue: Key not found in file:" + json + " " + key);
|
||||
string xnb = xnbFileName + this.getFileExtentionForTranslation(language);
|
||||
Dictionary<string, string> loadedDict = Game1.content.Load<Dictionary<string, string>>(xnb);
|
||||
|
||||
if (!loadedDict.TryGetValue(key, out string loaded))
|
||||
{
|
||||
Omegasis.HappyBirthday.HappyBirthday.ModMonitor.Log("Big issue: Key not found in file:" + xnb + " " + key);
|
||||
return "";
|
||||
}
|
||||
else return loaded;
|
||||
return loaded;
|
||||
}
|
||||
|
||||
/// <summary>Loads a string dictionary from a json file.</summary>
|
||||
/// <param name="jsonFileName"></param>
|
||||
/// <param name="translation"></param>
|
||||
public Dictionary<string, string> LoadJsonFileDictionary(string jsonFileName, string translation)
|
||||
public virtual string LoadString(string path, LanguageName language, object sub1, object sub2, object sub3)
|
||||
{
|
||||
string json = jsonFileName + this.getFileExtentionForTranslation(translation);
|
||||
Dictionary<string, string> loadedDict = Game1.content.Load<Dictionary<string, string>>(json);
|
||||
|
||||
return loadedDict;
|
||||
}
|
||||
|
||||
public virtual string LoadString(string path, string translation, object sub1, object sub2, object sub3)
|
||||
{
|
||||
string format = this.LoadString(path, translation);
|
||||
string format = this.LoadString(path, language);
|
||||
try
|
||||
{
|
||||
return string.Format(format, sub1, sub2, sub3);
|
||||
|
@ -154,9 +173,9 @@ namespace Omegasis.HappyBirthday.Framework
|
|||
return format;
|
||||
}
|
||||
|
||||
public virtual string LoadString(string path, string translation, object sub1, object sub2)
|
||||
public virtual string LoadString(string path, LanguageName language, object sub1, object sub2)
|
||||
{
|
||||
string format = this.LoadString(path, translation);
|
||||
string format = this.LoadString(path, language);
|
||||
try
|
||||
{
|
||||
return string.Format(format, sub1, sub2);
|
||||
|
@ -166,9 +185,9 @@ namespace Omegasis.HappyBirthday.Framework
|
|||
return format;
|
||||
}
|
||||
|
||||
public virtual string LoadString(string path, string translation, object sub1)
|
||||
public virtual string LoadString(string path, LanguageName language, object sub1)
|
||||
{
|
||||
string format = this.LoadString(path, translation);
|
||||
string format = this.LoadString(path, language);
|
||||
try
|
||||
{
|
||||
return string.Format(format, sub1);
|
||||
|
@ -178,15 +197,16 @@ namespace Omegasis.HappyBirthday.Framework
|
|||
return format;
|
||||
}
|
||||
|
||||
public virtual string LoadString(string path, string translation)
|
||||
public virtual string LoadString(string path, LanguageName language)
|
||||
{
|
||||
this.parseStringPath(path, out string assetName, out string key);
|
||||
return this.LoadjsonFile(assetName, key, translation);
|
||||
|
||||
return this.LoadStringFromXNBFile(assetName, key, language);
|
||||
}
|
||||
|
||||
public virtual string LoadString(string path, string translation, params object[] substitutions)
|
||||
public virtual string LoadString(string path, LanguageName language, params object[] substitutions)
|
||||
{
|
||||
string format = this.LoadString(path, translation);
|
||||
string format = this.LoadString(path, language);
|
||||
if (substitutions.Length != 0)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -301,8 +301,11 @@ namespace Omegasis.HappyBirthday
|
|||
if (this.PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower())
|
||||
{
|
||||
int index = this.PlayerData.BirthdayDay;
|
||||
|
||||
string bdayDisplay = Game1.content.LoadString("Strings\\UI:Billboard_Birthday");
|
||||
Rectangle birthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124);
|
||||
billboard.calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", $"{Game1.player.Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
|
||||
billboard.calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", string.Format(bdayDisplay, Game1.player.Name), text, new Rectangle(0, 0, 124, 124), 1f, false));
|
||||
//billboard.calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", $"{Game1.player.Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,8 +313,10 @@ namespace Omegasis.HappyBirthday
|
|||
{
|
||||
if (pair.Value.BirthdaySeason != Game1.currentSeason.ToLower()) continue;
|
||||
int index = pair.Value.BirthdayDay;
|
||||
|
||||
string bdayDisplay = Game1.content.LoadString("Strings\\UI:Billboard_Birthday");
|
||||
Rectangle otherBirthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124);
|
||||
billboard.calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", $"{Game1.getFarmer(pair.Key).Name}'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false));
|
||||
billboard.calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", string.Format(bdayDisplay, Game1.getFarmer(pair.Key).Name), text, new Rectangle(0, 0, 124, 124), 1f, false));
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -406,10 +411,24 @@ namespace Omegasis.HappyBirthday
|
|||
{
|
||||
if (this.messages.spouseBirthdayWishes.ContainsKey(Game1.currentSpeaker.Name))
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(this.messages.spouseBirthdayWishes[Game1.currentSpeaker.Name])== false){
|
||||
d = new Dialogue(this.messages.spouseBirthdayWishes[Game1.currentSpeaker.Name], Game1.currentSpeaker);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.messages.birthdayWishes.ContainsKey(Game1.currentSpeaker.Name))
|
||||
{
|
||||
|
||||
d = new Dialogue(this.messages.birthdayWishes[Game1.currentSpeaker.Name], Game1.currentSpeaker);
|
||||
}
|
||||
else
|
||||
{
|
||||
d = new Dialogue("Happy Birthday @!", Game1.currentSpeaker);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
d = new Dialogue("Happy Birthday @!", Game1.currentSpeaker);
|
||||
}
|
||||
|
@ -418,7 +437,6 @@ namespace Omegasis.HappyBirthday
|
|||
{
|
||||
if (this.messages.birthdayWishes.ContainsKey(Game1.currentSpeaker.Name))
|
||||
{
|
||||
|
||||
d = new Dialogue(this.messages.birthdayWishes[Game1.currentSpeaker.Name], Game1.currentSpeaker);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue