From 897214ecef12fd1845a7dee96c6e233a33aefa3e Mon Sep 17 00:00:00 2001
From: Zamiell <5511220+Zamiell@users.noreply.github.com>
Date: Thu, 4 Apr 2024 18:36:49 -0400
Subject: [PATCH 01/11] feat: tree stage tooltip
---
UIInfoSuite2/Infrastructure/LanguageKeys.cs | 3 +-
.../UIElements/ShowCropAndBarrelTime.cs | 72 ++++++++++++++++---
UIInfoSuite2/i18n/default.json | 3 +-
3 files changed, 66 insertions(+), 12 deletions(-)
diff --git a/UIInfoSuite2/Infrastructure/LanguageKeys.cs b/UIInfoSuite2/Infrastructure/LanguageKeys.cs
index 341f822a..4c6bca17 100644
--- a/UIInfoSuite2/Infrastructure/LanguageKeys.cs
+++ b/UIInfoSuite2/Infrastructure/LanguageKeys.cs
@@ -8,6 +8,7 @@ public static class LanguageKeys
public const string Hours = "Hours";
public const string Minutes = "Minutes";
public const string ReadyToHarvest = "ReadyToHarvest";
+ public const string Tree = "Tree";
public const string TodaysRecipe = "TodaysRecipe";
public const string TravelingMerchantIsInTown = "TravelingMerchantIsInTown";
public const string RainNextDay = "RainNextDay";
@@ -33,5 +34,5 @@ public static class LanguageKeys
public const string NpcBirthday = "NpcBirthday";
public const string CanFindSalmonberry = "CanFindSalmonberry";
public const string CanFindBlackberry = "CanFindBlackberry";
- public const string CanFindHazelnut = "CanFindHazelnut";
+ public const string CanFindHazelnut = "CanFindHazelnut";
}
diff --git a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
index 342bcc40..e16daf80 100644
--- a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
+++ b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
@@ -349,17 +349,57 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
}
}
}
- else if (terrain is FruitTree tree)
- {
- string itemIdOfFruit =
- tree.GetData().Fruit.First().ItemId; // TODO 1.6: Might be broken because of more than one item.
- string? text = ItemRegistry.GetData(itemIdOfFruit).DisplayName;
- if (tree.daysUntilMature.Value > 0)
+ else if (terrain is Tree tree)
+ {
+ string treeTypeName = GetTreeTypeName(tree.treeType.Value);
+ string treeText = _helper.SafeGetString(LanguageKeys.Tree);
+ string treeName = $"{treeTypeName} {treeText}";
+
+ string text;
+
+ if (tree.growthStage.Value < 5)
+ {
+ // string daysToMatureText = _helper.SafeGetString(LanguageKeys.DaysToMature);
+ text = $"{treeName}\nstage {tree.growthStage.Value} / 5";
+ }
+ else
+ {
+ text = treeName;
+ }
+
+ if (Game1.options.gamepadControls && Game1.timerUntilMouseFade <= 0)
{
- text += Environment.NewLine +
- tree.daysUntilMature.Value +
- " " +
- _helper.SafeGetString(LanguageKeys.DaysToMature);
+ Vector2 tilePosition =
+ Utility.ModifyCoordinatesForUIScale(Game1.GlobalToLocal(terrain.Tile * Game1.tileSize));
+ overrideX = (int)(tilePosition.X + Utility.ModifyCoordinateForUIScale(32));
+ overrideY = (int)(tilePosition.Y + Utility.ModifyCoordinateForUIScale(32));
+ }
+
+ IClickableMenu.drawHoverText(
+ Game1.spriteBatch,
+ text,
+ Game1.smallFont,
+ overrideX: overrideX,
+ overrideY: overrideY
+ );
+ }
+ else if (terrain is FruitTree fruitTree)
+ {
+ string itemIdOfFruit = fruitTree.GetData().Fruit.First().ItemId; // TODO 1.6: Might be broken because of more than one item.
+ string fruitName = ItemRegistry.GetData(itemIdOfFruit).DisplayName ?? "Unknown";
+ string treeText = _helper.SafeGetString(LanguageKeys.Tree);
+ string treeName = $"{fruitName} {treeText}";
+
+ string text;
+
+ if (fruitTree.daysUntilMature.Value > 0)
+ {
+ string daysToMatureText = _helper.SafeGetString(LanguageKeys.DaysToMature);
+ text = $"{treeName}\n{fruitTree.daysUntilMature.Value} {daysToMatureText}";
+ }
+ else
+ {
+ text = treeName;
}
if (Game1.options.gamepadControls && Game1.timerUntilMouseFade <= 0)
@@ -410,6 +450,18 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
}
}
}
+ }
+
+ private string GetTreeTypeName(string treeType)
+ {
+ switch (treeType)
+ {
+ case "1": return "Oak";
+ case "2": return "Maple";
+ case "3": return "Pine";
+ case "13": return "Mystic";
+ default: return "Unknown";
+ }
}
private string? GetCropHarvestName(Crop crop)
diff --git a/UIInfoSuite2/i18n/default.json b/UIInfoSuite2/i18n/default.json
index 25ec79f2..8cf583c0 100644
--- a/UIInfoSuite2/i18n/default.json
+++ b/UIInfoSuite2/i18n/default.json
@@ -12,7 +12,8 @@
"Minutes": "minutes",
//Harvest
"DaysToMature": "days to mature",
- "ReadyToHarvest": "Ready To Harvest!",
+ "ReadyToHarvest": "Ready to harvest!",
+ "Tree": "Tree",
//Display icons - General
"TodaysRecipe": "Today's Recipe: ",
"TravelingMerchantIsInTown": "Traveling merchant is in town!",
From ee8181c693195f991e68fc2571bbf4a32f71da9a Mon Sep 17 00:00:00 2001
From: Zamiell <5511220+Zamiell@users.noreply.github.com>
Date: Thu, 4 Apr 2024 19:00:10 -0400
Subject: [PATCH 02/11] feat: missing tree names
---
UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
index e16daf80..5c333a11 100644
--- a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
+++ b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
@@ -354,9 +354,13 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
string treeTypeName = GetTreeTypeName(tree.treeType.Value);
string treeText = _helper.SafeGetString(LanguageKeys.Tree);
string treeName = $"{treeTypeName} {treeText}";
+ if (tree.stump.Value)
+ {
+ treeName += " (stump)";
+ }
string text;
-
+
if (tree.growthStage.Value < 5)
{
// string daysToMatureText = _helper.SafeGetString(LanguageKeys.DaysToMature);
@@ -459,8 +463,14 @@ private string GetTreeTypeName(string treeType)
case "1": return "Oak";
case "2": return "Maple";
case "3": return "Pine";
+ case "6": return "Palm";
+ case "7": return "Mushroom";
+ case "8": return "Mahogany";
+ case "10": return "Green Rain Type 1";
+ case "11": return "Green Rain Type 2";
+ case "12": return "Green Rain Type 3";
case "13": return "Mystic";
- default: return "Unknown";
+ default: return $"Unknown (#{treeType})";
}
}
From 049c1b891ca2432115359aeafbb9e07b4e62f0dc Mon Sep 17 00:00:00 2001
From: Zamiell <5511220+Zamiell@users.noreply.github.com>
Date: Thu, 4 Apr 2024 19:05:38 -0400
Subject: [PATCH 03/11] fix: warnings
---
.../UIElements/ShowCropAndBarrelTime.cs | 27 +++++++++----------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
index 5c333a11..288b5bda 100644
--- a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
+++ b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
@@ -53,7 +53,7 @@ public void ToggleOption(bool showCropAndBarrelTimes)
/// Raised after the game state is updated (≈60 times per second).
/// The event sender.
/// The event arguments.
- private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
+ private void OnUpdateTicked(object? sender, UpdateTickedEventArgs e)
{
if (!e.IsMultipleOf(4))
{
@@ -112,7 +112,7 @@ private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
///
/// The event sender.
/// The event arguments.
- private void OnRenderingHud(object sender, RenderingHudEventArgs e)
+ private void OnRenderingHud(object? sender, RenderingHudEventArgs e)
{
if (Game1.activeClickableMenu != null)
{
@@ -138,9 +138,9 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
currentTileBuilding.buildingChests.Count > inputKey &&
!currentTileBuilding.buildingChests[inputKey].isEmpty())
{
- var wheatCount = 0;
- var beetCount = 0;
- var unmilledriceCount = 0;
+ int wheatCount = 0;
+ int beetCount = 0;
+ int unmilledriceCount = 0;
foreach (Item item in currentTileBuilding.buildingChests[inputKey].Items)
{
@@ -221,10 +221,9 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
hoverText.AppendLine(currentTile.heldObject.Value.DisplayName);
- if (currentTile is Cask)
+ if (currentTile is Cask cask)
{
- var currentCask = currentTile as Cask;
- hoverText.Append((int)(currentCask.daysToMature.Value / currentCask.agingRate.Value))
+ hoverText.Append((int)(cask.daysToMature.Value / cask.agingRate.Value))
.Append(" " + _helper.SafeGetString(LanguageKeys.DaysToMature));
}
else
@@ -290,12 +289,11 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
}
else if (terrain != null)
{
- if (terrain is HoeDirt)
+ if (terrain is HoeDirt hoeDirt)
{
- var hoeDirt = terrain as HoeDirt;
if (hoeDirt.crop != null && !hoeDirt.crop.dead.Value)
{
- var num = 0;
+ int num = 0;
if (hoeDirt.crop.fullyGrown.Value && hoeDirt.crop.dayOfCurrentPhase.Value > 0)
{
@@ -303,7 +301,7 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
}
else
{
- for (var i = 0; i < hoeDirt.crop.phaseDays.Count - 1; ++i)
+ for (int i = 0; i < hoeDirt.crop.phaseDays.Count - 1; ++i)
{
if (hoeDirt.crop.currentPhase.Value == i)
{
@@ -360,7 +358,7 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
}
string text;
-
+
if (tree.growthStage.Value < 5)
{
// string daysToMatureText = _helper.SafeGetString(LanguageKeys.DaysToMature);
@@ -456,7 +454,8 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
}
}
- private string GetTreeTypeName(string treeType)
+ // See: https://stardewvalleywiki.com/Trees
+ private static string GetTreeTypeName(string treeType)
{
switch (treeType)
{
From afff530278cfc136d46cbeae0a93e8670a92fea1 Mon Sep 17 00:00:00 2001
From: Zamiell <5511220+Zamiell@users.noreply.github.com>
Date: Thu, 4 Apr 2024 19:06:33 -0400
Subject: [PATCH 04/11] chore: cleanup
---
UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
index 288b5bda..76f3e7a7 100644
--- a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
+++ b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
@@ -361,7 +361,6 @@ private void OnRenderingHud(object? sender, RenderingHudEventArgs e)
if (tree.growthStage.Value < 5)
{
- // string daysToMatureText = _helper.SafeGetString(LanguageKeys.DaysToMature);
text = $"{treeName}\nstage {tree.growthStage.Value} / 5";
}
else
From e010fd5c8ff62a4cc83cc2790d98f45f0023d426 Mon Sep 17 00:00:00 2001
From: Zamiell <5511220+Zamiell@users.noreply.github.com>
Date: Thu, 4 Apr 2024 20:01:51 -0400
Subject: [PATCH 05/11] feat: crop+tree fertilization
---
UIInfoSuite2/Infrastructure/LanguageKeys.cs | 3 +-
.../UIElements/ShowCropAndBarrelTime.cs | 107 ++++++++++--------
UIInfoSuite2/i18n/default.json | 1 +
3 files changed, 62 insertions(+), 49 deletions(-)
diff --git a/UIInfoSuite2/Infrastructure/LanguageKeys.cs b/UIInfoSuite2/Infrastructure/LanguageKeys.cs
index 4c6bca17..abb8049b 100644
--- a/UIInfoSuite2/Infrastructure/LanguageKeys.cs
+++ b/UIInfoSuite2/Infrastructure/LanguageKeys.cs
@@ -8,7 +8,8 @@ public static class LanguageKeys
public const string Hours = "Hours";
public const string Minutes = "Minutes";
public const string ReadyToHarvest = "ReadyToHarvest";
- public const string Tree = "Tree";
+ public const string With = "With";
+ public const string Tree = "Tree";
public const string TodaysRecipe = "TodaysRecipe";
public const string TravelingMerchantIsInTown = "TravelingMerchantIsInTown";
public const string RainNextDay = "RainNextDay";
diff --git a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
index 76f3e7a7..1f4388e7 100644
--- a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
+++ b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
@@ -326,6 +326,13 @@ private void OnRenderingHud(object? sender, RenderingHudEventArgs e)
else
{
hoverText.Append(_helper.SafeGetString(LanguageKeys.ReadyToHarvest));
+ }
+
+ if (!string.IsNullOrEmpty(hoeDirt.fertilizer.Value))
+ {
+ string fertilizerName = ItemRegistry.GetData(hoeDirt.fertilizer.Value).DisplayName ?? "Unknown Fertilizer";
+ string withText = _helper.SafeGetString(LanguageKeys.With);
+ hoverText.Append($"\n({withText} {fertilizerName})");
}
if (Game1.options.gamepadControls && Game1.timerUntilMouseFade <= 0)
@@ -348,26 +355,30 @@ private void OnRenderingHud(object? sender, RenderingHudEventArgs e)
}
}
else if (terrain is Tree tree)
- {
- string treeTypeName = GetTreeTypeName(tree.treeType.Value);
- string treeText = _helper.SafeGetString(LanguageKeys.Tree);
- string treeName = $"{treeTypeName} {treeText}";
- if (tree.stump.Value)
- {
- treeName += " (stump)";
- }
-
- string text;
-
- if (tree.growthStage.Value < 5)
- {
- text = $"{treeName}\nstage {tree.growthStage.Value} / 5";
- }
- else
- {
- text = treeName;
+ {
+ string treeTypeName = GetTreeTypeName(tree.treeType.Value);
+ string treeText = _helper.SafeGetString(LanguageKeys.Tree);
+ string treeName = $"{treeTypeName} {treeText}";
+ if (tree.stump.Value)
+ {
+ treeName += " (stump)";
}
+ string text;
+
+ if (tree.growthStage.Value < 5)
+ {
+ text = $"{treeName}\nstage {tree.growthStage.Value} / 5";
+ if (tree.fertilized.Value)
+ {
+ text += $"\n(fertilized)";
+ }
+ }
+ else
+ {
+ text = treeName;
+ }
+
if (Game1.options.gamepadControls && Game1.timerUntilMouseFade <= 0)
{
Vector2 tilePosition =
@@ -382,25 +393,25 @@ private void OnRenderingHud(object? sender, RenderingHudEventArgs e)
Game1.smallFont,
overrideX: overrideX,
overrideY: overrideY
- );
+ );
}
else if (terrain is FruitTree fruitTree)
{
string itemIdOfFruit = fruitTree.GetData().Fruit.First().ItemId; // TODO 1.6: Might be broken because of more than one item.
- string fruitName = ItemRegistry.GetData(itemIdOfFruit).DisplayName ?? "Unknown";
- string treeText = _helper.SafeGetString(LanguageKeys.Tree);
- string treeName = $"{fruitName} {treeText}";
-
- string text;
-
+ string fruitName = ItemRegistry.GetData(itemIdOfFruit).DisplayName ?? "Unknown";
+ string treeText = _helper.SafeGetString(LanguageKeys.Tree);
+ string treeName = $"{fruitName} {treeText}";
+
+ string text;
+
if (fruitTree.daysUntilMature.Value > 0)
- {
+ {
string daysToMatureText = _helper.SafeGetString(LanguageKeys.DaysToMature);
text = $"{treeName}\n{fruitTree.daysUntilMature.Value} {daysToMatureText}";
- }
+ }
else
- {
- text = treeName;
+ {
+ text = treeName;
}
if (Game1.options.gamepadControls && Game1.timerUntilMouseFade <= 0)
@@ -451,25 +462,25 @@ private void OnRenderingHud(object? sender, RenderingHudEventArgs e)
}
}
}
- }
-
- // See: https://stardewvalleywiki.com/Trees
- private static string GetTreeTypeName(string treeType)
- {
- switch (treeType)
- {
- case "1": return "Oak";
- case "2": return "Maple";
- case "3": return "Pine";
- case "6": return "Palm";
- case "7": return "Mushroom";
- case "8": return "Mahogany";
- case "10": return "Green Rain Type 1";
- case "11": return "Green Rain Type 2";
- case "12": return "Green Rain Type 3";
- case "13": return "Mystic";
- default: return $"Unknown (#{treeType})";
- }
+ }
+
+ // See: https://stardewvalleywiki.com/Trees
+ private static string GetTreeTypeName(string treeType)
+ {
+ switch (treeType)
+ {
+ case "1": return "Oak";
+ case "2": return "Maple";
+ case "3": return "Pine";
+ case "6": return "Palm";
+ case "7": return "Mushroom";
+ case "8": return "Mahogany";
+ case "10": return "Green Rain Type 1";
+ case "11": return "Green Rain Type 2";
+ case "12": return "Green Rain Type 3";
+ case "13": return "Mystic";
+ default: return $"Unknown (#{treeType})";
+ }
}
private string? GetCropHarvestName(Crop crop)
diff --git a/UIInfoSuite2/i18n/default.json b/UIInfoSuite2/i18n/default.json
index 8cf583c0..51ce956e 100644
--- a/UIInfoSuite2/i18n/default.json
+++ b/UIInfoSuite2/i18n/default.json
@@ -13,6 +13,7 @@
//Harvest
"DaysToMature": "days to mature",
"ReadyToHarvest": "Ready to harvest!",
+ "With": "with",
"Tree": "Tree",
//Display icons - General
"TodaysRecipe": "Today's Recipe: ",
From 0bfcaf74605d85b670082f1ed4be7cfdeba041d1 Mon Sep 17 00:00:00 2001
From: Zamiell <5511220+Zamiell@users.noreply.github.com>
Date: Thu, 4 Apr 2024 20:03:27 -0400
Subject: [PATCH 06/11] fix: use i18n
---
UIInfoSuite2/Infrastructure/LanguageKeys.cs | 1 +
UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs | 3 ++-
UIInfoSuite2/i18n/default.json | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/UIInfoSuite2/Infrastructure/LanguageKeys.cs b/UIInfoSuite2/Infrastructure/LanguageKeys.cs
index abb8049b..9d880235 100644
--- a/UIInfoSuite2/Infrastructure/LanguageKeys.cs
+++ b/UIInfoSuite2/Infrastructure/LanguageKeys.cs
@@ -9,6 +9,7 @@ public static class LanguageKeys
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 TodaysRecipe = "TodaysRecipe";
public const string TravelingMerchantIsInTown = "TravelingMerchantIsInTown";
diff --git a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
index 1f4388e7..290436e9 100644
--- a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
+++ b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
@@ -371,7 +371,8 @@ private void OnRenderingHud(object? sender, RenderingHudEventArgs e)
text = $"{treeName}\nstage {tree.growthStage.Value} / 5";
if (tree.fertilized.Value)
{
- text += $"\n(fertilized)";
+ string fertilizedText = _helper.SafeGetString(LanguageKeys.Fertilized);
+ text += $"\n({fertilizedText})";
}
}
else
diff --git a/UIInfoSuite2/i18n/default.json b/UIInfoSuite2/i18n/default.json
index 51ce956e..de3ecf06 100644
--- a/UIInfoSuite2/i18n/default.json
+++ b/UIInfoSuite2/i18n/default.json
@@ -14,6 +14,7 @@
"DaysToMature": "days to mature",
"ReadyToHarvest": "Ready to harvest!",
"With": "with",
+ "Fertilized": "fertilized",
"Tree": "Tree",
//Display icons - General
"TodaysRecipe": "Today's Recipe: ",
From d55333ce7b36cfda353f91f490f69e261a487242 Mon Sep 17 00:00:00 2001
From: Zamiell <5511220+Zamiell@users.noreply.github.com>
Date: Thu, 4 Apr 2024 20:05:10 -0400
Subject: [PATCH 07/11] refactor: remove magic numbers
---
UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
index 290436e9..89d1d6d1 100644
--- a/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
+++ b/UIInfoSuite2/UIElements/ShowCropAndBarrelTime.cs
@@ -19,7 +19,9 @@
namespace UIInfoSuite2.UIElements;
internal class ShowCropAndBarrelTime : IDisposable
-{
+{
+ private const int MAX_TREE_GROWTH_STAGE = 5;
+
private readonly PerScreen