Skip to content

Commit

Permalink
Added the option to show Birthday reminders (Disabled by default)
Browse files Browse the repository at this point in the history
Changed some message formatting
  • Loading branch information
GStefanowich committed Jul 4, 2022
1 parent ad1b1c5 commit dfbd1bb
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 50 deletions.
30 changes: 14 additions & 16 deletions ForecasterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,20 @@ public sealed class ForecasterConfig {
/// <summary>When to show the weather for Ginger Island</summary>
public WeatherDisplay GingerIslandWeather { get; set; } = WeatherDisplay.ALWAYS;

public uint SunWeatherEmoji { get; set; } = 99u;
public uint RainWeatherEmoji { get; set; } = 100u;
public uint ThunderWeatherEmoji { get; set; } = 102u;
public uint SnowWeatherEmoji { get; set; } = 103u;
public uint FestivalWeatherEmoji { get; set; } = 151u;
public uint WeddingWeatherEmoji { get; set; } = 46u;

#endregion
#region Luck Emoji

public bool ShowGoodLuck { get; set; } = true;
public bool ShowNeutralLuck { get; set; } = true;
public bool ShowBadLuck { get; set; } = true;

#endregion
#region Recipe Emoji

public bool ShowNewRecipes { get; set; } = true;
public bool ShowExistingRecipes { get; set; } = false;

#endregion
#region Spirits Emoji

public uint SpiritsEmoji { get; set; } = 119u;
public uint VeryHappySpiritEmoji { get; set; } = 43u;
public uint GoodHumorSpiritEmoji { get; set; } = 2u;
Expand All @@ -65,18 +63,18 @@ public sealed class ForecasterConfig {
#endregion
#region Recipe Emoji

public bool ShowNewRecipes { get; set; } = true;
public uint NewRecipeEmoji { get; set; } = 132u;

public bool ShowExistingRecipes { get; set; } = false;
public uint KnownRecipeEmoji { get; set; } = 135u;

#endregion
#region Weather Emoji
#region Birthdays

public uint SunWeatherEmoji { get; set; } = 99u;
public uint RainWeatherEmoji { get; set; } = 100u;
public uint ThunderWeatherEmoji { get; set; } = 102u;
public uint SnowWeatherEmoji { get; set; } = 103u;
public uint FestivalWeatherEmoji { get; set; } = 151u;
public uint WeddingWeatherEmoji { get; set; } = 46u;
public bool ShowBirthdays { get; set; } = false;
public bool UseVillagerNames { get; set; } = false;
public uint BirthdayEmoji { get; set; } = 152u;

#endregion
}
Expand Down
95 changes: 87 additions & 8 deletions ForecasterConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using ForecasterText.Objects;
using ForecasterText.Objects.Enums;
using GenericModConfigMenu;
using StardewModdingAPI;
using StardewValley;

namespace ForecasterText {
public sealed class ForecasterConfigManager {
Expand Down Expand Up @@ -80,6 +82,27 @@ public void RegisterConfigManager(IGenericModConfigMenuApi configMenu) {
"When to show the weather for Ginger Island"
);

// When to display birthdays
this.AddSectionTitle(
"Show Birthdays",
"When to show birthday messages"
);
this.AddBoolOption(
() => this.ModConfig.ShowBirthdays,
value => this.ModConfig.ShowBirthdays = value,
"Show Birthdays",
"If birthdays are shown"
);
this.AddBoolOption(
() => this.ModConfig.UseVillagerNames,
value => {
this.ModConfig.UseVillagerNames = value;
this.Examples.ForEach(message => message.Dirty = true);
},
"Use Names",
"Shows names of villagers instead of their face icon"
);

// When to display luck
this.AddSectionTitle(
"Show Luck",
Expand Down Expand Up @@ -185,6 +208,17 @@ public void RegisterConfigManager(IGenericModConfigMenuApi configMenu) {
message => this.RecipeExampleMessage(message, true)
);

// Emoji for birthdays
this.AddSectionTitle(
"Birthday Icons",
"The icons used for birthdays"
);
this.AddEmojiSelector("Birthday Today", null,
() => this.ModConfig.BirthdayEmoji,
i => this.ModConfig.BirthdayEmoji = i,
message => this.BirthdayExampleMessage(message, new [] { "Shane", "Abigail" })
);

// Emojis for weather
this.AddSectionTitle(
"Weather Icons",
Expand Down Expand Up @@ -247,8 +281,8 @@ private void AddEmojiSelector(string text, string tooltip = null, Func<uint> get
// Unlike other types check if the config exists before constructing types
if (this.ConfigMenu is {} config) {
ConfigEmojiMenu menu = new(this.Mod, text, tooltip, get, i => {
this.Examples.ForEach(message => message.Dirty = true);
set?.Invoke(i);
this.Examples.ForEach(message => message.Dirty = true);
});

if (parser is not null) {
Expand Down Expand Up @@ -285,7 +319,7 @@ private void AddParagraph(Func<string> text) =>
#endregion
#region Getters

public uint GetEmoji(WeatherIcons icon) => icon switch {
public uint? GetEmoji(WeatherIcons icon) => icon switch {
WeatherIcons.SUN => this.ModConfig.SunWeatherEmoji,
WeatherIcons.RAIN => this.ModConfig.RainWeatherEmoji,
WeatherIcons.LIGHTNING => this.ModConfig.ThunderWeatherEmoji,
Expand All @@ -294,7 +328,7 @@ private void AddParagraph(Func<string> text) =>
WeatherIcons.WEDDING => this.ModConfig.WeddingWeatherEmoji,
_ => 0u
};
public uint GetEmoji(SpiritMoods icon) => icon switch {
public uint? GetEmoji(SpiritMoods icon) => icon switch {
SpiritMoods.VERY_HAPPY => this.ModConfig.VeryHappySpiritEmoji,
SpiritMoods.GOOD_HUMOR => this.ModConfig.GoodHumorSpiritEmoji,
SpiritMoods.NEUTRAL => this.ModConfig.NeutralSpiritEmoji,
Expand All @@ -303,18 +337,63 @@ private void AddParagraph(Func<string> text) =>
SpiritMoods.VERY_DISPLEASED => this.ModConfig.VeryDispleasedSpiritEmoji,
_ => 0u
};
public uint? GetEmoji(Character character) => character switch {
NPC npc => this.GetNpcEmoji(npc.getName()),
_ => null
};
public uint? GetNpcEmoji(string name) => name.ToLower(CultureInfo.InvariantCulture) switch {
"abigail" => 154u,
"penny" => 155u,
"maru" => 156u,
"leah" => 157u,
"haley" => 158u,
"emily" => 159u,
"alex" => 160u,
"shane" => 161u,
"sebastian" => 162u,
"sam" => 163u,
"harvey" => 164u,
"elliot" => 165u,
"sandy" => 166u,
"evelyn" => 167u,
"marnie" => 168u,
"caroline" => 169u,
"robin" => 170u,
"pierre" => 171u,
"pam" => 172u,
"jodi" => 173u,
"lewis" => 174u,
"linus" => 175u,
"marlon" => 176u,
"willy" => 177u,
"wizard" => 178u,
"morris" => 179u,
"jas" => 180u,
"vincent" => 181u,
"krobus" => 182u,
"dwarf" => 183u,
"gus" => 184u,
"gunther" => 185u,
"george" => 186u,
"demestrius" => 187u,
"clint" => 188u,
_ => null
};

#endregion
#region Examples

internal string SpiritExampleMessage(ConfigEmojiMessage message, SpiritMoods mood)
=> this.Mod.Events.GetDailyLuck(mood);

internal string WeatherExampleMessage(ConfigEmojiMessage message, WeatherIcons weatherDisplay)
=> this.Mod.Events.GetTownForecast((int)weatherDisplay);
=> this.Mod.Events.GetDailyLuck(mood)?.ToString();

internal string RecipeExampleMessage(ConfigEmojiMessage message, bool hasRecipe)
=> this.Mod.Events.GetQueenOfSauce("Trout Soup", hasRecipe);
=> this.Mod.Events.GetQueenOfSauce("Trout Soup", hasRecipe)?.ToString();

internal string BirthdayExampleMessage(ConfigEmojiMessage message, IEnumerable<string> names)
=> this.Mod.Events.GetBirthdays(names)?.ToString();

internal string WeatherExampleMessage(ConfigEmojiMessage message, WeatherIcons weatherDisplay)
=> this.Mod.Events.GetTownForecast((int)weatherDisplay)?.ToString();

#endregion
}
Expand Down
1 change: 0 additions & 1 deletion Objects/ConfigEmojiMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ protected override void OnClick(Vector2I bounds, Vector2I mouse) {
Game1.playSound("Cowboy_Footstep");

this.PageIndex = Math.Min(this.PageIndex + ConfigEmojiMenu.SHIFT, ConfigEmojiMenu.SHIFT * (int)(Math.Floor((double)this.TotalEmojis / ConfigEmojiMenu.SHIFT)));
//this.PageIndex += ConfigEmojiMenu.SHIFT;
this.DownArrow.scale = 0.75f;

this.ResetIcons();
Expand Down
2 changes: 1 addition & 1 deletion Objects/ConfigEmojiMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void UpdateText() {
try {
// Clear the snippets
this.Snippets.Clear();
this.Snippets.Add(new ChatSnippet("> TV: ", this.Language));
this.Snippets.Add(new ChatSnippet("> ", this.Language));
if (this.Setter is {} renderer && renderer(this) is {} ienumerable)
this.Snippets.AddRange(ienumerable);
} finally {
Expand Down
24 changes: 24 additions & 0 deletions Objects/MessageSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace ForecasterText.Objects {
internal sealed class MessageSource {
public string Source;
public string Message;

private MessageSource(string source, string message) {
this.Source = source;
this.Message = message;
}

public override string ToString() => $"{this.Source}: {this.Message}";

public static MessageSource TV(string message = "") {
if (message is null)
return null;
return new MessageSource("TV", message);
}
public static MessageSource Calendar(string message = "") {
if (message is null)
return null;
return new MessageSource("Calendar", message);
}
}
}
Loading

0 comments on commit dfbd1bb

Please sign in to comment.