private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (isHidden) { return; } if (e.NewMenu is GameMenu menu) { if (menu.currentTab == GameMenu.craftingTab) { currentCraftingPage = (CraftingPage)(Game1.activeClickableMenu as GameMenu).GetCurrentPage(); scavengermenu.iscooking = this.Helper.Reflection.GetField <bool>(currentCraftingPage, "cooking").GetValue(); checkForClick = true; return; } // I suspect that unless it immediately goes to the Crafting Tab, it's not going to update, so I need to check every tick for page changes scanForCraftingPageOnGameMenu = true; return; } if (e.NewMenu is CraftingPage) { currentCraftingPage = (e.NewMenu as CraftingPage); scavengermenu.iscooking = this.Helper.Reflection.GetField <bool>(currentCraftingPage, "cooking").GetValue(); checkForClick = true; return; } checkForClick = false; scanForCraftingPageOnGameMenu = false; }
public void SetMouseUpMenuItems(MenuChangedEventArgs args) { MenuItemName menuItemName = args.MenuItemName; switch (menuItemName) { case MenuItemName.PriceList: PriceListMenuItemStyle.Selected = true; break; case MenuItemName.Orders: OrdersMenuItemStyle.Selected = true; break; case MenuItemName.Documents: DocumentsMenuItemStyle.Selected = true; break; case MenuItemName.Sync: SyncMenuItemStyle.Selected = true; break; case MenuItemName.Settings: SettingsMenuItemStyle.Selected = true; break; } }
public void SetMouseUpMenuItems(MenuChangedEventArgs args) { MenuItemName menuItemName = args.MenuItemName; switch (menuItemName) { case MenuItemName.HighSchool: HighSchoolMenuItemStyle.Selected = true; break; case MenuItemName.Faculty: FacultyMenuItemStyle.Selected = true; break; case MenuItemName.Chair: ChairMenuItemStyle.Selected = true; break; case MenuItemName.Specialty: SpecialtyMenuItemStyle.Selected = true; break; case MenuItemName.Specialization: SpecializationMenuItemStyle.Selected = true; break; case MenuItemName.Employee: EmployeeMenuItemStyle.Selected = true; break; } }
private void MenuCloseHandler(object sender, MenuChangedEventArgs e) { if (this.shouldCreateFailedToRentTools) { this.SetupFailedToRentDialog(this.player); this.shouldCreateFailedToRentTools = false; } else if (this.shouldCreateSucceededToRentTools) { this.SetupSucceededToRentDialog(); this.shouldCreateSucceededToRentTools = false; } else if (this.rentedToolsOffered) { this.rentedToolsOffered = false; } else if (this.recycleOffered) { this.recycleOffered = false; } else if (this.inited && this.IsPlayerAtCounter(this.player)) { if (this.player.toolBeingUpgraded.Value == null && this.HasRentedTools(this.player)) { this.SetupRentToolsRemovalDialog(this.player); } else if (this.ShouldOfferTools(this.player)) { this.SetupRentToolsOfferDialog(this.player); } } }
/// <summary>The event called after an active menu is opened or closed.</summary> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { // Add the blueprint if (e.NewMenu is CarpenterMenu carpenterMenu) { bool isMagicalMenu = Helper.Reflection.GetField <bool>(carpenterMenu, "magicalConstruction").GetValue(); if (isMagicalMenu) { return; } IList <BluePrint> blueprints = Helper.Reflection .GetField <List <BluePrint> >(carpenterMenu, "blueprints") .GetValue(); // Add furnace blueprint, and tag it uniquely based on how many have been built blueprints.Add(new BluePrint(furnaceBuildingType) { maxOccupants = furnacesBuilt, }); } // If a menu was closed, reset the currently looked at furnace, just in case. else if (Game1.activeClickableMenu is null) { currentlyLookingAtFurnace = -1; } }
/// <summary>The event called after an active menu is opened or closed.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (!this.IsEnabled || !Context.IsWorldReady) { return; } // add blueprints if (e.NewMenu is CarpenterMenu || e.NewMenu?.GetType().FullName == this.PelicanFiberMenuFullName) { // get field IList <BluePrint> blueprints = this.Helper.Reflection .GetField <List <BluePrint> >(e.NewMenu, e.NewMenu is CarpenterMenu ? "blueprints" : "Blueprints") .GetValue(); // add garage blueprint blueprints.Add(this.GetBlueprint()); // add stable blueprint if needed // (If player built a tractor garage first, the game won't let them build a stable since it thinks they already have one. Derived from the CarpenterMenu constructor.) if (!blueprints.Any(p => p.name == "Stable" && p.maxOccupants != this.MaxOccupantsID)) { Farm farm = Game1.getFarm(); int cabins = farm.getNumberBuildingsConstructed("Cabin"); int stables = farm.getNumberBuildingsConstructed("Stable") - Game1.getFarm().buildings.OfType <Stable>().Count(this.IsGarage); if (stables < cabins + 1) { blueprints.Add(new BluePrint("Stable")); } } } }
private void OnQuestLogMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is QuestLog && !(e.NewMenu is ManagedQuestLog)) { Game1.activeClickableMenu = new ManagedQuestLog(); return; } if (e.NewMenu is QuestLog && !(e.OldMenu is QuestLog)) { this.EventManager.QuestLogMenuOpen.Fire(new System.EventArgs(), this); } if (!(e.NewMenu is QuestLog) && e.OldMenu is QuestLog) { this.EventManager.QuestLogMenuClosed.Fire(new System.EventArgs(), this); // Remove quests marked for destroy from questlog int i = 0; while (i < Game1.player.questLog.Count) { if (Game1.player.questLog[i].destroy.Value == true) { Game1.player.questLog.RemoveAt(i); } else { i++; } } } }
private void onMenuChanged(object sender, MenuChangedEventArgs args) { if (args.NewMenu is GameMenu gm) { var pages = Helper.Reflection.GetField <List <IClickableMenu> >(gm, "pages").GetValue(); var tabs = Helper.Reflection.GetField <List <ClickableComponent> >(gm, "tabs").GetValue(); myTabIndex = tabs.Count; tabs.Add(new ClickableComponent(new Rectangle(gm.xPositionOnScreen + 192, gm.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + 64 - 64, 64, 64), "animals", "Animals") { myID = 912342, downNeighborID = 12342, rightNeighborID = 12343, leftNeighborID = 12341, tryDefaultIfNoDownNeighborExists = true, fullyImmutable = true }); tabs[1].upNeighborID = 912342; pages.Add((IClickableMenu) new AnimalSocialPage(gm.xPositionOnScreen, gm.yPositionOnScreen, gm.width, gm.height)); Helper.Events.Display.RenderedActiveMenu += drawSocialIcon; } else if (args.OldMenu is GameMenu ogm) { Helper.Events.Display.RenderedActiveMenu -= drawSocialIcon; } }
/// <summary>The event called after an active menu is opened or closed.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (!Context.IsWorldReady) { return; } // add blueprints if (e.NewMenu is CarpenterMenu) { CarpenterMenu carpenterMenu = e.NewMenu as CarpenterMenu; bool magicalConstruction = this.Helper.Reflection .GetField <bool>(e.NewMenu, "magicalConstruction") .GetValue(); // get field IList <BluePrint> blueprints = this.Helper.Reflection .GetField <List <BluePrint> >(e.NewMenu, "blueprints") .GetValue(); List <BuildingPatch> buildingPatches = this.BuildingPatches.Values // to get just the List<BuildingPatch>s .SelectMany(x => x.Where(patch => (magicalConstruction && patch.IsMagical()) || (!magicalConstruction && !patch.IsMagical()))) // flatten and remove magical if necessary .ToList(); // convert to list foreach (BuildingPatch patch in buildingPatches) { blueprints.Add(new BluePrint(patch.Type)); // add unloaded blueprints } } }
/// <summary> /// Checks for when Robin's store is open and adds the Farm Renderer to the stock as necessary /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Display_MenuChanged(object sender, MenuChangedEventArgs e) { //we don't care if it's not a shop menu if (!(e.NewMenu is ShopMenu)) { return; } var shop = (ShopMenu)e.NewMenu; //we don't care if it's not robin's store if (shop.portraitPerson == null || !(shop.portraitPerson.Name == "Robin")) { return; } //ignore if player hasn't seen the mail yet if (!Game1.player.mailReceived.Contains("FarmRearrangerMail")) { return; } //create the farm renderer object and add it to robin's stock var itemStock = shop.itemPriceAndStock; var obj = new StardewValley.Object(Vector2.Zero, FarmRearrangerID); itemStock.Add(obj, new int[] { Config.Price, int.MaxValue }); shop.setItemPriceAndStock(itemStock); }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is GameMenu gameMenu) { InjectAudioOptionsIntoGameMenu(gameMenu); } }
private void Display_MenuChanged(object sender, MenuChangedEventArgs e) { if (!(e.NewMenu is ShopMenu)) { return; } var shop = (ShopMenu)e.NewMenu; if (shop.portraitPerson == null || !(shop.portraitPerson.Name == "Robin")) { return; } if (!Game1.player.mailReceived.Contains("SolarionChroniclesMail")) { return; } var itemStock = shop.itemPriceAndStock; var obj = new StardewValley.Object(Vector2.Zero, SolarionChroniclesGameID); itemStock.Add(obj, new int[] { Config.Price, int.MaxValue }); shop.setItemPriceAndStock(itemStock); }
/// <summary>Raised after a menu was opened.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> void MenuChanged(object sender, MenuChangedEventArgs e) { //check if we are in a shop menu if (e.NewMenu is ShopMenu shopMenu) { if (config.exclude_pierre && Game1.currentLocation is StardewValley.Locations.SeedShop) { return; } if (config.exclude_oasis && shopMenu.portraitPerson != null && shopMenu.portraitPerson.Name.Equals("Sandy")) { return; } if (config.exclude_traveling_merchant && Game1.currentLocation is StardewValley.Locations.Forest) { return; } if (config.exclude_night_market && Game1.currentLocation is StardewValley.Locations.BeachNightMarket) { return; } List <Item> shopInventory = this.Helper.Reflection.GetField <List <Item> >(shopMenu, "forSale").GetValue(); //remove all seeds but do not remove the tree saplings (those are also categorized as seeds) shopInventory.RemoveAll((Item item) => item.Category == StardewValley.Object.SeedsCategory && !(config.exclude_rare_seed && item.Name.Equals("Rare Seed")) && !item.Name.EndsWith("Sapling", StringComparison.Ordinal)); } }
public void MenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is CarpenterMenu) { this.MenuChanged_CarpenterMenu(sender, e); } }
private void OnMenuChanged(object sender, MenuChangedEventArgs e) { GameMenu menu = e.NewMenu as GameMenu; if (null != menu) { OptionsPage oPage = menu.pages[GameMenu.optionsTab] as OptionsPage; if (null != oPage) { oPage.options.Add(new OptionsElement("DailyScreenshot Mod:")); oPage.options.Add(new OptionsButton("Show config.json", delegate { try { Process.Start(new ProcessStartInfo { FileName = Path.Combine("Mods", "DailyScreenshot"), UseShellExecute = true, Verb = "open" }); } catch (Exception) { } })); // Show a list of rules and allow the user to enable/disable them here //oPage.options.Add(new OptionsElement("DailyScreenshot Mod Rules:")); } } }
private void Display_MenuChanged(object sender, MenuChangedEventArgs e) { if (pres_comp) { if (e.OldMenu.GetType().FullName == "SkillPrestige.Menus.PrestigeMenu") { //closing(); SetTimer(); } else if (e.OldMenu.GetType().FullName == "StardewValley.Menus.GameMenu") { //closing(); SetTimer(); } else if (e.OldMenu.GetType().FullName == "SkillPrestige.Menus.SettingsMenu") { //closing(); SetTimer(); } else if (e.OldMenu.GetType().FullName == "SkillPrestige.Menus.Dialogs.WarningDialog") { //closing(); SetTimer(); } } }
/// Activates drawing of remote button if menu is game menu. private void RemoteFridgeOnMenuChanged(object sender, MenuChangedEventArgs e) { if (!this.remoteButtonActive) { return; } if (e.NewMenu is GameMenu menu) { if (!this.remoteButtonDraw) { this.remoteButtonTab.bounds.X = menu.xPositionOnScreen + 64; this.remoteButtonTab.bounds.Y = menu.yPositionOnScreen - 40; this.remoteButton.bounds.X = this.remoteButtonTab.bounds.X + 16; this.remoteButton.bounds.Y = this.remoteButtonTab.bounds.Y + 16; if (ModEntry.cheatUpgrades || this.upgradeModules.Contains(upgradeWarp.ToString()) || this.upgradeModules.Contains(upgradePortal.ToString()) || this.upgradeModules.Contains(upgradeDimension.ToString())) { this.remoteButtonDraw = true; } } } else if (this.remoteButtonDraw) { this.remoteButtonDraw = false; } }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is DialogueBox dBox && OurMoon.CurrentPhase() == MoonPhase.BloodMoon) { if (!(BloodMoonTracker.Contains(Game1.currentSpeaker.Name))) { Game1.player.changeFriendship(-60, Game1.currentSpeaker); BloodMoonTracker.Add(Game1.currentSpeaker.Name); } if (!Game1.eventUp) { var cDBU = Helper.Reflection.GetField <Stack <string> >(dBox, "characterDialoguesBrokenUp").GetValue(); cDBU.Clear(); Helper.Reflection.GetField <Stack <string> >(dBox, "characterDialoguesBrokenUp").SetValue(cDBU); Dialogue diag = Helper.Reflection.GetField <Dialogue>(dBox, "characterDialogue").GetValue(); diag.setCurrentDialogue(Helper.Translation.Get("moon-text.bloodmoon_villager_generic")); Helper.Reflection.GetField <Dialogue>(dBox, "characterDialogue").SetValue(diag); Helper.Reflection.GetMethod(dBox, "checkDialogue").Invoke(new[] { diag }); } } if (!UseJsonAssetsApi) { if (e.NewMenu is ShopMenu menu && menu.portraitPerson != null) { float sellPrice, buyPrice; switch (OurMoon.CurrentPhase()) { case MoonPhase.BloodMoon: sellPrice = .75f; buyPrice = 1.85f; break; case MoonPhase.BlueMoon: sellPrice = 1.175f; buyPrice = .825f; break; case MoonPhase.HarvestMoon: sellPrice = 1.1f; buyPrice = .9f; break; default: sellPrice = 1f; buyPrice = 1f; break; } Helper.Reflection.GetField <float>(menu, "sellPercentage").SetValue(Helper.Reflection.GetField <float>(menu, "sellPercentage").GetValue() * sellPrice); var itemPriceAndStock = Helper.Reflection.GetField <Dictionary <ISalable, int[]> >(menu, "itemPriceAndStock").GetValue(); foreach (var kvp in itemPriceAndStock) { kvp.Value[0] = (int)Math.Floor(kvp.Value[0] * buyPrice); } } } }
public void SetEntryControl(MenuChangedEventArgs args) { var viewFactory = new ViewFactory(DomainContext, ViewModelRouter); View = viewFactory.GetView(args.MenuItemName, View); Messenger?.Send(CommandName.SelectLeftMenu, args); }
/********* ** Private methods *********/ /**** ** Event handlers ****/ /// <summary>The method called when the player returns to the title screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is TitleMenu) { this.CurrentStage = Stage.SkipIntro; } }
/// <summary>Raised after a menu was opened.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> void MenuChanged(object sender, MenuChangedEventArgs e) { //check if we are in a shop menu if (e.NewMenu is ShopMenu shopMenu) { if (config.exclude_pierre && Game1.currentLocation is StardewValley.Locations.SeedShop) { return; } if (config.exclude_oasis && shopMenu.portraitPerson != null && shopMenu.portraitPerson.Name.Equals("Sandy")) { return; } if (config.exclude_traveling_merchant && Game1.currentLocation is StardewValley.Locations.Forest) { return; } if (config.exclude_night_market && Game1.currentLocation is StardewValley.Locations.BeachNightMarket) { return; } if (config.exclude_egg_festival && Game1.isFestival() && Game1.dayOfMonth == 13 && Game1.IsSpring) { return; } //remove all seeds but do not remove the tree saplings (those are also categorized as seeds) shopMenu.forSale.RemoveAll((ISalable sale) => sale is Item item && item.Category == StardewValley.Object.SeedsCategory && !(config.exclude_rare_seed && item.Name.Equals("Rare Seed")) && !item.Name.EndsWith("Sapling", StringComparison.Ordinal)); } }
/// <summary> /// Raised after a game menu is opened, closed, or replaced. /// Here it invoke the MailController to show a custom mail when the it's a LetterViewerMenu, called from open the mailbox and there is CustomMails to be delivered /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is LetterViewerMenu && this.Helper.Reflection.GetField <string>(e.NewMenu, "mailTitle").GetValue() != null && MailController.HasCustomMail()) { MailController.ShowLetter(); } }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void ToggleModOptions(object sender, MenuChangedEventArgs e) { // remove from old menu if (e.OldMenu != null) { _helper.Events.Display.RenderedActiveMenu -= DrawButton; if (_modOptionsPageButton != null) { _modOptionsPageButton.OnLeftClicked -= OnButtonLeftClicked; } if (e.OldMenu is GameMenu gameMenu) { List <IClickableMenu> tabPages = gameMenu.pages; tabPages.Remove(_modOptionsPage); } } // add to new menu if (e.NewMenu is GameMenu newMenu) { if (_modOptionsPageButton == null) { _modOptionsPage = new ModOptionsPage(_optionsElements, _helper.Events); _modOptionsPageButton = new ModOptionsPageButton(_helper.Events); } _helper.Events.Display.RenderedActiveMenu += DrawButton; _modOptionsPageButton.OnLeftClicked += OnButtonLeftClicked; List <IClickableMenu> tabPages = newMenu.pages; _modOptionsTabPageNumber = tabPages.Count; tabPages.Add(_modOptionsPage); } }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is GameMenu menu) { xPositionOnScreen = menu.xPositionOnScreen + menu.width - 200; } }
/// <summary> /// Raised after a game menu is opened, closed, or replaced. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void onMenuChanged(object sender, MenuChangedEventArgs e) { // carpenter dialog in science house? if (Game1.currentLocation?.Name == "ScienceHouse" && e.NewMenu is DialogueBox && Game1.currentLocation.lastQuestionKey == "carpenter" && Game1.IsMasterGame) { handleDialogueMenu(); } }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void onMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is BobberBar bobber && hasRingEquipped(Ring_Fishing_LargeBar) > 0) { var field = Helper.Reflection.GetField <int>(bobber, "bobberBarHeight"); field.SetValue((int)(field.GetValue() * 1.50)); } }
/// <summary>Raised after a game menu is opened, closed, or replaced.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (LastLinkOpened != null && e.NewMenu == null && ReferenceEquals(e.OldMenu, LastLinkOpened)) { OpenMainMenu(); LastLinkOpened = null; } }
/// <inheritdoc cref="IDisplayEvents.MenuChanged"/> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is BobberBar bobber && this.HasRingEquipped(this.RingFishingLargeBar)) { var field = this.Helper.Reflection.GetField <int>(bobber, "bobberBarHeight"); field.SetValue((int)(field.GetValue() * this.Config.RingOfWideNets_BarSizeMultiplier)); } }
/// <summary> /// Event handler, used to add in the options into the base game options menu. /// This occurs every time an instance of the base game <c>GameMenu</c> is the activeMenu. /// </summary> /// /// <param name="sender">The object from which the event originated.</param> /// <param name="e">These are the arguments sent along with the event from SMAPI, contains the previous and current menu's.</param> private void Display_MenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu is GameMenu) { GameMenu menu = e.NewMenu as GameMenu; AddOptionsToMenu(menu); } }
private void OnMenuChanged(object sender, MenuChangedEventArgs e) { if (e.NewMenu != null) { setActiveProfile(); this.Helper.Events.Display.MenuChanged -= OnMenuChanged; } }