public static void Draw_Postfix(MenuWithInventory __instance, SpriteBatch b) { try { ConvenientInventory.PostMenuDraw(__instance, b); } catch (Exception e) { ModEntry.Instance.Monitor.Log($"Failed in {nameof(Draw_Postfix)}:\n{e}", LogLevel.Error); } }
public static bool ReceiveRightClick_Prefix(MenuWithInventory __instance, int x, int y) { try { return(ConvenientInventory.PreReceiveRightClickInMenu(__instance, x, y)); } catch (Exception e) { ModEntry.Instance.Monitor.Log($"Failed in {nameof(ReceiveRightClick_Prefix)}:\n{e}", LogLevel.Error); } return(true); }
private void Events_DrawTick(object sender, EventArgs e) { if (Game1.activeClickableMenu == null) { return; } Item obj = null; if (Game1.activeClickableMenu is GameMenu) { GameMenu gameMenu = (GameMenu)Game1.activeClickableMenu; IList <IClickableMenu> pages = this.Helper.Reflection.GetPrivateValue <List <IClickableMenu> >(gameMenu, "pages"); if (gameMenu.currentTab == 0) { obj = this.Helper.Reflection.GetPrivateValue <Item>(pages[0], "hoveredItem"); } else if (gameMenu.currentTab == 4) { obj = this.Helper.Reflection.GetPrivateValue <Item>(pages[4], "hoverItem"); } } else if (Game1.activeClickableMenu is MenuWithInventory) { MenuWithInventory menuWithInventory = (MenuWithInventory)Game1.activeClickableMenu; obj = menuWithInventory.hoveredItem; } if (obj == null) { return; } foreach (int bundleIndex in neededItems.Keys) { if (obj.parentSheetIndex != -1 && neededItems[bundleIndex].ContainsKey(obj.parentSheetIndex)) { drawNeededText(Game1.smallFont); } } }
private void GraphicsEvents_OnPostRenderGuiEvent(object sender, EventArgs e) { if (Game1.activeClickableMenu != null) { Item item = null; if (Game1.activeClickableMenu is GameMenu) { GameMenu menu = (GameMenu)Game1.activeClickableMenu; if (menu.currentTab == 0) { List <IClickableMenu> pages = (List <IClickableMenu>) typeof(GameMenu).GetField("pages", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(menu); InventoryPage inv = (InventoryPage)pages[0]; item = (Item)typeof(InventoryPage).GetField("hoveredItem", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(inv); } if (menu.currentTab == 4) { List <IClickableMenu> pages = (List <IClickableMenu>) typeof(GameMenu).GetField("pages", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(menu); CraftingPage inv = (CraftingPage)pages[4]; item = (Item)typeof(CraftingPage).GetField("hoverItem", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(inv); } } if (Game1.activeClickableMenu is MenuWithInventory) { MenuWithInventory menu = (MenuWithInventory)Game1.activeClickableMenu; InventoryMenu inv = menu.inventory; item = menu.hoveredItem; } if (item == null) { return; } if (item is StardewValley.Object) { StardewValley.Object o = item as StardewValley.Object; if (o.stack > 1) { drawHoverTextBox(Game1.smallFont, o.sellToStorePrice(), o.stack); } else { drawHoverTextBox(Game1.smallFont, o.sellToStorePrice()); } } else if (item != null) { if (item.Stack > 1) { drawHoverTextBox(Game1.smallFont, (item.salePrice() / 2), item.Stack); } else { drawHoverTextBox(Game1.smallFont, item.salePrice()); } } } }