Added in spouse specific gifts, spouse birthday messages, and translated birthday messages.
This commit is contained in:
parent
b69882cf20
commit
0b914e17b5
|
@ -93,7 +93,7 @@ namespace Omegasis.HappyBirthday
|
||||||
string path = Path.Combine( "Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, birthdayFileDict);
|
string path = Path.Combine( "Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, birthdayFileDict);
|
||||||
|
|
||||||
//Handle normal birthday wishes.
|
//Handle normal birthday wishes.
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath,path)))
|
||||||
{
|
{
|
||||||
|
|
||||||
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(path, defaultBirthdayWishes);
|
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(path, defaultBirthdayWishes);
|
||||||
|
@ -107,9 +107,9 @@ namespace Omegasis.HappyBirthday
|
||||||
//handle spouse birthday wishes.
|
//handle spouse birthday wishes.
|
||||||
string spouseBirthdayFileDict = HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", HappyBirthday.Config.translationInfo.currentTranslation);
|
string spouseBirthdayFileDict = HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", HappyBirthday.Config.translationInfo.currentTranslation);
|
||||||
string spousePath = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, spouseBirthdayFileDict);
|
string spousePath = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, spouseBirthdayFileDict);
|
||||||
if (!File.Exists(spousePath))
|
if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath,spousePath)))
|
||||||
{
|
{
|
||||||
|
HappyBirthday.ModMonitor.Log("Creating Spouse Messages", StardewModdingAPI.LogLevel.Alert);
|
||||||
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(spousePath, defaultSpouseBirthdayWishes);
|
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(spousePath, defaultSpouseBirthdayWishes);
|
||||||
this.spouseBirthdayWishes = defaultSpouseBirthdayWishes;
|
this.spouseBirthdayWishes = defaultSpouseBirthdayWishes;
|
||||||
}
|
}
|
||||||
|
@ -122,32 +122,49 @@ namespace Omegasis.HappyBirthday
|
||||||
foreach(var translation in HappyBirthday.Config.translationInfo.translationCodes)
|
foreach(var translation in HappyBirthday.Config.translationInfo.translationCodes)
|
||||||
{
|
{
|
||||||
if (translation.Key == "English") continue;
|
if (translation.Key == "English") continue;
|
||||||
string basePath = Path.Combine("Content", "Dialogue", translation.Key);
|
string basePath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath,"Content", "Dialogue", translation.Key);
|
||||||
if (!Directory.Exists(basePath)) Directory.CreateDirectory(basePath);
|
if (!Directory.Exists(basePath)) Directory.CreateDirectory(basePath);
|
||||||
string tempBirthdayFile =Path.Combine(basePath,HappyBirthday.Config.translationInfo.getjsonForTranslation("BirthdayWishes", translation.Key));
|
string tempBirthdayFile =Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("BirthdayWishes", translation.Key));
|
||||||
string tempSpouseBirthdayFile =Path.Combine(basePath,HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", translation.Key));
|
string tempSpouseBirthdayFile =Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", translation.Key));
|
||||||
|
|
||||||
|
|
||||||
Dictionary<string, string> tempBirthdayDict = new Dictionary<string, string>();
|
Dictionary<string, string> tempBirthdayDict = new Dictionary<string, string>();
|
||||||
|
if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, tempBirthdayFile)))
|
||||||
|
{
|
||||||
|
|
||||||
foreach (var pair in defaultBirthdayWishes)
|
foreach (var pair in defaultBirthdayWishes)
|
||||||
{
|
{
|
||||||
tempBirthdayDict.Add(pair.Key, "");
|
tempBirthdayDict.Add(pair.Key, "");
|
||||||
}
|
}
|
||||||
if(!File.Exists(tempBirthdayFile)) HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(tempBirthdayFile, tempBirthdayDict);
|
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(tempBirthdayFile, tempBirthdayDict);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempBirthdayDict = HappyBirthday.ModHelper.Data.ReadJsonFile<Dictionary<string, string>>(tempBirthdayFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Dictionary<string, string> tempSpouseBirthdayDict = new Dictionary<string, string>();
|
Dictionary<string, string> tempSpouseBirthdayDict = new Dictionary<string, string>();
|
||||||
|
if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, tempSpouseBirthdayFile)))
|
||||||
|
{
|
||||||
|
|
||||||
foreach (var pair in defaultSpouseBirthdayWishes)
|
foreach (var pair in defaultSpouseBirthdayWishes)
|
||||||
{
|
{
|
||||||
tempSpouseBirthdayDict.Add(pair.Key, "");
|
tempSpouseBirthdayDict.Add(pair.Key, "");
|
||||||
}
|
}
|
||||||
|
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(tempSpouseBirthdayFile, tempSpouseBirthdayDict);
|
||||||
if (!File.Exists(tempSpouseBirthdayFile)) HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(tempSpouseBirthdayFile, tempSpouseBirthdayDict);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempBirthdayDict = HappyBirthday.ModHelper.Data.ReadJsonFile<Dictionary<string, string>>(tempSpouseBirthdayFile);
|
||||||
|
}
|
||||||
|
|
||||||
//Set translated birthday info.
|
//Set translated birthday info.
|
||||||
if (HappyBirthday.Config.translationInfo.currentTranslation == translation.Key)
|
if (HappyBirthday.Config.translationInfo.currentTranslation == translation.Key)
|
||||||
{
|
{
|
||||||
this.birthdayWishes = tempBirthdayDict;
|
this.birthdayWishes = tempBirthdayDict;
|
||||||
this.spouseBirthdayWishes = tempSpouseBirthdayDict;
|
this.spouseBirthdayWishes = tempSpouseBirthdayDict;
|
||||||
|
HappyBirthday.ModMonitor.Log("Language set to: " + translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace Omegasis.HappyBirthday.Framework
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
|
HappyBirthday.ModMonitor.Log("WTF SOMETHING IS WRONG!", StardewModdingAPI.LogLevel.Warn);
|
||||||
//Vocalization.ModMonitor.Log(err.ToString());
|
//Vocalization.ModMonitor.Log(err.ToString());
|
||||||
//Vocalization.ModMonitor.Log("Attempted to get translation: " + translation);
|
//Vocalization.ModMonitor.Log("Attempted to get translation: " + translation);
|
||||||
return ".json";
|
return ".json";
|
||||||
|
|
|
@ -61,9 +61,7 @@ namespace Omegasis.HappyBirthday
|
||||||
|
|
||||||
public Dictionary<string, string> defaultSpouseBirthdayGifts = new Dictionary<string, string>() {
|
public Dictionary<string, string> defaultSpouseBirthdayGifts = new Dictionary<string, string>() {
|
||||||
|
|
||||||
["Universal_Love_Gift"] = "74 1 446 1 204 1 446 5 773 1",
|
["Universal_Gifts"] = "74 1 446 1 204 1 446 5 773 1",
|
||||||
["Universal_Like_Gift"] = "-2 3 -7 1 -26 2 -75 5 -80 3 72 1 220 1 221 1 395 1 613 1 634 1 635 1 636 1 637 1 638 1 724 1 233 1 223 1 465 20 -79 5",
|
|
||||||
["Universal_Neutral_Gift"] = "194 1 262 5 -74 5 -75 3 334 5 335 1 390 20 388 20 -81 5 -79 3",
|
|
||||||
["Alex"] = "",
|
["Alex"] = "",
|
||||||
["Elliott"] = "",
|
["Elliott"] = "",
|
||||||
["Harvey"] = "",
|
["Harvey"] = "",
|
||||||
|
@ -90,28 +88,28 @@ namespace Omegasis.HappyBirthday
|
||||||
{
|
{
|
||||||
this.BirthdayGifts = new List<Item>();
|
this.BirthdayGifts = new List<Item>();
|
||||||
this.loadVillagerBirthdayGifts();
|
this.loadVillagerBirthdayGifts();
|
||||||
|
this.loadSpouseBirthdayGifts();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load birthday gift information from disk. Preferably from BirthdayGift.json in the mod's directory.
|
/// Load birthday gift information from disk. Preferably from BirthdayGift.json in the mod's directory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Dictionary<string,string> loadVillagerBirthdayGifts()
|
public void loadVillagerBirthdayGifts()
|
||||||
{
|
{
|
||||||
if (HappyBirthday.Config.useLegacyBirthdayFiles == false)
|
if (HappyBirthday.Config.useLegacyBirthdayFiles == false)
|
||||||
{
|
{
|
||||||
if (File.Exists("BirthdayGifts.json"))
|
string villagerGifts = Path.Combine("Content", "Gifts", "BirthdayGifts.json");
|
||||||
|
|
||||||
|
if (File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, villagerGifts)))
|
||||||
{
|
{
|
||||||
HappyBirthday.ModMonitor.Log("Load from BirthdayGifts.json");
|
this.defaultBirthdayGifts = HappyBirthday.ModHelper.Data.ReadJsonFile<Dictionary<string, string>>(villagerGifts);
|
||||||
this.defaultBirthdayGifts = HappyBirthday.ModHelper.Data.ReadJsonFile<Dictionary<string, string>>(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "BirthdayGifts.json"));
|
|
||||||
return this.defaultBirthdayGifts;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HappyBirthday.ModMonitor.Log("BirthdayGifts.json created from default birthday gift information and can be overridden.");
|
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(villagerGifts, this.defaultBirthdayGifts);
|
||||||
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "BirthdayGifts.json"), this.defaultBirthdayGifts);
|
|
||||||
return defaultBirthdayGifts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -119,12 +117,10 @@ namespace Omegasis.HappyBirthday
|
||||||
if (File.Exists(Path.Combine(Game1.content.RootDirectory, "Data", "PossibleBirthdayGifts.xnb"))){
|
if (File.Exists(Path.Combine(Game1.content.RootDirectory, "Data", "PossibleBirthdayGifts.xnb"))){
|
||||||
HappyBirthday.ModMonitor.Log("Legacy loading detected. Attempting to load from StardewValley/Content/Data/PossibleBirthdayGifts.xnb");
|
HappyBirthday.ModMonitor.Log("Legacy loading detected. Attempting to load from StardewValley/Content/Data/PossibleBirthdayGifts.xnb");
|
||||||
this.defaultBirthdayGifts = Game1.content.Load<Dictionary<string, string>>(Path.Combine("Data", "PossibleBirthdayGifts"));
|
this.defaultBirthdayGifts = Game1.content.Load<Dictionary<string, string>>(Path.Combine("Data", "PossibleBirthdayGifts"));
|
||||||
return this.defaultBirthdayGifts;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HappyBirthday.ModMonitor.Log("No birthday gift information found. Loading from internal birthday list");
|
HappyBirthday.ModMonitor.Log("No birthday gift information found. Loading from internal birthday list");
|
||||||
return this.defaultBirthdayGifts;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,9 +129,19 @@ namespace Omegasis.HappyBirthday
|
||||||
/// Used to load spouse birthday gifts from disk.
|
/// Used to load spouse birthday gifts from disk.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Dictionary<string, string> loadSpouseBirthdayGifts()
|
public void loadSpouseBirthdayGifts()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
string spouseGifts = Path.Combine("Content", "Gifts", "SpouseBirthdayGifts.json");
|
||||||
|
if (File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, spouseGifts)))
|
||||||
|
{
|
||||||
|
HappyBirthday.ModMonitor.Log("Load from SpouseBirthdayGifts.json");
|
||||||
|
this.defaultSpouseBirthdayGifts = HappyBirthday.ModHelper.Data.ReadJsonFile<Dictionary<string, string>>(spouseGifts);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HappyBirthday.ModMonitor.Log("SpouseBirthdayGifts.json created from default spouse birthday gift information and can be overridden.");
|
||||||
|
HappyBirthday.ModHelper.Data.WriteJsonFile<Dictionary<string, string>>(spouseGifts, this.defaultSpouseBirthdayGifts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,7 +153,7 @@ namespace Omegasis.HappyBirthday
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// read from birthday gifts file
|
// read from birthday gifts file
|
||||||
IDictionary<string, string> data = loadVillagerBirthdayGifts();
|
IDictionary<string, string> data = defaultBirthdayGifts;
|
||||||
data.TryGetValue(name, out string text);
|
data.TryGetValue(name, out string text);
|
||||||
if (text != null)
|
if (text != null)
|
||||||
{
|
{
|
||||||
|
@ -222,30 +228,42 @@ namespace Omegasis.HappyBirthday
|
||||||
this.BirthdayGifts.AddRange(this.GetUniversalItems("Neutral", false));
|
this.BirthdayGifts.AddRange(this.GetUniversalItems("Neutral", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Add in spouse specific birthday gifts.
|
||||||
if (Game1.player.isMarried())
|
if (Game1.player.isMarried())
|
||||||
{
|
{
|
||||||
if (name == Game1.player.spouse)
|
if (name == Game1.player.spouse)
|
||||||
{
|
{
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(204, 1));
|
this.BirthdayGifts.AddRange(getSpouseBirthdayGifts(name));
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(220, 1));
|
this.BirthdayGifts.AddRange(getSpouseBirthdayGifts("Universal_Gifts"));
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(221, 1));
|
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(223, 3));
|
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(233, 3));
|
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(234, 1));
|
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(608, 1)); //pumpkin pie
|
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(612, 5));
|
|
||||||
this.BirthdayGifts.Add((Item)new StardewValley.Object(773, 1)); //life elixer
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Make different tiers of gifts depending on the friendship, and if it is the spouse.
|
|
||||||
/*
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
return gifts;
|
return gifts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="group"></param>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private IEnumerable<Item> getSpouseBirthdayGifts(string npcName)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> data = this.defaultSpouseBirthdayGifts;
|
||||||
|
data.TryGetValue(npcName, out string text);
|
||||||
|
if (String.IsNullOrEmpty(text))
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
// parse
|
||||||
|
string[] array = text.Split(' ');
|
||||||
|
for (int i = 0; i < array.Length; i += 2)
|
||||||
|
{
|
||||||
|
foreach (SObject obj in this.GetItems(Convert.ToInt32(array[i]), Convert.ToInt32(array[i + 1])))
|
||||||
|
yield return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Get the items loved by all villagers.</summary>
|
/// <summary>Get the items loved by all villagers.</summary>
|
||||||
/// <param name="group">The group to get (one of <c>Like</c>, <c>Love</c>, <c>Neutral</c>).</param>
|
/// <param name="group">The group to get (one of <c>Like</c>, <c>Love</c>, <c>Neutral</c>).</param>
|
||||||
/// <param name="isBirthdayGiftList">Whether to get data from <c>Data\BirthdayGifts.xnb</c> instead of the game data.</param>
|
/// <param name="isBirthdayGiftList">Whether to get data from <c>Data\BirthdayGifts.xnb</c> instead of the game data.</param>
|
||||||
|
|
|
@ -111,6 +111,11 @@ namespace Omegasis.HappyBirthday
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to check when a menu is closed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e)
|
private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e)
|
||||||
{
|
{
|
||||||
this.isDailyQuestBoard = false;
|
this.isDailyQuestBoard = false;
|
||||||
|
@ -318,15 +323,38 @@ namespace Omegasis.HappyBirthday
|
||||||
if (npc is Child || npc is Horse || npc is Junimo || npc is Monster || npc is Pet)
|
if (npc is Child || npc is Horse || npc is Junimo || npc is Monster || npc is Pet)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
//Add in birthday dialogues for npc.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Game1.player.getFriendshipHeartLevelForNPC(npc.Name) >= Config.minimumFriendshipLevelForBirthdayWish)
|
if (Game1.player.getFriendshipHeartLevelForNPC(npc.Name) >= Config.minimumFriendshipLevelForBirthdayWish)
|
||||||
{
|
{
|
||||||
|
bool spouseMessage = false; //Used to determine if there is a valid spouse message for the player. If false load in the generic birthday wish.
|
||||||
|
//Check if npc name is spouse's name. If no spouse then add in generic dialogue.
|
||||||
|
if (messages.spouseBirthdayWishes.ContainsKey(npc.Name) && Game1.player.isMarried())
|
||||||
|
{
|
||||||
|
Monitor.Log("Spouse Checks out");
|
||||||
|
//Check to see if spouse message exists.
|
||||||
|
if (!String.IsNullOrEmpty(messages.spouseBirthdayWishes[npc.Name]))
|
||||||
|
{
|
||||||
|
spouseMessage = true;
|
||||||
|
Dialogue d = new Dialogue(messages.spouseBirthdayWishes[npc.Name], npc);
|
||||||
|
npc.CurrentDialogue.Push(d);
|
||||||
|
if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(messages.spouseBirthdayWishes[npc.Name]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Monitor.Log("No spouse message???", LogLevel.Warn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (spouseMessage == false)
|
||||||
|
{
|
||||||
|
//Load in
|
||||||
Dialogue d = new Dialogue(messages.birthdayWishes[npc.Name], npc);
|
Dialogue d = new Dialogue(messages.birthdayWishes[npc.Name], npc);
|
||||||
npc.CurrentDialogue.Push(d);
|
npc.CurrentDialogue.Push(d);
|
||||||
if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(messages.birthdayWishes[npc.Name]);
|
if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(messages.birthdayWishes[npc.Name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if (Game1.player.getFriendshipHeartLevelForNPC(npc.Name) >= Config.minimumFriendshipLevelForBirthdayWish)
|
if (Game1.player.getFriendshipHeartLevelForNPC(npc.Name) >= Config.minimumFriendshipLevelForBirthdayWish)
|
||||||
|
|
Loading…
Reference in New Issue