From 0f7cb1e1f64be3637ca735ae3190fd9c181172b8 Mon Sep 17 00:00:00 2001 From: yangzhi <@4F!xZpJwly&KbWq> Date: Sun, 9 Feb 2020 01:01:28 +0800 Subject: [PATCH] TypeFieldToAnotherTypeMethodRewriter, a much more flexible choice to deal with fields changes --- src/SMAPI/Framework/ModLoading/RewriteHelper.cs | 2 +- src/SMAPI/Metadata/InstructionMetadata.cs | 9 +++++++++ src/SMAPI/SMAPI.csproj | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/SMAPI/Framework/ModLoading/RewriteHelper.cs b/src/SMAPI/Framework/ModLoading/RewriteHelper.cs index 7c27cb03..05cce437 100644 --- a/src/SMAPI/Framework/ModLoading/RewriteHelper.cs +++ b/src/SMAPI/Framework/ModLoading/RewriteHelper.cs @@ -43,7 +43,7 @@ namespace StardewModdingAPI.Framework.ModLoading public static bool IsSameType(Type type, TypeReference reference) { // same namespace & name - if (type.Namespace != reference.Namespace || type.Name != reference.Name) + if ((type.Namespace != reference.Namespace || type.Name != reference.Name) && !(reference.Namespace == "" && reference.FullName.Replace("/", "+") == type.FullName)) return false; // same generic parameters diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs index 6844379a..92876406 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -53,6 +53,15 @@ namespace StardewModdingAPI.Metadata yield return new PropertyToFieldRewriter(typeof(Game1), "toolSpriteSheet", "toolSpriteSheet"); + // Accessibility fix + yield return new TypeFieldToAnotherTypeMethodRewriter(typeof(GameMenu), typeof(GameMenuMethods), "hoverText", "GetHoverText"); + yield return new TypeFieldToAnotherTypeMethodRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "heldItem", "GetHeldItem"); + yield return new TypeFieldToAnotherTypeMethodRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "hoveredItem", "GetHoveredItem"); + yield return new TypeFieldToAnotherTypeMethodRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "hoverPrice", "GetHoverPrice"); + yield return new TypeFieldToAnotherTypeMethodRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "hoverText", "GetHoverText"); + yield return new TypeFieldToAnotherTypeMethodRewriter(typeof(ShopMenu), typeof(ShopMenuMethods), "categoriesToSellHere", "GetCategoriesToSellHere"); + yield return new TypeFieldToAnotherTypeMethodRewriter(typeof(MenuWithInventory), typeof(MenuWithInventoryMethods), "trashCan", "GetTrashCan"); + //Method Rewrites yield return new MethodParentRewriter(typeof(Game1), typeof(Game1Methods)); yield return new MethodParentRewriter(typeof(Farmer), typeof(FarmerMethods)); diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj index 176763df..e91d8d91 100644 --- a/src/SMAPI/SMAPI.csproj +++ b/src/SMAPI/SMAPI.csproj @@ -226,6 +226,7 @@ + @@ -255,12 +256,15 @@ + + +