From 0e1baf58251606737cb36cb402f4dec1b638c7b1 Mon Sep 17 00:00:00 2001 From: Seawolf Date: Wed, 27 Nov 2019 20:37:03 -0800 Subject: [PATCH 1/3] Update for SMAPI 3.0 Update for compatibility with SMAPI 3.0 and SDV 1.4 --- PrismaticTools.sln | 12 ++++----- PrismaticTools/Framework/Blacksmith.cs | 34 +++++++++++++++++--------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/PrismaticTools.sln b/PrismaticTools.sln index 8ee10b1..16dcfc2 100644 --- a/PrismaticTools.sln +++ b/PrismaticTools.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.202 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2018 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{7EF5E22B-2A2D-4B4A-9903-6B118B874F64}" ProjectSection(SolutionItems) = preProject @@ -19,10 +19,10 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Debug|x86.ActiveCfg = Debug|x86 - {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Debug|x86.Build.0 = Debug|x86 - {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Release|x86.ActiveCfg = Release|x86 - {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Release|x86.Build.0 = Release|x86 + {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Debug|x86.ActiveCfg = Debug|Any CPU + {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Debug|x86.Build.0 = Debug|Any CPU + {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Release|x86.ActiveCfg = Release|Any CPU + {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrismaticTools/Framework/Blacksmith.cs b/PrismaticTools/Framework/Blacksmith.cs index 55a7cf5..ea15f54 100644 --- a/PrismaticTools/Framework/Blacksmith.cs +++ b/PrismaticTools/Framework/Blacksmith.cs @@ -4,23 +4,29 @@ using StardewValley.Menus; using StardewValley.Tools; -namespace PrismaticTools.Framework { - internal class BlacksmithInitializer { +namespace PrismaticTools.Framework +{ + internal class BlacksmithInitializer + { private static readonly int UpgradeCost = ModEntry.Config.PrismaticToolCost; - public static void Init(IModEvents events) { + public static void Init(IModEvents events) + { events.Display.MenuChanged += OnMenuChanged; } /// Raised after a game menu is opened, closed, or replaced. /// The event sender. /// The event arguments. - private static void OnMenuChanged(object sender, MenuChangedEventArgs e) { - if (!(e.NewMenu is ShopMenu menu)) { + private static void OnMenuChanged(object sender, MenuChangedEventArgs e) + { + if (!(e.NewMenu is ShopMenu menu)) + { return; } List categories = ModEntry.ModHelper.Reflection.GetField>(menu, "categoriesToSellHere").GetValue(); - if (!categories.Contains(Object.GemCategory) || !categories.Contains(Object.mineralsCategory) || !categories.Contains(Object.metalResources)) { + if (!categories.Contains(Object.GemCategory) || !categories.Contains(Object.mineralsCategory) || !categories.Contains(Object.metalResources)) + { return; } Farmer who = Game1.player; @@ -31,25 +37,29 @@ private static void OnMenuChanged(object sender, MenuChangedEventArgs e) { Tool toolFromName4 = who.getToolFromName("Hoe"); Tool tool; - List forSale = ModEntry.ModHelper.Reflection.GetField>(menu, "forSale").GetValue(); - Dictionary stock = ModEntry.ModHelper.Reflection.GetField>(menu, "itemPriceAndStock").GetValue(); + List forSale = menu.forSale; + Dictionary stock = menu.itemPriceAndStock; - if (toolFromName1 != null && toolFromName1.UpgradeLevel == 4) { + if (toolFromName1 != null && toolFromName1.UpgradeLevel == 4) + { tool = new Axe { UpgradeLevel = 5 }; forSale.Add(tool); stock.Add(tool, new[] { UpgradeCost, 1, PrismaticBarItem.INDEX }); } - if (toolFromName2 != null && toolFromName2.UpgradeLevel == 4) { + if (toolFromName2 != null && toolFromName2.UpgradeLevel == 4) + { tool = new WateringCan { UpgradeLevel = 5 }; forSale.Add(tool); stock.Add(tool, new[] { UpgradeCost, 1, PrismaticBarItem.INDEX }); } - if (toolFromName3 != null && toolFromName3.UpgradeLevel == 4) { + if (toolFromName3 != null && toolFromName3.UpgradeLevel == 4) + { tool = new Pickaxe { UpgradeLevel = 5 }; forSale.Add(tool); stock.Add(tool, new[] { UpgradeCost, 1, PrismaticBarItem.INDEX }); } - if (toolFromName4 != null && toolFromName4.UpgradeLevel == 4) { + if (toolFromName4 != null && toolFromName4.UpgradeLevel == 4) + { tool = new Hoe { UpgradeLevel = 5 }; forSale.Add(tool); stock.Add(tool, new[] { UpgradeCost, 1, PrismaticBarItem.INDEX }); From 89b99888bbebea9069464913d267b9188eb23717 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 30 Dec 2020 20:40:25 -0500 Subject: [PATCH 2/3] fix platform targets --- PrismaticTools.sln | 12 ++++++------ PrismaticTools/PrismaticTools.csproj | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/PrismaticTools.sln b/PrismaticTools.sln index 16dcfc2..8ee10b1 100644 --- a/PrismaticTools.sln +++ b/PrismaticTools.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2018 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28803.202 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{7EF5E22B-2A2D-4B4A-9903-6B118B874F64}" ProjectSection(SolutionItems) = preProject @@ -19,10 +19,10 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Debug|x86.ActiveCfg = Debug|Any CPU - {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Debug|x86.Build.0 = Debug|Any CPU - {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Release|x86.ActiveCfg = Release|Any CPU - {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Release|x86.Build.0 = Release|Any CPU + {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Debug|x86.ActiveCfg = Debug|x86 + {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Debug|x86.Build.0 = Debug|x86 + {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Release|x86.ActiveCfg = Release|x86 + {7A6634BD-1FF7-4711-99B6-FD503ED9B5C0}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PrismaticTools/PrismaticTools.csproj b/PrismaticTools/PrismaticTools.csproj index e318861..196de1c 100644 --- a/PrismaticTools/PrismaticTools.csproj +++ b/PrismaticTools/PrismaticTools.csproj @@ -5,6 +5,8 @@ PrismaticTools 1.7.1 net452 + x86 + x86 true From faaae568290de301390f8888def615e9edc000b8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 30 Dec 2020 20:41:10 -0500 Subject: [PATCH 3/3] restore original code style for consistency --- PrismaticTools/Framework/Blacksmith.cs | 30 +++++++++----------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/PrismaticTools/Framework/Blacksmith.cs b/PrismaticTools/Framework/Blacksmith.cs index ea15f54..4a6a9de 100644 --- a/PrismaticTools/Framework/Blacksmith.cs +++ b/PrismaticTools/Framework/Blacksmith.cs @@ -4,29 +4,23 @@ using StardewValley.Menus; using StardewValley.Tools; -namespace PrismaticTools.Framework -{ - internal class BlacksmithInitializer - { +namespace PrismaticTools.Framework { + internal class BlacksmithInitializer { private static readonly int UpgradeCost = ModEntry.Config.PrismaticToolCost; - public static void Init(IModEvents events) - { + public static void Init(IModEvents events) { events.Display.MenuChanged += OnMenuChanged; } /// Raised after a game menu is opened, closed, or replaced. /// The event sender. /// The event arguments. - private static void OnMenuChanged(object sender, MenuChangedEventArgs e) - { - if (!(e.NewMenu is ShopMenu menu)) - { + private static void OnMenuChanged(object sender, MenuChangedEventArgs e) { + if (!(e.NewMenu is ShopMenu menu)) { return; } List categories = ModEntry.ModHelper.Reflection.GetField>(menu, "categoriesToSellHere").GetValue(); - if (!categories.Contains(Object.GemCategory) || !categories.Contains(Object.mineralsCategory) || !categories.Contains(Object.metalResources)) - { + if (!categories.Contains(Object.GemCategory) || !categories.Contains(Object.mineralsCategory) || !categories.Contains(Object.metalResources)) { return; } Farmer who = Game1.player; @@ -40,26 +34,22 @@ private static void OnMenuChanged(object sender, MenuChangedEventArgs e) List forSale = menu.forSale; Dictionary stock = menu.itemPriceAndStock; - if (toolFromName1 != null && toolFromName1.UpgradeLevel == 4) - { + if (toolFromName1 != null && toolFromName1.UpgradeLevel == 4) { tool = new Axe { UpgradeLevel = 5 }; forSale.Add(tool); stock.Add(tool, new[] { UpgradeCost, 1, PrismaticBarItem.INDEX }); } - if (toolFromName2 != null && toolFromName2.UpgradeLevel == 4) - { + if (toolFromName2 != null && toolFromName2.UpgradeLevel == 4) { tool = new WateringCan { UpgradeLevel = 5 }; forSale.Add(tool); stock.Add(tool, new[] { UpgradeCost, 1, PrismaticBarItem.INDEX }); } - if (toolFromName3 != null && toolFromName3.UpgradeLevel == 4) - { + if (toolFromName3 != null && toolFromName3.UpgradeLevel == 4) { tool = new Pickaxe { UpgradeLevel = 5 }; forSale.Add(tool); stock.Add(tool, new[] { UpgradeCost, 1, PrismaticBarItem.INDEX }); } - if (toolFromName4 != null && toolFromName4.UpgradeLevel == 4) - { + if (toolFromName4 != null && toolFromName4.UpgradeLevel == 4) { tool = new Hoe { UpgradeLevel = 5 }; forSale.Add(tool); stock.Add(tool, new[] { UpgradeCost, 1, PrismaticBarItem.INDEX });