Let SMAPI rewrite broken code instead

This commit is contained in:
yangzhi 2020-02-09 00:58:23 +08:00
parent f3dfcc64ae
commit 134eb34c0a
2 changed files with 4 additions and 6 deletions

View File

@ -42,8 +42,7 @@ namespace UIInfoSuite.UIElements
// draw shop harvest prices
if (Game1.activeClickableMenu is ShopMenu menu)
{
object item = _helper.Reflection.GetField<object>(menu, "hoveredItem").GetValue();
if (item is Item hoverItem)
if (menu.hoveredItem is Item hoverItem)
{
String text = string.Empty;
bool itemHasPriceInfo = Tools.GetTruePrice(hoverItem) > 0;
@ -68,8 +67,7 @@ namespace UIInfoSuite.UIElements
text = " " + temp.Price;
}
item = _helper.Reflection.GetField<object>(menu, "heldItem").GetValue();
var heldItem = item as Item;
var heldItem = menu.heldItem as Item;
if (heldItem == null)
{
int value = 0;
@ -164,7 +162,7 @@ namespace UIInfoSuite.UIElements
getHoveredItemExtraItemIndex.Invoke<int>(new object[0]),
getHoveredItemExtraItemAmount.Invoke<int>(new object[0]),
null,
_helper.Reflection.GetField<Int32>(menu, "hoverPrice").GetValue());
menu.hoverPrice);
}
}
}

View File

@ -103,7 +103,7 @@ namespace UIInfoSuite.UIElements
}
}
String hoverText = (string)gameMenu.GetType().GetField("hoverText", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)?.GetValue(gameMenu);
String hoverText = gameMenu.hoverText;
IClickableMenu.drawHoverText(
Game1.spriteBatch,
hoverText,