From 1bc88f28179d6eadd5f1d5e6d2f2622e471966f4 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 +++++++++ 2 files changed, 10 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 fa3d008a..176348f5 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -86,6 +86,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(IClickableMenu), typeof(IClickableMenuMethods));