Skip to content

Commit

Permalink
Add indicator for upcoming rain
Browse files Browse the repository at this point in the history
  • Loading branch information
Annosz committed Oct 18, 2020
1 parent e1a07a1 commit afc284f
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 236 deletions.
3 changes: 3 additions & 0 deletions SDVModTest/Infrastucture/LanguageKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public static class LanguageKeys
public const string LuckyButNotTooLucky = "LuckyButNotTooLucky";
public const string FeelingLucky = "FeelingLucky";
public const string TravelingMerchantIsInTown = "TravelingMerchantIsInTown";
public const string RainNextDay = "RainNextDay";
public const string ThunderstormNextDay = "ThunderstormNextDay";
public const string SnowNextDay = "SnowNextDay";
public const string HarvestPrice = "HarvestPrice";
public const string LevelUp = "LevelUp";
public const string Calendar = "Calendar";
Expand Down
4 changes: 4 additions & 0 deletions SDVModTest/Options/ModOptionsPageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ModOptionsPageHandler : IDisposable
private readonly ExperienceBar _experienceBar;
private readonly ShowItemHoverInformation _showItemHoverInformation;
private readonly ShowTravelingMerchant _showTravelingMerchant;
private readonly ShowRainyDayIcon _showRainyDayIcon;
private readonly ShopHarvestPrices _shopHarvestPrices;
private readonly ShowQueenOfSauceIcon _showQueenOfSauceIcon;
private readonly ShowToolUpgradeStatus _showToolUpgradeStatus;
Expand All @@ -53,6 +54,7 @@ public ModOptionsPageHandler(IModHelper helper, IDictionary<string, string> opti
_shopHarvestPrices = new ShopHarvestPrices(helper);
_showQueenOfSauceIcon = new ShowQueenOfSauceIcon(helper);
_showTravelingMerchant = new ShowTravelingMerchant(helper);
_showRainyDayIcon = new ShowRainyDayIcon(helper);
_showCropAndBarrelTime = new ShowCropAndBarrelTime(helper);
_showToolUpgradeStatus = new ShowToolUpgradeStatus(helper);

Expand All @@ -68,6 +70,7 @@ public ModOptionsPageHandler(IModHelper helper, IDictionary<string, string> opti
_experienceBar,
_showItemHoverInformation,
_showTravelingMerchant,
_showRainyDayIcon,
_shopHarvestPrices,
_showQueenOfSauceIcon,
_showToolUpgradeStatus
Expand All @@ -91,6 +94,7 @@ public ModOptionsPageHandler(IModHelper helper, IDictionary<string, string> opti
_optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowItemEffectRanges), whichOption++, _showScarecrowAndSprinklerRange.ToggleOption, _options, OptionKeys.ShowItemEffectRanges));
_optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowExtraItemInformation), whichOption++, _showItemHoverInformation.ToggleOption, _options, OptionKeys.ShowExtraItemInformation));
_optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowTravelingMerchant), whichOption++, _showTravelingMerchant.ToggleOption, _options, OptionKeys.ShowTravelingMerchant));
_optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowRainyDay), whichOption++, _showRainyDayIcon.ToggleOption, _options, OptionKeys.ShowRainyDay));
_optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowHarvestPricesInShop), whichOption++, _shopHarvestPrices.ToggleOption, _options, OptionKeys.ShowHarvestPricesInShop));
_optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowWhenNewRecipesAreAvailable), whichOption++, _showQueenOfSauceIcon.ToggleOption, _options, OptionKeys.ShowWhenNewRecipesAreAvailable));
_optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowToolUpgradeStatus), whichOption++, _showToolUpgradeStatus.ToggleOption, _options, OptionKeys.ShowToolUpgradeStatus));
Expand Down
1 change: 1 addition & 0 deletions SDVModTest/Options/OptionKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class OptionKeys
public const string ShowLocationOfTownsPeople = "ShowLocationOfTownsPeople";
public const string ShowLuckIcon = "ShowLuckIcon";
public const string ShowTravelingMerchant = "ShowTravelingMerchant";
public const string ShowRainyDay = "ShowRainyDay";
public const string ShowLocationOfTownsPeopleShowQuestIcon = "ShowLocationOfTownsPeopleShowQuestIcon";
public const string ShowCropAndBarrelTooltip = "ShowCropAndBarrelTooltip";
public const string ShowBirthdayIcon = "ShowBirthdayIcon";
Expand Down
1 change: 1 addition & 0 deletions SDVModTest/UI Info Suite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<Compile Include="UIElements\ShowItemHoverInformation.cs" />
<Compile Include="UIElements\ShowItemEffectRanges.cs" />
<Compile Include="UIElements\ShowQueenOfSauceIcon.cs" />
<Compile Include="UIElements\ShowRainyDayIcon.cs" />
<Compile Include="UIElements\ShowToolUpgradeStatus.cs" />
<Compile Include="UIElements\ShowTravelingMerchant.cs" />
<Compile Include="UIElements\ShowWhenAnimalNeedsPet.cs" />
Expand Down
121 changes: 121 additions & 0 deletions SDVModTest/UIElements/ShowRainyDayIcon.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using StardewValley.Menus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UIInfoSuite.Infrastructure;
using UIInfoSuite.Infrastructure.Extensions;

