Skip to content

Commit dfbd1bb

Browse files
committed
Added the option to show Birthday reminders (Disabled by default)
Changed some message formatting
1 parent ad1b1c5 commit dfbd1bb

File tree

6 files changed

+189
-50
lines changed

6 files changed

+189
-50
lines changed

ForecasterConfig.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,20 @@ public sealed class ForecasterConfig {
3838
/// <summary>When to show the weather for Ginger Island</summary>
3939
public WeatherDisplay GingerIslandWeather { get; set; } = WeatherDisplay.ALWAYS;
4040

41+
public uint SunWeatherEmoji { get; set; } = 99u;
42+
public uint RainWeatherEmoji { get; set; } = 100u;
43+
public uint ThunderWeatherEmoji { get; set; } = 102u;
44+
public uint SnowWeatherEmoji { get; set; } = 103u;
45+
public uint FestivalWeatherEmoji { get; set; } = 151u;
46+
public uint WeddingWeatherEmoji { get; set; } = 46u;
47+
4148
#endregion
4249
#region Luck Emoji
4350

4451
public bool ShowGoodLuck { get; set; } = true;
4552
public bool ShowNeutralLuck { get; set; } = true;
4653
public bool ShowBadLuck { get; set; } = true;
4754

48-
#endregion
49-
#region Recipe Emoji
50-
51-
public bool ShowNewRecipes { get; set; } = true;
52-
public bool ShowExistingRecipes { get; set; } = false;
53-
54-
#endregion
55-
#region Spirits Emoji
56-
5755
public uint SpiritsEmoji { get; set; } = 119u;
5856
public uint VeryHappySpiritEmoji { get; set; } = 43u;
5957
public uint GoodHumorSpiritEmoji { get; set; } = 2u;
@@ -65,18 +63,18 @@ public sealed class ForecasterConfig {
6563
#endregion
6664
#region Recipe Emoji
6765

66+
public bool ShowNewRecipes { get; set; } = true;
6867
public uint NewRecipeEmoji { get; set; } = 132u;
68+
69+
public bool ShowExistingRecipes { get; set; } = false;
6970
public uint KnownRecipeEmoji { get; set; } = 135u;
7071

7172
#endregion
72-
#region Weather Emoji
73+
#region Birthdays
7374

74-
public uint SunWeatherEmoji { get; set; } = 99u;
75-
public uint RainWeatherEmoji { get; set; } = 100u;
76-
public uint ThunderWeatherEmoji { get; set; } = 102u;
77-
public uint SnowWeatherEmoji { get; set; } = 103u;
78-
public uint FestivalWeatherEmoji { get; set; } = 151u;
79-
public uint WeddingWeatherEmoji { get; set; } = 46u;
75+
public bool ShowBirthdays { get; set; } = false;
76+
public bool UseVillagerNames { get; set; } = false;
77+
public uint BirthdayEmoji { get; set; } = 152u;
8078

8179
#endregion
8280
}

ForecasterConfigManager.cs

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525

2626
using System;
2727
using System.Collections.Generic;
28+
using System.Globalization;
2829
using ForecasterText.Objects;
2930
using ForecasterText.Objects.Enums;
3031
using GenericModConfigMenu;
3132
using StardewModdingAPI;
33+
using StardewValley;
3234

3335
namespace ForecasterText {
3436
public sealed class ForecasterConfigManager {
@@ -80,6 +82,27 @@ public void RegisterConfigManager(IGenericModConfigMenuApi configMenu) {
8082
"When to show the weather for Ginger Island"
8183
);
8284

85+
// When to display birthdays
86+
this.AddSectionTitle(
87+
"Show Birthdays",
88+
"When to show birthday messages"
89+
);
90+
this.AddBoolOption(
91+
() => this.ModConfig.ShowBirthdays,
92+
value => this.ModConfig.ShowBirthdays = value,
93+
"Show Birthdays",
94+
"If birthdays are shown"
95+
);
96+
this.AddBoolOption(
97+
() => this.ModConfig.UseVillagerNames,
98+
value => {
99+
this.ModConfig.UseVillagerNames = value;
100+
this.Examples.ForEach(message => message.Dirty = true);
101+
},
102+
"Use Names",
103+
"Shows names of villagers instead of their face icon"
104+
);
105+
83106
// When to display luck
84107
this.AddSectionTitle(
85108
"Show Luck",
@@ -185,6 +208,17 @@ public void RegisterConfigManager(IGenericModConfigMenuApi configMenu) {
185208
message => this.RecipeExampleMessage(message, true)
186209
);
187210

211+
// Emoji for birthdays
212+
this.AddSectionTitle(
213+
"Birthday Icons",
214+
"The icons used for birthdays"
215+
);
216+
this.AddEmojiSelector("Birthday Today", null,
217+
() => this.ModConfig.BirthdayEmoji,
218+
i => this.ModConfig.BirthdayEmoji = i,
219+
message => this.BirthdayExampleMessage(message, new [] { "Shane", "Abigail" })
220+
);
221+
188222
// Emojis for weather
189223
this.AddSectionTitle(
190224
"Weather Icons",
@@ -247,8 +281,8 @@ private void AddEmojiSelector(string text, string tooltip = null, Func<uint> get
247281
// Unlike other types check if the config exists before constructing types
248282
if (this.ConfigMenu is {} config) {
249283
ConfigEmojiMenu menu = new(this.Mod, text, tooltip, get, i => {
250-
this.Examples.ForEach(message => message.Dirty = true);
251284
set?.Invoke(i);
285+
this.Examples.ForEach(message => message.Dirty = true);
252286
});
253287

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

288-
public uint GetEmoji(WeatherIcons icon) => icon switch {
322+
public uint? GetEmoji(WeatherIcons icon) => icon switch {
289323
WeatherIcons.SUN => this.ModConfig.SunWeatherEmoji,
290324
WeatherIcons.RAIN => this.ModConfig.RainWeatherEmoji,
291325
WeatherIcons.LIGHTNING => this.ModConfig.ThunderWeatherEmoji,
@@ -294,7 +328,7 @@ private void AddParagraph(Func<string> text) =>
294328
WeatherIcons.WEDDING => this.ModConfig.WeddingWeatherEmoji,
295329
_ => 0u
296330
};
297-
public uint GetEmoji(SpiritMoods icon) => icon switch {
331+
public uint? GetEmoji(SpiritMoods icon) => icon switch {
298332
SpiritMoods.VERY_HAPPY => this.ModConfig.VeryHappySpiritEmoji,
299333
SpiritMoods.GOOD_HUMOR => this.ModConfig.GoodHumorSpiritEmoji,
300334
SpiritMoods.NEUTRAL => this.ModConfig.NeutralSpiritEmoji,
@@ -303,18 +337,63 @@ private void AddParagraph(Func<string> text) =>
303337
SpiritMoods.VERY_DISPLEASED => this.ModConfig.VeryDispleasedSpiritEmoji,
304338
_ => 0u
305339
};
340+
public uint? GetEmoji(Character character) => character switch {
341+
NPC npc => this.GetNpcEmoji(npc.getName()),
342+
_ => null
343+
};
344+
public uint? GetNpcEmoji(string name) => name.ToLower(CultureInfo.InvariantCulture) switch {
345+
"abigail" => 154u,
346+
"penny" => 155u,
347+
"maru" => 156u,
348+
"leah" => 157u,
349+
"haley" => 158u,
350+
"emily" => 159u,
351+
"alex" => 160u,
352+
"shane" => 161u,
353+
"sebastian" => 162u,
354+
"sam" => 163u,
355+
"harvey" => 164u,
356+
"elliot" => 165u,
357+
"sandy" => 166u,
358+
"evelyn" => 167u,
359+
"marnie" => 168u,
360+
"caroline" => 169u,
361+
"robin" => 170u,
362+
"pierre" => 171u,
363+
"pam" => 172u,
364+
"jodi" => 173u,
365+
"lewis" => 174u,
366+
"linus" => 175u,
367+
"marlon" => 176u,
368+
"willy" => 177u,
369+
"wizard" => 178u,
370+
"morris" => 179u,
371+
"jas" => 180u,
372+
"vincent" => 181u,
373+
"krobus" => 182u,
374+
"dwarf" => 183u,
375+
"gus" => 184u,
376+
"gunther" => 185u,
377+
"george" => 186u,
378+
"demestrius" => 187u,
379+
"clint" => 188u,
380+
_ => null
381+
};
306382

307383
#endregion
308384
#region Examples
309385

310386
internal string SpiritExampleMessage(ConfigEmojiMessage message, SpiritMoods mood)
311-
=> this.Mod.Events.GetDailyLuck(mood);
312-
313-
internal string WeatherExampleMessage(ConfigEmojiMessage message, WeatherIcons weatherDisplay)
314-
=> this.Mod.Events.GetTownForecast((int)weatherDisplay);
387+
=> this.Mod.Events.GetDailyLuck(mood)?.ToString();
315388

316389
internal string RecipeExampleMessage(ConfigEmojiMessage message, bool hasRecipe)
317-
=> this.Mod.Events.GetQueenOfSauce("Trout Soup", hasRecipe);
390+
=> this.Mod.Events.GetQueenOfSauce("Trout Soup", hasRecipe)?.ToString();
391+
392+
internal string BirthdayExampleMessage(ConfigEmojiMessage message, IEnumerable<string> names)
393+
=> this.Mod.Events.GetBirthdays(names)?.ToString();
394+
395+
internal string WeatherExampleMessage(ConfigEmojiMessage message, WeatherIcons weatherDisplay)
396+
=> this.Mod.Events.GetTownForecast((int)weatherDisplay)?.ToString();
318397

319398
#endregion
320399
}

Objects/ConfigEmojiMenu.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ protected override void OnClick(Vector2I bounds, Vector2I mouse) {
147147
Game1.playSound("Cowboy_Footstep");
148148

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

153152
this.ResetIcons();

Objects/ConfigEmojiMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private void UpdateText() {
9191
try {
9292
// Clear the snippets
9393
this.Snippets.Clear();
94-
this.Snippets.Add(new ChatSnippet("> TV: ", this.Language));
94+
this.Snippets.Add(new ChatSnippet("> ", this.Language));
9595
if (this.Setter is {} renderer && renderer(this) is {} ienumerable)
9696
this.Snippets.AddRange(ienumerable);
9797
} finally {

Objects/MessageSource.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace ForecasterText.Objects {
2+
internal sealed class MessageSource {
3+
public string Source;
4+
public string Message;
5+
6+
private MessageSource(string source, string message) {
7+
this.Source = source;
8+
this.Message = message;
9+
}
10+
11+
public override string ToString() => $"{this.Source}: {this.Message}";
12+
13+
public static MessageSource TV(string message = "") {
14+
if (message is null)
15+
return null;
16+
return new MessageSource("TV", message);
17+
}
18+
public static MessageSource Calendar(string message = "") {
19+
if (message is null)
20+
return null;
21+
return new MessageSource("Calendar", message);
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)