From f32d3d7443e882ead1354f379aee730826410fb3 Mon Sep 17 00:00:00 2001 From: Drew Hoener Date: Mon, 10 Jun 2024 23:40:49 -0400 Subject: [PATCH 1/8] chore: Finally use I18n static strings instead of LanguageKeys file (cherry picked from commit 55ea09783f47900907bf2535dd0c186dc7d42b1c) --- UIInfoSuite2/Infrastructure/LanguageKeys.cs | 52 ------------------- UIInfoSuite2/Options/ModOptionsPageHandler.cs | 3 +- UIInfoSuite2/UIElements/ExperienceBar.cs | 2 +- UIInfoSuite2/UIElements/LuckOfDay.cs | 14 ++--- UIInfoSuite2/UIElements/ShopHarvestPrices.cs | 2 +- UIInfoSuite2/UIElements/ShowBirthdayIcon.cs | 2 +- ...howCalendarAndBillboardOnGameMenuButton.cs | 6 +-- .../UIElements/ShowQueenOfSauceIcon.cs | 2 +- UIInfoSuite2/UIElements/ShowRainyDayIcon.cs | 14 ++--- .../UIElements/ShowRobinBuildingStatusIcon.cs | 6 +-- UIInfoSuite2/UIElements/ShowSeasonalBerry.cs | 6 +-- .../UIElements/ShowTravelingMerchant.cs | 2 +- 12 files changed, 29 insertions(+), 82 deletions(-) delete mode 100644 UIInfoSuite2/Infrastructure/LanguageKeys.cs diff --git a/UIInfoSuite2/Infrastructure/LanguageKeys.cs b/UIInfoSuite2/Infrastructure/LanguageKeys.cs deleted file mode 100644 index b09045dc..00000000 --- a/UIInfoSuite2/Infrastructure/LanguageKeys.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace UIInfoSuite2.Infrastructure; - -public static class LanguageKeys -{ - public const string OptionsTabTooltip = "OptionsTabTooltip"; - public const string Days = "Days"; - public const string DaysToMature = "DaysToMature"; - public const string Hours = "Hours"; - public const string Minutes = "Minutes"; - public const string ReadyToHarvest = "ReadyToHarvest"; - public const string With = "With"; - public const string Fertilized = "Fertilized"; - public const string Tree = "Tree"; - public const string stage = "stage"; - public const string Oak = "Oak"; - public const string Maple = "Maple"; - public const string Pine = "Pine"; - public const string Palm = "Palm"; - public const string Mushroom = "Mushroom"; - public const string Mahogany = "Mahogany"; - public const string PalmJungle = "Palm(Jungle)"; - public const string GreenRainType1 = "GreenRainType1"; - public const string GreenRainType2 = "GreenRainType2"; - public const string GreenRainType3 = "GreenRainType3"; - public const string Mystic = "Mystic"; - public const string TodaysRecipe = "TodaysRecipe"; - public const string TravelingMerchantIsInTown = "TravelingMerchantIsInTown"; - public const string RainNextDay = "RainNextDay"; - public const string ThunderstormNextDay = "ThunderstormNextDay"; - public const string SnowNextDay = "SnowNextDay"; - public const string IslandRainNextDay = "IslandRainNextDay"; - public const string IslandThunderstormNextDay = "IslandThunderstormNextDay"; - public const string HarvestPrice = "HarvestPrice"; - public const string LevelUp = "LevelUp"; - public const string Calendar = "Calendar"; - public const string Billboard = "Billboard"; - public const string DaysUntilToolIsUpgraded = "DaysUntilToolIsUpgraded"; - public const string ToolIsFinishedBeingUpgraded = "ToolIsFinishedBeingUpgraded"; - public const string DailyLuckValue = "DailyLuckValue"; - public const string LuckStatus1 = "LuckStatus1"; - public const string LuckStatus2 = "LuckStatus2"; - public const string LuckStatus3 = "LuckStatus3"; - public const string LuckStatus4 = "LuckStatus4"; - public const string LuckStatus5 = "LuckStatus5"; - public const string LuckStatus6 = "LuckStatus6"; - public const string RobinBuildingStatus = "RobinBuildingStatus"; - public const string RobinHouseUpgradeStatus = "RobinHouseUpgradeStatus"; - public const string NpcBirthday = "NpcBirthday"; - public const string CanFindSalmonberry = "CanFindSalmonberry"; - public const string CanFindBlackberry = "CanFindBlackberry"; - public const string CanFindHazelnut = "CanFindHazelnut"; -} diff --git a/UIInfoSuite2/Options/ModOptionsPageHandler.cs b/UIInfoSuite2/Options/ModOptionsPageHandler.cs index 6f460065..ef17e8e1 100644 --- a/UIInfoSuite2/Options/ModOptionsPageHandler.cs +++ b/UIInfoSuite2/Options/ModOptionsPageHandler.cs @@ -595,8 +595,7 @@ private void OnRenderedMenu(object? sender, RenderedActiveMenuEventArgs e) // Draw our tab's hover text if (_modOptionsTab.Value?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) == true) { - Translation tooltip = _helper.Translation.Get(LanguageKeys.OptionsTabTooltip).Default("UI Info Mod Options"); - IClickableMenu.drawHoverText(Game1.spriteBatch, tooltip, Game1.smallFont); + IClickableMenu.drawHoverText(Game1.spriteBatch, I18n.OptionsTabTooltip(), Game1.smallFont); if (!gameMenu.hoverText.Equals("")) { diff --git a/UIInfoSuite2/UIElements/ExperienceBar.cs b/UIInfoSuite2/UIElements/ExperienceBar.cs index eceb1c0a..b0da7320 100644 --- a/UIInfoSuite2/UIElements/ExperienceBar.cs +++ b/UIInfoSuite2/UIElements/ExperienceBar.cs @@ -218,7 +218,7 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e) // Level up text if (LevelUpAnimationEnabled && _levelUpVisibleTimer.Value != 0) { - _displayedLevelUpMessage.Value.Draw(_levelUpIconRectangle.Value, _helper.SafeGetString(LanguageKeys.LevelUp)); + _displayedLevelUpMessage.Value.Draw(_levelUpIconRectangle.Value, I18n.LevelUp()); } // Experience values diff --git a/UIInfoSuite2/UIElements/LuckOfDay.cs b/UIInfoSuite2/UIElements/LuckOfDay.cs index 79f60571..d261a1dc 100644 --- a/UIInfoSuite2/UIElements/LuckOfDay.cs +++ b/UIInfoSuite2/UIElements/LuckOfDay.cs @@ -117,35 +117,35 @@ private void CalculateLuck(UpdateTickedEventArgs e) { // Spirits are very happy (FeelingLucky) case var l when l > 0.07: - _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus1); + _hoverText.Value = I18n.LuckStatus1(); _color.Value = Luck1Color; break; // Spirits are in good humor (LuckyButNotTooLucky) case var l when l > 0.02 && l <= 0.07: - _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus2); + _hoverText.Value = I18n.LuckStatus2(); _color.Value = Luck2Color; break; // The spirits feel neutral case var l when l >= -0.02 && l <= 0.02 && l != 0: - _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus3); + _hoverText.Value = I18n.LuckStatus3(); _color.Value = Luck3Color; break; // The spirits feel absolutely neutral case var l when l == 0: - _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus4); + _hoverText.Value = I18n.LuckStatus4(); _color.Value = Luck4Color; break; // The spirits are somewhat annoyed (NotFeelingLuckyAtAll) case var l when l >= -0.07 && l < -0.02: - _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus5); + _hoverText.Value = I18n.LuckStatus5(); _color.Value = Luck5Color; break; // The spirits are very displeased (MaybeStayHome) case var l when l < -0.07: - _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus6); + _hoverText.Value = I18n.LuckStatus6(); _color.Value = Luck6Color; break; } @@ -154,7 +154,7 @@ private void CalculateLuck(UpdateTickedEventArgs e) if (ShowExactValue) { _hoverText.Value = string.Format( - _helper.SafeGetString(LanguageKeys.DailyLuckValue), + I18n.DailyLuckValue(), Game1.player.DailyLuck.ToString("N3") ); } diff --git a/UIInfoSuite2/UIElements/ShopHarvestPrices.cs b/UIInfoSuite2/UIElements/ShopHarvestPrices.cs index 6f82e590..8a672240 100644 --- a/UIInfoSuite2/UIElements/ShopHarvestPrices.cs +++ b/UIInfoSuite2/UIElements/ShopHarvestPrices.cs @@ -61,7 +61,7 @@ private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e) int yPosition = menu.yPositionOnScreen + 580; IClickableMenu.drawTextureBox(Game1.spriteBatch, xPosition + 20, yPosition - 52, 264, 108, Color.White); // Title "Harvest Price" - string textToRender = _helper.SafeGetString(LanguageKeys.HarvestPrice); + string textToRender = I18n.HarvestPrice(); Game1.spriteBatch.DrawString( Game1.dialogueFont, textToRender, diff --git a/UIInfoSuite2/UIElements/ShowBirthdayIcon.cs b/UIInfoSuite2/UIElements/ShowBirthdayIcon.cs index 13cc5959..c6ba1743 100644 --- a/UIInfoSuite2/UIElements/ShowBirthdayIcon.cs +++ b/UIInfoSuite2/UIElements/ShowBirthdayIcon.cs @@ -211,7 +211,7 @@ private void DrawHoverText() { if (icons[i].containsPoint(Game1.getMouseX(), Game1.getMouseY())) { - string hoverText = string.Format(_helper.SafeGetString(LanguageKeys.NpcBirthday), npcs[i].displayName); + string hoverText = string.Format(I18n.NpcBirthday(), npcs[i].displayName); IClickableMenu.drawHoverText(Game1.spriteBatch, hoverText, Game1.dialogueFont); } } diff --git a/UIInfoSuite2/UIElements/ShowCalendarAndBillboardOnGameMenuButton.cs b/UIInfoSuite2/UIElements/ShowCalendarAndBillboardOnGameMenuButton.cs index 11d06d6e..aef7bac6 100644 --- a/UIInfoSuite2/UIElements/ShowCalendarAndBillboardOnGameMenuButton.cs +++ b/UIInfoSuite2/UIElements/ShowCalendarAndBillboardOnGameMenuButton.cs @@ -121,9 +121,9 @@ private void DrawBillboard() { string hoverText = Game1.getMouseX() < _showBillboardButton.Value.bounds.X + _showBillboardButton.Value.bounds.Width / 2 - ? LanguageKeys.Calendar - : LanguageKeys.Billboard; - IClickableMenu.drawHoverText(Game1.spriteBatch, _helper.SafeGetString(hoverText), Game1.dialogueFont); + ? I18n.Calendar() + : I18n.Billboard(); + IClickableMenu.drawHoverText(Game1.spriteBatch, hoverText, Game1.dialogueFont); } } diff --git a/UIInfoSuite2/UIElements/ShowQueenOfSauceIcon.cs b/UIInfoSuite2/UIElements/ShowQueenOfSauceIcon.cs index 3536be15..a2c93c85 100644 --- a/UIInfoSuite2/UIElements/ShowQueenOfSauceIcon.cs +++ b/UIInfoSuite2/UIElements/ShowQueenOfSauceIcon.cs @@ -114,7 +114,7 @@ private void OnRenderedHud(object sender, RenderedHudEventArgs e) { IClickableMenu.drawHoverText( Game1.spriteBatch, - _helper.SafeGetString(LanguageKeys.TodaysRecipe) + _todaysRecipe.DisplayName, + I18n.TodaysRecipe() + _todaysRecipe.DisplayName, Game1.dialogueFont ); } diff --git a/UIInfoSuite2/UIElements/ShowRainyDayIcon.cs b/UIInfoSuite2/UIElements/ShowRainyDayIcon.cs index 4dd09e1f..daf434f7 100644 --- a/UIInfoSuite2/UIElements/ShowRainyDayIcon.cs +++ b/UIInfoSuite2/UIElements/ShowRainyDayIcon.cs @@ -228,25 +228,25 @@ private void SetValleyWeatherSprite() case Game1.weather_rain: _valleyWeather.IsRainyTomorrow = true; _valleyWeather.SpriteLocation = new Rectangle(0, 0, 15, 15); - _valleyWeather.HoverText = _helper.SafeGetString(LanguageKeys.RainNextDay); + _valleyWeather.HoverText = I18n.RainNextDay(); break; case Game1.weather_lightning: _valleyWeather.IsRainyTomorrow = true; _valleyWeather.SpriteLocation = new Rectangle(15, 0, 15, 15); - _valleyWeather.HoverText = _helper.SafeGetString(LanguageKeys.ThunderstormNextDay); + _valleyWeather.HoverText = I18n.ThunderstormNextDay(); break; case Game1.weather_snow: _valleyWeather.IsRainyTomorrow = true; _valleyWeather.SpriteLocation = new Rectangle(30, 0, 15, 15); - _valleyWeather.HoverText = _helper.SafeGetString(LanguageKeys.SnowNextDay); + _valleyWeather.HoverText = I18n.SnowNextDay(); break; case Game1.weather_green_rain: _valleyWeather.IsRainyTomorrow = true; _valleyWeather.SpriteLocation = new Rectangle(45, 0, 15, 15); - _valleyWeather.HoverText = _helper.SafeGetString(LanguageKeys.RainNextDay); + _valleyWeather.HoverText = I18n.RainNextDay(); break; default: @@ -262,19 +262,19 @@ private void SetIslandWeatherSprite() case Game1.weather_rain: _islandWeather.IsRainyTomorrow = true; _islandWeather.SpriteLocation = new Rectangle(60, 0, 18, 18); - _islandWeather.HoverText = _helper.SafeGetString(LanguageKeys.IslandRainNextDay); + _islandWeather.HoverText = I18n.IslandRainNextDay(); break; case Game1.weather_lightning: _islandWeather.IsRainyTomorrow = true; _islandWeather.SpriteLocation = new Rectangle(78, 0, 18, 18); - _islandWeather.HoverText = _helper.SafeGetString(LanguageKeys.IslandThunderstormNextDay); + _islandWeather.HoverText = I18n.IslandThunderstormNextDay(); break; case Game1.weather_green_rain: _islandWeather.IsRainyTomorrow = true; _islandWeather.SpriteLocation = new Rectangle(96, 0, 18, 18); - _islandWeather.HoverText = _helper.SafeGetString(LanguageKeys.IslandRainNextDay); + _islandWeather.HoverText = I18n.IslandRainNextDay(); break; default: diff --git a/UIInfoSuite2/UIElements/ShowRobinBuildingStatusIcon.cs b/UIInfoSuite2/UIElements/ShowRobinBuildingStatusIcon.cs index 2f6305c2..17cbdd6e 100644 --- a/UIInfoSuite2/UIElements/ShowRobinBuildingStatusIcon.cs +++ b/UIInfoSuite2/UIElements/ShowRobinBuildingStatusIcon.cs @@ -113,7 +113,7 @@ private bool GetRobinMessage(out string hoverText) if (building.daysOfConstructionLeft.Value > building.daysUntilUpgrade.Value) { hoverText = string.Format( - _helper.SafeGetString(LanguageKeys.RobinBuildingStatus), + I18n.RobinBuildingStatus(), building.daysOfConstructionLeft.Value ); return true; @@ -121,7 +121,7 @@ private bool GetRobinMessage(out string hoverText) // Add another translation string for this? hoverText = string.Format( - _helper.SafeGetString(LanguageKeys.RobinBuildingStatus), + I18n.RobinBuildingStatus(), building.daysUntilUpgrade.Value ); return true; @@ -131,7 +131,7 @@ private bool GetRobinMessage(out string hoverText) return false; } - hoverText = string.Format(_helper.SafeGetString(LanguageKeys.RobinHouseUpgradeStatus), remainingDays); + hoverText = string.Format(I18n.RobinHouseUpgradeStatus(), remainingDays); return true; } diff --git a/UIInfoSuite2/UIElements/ShowSeasonalBerry.cs b/UIInfoSuite2/UIElements/ShowSeasonalBerry.cs index a6eab1f9..673122c0 100644 --- a/UIInfoSuite2/UIElements/ShowSeasonalBerry.cs +++ b/UIInfoSuite2/UIElements/ShowSeasonalBerry.cs @@ -20,17 +20,17 @@ private void UpdateBerryForDay() { case "spring" when day is >= 15 and <= 18: _berrySpriteLocation = new Rectangle(128, 193, 15, 15); - _hoverText = _helper.SafeGetString(LanguageKeys.CanFindSalmonberry); + _hoverText = I18n.CanFindSalmonberry(); _spriteScale = 8 / 3f; break; case "fall" when day is >= 8 and <= 11: _berrySpriteLocation = new Rectangle(32, 272, 16, 16); - _hoverText = _helper.SafeGetString(LanguageKeys.CanFindBlackberry); + _hoverText = I18n.CanFindBlackberry(); _spriteScale = 5 / 2f; break; case "fall" when day >= 15 && ShowHazelnut: _berrySpriteLocation = new Rectangle(1, 274, 14, 14); - _hoverText = _helper.SafeGetString(LanguageKeys.CanFindHazelnut); + _hoverText = I18n.CanFindHazelnut(); _spriteScale = 20 / 7f; break; default: diff --git a/UIInfoSuite2/UIElements/ShowTravelingMerchant.cs b/UIInfoSuite2/UIElements/ShowTravelingMerchant.cs index 50198160..8d731c17 100644 --- a/UIInfoSuite2/UIElements/ShowTravelingMerchant.cs +++ b/UIInfoSuite2/UIElements/ShowTravelingMerchant.cs @@ -99,7 +99,7 @@ private void OnRenderedHud(object sender, RenderedHudEventArgs e) // Show text on hover if (ShouldDrawIcon() && (_travelingMerchantIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { - string hoverText = _helper.SafeGetString(LanguageKeys.TravelingMerchantIsInTown); + string hoverText = I18n.TravelingMerchantIsInTown(); IClickableMenu.drawHoverText(Game1.spriteBatch, hoverText, Game1.dialogueFont); } } From c6deef806843fbc42b8e1c21f5a73b3bb9711126 Mon Sep 17 00:00:00 2001 From: Drew Hoener Date: Tue, 11 Jun 2024 16:39:51 -0400 Subject: [PATCH 2/8] chore: Qualify SoundHelper sounds with the actual mod name, not a static string (cherry picked from commit 454d203ae4c0ad9902f66b1e6e7c8603f932fd36) --- UIInfoSuite2/Infrastructure/SoundHelper.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/UIInfoSuite2/Infrastructure/SoundHelper.cs b/UIInfoSuite2/Infrastructure/SoundHelper.cs index d9947953..a2cfe9d6 100644 --- a/UIInfoSuite2/Infrastructure/SoundHelper.cs +++ b/UIInfoSuite2/Infrastructure/SoundHelper.cs @@ -15,6 +15,7 @@ public class SoundHelper { private static readonly Lazy LazyInstance = new(() => new SoundHelper()); + private string _modId = "InfoSuite"; private bool _initialized; protected SoundHelper() { } @@ -28,14 +29,16 @@ public void Initialize(IModHelper helper) throw new InvalidOperationException("Cannot re-initialize sound helper"); } + _modId = helper.ModContent.ModID; + RegisterSound(helper, Sounds.LevelUp, "LevelUp.wav"); _initialized = true; } - private static string GetQualifiedSoundName(Sounds sound) + private string GetQualifiedSoundName(Sounds sound) { - return $"UIInfoSuite.sounds.{sound.ToString()}"; + return $"{_modId}.sounds.{sound.ToString()}"; } private static void RegisterSound( @@ -47,7 +50,7 @@ private static void RegisterSound( CueDefinition.LimitBehavior? limitBehavior = null ) { - CueDefinition newCueDefinition = new() { name = GetQualifiedSoundName(sound) }; + CueDefinition newCueDefinition = new() { name = Instance.GetQualifiedSoundName(sound) }; if (instanceLimit > 0) { @@ -72,6 +75,6 @@ private static void RegisterSound( public static void Play(Sounds sound) { - Game1.playSound(GetQualifiedSoundName(sound)); + Game1.playSound(Instance.GetQualifiedSoundName(sound)); } } From 4849cbb7f1038d83f4357cf3a5876690dbd3676e Mon Sep 17 00:00:00 2001 From: Drew Hoener Date: Tue, 11 Jun 2024 16:57:45 -0400 Subject: [PATCH 3/8] fix: Use correct logic for getting position above animal when on larger screens (cherry picked from commit 0e8a0cb15764c33920cdc8f982a9d5d95d7674af) --- .../UIElements/ShowWhenAnimalNeedsPet.cs | 243 +++++++++--------- 1 file changed, 123 insertions(+), 120 deletions(-) diff --git a/UIInfoSuite2/UIElements/ShowWhenAnimalNeedsPet.cs b/UIInfoSuite2/UIElements/ShowWhenAnimalNeedsPet.cs index bb87bb8c..89283d17 100644 --- a/UIInfoSuite2/UIElements/ShowWhenAnimalNeedsPet.cs +++ b/UIInfoSuite2/UIElements/ShowWhenAnimalNeedsPet.cs @@ -67,9 +67,9 @@ public void ToggleDisableOnMaxFriendshipOption(bool hideOnMaxFriendship) #region Event subscriptions - private void OnWarped(object sender, WarpedEventArgs e) { } + private void OnWarped(object? sender, WarpedEventArgs e) { } - private void OnRenderingHud_DrawNeedsPetTooltip(object sender, RenderingHudEventArgs e) + private void OnRenderingHud_DrawNeedsPetTooltip(object? sender, RenderingHudEventArgs e) { if (UIElementUtils.IsRenderingNormally() && Game1.activeClickableMenu == null && @@ -80,7 +80,7 @@ private void OnRenderingHud_DrawNeedsPetTooltip(object sender, RenderingHudEvent } } - private void OnRenderingHud_DrawAnimalHasProduct(object sender, RenderingHudEventArgs e) + private void OnRenderingHud_DrawAnimalHasProduct(object? sender, RenderingHudEventArgs e) { if (UIElementUtils.IsRenderingNormally() && Game1.activeClickableMenu == null && @@ -90,7 +90,7 @@ private void OnRenderingHud_DrawAnimalHasProduct(object sender, RenderingHudEven } } - private void UpdateTicked(object sender, UpdateTickedEventArgs e) + private void UpdateTicked(object? sender, UpdateTickedEventArgs e) { if (!UIElementUtils.IsRenderingNormally() || Game1.activeClickableMenu != null || @@ -109,56 +109,60 @@ private void UpdateTicked(object sender, UpdateTickedEventArgs e) private void DrawAnimalHasProduct() { NetLongDictionary>? animalsInCurrentLocation = GetAnimalsInCurrentLocation(); - if (animalsInCurrentLocation != null) + if (animalsInCurrentLocation == null) { - foreach (KeyValuePair animal in animalsInCurrentLocation.Pairs) + return; + } + + foreach (KeyValuePair animal in animalsInCurrentLocation.Pairs) + { + FarmAnimalHarvestType? harvestType = animal.Value.GetHarvestType(); + if (harvestType == FarmAnimalHarvestType.DropOvernight || + animal.Value.IsEmoting || + animal.Value.currentProduce.Value == "430" || // 430 is truffle + animal.Value.currentProduce.Value == null || + animal.Value.age.Value < animal.Value.GetAnimalData().DaysToMature) { - FarmAnimalHarvestType? harvestType = animal.Value.GetHarvestType(); - if (harvestType != FarmAnimalHarvestType.DropOvernight && - !animal.Value.IsEmoting && - animal.Value.currentProduce.Value != "430" && // 430 is truffle - animal.Value.currentProduce.Value != null && - animal.Value.age.Value >= animal.Value.GetAnimalData().DaysToMature) - { - Vector2 positionAboveAnimal = GetPetPositionAboveAnimal(animal.Value); - positionAboveAnimal.Y += (float)(Math.Sin( - Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 300.0 + - animal.Value.Name.GetHashCode() - ) * - 5.0); - Game1.spriteBatch.Draw( - Game1.emoteSpriteSheet, - Utility.ModifyCoordinatesForUIScale(new Vector2(positionAboveAnimal.X + 14f, positionAboveAnimal.Y)), - new Rectangle( - 3 * (Game1.tileSize / 4) % Game1.emoteSpriteSheet.Width, - 3 * (Game1.tileSize / 4) / Game1.emoteSpriteSheet.Width * (Game1.tileSize / 4), - Game1.tileSize / 4, - Game1.tileSize / 4 - ), - Color.White * 0.9f, - 0.0f, - Vector2.Zero, - 4f, - SpriteEffects.None, - 1f - ); - - string produceItemId = animal.Value.currentProduce.Value; - ParsedItemData? produceData = ItemRegistry.GetData(produceItemId); - Rectangle sourceRectangle = produceData.GetSourceRect(); - Game1.spriteBatch.Draw( - produceData.GetTexture(), - Utility.ModifyCoordinatesForUIScale(new Vector2(positionAboveAnimal.X + 28f, positionAboveAnimal.Y + 8f)), - sourceRectangle, - Color.White * 0.9f, - 0.0f, - Vector2.Zero, - 2.2f, - SpriteEffects.None, - 1f - ); - } + continue; } + + Vector2 positionAboveAnimal = GetPetPositionAboveAnimal(animal.Value); + positionAboveAnimal.Y += (float)(Math.Sin( + Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 300.0 + + animal.Value.Name.GetHashCode() + ) * + 5.0); + Game1.spriteBatch.Draw( + Game1.emoteSpriteSheet, + Utility.ModifyCoordinatesForUIScale(new Vector2(positionAboveAnimal.X + 14f, positionAboveAnimal.Y)), + new Rectangle( + 3 * (Game1.tileSize / 4) % Game1.emoteSpriteSheet.Width, + 3 * (Game1.tileSize / 4) / Game1.emoteSpriteSheet.Width * (Game1.tileSize / 4), + Game1.tileSize / 4, + Game1.tileSize / 4 + ), + Color.White * 0.9f, + 0.0f, + Vector2.Zero, + 4f, + SpriteEffects.None, + 1f + ); + + string produceItemId = animal.Value.currentProduce.Value; + ParsedItemData? produceData = ItemRegistry.GetData(produceItemId); + Rectangle sourceRectangle = produceData.GetSourceRect(); + Game1.spriteBatch.Draw( + produceData.GetTexture(), + Utility.ModifyCoordinatesForUIScale(new Vector2(positionAboveAnimal.X + 28f, positionAboveAnimal.Y + 8f)), + sourceRectangle, + Color.White * 0.9f, + 0.0f, + Vector2.Zero, + 2.2f, + SpriteEffects.None, + 1f + ); } } @@ -166,41 +170,45 @@ private void DrawIconForFarmAnimals() { NetLongDictionary>? animalsInCurrentLocation = GetAnimalsInCurrentLocation(); - if (animalsInCurrentLocation != null) + if (animalsInCurrentLocation == null) { - foreach (KeyValuePair animal in animalsInCurrentLocation.Pairs) + return; + } + + foreach (KeyValuePair animal in animalsInCurrentLocation.Pairs) + { + if (animal.Value.IsEmoting || + animal.Value.wasPet.Value || + (animal.Value.friendshipTowardFarmer.Value >= 1000 && HideOnMaxFriendship)) { - if (!animal.Value.IsEmoting && - !animal.Value.wasPet.Value && - (animal.Value.friendshipTowardFarmer.Value < 1000 || !HideOnMaxFriendship)) - { - Vector2 positionAboveAnimal = GetPetPositionAboveAnimal(animal.Value); - string animalType = animal.Value.type.Value.ToLower(); - - if (animalType.Contains("cow") || - animalType.Contains("sheep") || - animalType.Contains("goat") || - animalType.Contains("pig")) - { - positionAboveAnimal.X += 50f; - positionAboveAnimal.Y += 50f; - } - - Game1.spriteBatch.Draw( - Game1.mouseCursors, - Utility.ModifyCoordinatesForUIScale( - new Vector2(positionAboveAnimal.X, positionAboveAnimal.Y + _yMovementPerDraw.Value) - ), - new Rectangle(32, 0, 16, 16), - Color.White * _alpha.Value, - 0.0f, - Vector2.Zero, - 4f, - SpriteEffects.None, - 1f - ); - } + continue; } + + Vector2 positionAboveAnimal = GetPetPositionAboveAnimal(animal.Value); + string animalType = animal.Value.type.Value.ToLower(); + + if (animalType.Contains("cow") || + animalType.Contains("sheep") || + animalType.Contains("goat") || + animalType.Contains("pig")) + { + positionAboveAnimal.X += 50f; + positionAboveAnimal.Y += 50f; + } + + Game1.spriteBatch.Draw( + Game1.mouseCursors, + Utility.ModifyCoordinatesForUIScale( + new Vector2(positionAboveAnimal.X, positionAboveAnimal.Y + _yMovementPerDraw.Value) + ), + new Rectangle(32, 0, 16, 16), + Color.White * _alpha.Value, + 0.0f, + Vector2.Zero, + 4f, + SpriteEffects.None, + 1f + ); } } @@ -208,54 +216,49 @@ private void DrawIconForPets() { foreach (NPC? character in Game1.currentLocation.characters) { - if (character is Pet pet && - !pet.lastPetDay.Values.Any(day => day == Game1.Date.TotalDays) && - (pet.friendshipTowardFarmer.Value < 1000 || !HideOnMaxFriendship)) + if (character is not Pet pet || + pet.lastPetDay.Values.Any(day => day == Game1.Date.TotalDays) || + (pet.friendshipTowardFarmer.Value >= 1000 && HideOnMaxFriendship)) { - Vector2 positionAboveAnimal = GetPetPositionAboveAnimal(character); - positionAboveAnimal.X += 50f; - positionAboveAnimal.Y += 30f; - Game1.spriteBatch.Draw( - Game1.mouseCursors, - Utility.ModifyCoordinatesForUIScale( - new Vector2(positionAboveAnimal.X, positionAboveAnimal.Y + _yMovementPerDraw.Value) - ), - new Rectangle(32, 0, 16, 16), - Color.White * _alpha.Value, - 0.0f, - Vector2.Zero, - 4f, - SpriteEffects.None, - 1f - ); + continue; } + + Vector2 positionAboveAnimal = GetPetPositionAboveAnimal(character); + + positionAboveAnimal.X += 50f; + positionAboveAnimal.Y += 20f; + Game1.spriteBatch.Draw( + Game1.mouseCursors, + Utility.ModifyCoordinatesForUIScale( + new Vector2(positionAboveAnimal.X, positionAboveAnimal.Y + _yMovementPerDraw.Value) + ), + new Rectangle(32, 0, 16, 16), + Color.White * _alpha.Value, + 0.0f, + Vector2.Zero, + 4f, + SpriteEffects.None, + 1f + ); } } private Vector2 GetPetPositionAboveAnimal(Character animal) { - return new Vector2( - Game1.viewport.Width <= Game1.currentLocation.map.DisplayWidth - ? animal.position.X - Game1.viewport.X + 16 - : animal.position.X + ((Game1.viewport.Width - Game1.currentLocation.map.DisplayWidth) / 2 + 18), - Game1.viewport.Height <= Game1.currentLocation.map.DisplayHeight - ? animal.position.Y - Game1.viewport.Y - 34 - : animal.position.Y + ((Game1.viewport.Height - Game1.currentLocation.map.DisplayHeight) / 2 - 50) - ); + Vector2 animalPosition = animal.getLocalPosition(Game1.viewport); + animalPosition.X += 10; + animalPosition.Y -= 34; + return animalPosition; } - private NetLongDictionary> GetAnimalsInCurrentLocation() + private NetLongDictionary>? GetAnimalsInCurrentLocation() { - NetLongDictionary> animals = null; - - if (Game1.currentLocation is AnimalHouse) + NetLongDictionary>? animals = Game1.currentLocation switch { - animals = (Game1.currentLocation as AnimalHouse).animals; - } - else if (Game1.currentLocation is Farm) - { - animals = (Game1.currentLocation as Farm).animals; - } + AnimalHouse animalHouse => animalHouse.Animals, + Farm farm => farm.Animals, + _ => null + }; return animals; } From 64b7208ef37b0c207acdd33b6b89bec131755dcb Mon Sep 17 00:00:00 2001 From: Drew Hoener Date: Tue, 11 Jun 2024 17:29:55 -0400 Subject: [PATCH 4/8] chore: Refactor DeluxeJournal to the modcompat enum --- UIInfoSuite2/Compatibility/ApiManager.cs | 1 + UIInfoSuite2/ModEntry.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/UIInfoSuite2/Compatibility/ApiManager.cs b/UIInfoSuite2/Compatibility/ApiManager.cs index 6ed2da3d..3486c14a 100644 --- a/UIInfoSuite2/Compatibility/ApiManager.cs +++ b/UIInfoSuite2/Compatibility/ApiManager.cs @@ -8,6 +8,7 @@ public static class ModCompat { public const string CustomBush = "furyx639.CustomBush"; public const string Gmcm = "spacechase0.GenericModConfigMenu"; + public const string DeluxeJournal = "MolsonCAD.DeluxeJournal"; } public static class ApiManager diff --git a/UIInfoSuite2/ModEntry.cs b/UIInfoSuite2/ModEntry.cs index 3c1ed9cd..451c7601 100644 --- a/UIInfoSuite2/ModEntry.cs +++ b/UIInfoSuite2/ModEntry.cs @@ -28,9 +28,9 @@ public class ModEntry : Mod #region Entry public override void Entry(IModHelper helper) { + I18n.Init(helper.Translation); Reflection = helper.Reflection; MonitorObject = Monitor; - I18n.Init(helper.Translation); _skipIntro = new SkipIntro(helper.Events); _modConfig = Helper.ReadConfig(); From 4ae1399d43fc801435e5ab71b25c755b0aac41cb Mon Sep 17 00:00:00 2001 From: Drew Hoener Date: Wed, 12 Jun 2024 20:58:28 -0400 Subject: [PATCH 5/8] fix: Don't display weeds as fertilizer if they somehow get in there (cherry picked from commit 1a072f70f73bbf50f3de17b27184e46dd21502a6) --- UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs index d1d42954..575ac2b6 100644 --- a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs +++ b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs @@ -411,7 +411,13 @@ public static bool CropRender(TerrainFeature? terrain, List entries) return false; } - string fertilizerStr = string.IsNullOrEmpty(hoeDirt.fertilizer.Value) ? "" : GetFertilizerString(hoeDirt); + var fertilizerStr = ""; + // Special case, someone had a case where id "0" was set in fertilizer, which is weeds... + // Weird, right? + if (!string.IsNullOrEmpty(hoeDirt.fertilizer.Value) && !"0".Equals(hoeDirt.fertilizer.Value)) + { + fertilizerStr = GetFertilizerString(hoeDirt); + } if (hoeDirt.crop is not null && !hoeDirt.crop.dead.Value) { From 1ae637b6e9b04b0240961ef0f93c248358836e3c Mon Sep 17 00:00:00 2001 From: Drew Hoener Date: Thu, 13 Jun 2024 09:50:04 -0400 Subject: [PATCH 6/8] fix: Pan should be included in upgraded tools (cherry picked from commit 8577e509d6d4b4c5175459d6b4de371f071a4aeb) --- UIInfoSuite2/UIElements/ShowToolUpgradeStatus.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/UIInfoSuite2/UIElements/ShowToolUpgradeStatus.cs b/UIInfoSuite2/UIElements/ShowToolUpgradeStatus.cs index b97f6b66..a015572c 100644 --- a/UIInfoSuite2/UIElements/ShowToolUpgradeStatus.cs +++ b/UIInfoSuite2/UIElements/ShowToolUpgradeStatus.cs @@ -28,6 +28,7 @@ private void UpdateToolInfo() or Pickaxe or Hoe or WateringCan + or Pan or GenericTool { IndexOfMenuItemView: >= 13 and <= 16 }) { ParsedItemData? itemData = ItemRegistry.GetDataOrErrorItem(toolBeingUpgraded.QualifiedItemId); @@ -60,7 +61,18 @@ or WateringCan #region Properties private readonly PerScreen _hoverText = new(); private readonly PerScreen _toolBeingUpgraded = new(); - private readonly PerScreen _toolUpgradeIcon = new(); + + private readonly PerScreen _toolUpgradeIcon = new( + () => + { + return new ClickableTextureComponent( + new Rectangle(0, 0, 40, 40), + Game1.mouseCursors, + new Rectangle(322, 498, 12, 12), + 40 / 12f + ); + } + ); private readonly IModHelper _helper; #endregion From 150a755e6e10325686cb28a16bdc07b155a530bf Mon Sep 17 00:00:00 2001 From: Drew Hoener Date: Tue, 22 Oct 2024 14:27:17 -0400 Subject: [PATCH 7/8] Bump version for nexus release --- UIInfoSuite2/UIInfoSuite2.csproj | 2 +- UIInfoSuite2/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/UIInfoSuite2/UIInfoSuite2.csproj b/UIInfoSuite2/UIInfoSuite2.csproj index 741d7d6f..31c0776c 100644 --- a/UIInfoSuite2/UIInfoSuite2.csproj +++ b/UIInfoSuite2/UIInfoSuite2.csproj @@ -1,6 +1,6 @@  - 2.3.4 + 2.3.5 net6.0 enable $(SolutionDir)\Releases diff --git a/UIInfoSuite2/manifest.json b/UIInfoSuite2/manifest.json index 8a7068a5..0af72370 100644 --- a/UIInfoSuite2/manifest.json +++ b/UIInfoSuite2/manifest.json @@ -1,7 +1,7 @@ { "Name": "UI Info Suite 2", "Author": "Annosz", - "Version": "2.3.4", + "Version": "2.3.5", "Description": "Adds a useful information to the user interface. Based on Cdaragorn's excellent UI Info Suite.", "UniqueID": "Annosz.UiInfoSuite2", "EntryDll": "UIInfoSuite2.dll", From 13af2e3f2ba4ff085993617ce4de7ec49f3cbd67 Mon Sep 17 00:00:00 2001 From: Drew Hoener Date: Tue, 22 Oct 2024 14:45:55 -0400 Subject: [PATCH 8/8] Update for nexus --- README.md | 7 +++++++ UIInfoSuite2/manifest.json | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a3742da6..66f4eee5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,11 @@ # If you are here to install the mod + +## We're on Nexus again!! +Big thank you to the Nexus support staff for clearing us to be back on the NexusMods site under the UIInfoSuite name! + +**[Download Here](https://www.nexusmods.com/stardewvalley/mods/7098)** + +### GitHub Download **Go to the [Releases page](https://github.com/Annosz/UIInfoSuite2/releases) on the side, where you can always find the latest release. Download the UIInfoSuite2.zip file and copy it's content to the mod folder.** ![image](https://user-images.githubusercontent.com/10620868/145580465-5dc6cd97-e4da-4830-a639-8f3fb94a1001.png) _Do **NOT** download the Source code (zip) or Source code (tar.gz). Also, do **NOT** use the green Code > Download ZIP button on the main page. These methods will only give you the source code but you will not be able to run the mod and use it with Stardew Valley!_ diff --git a/UIInfoSuite2/manifest.json b/UIInfoSuite2/manifest.json index 0af72370..7b050624 100644 --- a/UIInfoSuite2/manifest.json +++ b/UIInfoSuite2/manifest.json @@ -7,6 +7,7 @@ "EntryDll": "UIInfoSuite2.dll", "MinimumApiVersion": "4.0.5", "UpdateKeys": [ - "GitHub:Annosz/UIInfoSuite2" + "GitHub:Annosz/UIInfoSuite2", + "Nexus:7098" ] }