/// <summary>
 /// Sets the given menu's X and Y position, and width and height to that of the given bounds.
 /// </summary>
 public static void SetBounds(this StardewValley.Menus.IClickableMenu menu, Rectangle bounds)
 {
     menu.xPositionOnScreen = bounds.X;
     menu.yPositionOnScreen = bounds.Y;
     menu.width             = bounds.Width;
     menu.height            = bounds.Height;
 }
 /// <summary>
 /// Sets the given menu's X and Y position, and width and height to that of the given values.
 /// </summary>
 public static void SetBounds(this StardewValley.Menus.IClickableMenu menu, Int32 x, Int32 y, Int32 width, Int32 height)
 {
     menu.xPositionOnScreen = x;
     menu.yPositionOnScreen = y;
     menu.width             = width;
     menu.height            = height;
 }
Esempio n. 3
0
 /// <summary>
 /// Saves the menu state from e if e is a geode menu.
 /// </summary>
 /// <param name="e">A menu</param>
 public void SaveMenuState(StardewValley.Menus.IClickableMenu e)
 {
     if (e is GeodeMenu menu)
     {
         this.menuStateInfo = menu.SaveState();
     }
 }
 /// <summary>
 /// Gets the bounds of the given <see cref="StardewValley.Menus.IClickableMenu"/>.
 /// </summary>
 /// <returns>A <see cref="Rectangle"/> containing the bounds of the given menu.</returns>
 public static Rectangle GetBounds(this StardewValley.Menus.IClickableMenu menu)
 {
     return(new Rectangle(menu.xPositionOnScreen,
                          menu.yPositionOnScreen,
                          menu.width,
                          menu.height));
 }
Esempio n. 5
0
        private bool IsGoToSleepDialog(StardewValley.Menus.IClickableMenu menu)
        {
            StardewValley.Menus.DialogueBox dialogBox = menu as StardewValley.Menus.DialogueBox;
            if (dialogBox != null)
            {
                List <string> dialogs = this.Helper.Reflection.GetField <List <string> >(dialogBox, "dialogues").GetValue();
                if (dialogs != null && dialogs.Count >= 1)
                {
                    return(dialogs[0].Equals(StardewValley.Game1.content.LoadString("Strings\\Locations:FarmHouse_Bed_GoToSleep")));
                }
            }

            return(false);
        }
Esempio n. 6
0
        /// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            // open the menu if activation key pressed
            bool canOpen = Game1.activeClickableMenu == null || Game1.activeClickableMenu is StardewValley.Menus.GeodeMenu;

            if (Game1.activeClickableMenu is StardewValley.Menus.GeodeMenu)
            {
                this.GeodeBreakingMenu = Game1.activeClickableMenu;
            }
            if (e.Button == this.config.ActivationKey && canOpen)
            {
                GeodeMenu menu = new GeodeMenu(this, this.config, this.GetNextDropsForGeodes(this.config.NumberOfNextGeodeDropsToShow), this.config.RememberMenuStateAfterClose ? this.menuStateInfo : null);
                Game1.activeClickableMenu = menu;
                menu.SetSearchTabSearchBoxSelectedStatus(true);
            }
        }
        /// <summary>
        /// Key pressed event listener. Listens for the activation key and opens the menu.
        /// </summary>
        /// <param name="sender">Event sender</param>
        /// <param name="e">Event arguments</param>
        private void KeyPressed(object sender, EventArgsKeyPressed e)
        {
            bool canOpen = Game1.activeClickableMenu == null || Game1.activeClickableMenu is StardewValley.Menus.GeodeMenu;

            if (Game1.activeClickableMenu is StardewValley.Menus.GeodeMenu)
            {
                this.GeodeBreakingMenu = Game1.activeClickableMenu;
            }

            if (e.KeyPressed.ToString().ToLower() == this.config.ActivationKey.ToLower() && canOpen)
            {
                GeodeMenu menu = new GeodeMenu(this, this.config, GetNextDropsForGeodes(this.config.NumberOfNextGeodeDropsToShow), this.config.RememberMenuStateAfterClose ? this.menuStateInfo : null);
                Game1.activeClickableMenu = menu;
                menu.SetSearchTabSearchBoxSelectedStatus(true);
            }
        }
 /// <summary>
 /// Sets the given menu's and its clickable components' visibiliy to '<paramref name="isVisible"/>'.
 /// </summary>
 /// <param name="isVisible">Whether this menu should be visible.</param>
 public static void SetVisibleEx(this StardewValley.Menus.IClickableMenu menu, Boolean isVisible)
 {
     menu.allClickableComponents.ForEach((cc) => cc.visible = isVisible);
 }