namespace UIInfoSuite.UIElements
{
class ShowRainyDayIcon : IDisposable
{
#region Properties
private bool _IsNextDayRainy;
Rectangle? _weatherIconSpriteLocation;
private string _hoverText;
private ClickableTextureComponent _rainyDayIcon;

private readonly IModHelper _helper;
#endregion

#region Lifecycle
public ShowRainyDayIcon(IModHelper helper)
{
_helper = helper;
}

public void Dispose()
{
ToggleOption(false);
}

public void ToggleOption(bool showTravelingMerchant)
{
_helper.Events.Display.RenderingHud -= OnRenderingHud;
_helper.Events.Display.RenderedHud -= OnRenderedHud;

if (showTravelingMerchant)
{
_helper.Events.Display.RenderingHud += OnRenderingHud;
_helper.Events.Display.RenderedHud += OnRenderedHud;
}
}
#endregion

#region Event subscriptions
private void OnRenderingHud(object sender, RenderingHudEventArgs e)
{
GetWeatherIconSpriteLocation();

// Draw icon
if (!Game1.eventUp && _IsNextDayRainy && _weatherIconSpriteLocation.HasValue)
{
Point iconPosition = IconHandler.Handler.GetNewIconPosition();
_rainyDayIcon =
new ClickableTextureComponent(
new Rectangle(iconPosition.X, iconPosition.Y, 40, 40),
Game1.animations,
_weatherIconSpriteLocation.Value,
2f);
_rainyDayIcon.draw(Game1.spriteBatch);
}
}

private void OnRenderedHud(object sender, RenderedHudEventArgs e)
{
// Show text on hover
if (_IsNextDayRainy && (_rainyDayIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false) && !String.IsNullOrEmpty(_hoverText))
{
IClickableMenu.drawHoverText(
Game1.spriteBatch,
_hoverText,
Game1.dialogueFont
);
}
}
#endregion

#region Logic
private void GetWeatherIconSpriteLocation()
{
switch (Game1.weatherForTomorrow)
{
case Game1.weather_sunny:
case Game1.weather_debris:
case Game1.weather_festival:
case Game1.weather_wedding:
_IsNextDayRainy = false;
break;

case Game1.weather_rain:
_IsNextDayRainy = true;
_weatherIconSpriteLocation = new Rectangle(268, 1750, 20, 20);
_hoverText = _helper.SafeGetString(LanguageKeys.RainNextDay);
break;

case Game1.weather_lightning:
_IsNextDayRainy = true;
_weatherIconSpriteLocation = new Rectangle(272, 1641, 20, 20);
_hoverText = _helper.SafeGetString(LanguageKeys.ThunderstormNextDay);
break;

case Game1.weather_snow:
_IsNextDayRainy = true;
_weatherIconSpriteLocation = new Rectangle(260, 680, 20, 20);
_hoverText = _helper.SafeGetString(LanguageKeys.SnowNextDay);
break;

default:
_IsNextDayRainy = false;
break;
}
}
#endregion
}
}
3 changes: 2 additions & 1 deletion SDVModTest/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ShowLuckIcon" : "Zeige Glücksymbol",
"ShowLevelUpAnimation" : "Zeige Aufstiegsanimation",
"ShowExperienceBar" : "Zeige Erfahrungsleiste",
"AllowExperienceBarToFadeOut" : "Erlauben verblassende Erfahrungsleiste",s
"AllowExperienceBarToFadeOut" : "Erlauben verblassende Erfahrungsleiste",
"ShowExperienceGain" : "Zeige Erfahrungsgewinn",
"ShowLocationOfTownsPeople" : "Zeige Bewohner auf der Karte",
"ShowBirthdayIcon" : "Zeige Geburtstagssymbol",
Expand All @@ -30,6 +30,7 @@
"ShowItemEffectRanges" : "Zeige Vogelscheuche und Sprinkler-Bereich",
"ShowExtraItemInformation" : "Zeige schwebende Info für Gegenstände",
"ShowTravelingMerchant" : "Zeige reisenden Händler",
"ShowRainyDay": "Show rainy days", // TODO
"ShowHarvestPricesInShop" : "Zeige Erntewerte",
"ShowWhenNewRecipesAreAvailable" : "Zeige, wenn neue Rezepte verfügbar sind",
"ShowToolUpgradeStatus" : "Zeige Werkzeugverbesserungsfortschritt"
Expand Down
72 changes: 38 additions & 34 deletions SDVModTest/i18n/default.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
{
"Billboard" : "Billboard",
"Calendar" : "Calendar",
"Days" : "days",
"DaysToMature" : "days to mature",
"FeelingLucky" : "You're feelin' lucky!!",
"HarvestPrice" : "Harvest price",
"Hours" : "hours",
"LevelUp" : "Level Up",
"LuckyButNotTooLucky" : "Feelin' lucky... but not too lucky",
"MaybeStayHome" : "Maybe you should stay home today...",
"Minutes" : "minutes",
"NotFeelingLuckyAtAll" : "You're not feeling lucky at all today...",
"ReadyToHarvest" : "Ready To Harvest!",
"TodaysRecipe" : "Today's Recipe: ",
"TravelingMerchantIsInTown" : "Traveling merchant is in town!",
"DaysUntilToolIsUpgraded" : "{0} days until {1} is finished being upgraded",
"ToolIsFinishedBeingUpgraded" : "{0} is finished!",
"ShowLuckIcon" : "Show luck icon",
"ShowLevelUpAnimation" : "Show level up animation",
"ShowExperienceBar" : "Show experience bar",
"AllowExperienceBarToFadeOut" : "Allow experience bar to fade out",
"ShowExperienceGain" : "Show experience gain",
"ShowLocationOfTownsPeople" : "Show townspeople on map",
"ShowBirthdayIcon" : "Show Birthday icon",
"ShowHeartFills" : "Show heart fills",
"ShowAnimalsNeedPets" : "Show when animals need pets",
"DisplayCalendarAndBillboard" : "Show calendar/billboard button",
"ShowCropAndBarrelTooltip" : "Show crop and barrel times",
"ShowItemEffectRanges" : "Show scarecrow and sprinkler range",
"ShowExtraItemInformation" : "Show item hover information",
"ShowTravelingMerchant" : "Show Traveling Merchant",
"ShowHarvestPricesInShop" : "Show shop harvest prices",
"ShowWhenNewRecipesAreAvailable" : "Show when new recipes are available",
"ShowToolUpgradeStatus" : "Show tool upgrade status"
"Billboard": "Billboard",
"Calendar": "Calendar",
"Days": "days",
"DaysToMature": "days to mature",
"FeelingLucky": "You're feelin' lucky!!",
"HarvestPrice": "Harvest price",
"Hours": "hours",
"LevelUp": "Level Up",
"LuckyButNotTooLucky": "Feelin' lucky... but not too lucky",
"MaybeStayHome": "Maybe you should stay home today...",
"Minutes": "minutes",
"NotFeelingLuckyAtAll": "You're not feeling lucky at all today...",
"ReadyToHarvest": "Ready To Harvest!",
"TodaysRecipe": "Today's Recipe: ",
"TravelingMerchantIsInTown": "Traveling merchant is in town!",
"RainNextDay": "There will be rain tomorrow",
"ThunderstormNextDay": "There will be a thunderstorm tomorrow",
"SnowNextDay": "There will be snow tomorrow",
"DaysUntilToolIsUpgraded": "{0} days until {1} is finished being upgraded",
"ToolIsFinishedBeingUpgraded": "{0} is finished!",
"ShowLuckIcon": "Show luck icon",
"ShowLevelUpAnimation": "Show level up animation",
"ShowExperienceBar": "Show experience bar",
"AllowExperienceBarToFadeOut": "Allow experience bar to fade out",
"ShowExperienceGain": "Show experience gain",
"ShowLocationOfTownsPeople": "Show townspeople on map",
"ShowBirthdayIcon": "Show Birthday icon",
"ShowHeartFills": "Show heart fills",
"ShowAnimalsNeedPets": "Show when animals need pets",
"DisplayCalendarAndBillboard": "Show calendar/billboard button",
"ShowCropAndBarrelTooltip": "Show crop and barrel times",
"ShowItemEffectRanges": "Show scarecrow and sprinkler range",
"ShowExtraItemInformation": "Show item hover information",
"ShowTravelingMerchant": "Show Traveling Merchant",
"ShowRainyDay": "Show rainy days",
"ShowHarvestPricesInShop": "Show shop harvest prices",
"ShowWhenNewRecipesAreAvailable": "Show when new recipes are available",
"ShowToolUpgradeStatus": "Show tool upgrade status"
}
69 changes: 35 additions & 34 deletions SDVModTest/i18n/es.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
{
"Billboard" : "Tablón de anuncios",
"Calendar" : "Calendario",
"Days" : "días",
"DaysToMature" : "días para madurar",
"FeelingLucky" : "¡Tienes suerte!",
"HarvestPrice" : "Precio de la cosecha",
"Hours" : "horas",
"LevelUp" : "Subida de nivel",
"LuckyButNotTooLucky" : "Te sientes con suerte... aunque no demasiado",
"MaybeStayHome" : "Tal vez deberías quedarte en casa hoy",
"Minutes" : "minutos",
"NotFeelingLuckyAtAll" : "No te sientes afortunado en absoluto...",
"ReadyToHarvest" : "¡Listo para cosechar!",
"TodaysRecipe" : "Receta de hoy: ",
"TravelingMerchantIsInTown" : "¡El comerciante ambulante está en la zona!",
"DaysUntilToolIsUpgraded" : "{0} días hasta que {1} termine de actualizarse",
"ToolIsFinishedBeingUpgraded" : "¡{0} está terminado!",
"ShowLuckIcon" : "Mostrar icono de suerte",
"ShowLevelUpAnimation" : "Mostrar animación de subida de nivel",
"ShowExperienceBar" : "Mostrar barra de experiencia",
"AllowExperienceBarToFadeOut" : "Permitir que la barra de experiencia se desvanezca",
"ShowExperienceGain" : "Mostrar ganancia de experiencia",
"ShowLocationOfTownsPeople" : "Mostrar a la gente del pueblo en el mapa",
"ShowBirthdayIcon" : "Mostrar icono de cumpleaños",
"ShowHeartFills" : "Mostrar rellenos de corazón",
"ShowAnimalsNeedPets" : "Mostrar si los animales necesitan caricias",
"DisplayCalendarAndBillboard" : "Mostrar el botón de calendario/tablón",
"ShowCropAndBarrelTooltip" : "Mostrar tiempo restante de cosechas y barriles",
"ShowItemEffectRanges" : "Mostrar rango de espantapájaros y aspersores",
"ShowExtraItemInformation" : "Mostrar información extra de objetos",
"ShowTravelingMerchant" : "Mostrar comerciante ambulante",
"ShowHarvestPricesInShop" : "Mostrar los precios de cosechas de la tienda",
"ShowWhenNewRecipesAreAvailable" : "Mostrar cuando hay nuevas recetas disponibles",
"ShowToolUpgradeStatus" : "Mostrar el estado de actualización de la herramienta"
"Billboard": "Tablón de anuncios",
"Calendar": "Calendario",
"Days": "días",
"DaysToMature": "días para madurar",
"FeelingLucky": "¡Tienes suerte!",
"HarvestPrice": "Precio de la cosecha",
"Hours": "horas",
"LevelUp": "Subida de nivel",
"LuckyButNotTooLucky": "Te sientes con suerte... aunque no demasiado",
"MaybeStayHome": "Tal vez deberías quedarte en casa hoy",
"Minutes": "minutos",
"NotFeelingLuckyAtAll": "No te sientes afortunado en absoluto...",
"ReadyToHarvest": "¡Listo para cosechar!",
"TodaysRecipe": "Receta de hoy: ",
"TravelingMerchantIsInTown": "¡El comerciante ambulante está en la zona!",
"DaysUntilToolIsUpgraded": "{0} días hasta que {1} termine de actualizarse",
"ToolIsFinishedBeingUpgraded": "¡{0} está terminado!",
"ShowLuckIcon": "Mostrar icono de suerte",
"ShowLevelUpAnimation": "Mostrar animación de subida de nivel",
"ShowExperienceBar": "Mostrar barra de experiencia",
"AllowExperienceBarToFadeOut": "Permitir que la barra de experiencia se desvanezca",
"ShowExperienceGain": "Mostrar ganancia de experiencia",
"ShowLocationOfTownsPeople": "Mostrar a la gente del pueblo en el mapa",
"ShowBirthdayIcon": "Mostrar icono de cumpleaños",
"ShowHeartFills": "Mostrar rellenos de corazón",
"ShowAnimalsNeedPets": "Mostrar si los animales necesitan caricias",
"DisplayCalendarAndBillboard": "Mostrar el botón de calendario/tablón",
"ShowCropAndBarrelTooltip": "Mostrar tiempo restante de cosechas y barriles",
"ShowItemEffectRanges": "Mostrar rango de espantapájaros y aspersores",
"ShowExtraItemInformation": "Mostrar información extra de objetos",
"ShowTravelingMerchant": "Mostrar comerciante ambulante",
"ShowRainyDay": "Show rainy days", // TODO
"ShowHarvestPricesInShop": "Mostrar los precios de cosechas de la tienda",
"ShowWhenNewRecipesAreAvailable": "Mostrar cuando hay nuevas recetas disponibles",
"ShowToolUpgradeStatus": "Mostrar el estado de actualización de la herramienta"
}
Loading

0 comments on commit afc284f

Please sign in to comment.