private void getTractorBlueprintFromCarpenterMenu() { BluePrint tractorBlueprint = null; try { IClickableMenu menu = Game1.activeClickableMenu is CarpenterMenu ? (CarpenterMenu)Game1.activeClickableMenu : null; if (menu != null) { var blueprints = this.Helper.Reflection .GetField <List <BluePrint> >(menu, "blueprints") .GetValue(); tractorBlueprint = blueprints.SingleOrDefault(b => b.name == "TractorGarage"); menu.exitThisMenu(); } else { BitwiseJonMods.Common.Utility.Log("Unable to get Carpenter menu as active game menu. Might be another type."); } } catch (Exception ex) { BitwiseJonMods.Common.Utility.Log(string.Format("Exception trying to load Tractor blueprint, probably due to an incompatibility with another mod: {0}", ex.Message), LogLevel.Error); } activateInstantBuildMenu(tractorBlueprint); }
private static void base_receiveLeftClick(IClickableMenu __instance, int x, int y, bool playSound) { if (__instance.upperRightCloseButton == null || !__instance.readyToClose() || !__instance.upperRightCloseButton.containsPoint(x, y)) { return; } if (playSound) { Game1.playSound("bigDeSelect"); } __instance.exitThisMenu(true); }
private void getTractorBlueprintFromCarpenterMenu() { BluePrint tractorBlueprint = null; try { //jon, 11/27/19: For some reason, this is no longer showing the tractor garage image even though the blueprint is loading from the carpenter menu // correctly. It shows the default stable instead. IClickableMenu menu = Game1.activeClickableMenu is CarpenterMenu ? (CarpenterMenu)Game1.activeClickableMenu : null; if (menu != null) { var blueprints = this.Helper.Reflection .GetField <List <BluePrint> >(menu, "blueprints") .GetValue(); var tractorModName = "Tractor Garage"; tractorBlueprint = blueprints.SingleOrDefault(b => b.displayName == tractorModName); if (tractorBlueprint == null) { BitwiseJonMods.Common.Utility.Log(string.Format("Could not load Tractor blueprint since it did not exist in Carpenter menu with display name '{0}'.", tractorModName)); } menu.exitThisMenu(); } else { BitwiseJonMods.Common.Utility.Log("Unable to get Carpenter menu as active game menu. Might be another type."); } } catch (Exception ex) { BitwiseJonMods.Common.Utility.Log(string.Format("Exception trying to load Tractor blueprint, probably due to an incompatibility with another mod: {0}", ex.Message), LogLevel.Error); } activateInstantBuildMenu(tractorBlueprint); }