Esempio n. 9
0
 /// <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)
 {
     // save the last geode menu state
     this.SaveMenuState(e.OldMenu);
     this.GeodeBreakingMenu = null;
 }
Esempio n. 10
0
 /// <summary>
 /// Menu closed event listener. Saves the last geode menu state.
 /// </summary>
 /// <param name="sender">Event sender</param>
 /// <param name="e">Event arguments</param>
 private void MenuClosed(object sender, EventArgsClickableMenuClosed e)
 {
     SaveMenuState(e.PriorMenu);
     this.GeodeBreakingMenu = null;
 }
Esempio n. 11
0
        private void OnMenuChanged(object sender, MenuChangedEventArgs e)
        {
            if (e != null)
            {
                currentMenu = e.NewMenu;
                if (currentMenu != null)
                {
                    if (currentMenu is StardewValley.Menus.ShopMenu)
                    {
                        StardewValley.Menus.ShopMenu shopMenu = (StardewValley.Menus.ShopMenu)currentMenu;

                        if (shopMenu != null && shopMenu.portraitPerson != null && shopMenu.portraitPerson.Name == "Marnie")
                        {
                            IReflectedField <Dictionary <ISalable, int[]> > inventoryInformation = Helper.Reflection.GetField <Dictionary <ISalable, int[]> >(shopMenu, "itemPriceAndStock");
                            Dictionary <ISalable, int[]> itemPriceAndStock = null;
                            if (inventoryInformation != null)
                            {
                                itemPriceAndStock = inventoryInformation.GetValue();
                            }
                            IReflectedField <List <ISalable> > forSaleInformation = Helper.Reflection.GetField <List <ISalable> >(shopMenu, "forSale");
                            List <ISalable> forSale = null;
                            if (forSaleInformation != null)
                            {
                                forSale = forSaleInformation.GetValue();
                            }

                            if (forSale != null && itemPriceAndStock != null)
                            {
                                Item milk = new StardewValley.Object(184, config.numMilkToStock, false, -1, 0);
                                itemPriceAndStock.Add(milk, new[] { milk.salePrice() * 3, milk.Stack });
                                if (!forSale.Contains(milk))
                                {
                                    forSale.Add(milk);
                                }

                                List <Item> eggsToAdd = GetEggsOfTheDay();
                                if (eggsToAdd != null)
                                {
                                    foreach (Item eggToAdd in eggsToAdd)
                                    {
                                        itemPriceAndStock.Add(eggToAdd, new[] { eggToAdd.salePrice() * 5, eggToAdd.Stack });
                                        if (!forSale.Contains(eggToAdd))
                                        {
                                            forSale.Add(eggToAdd);
                                        }
                                    }
                                }

                                inventoryInformation.SetValue(itemPriceAndStock);
                                forSaleInformation.SetValue(forSale);
                            }
                        }
                    }
                    else if (currentMenu is StardewValley.Menus.DialogueBox)
                    {
                        StardewValley.Menus.DialogueBox dialogueBox = (StardewValley.Menus.DialogueBox)currentMenu;
                        if (eventText != "")
                        {
                            if (dialogueBox != null && dialogueBox.getCurrentString() == "??")
                            {
                                string eventTextClone = eventText;
                                Game1.drawObjectDialogue(eventTextClone);
                            }
                            eventText = "";
                        }
                    }
                }
            }
        }