Exemple #1
0
 private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.NewMenu is ItemGrabMenu m && m.context is CrafterMachine c)
     {
         Game1.activeClickableMenu = c.createMenu();
     }
 }
        /// <summary>
        /// Stops Marnie's portrait from appearing in non-Marnie animal shops after animal purchasing
        /// And removes specified animals from Marnie's store
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            //this block fixes marnie's portrait popping up after purchasing an animal
            if (e.OldMenu is PurchaseAnimalsMenu && e.NewMenu is DialogueBox && SourceLocation != null)
            {
                var AnimalPurchaseMessage = ((DialogueBox)e.NewMenu).getCurrentString();

                //go away marnie we don't want you
                Game1.exitActiveMenu();

                //display the animal purchase message without Marnie's face
                Game1.activeClickableMenu = new DialogueBox(AnimalPurchaseMessage);
            }

            //this is the vanilla Marnie menu for us to exclude animals from
            if (e.NewMenu is PurchaseAnimalsMenu && SourceLocation == null && !ChangedMarnieStock && ExcludeFromMarnie.Count > 0)
            {
                //close the current menu to open our own
                Game1.exitActiveMenu();
                var AllAnimalsStock = Utility.getPurchaseAnimalStock();
                var newAnimalStock  = new List <StardewValley.Object>();
                foreach (var animal in AllAnimalsStock)
                {
                    if (!ExcludeFromMarnie.Contains(animal.Name))
                    {
                        newAnimalStock.Add(animal);
                    }
                }
                ChangedMarnieStock        = true;
                Game1.activeClickableMenu = new PurchaseAnimalsMenu(newAnimalStock);
            }
        }
 private void OnDialogueOpen(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.NewMenu is DialogueBox)
     {
         this.lastEmotion = null;
     }
 }
Exemple #4
0
        public static void updateItemListAfterShop(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            if (e.OldMenu is ShopMenu sm && lastInventoryId != null && itemLists.ContainsKey(lastInventoryId))
            {
                Dictionary <ISalable, int[]> itemPriceAndStock = sm.itemPriceAndStock;
                foreach (Item item in itemLists[lastInventoryId])
                {
                    Item i    = item.getOne();
                    int  sold = 0;
                    if (itemPriceAndStock.ContainsKey(i))
                    {
                        sold       = item.Stack - itemPriceAndStock[i][1];
                        item.Stack = itemPriceAndStock[i][1];
                    }
                    else
                    {
                        sold       = item.Stack;
                        item.Stack = 0;
                    }

                    if (sm.portraitPerson is NPC npc && npc.Name == "PlayerShop")
                    {
                        long umid = long.Parse(sm.portraitPerson.endOfRouteMessage.Value);
                        if (Game1.getFarmer(umid) is Farmer f)
                        {
                            ShopMenu.chargePlayer(f, sm.getCurrency(), -(i.salePrice() * sold));
                        }
                    }
                }

                itemLists[lastInventoryId].RemoveAll(it => it.Stack <= 0);
                lastInventoryId = null;
            }
        }
Exemple #5
0
        /// <summary>
        /// If the sortOption is active then this will enable the events required for custom sort functionality
        /// otherwise it will remove these events from the event handler.
        ///
        /// Also gets menu data so the button can be placed in the correct location.
        /// </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.</param>
        private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            if (!this.sortOption.IsActive)
            {
                ModEntry.Helper.Events.Input.ButtonPressed -= Input_ButtonPressed;
                ModEntry.Helper.Events.Input.CursorMoved   -= Input_CursorMoved;

                ModEntry.Helper.Events.Display.RenderingActiveMenu -= Display_RenderingActiveMenu;
                ModEntry.Helper.Events.Display.RenderedActiveMenu  -= Display_RenderedActiveMenu;
                return;
            }
            else
            {
                ModEntry.Helper.Events.Input.ButtonPressed += Input_ButtonPressed;
                ModEntry.Helper.Events.Input.CursorMoved   += Input_CursorMoved;

                ModEntry.Helper.Events.Display.RenderingActiveMenu += Display_RenderingActiveMenu;
                ModEntry.Helper.Events.Display.RenderedActiveMenu  += Display_RenderedActiveMenu;
            }

            GameMenu menu = Game1.activeClickableMenu as GameMenu;

            if (menu != null)
            {
                this.reflectedInventoryPage  = ModEntry.Helper.Reflection.GetField <List <IClickableMenu> >(menu, "pages").GetValue()[0] as InventoryPage;
                this.organiseButton.bounds.X = this.reflectedInventoryPage.organizeButton.bounds.X + this.organiseButton.bounds.Width + SEPARATION_SPACE;
                this.organiseButton.bounds.Y = this.reflectedInventoryPage.organizeButton.bounds.Y;
            }
        }
 static void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (Game1.currentLocation is LibraryMuseum && e.NewMenu is ItemGrabMenu grabMenu)
     {
         grabMenu.reverseGrab = true;
     }
 }
Exemple #7
0
 private void OnMenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.NewMenu is DialogueBox dBox && !Game1.eventUp && StaminaCheck() && Game1.random.NextDouble() < ModConfig.CommentChance)
     {
         var      cDBU = Helper.Reflection.GetField <Stack <string> >(dBox, "characterDialoguesBrokenUp").GetValue();
         Dialogue diag = Helper.Reflection.GetField <Dialogue>(dBox, "characterDialogue").GetValue();
         if (diag != null && diag.speaker != null && !NPCCommenters.Contains(diag.speaker.Name))
         {
             if (diag.temporaryDialogue == Helper.Translation.Get("Strings\\UI:Carpenter_DemolishCabinConfirm") ||
                 diag.temporaryDialogue == Helper.Translation.Get("Data\\ExtraDialogue:Robin_Instant") ||
                 diag.temporaryDialogue == Helper.Translation.Get("Data\\ExtraDialogue:Robin_UpgradeConstruction") ||
                 diag.temporaryDialogue == Helper.Translation.Get("Data\\ExtraDialogue:Robin_NewConstruction") ||
                 diag.temporaryDialogue == Helper.Translation.Get("Data\\ExtraDialogue:Robin_UpgradeConstructionFestival") || diag.temporaryDialogue == Helper.Translation.Get("Data\\ExtraDialogue:Robin_NewConstructionFestival")
                 )
             {
                 return;
             }
             NPCCommenters.Add(diag.speaker.Name);
             string key = GetDialogueForConditions(diag.speaker);
             string ret;
             if (!string.IsNullOrEmpty(key) && ModDialogues.ContainsKey(key))
             {
                 ret = ModDialogues[key].Text;
                 cDBU.Push(ret);
             }
             Helper.Reflection.GetField <Stack <string> >(dBox, "characterDialoguesBrokenUp").SetValue(cDBU);
         }
     }
 }
 public static void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (Game1.activeClickableMenu is ShopMenu menu && !(menu is AdventurersGuildShopMenu) && Game1.currentLocation is AdventureGuild)
     {
         Monitor.Log("Replacing Adventure Guild ShopMenu with custom ShopMenu", LogLevel.Trace);
         Dictionary <Item, int[]> itemPriceAndStock = Helper.Reflection.GetField <Dictionary <Item, int[]> >(menu, "itemPriceAndStock").GetValue();
         Game1.activeClickableMenu = new AdventurersGuildShopMenu(Helper, Monitor, itemPriceAndStock, Config.SlingshotFeature);
     }
 }
Exemple #9
0
 static void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.NewMenu is CarpenterMenu carpenterMenu && !(e.NewMenu is ModCarpenterMenu))
     {
         Monitor.Log("Replacing carpenter menu with custom menu", LogLevel.Trace);
         bool magicalConstruction = Helper.Reflection.GetField <bool>(carpenterMenu, "magicalConstruction").GetValue();
         Game1.activeClickableMenu = new ModCarpenterMenu(Monitor, Helper, magicalConstruction);
     }
 }
Exemple #10
0
 private void OnMenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs menuChangedEventArgs)
 {
     if (IsGoToSleepDialog(menuChangedEventArgs.NewMenu))
     {
         foreach (Buildings.AnimalBuilding eligibleAnimalBuilding in this.EligibleAnimalBuildings)
         {
             eligibleAnimalBuilding.SendAllAnimalsHome();
         }
     }
 }
Exemple #11
0
 private void OnMenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs menuChangedEventArgs)
 {
     if (!config.WarpAnimalsWhileClosingDoors && IsGoToSleepDialog(menuChangedEventArgs.NewMenu))
     {
         for (short i = 0; i < this.EligibleAnimalBuildings.Count; ++i)
         {
             this.EligibleAnimalBuildings[i].SendAllAnimalsHome();
         }
     }
 }
Exemple #12
0
 private void OnMenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs menuChangedEventArgs)
 {
     if (IsGoToSleepDialog(menuChangedEventArgs.NewMenu))
     {
         foreach (Farm farm in Game.Instance.Farms)
         {
             farm.SendAllAnimalsHome();
         }
     }
 }
Exemple #13
0
 private void OnMenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.NewMenu is DialogueBox dBox && !Game1.eventUp && StaminaCheck())
     {
         var      cDBU = Helper.Reflection.GetField <Stack <string> >(dBox, "characterDialoguesBrokenUp").GetValue();
         Dialogue diag = Helper.Reflection.GetField <Dialogue>(dBox, "characterDialogue").GetValue();
         cDBU.Push(Helper.Translation.Get(GetDialogueForConditions(diag.speaker)));
         Helper.Reflection.GetField <Stack <string> >(dBox, "characterDialoguesBrokenUp").SetValue(cDBU);
     }
 }
 public static void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.NewMenu is ShopMenu shopMenu && Game1.currentLocation is AdventureGuild)
     {
         AddSlingshots(shopMenu);
         Helper.Events.Display.RenderingActiveMenu += Display_RenderingActiveMenu;
         //Helper.Events.Display.RenderedActiveMenu += Display_RenderedActiveMenu;
         Helper.Events.Input.ButtonPressed  += Input_ButtonPressed;
         Helper.Events.Input.ButtonReleased += Input_ButtonReleased;
         ConvertSlingshots(shopMenu);
     }
 private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.OldMenu == null ||
         e.OldMenu is CustomCraftingMenu
         || e.OldMenu is CraftingPage
         || e.OldMenu is GameMenu
         || e.OldMenu.GetType() == CookingSkillMenu)
     {
         _openedNonCustomMenu = false;
     }
 }
 private static void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.OldMenu is TailoringMenu)
     {
         // Tailoring menu got closed
         if (!String.IsNullOrEmpty(DeferredMessage))
         {
             Game1.addHUDMessage(new CustomHUDMessage(DeferredMessage, FailedItem, Color.DarkGray, TimeSpan.FromSeconds(3)));
             DeferredMessage = null;
         }
     }
 }
        private static void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            if (e.NewMenu is ShopMenu shopMenu)
            {
                Logger.Info($"Opened shop of {shopMenu.portraitPerson?.name}");

                var shop = shopMenu.GetShop();
                if (shop != Shop.None)
                {
                    EditShop(shopMenu, shop);
                }
            }
        }
Exemple #18
0
        private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            if (!finishedTrainWarp)
            {
                return;
            }

            if (e.NewMenu is DialogueBox)
            {
                AfterWarpPause();
            }
            finishedTrainWarp = false;
        }
Exemple #19
0
        /// <summary>
        /// Stops Marnie's portrait from appearing in non-Marnie animal shops after animal purchasing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            //this block fixes marnie's portrait popping up after purchasing an animal
            if (e.OldMenu is PurchaseAnimalsMenu && e.NewMenu is DialogueBox && SourceLocation != null)
            {
                var AnimalPurchaseMessage = ((DialogueBox)e.NewMenu).getCurrentString();

                //go away marnie we don't want you
                Game1.exitActiveMenu();

                //display the animal purchase message without Marnie's face
                Game1.activeClickableMenu = new DialogueBox(AnimalPurchaseMessage);
            }
        }
Exemple #20
0
        private void AndroidPlsHaveMercyOnMe(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            //don't ask me what the heck is going on here but its the only way to get it to work
            if (!(e.OldMenu is DonateFishMenuAndroid androidMenu))
            {
                return;
            }
            //80% sure this is a DonateFishMenuAndroid but it won't work if i check for that but the harmony patch seems to work on it so idk
            if (!(e.NewMenu is ShopMenu menu))
            {
                return;
            }

            menu.exitFunction = androidMenu.OnExit;
        }
Exemple #21
0
        private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            if (e.NewMenu is ShopMenu shopMenu && shopMenu.GetShop() == Parameters.Shop)
            {
                // reduce price of all items
                foreach (var element in shopMenu.itemPriceAndStock)
                {
                    int[] arr = element.Value;
                    if (arr != null && arr.Length > 0)
                    {
                        arr[0] = (int)Math.Max(0, arr[0] * (1 - Parameters.Discount));
                    }
                }

                EffectHelper.Overlays.AddSparklingText(new SparklingText(Game1.dialogueFont, $"You received a discount ({Parameters.Discount * 100:0}%)", Color.LimeGreen, Color.Azure), new Vector2(64f, Game1.uiViewport.Height - 64));
            }
        }
Exemple #22
0
 private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.OldMenu != null && forageFoundDialogue != null)
     {
         DialogueBox db = (e.OldMenu as DialogueBox);
         if (db != null)
         {
             Dialogue d = (Dialogue)typeof(DialogueBox).GetField("characterDialogue", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(db);
             if (d != null && d.Equals(forageFoundDialogue))
             {
                 buffOwner.addItemToInventory(foragedObject);
                 forageFoundDialogue = null;
                 foragedObject       = null;
                 buffGranter.faceTowardFarmerTimer = 0;
                 buffGranter.movementPause         = 0;
             }
         }
     }
 }
        private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            if (e.NewMenu is BobberBar bobberBar)
            {
                if (!Game1.isFestival())
                {
                    var hasTreasure = EffectHelper.ModHelper.Reflection.GetField <bool>(bobberBar, "treasure");
                    if (!hasTreasure.GetValue())
                    {
                        if (Game1.random.Next(0, 11) <= Game1.player.LuckLevel + Math.Round((double)Game1.player.addedLuckLevel))
                        {
                            Logger.Debug("Added treasure");
                            var treasureAppearTimer = EffectHelper.ModHelper.Reflection.GetField <float>(bobberBar, "treasureAppearTimer");
                            treasureAppearTimer.SetValue(Game1.random.Next(1000, 3000)); // as in the base game

                            hasTreasure.SetValue(true);
                        }
                    }
                }
            }
        }
        private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            if (e.NewMenu is BobberBar bobberBar)
            {
                Farmer farmer = Game1.player;

                var bobberBarHeight = EffectHelper.ModHelper.Reflection.GetField <int>(bobberBar, "bobberBarHeight");
                int currentHeight   = bobberBarHeight.GetValue();

                int fishCaught = 0;
                foreach (var fishidx in farmer.fishCaught.Keys)
                {
                    if (IsRealFish(fishidx))
                    {
                        int[] fishStat = farmer.fishCaught[fishidx];
                        if (fishStat != null && fishStat.Length > 0)
                        {
                            fishCaught += fishStat[0];
                        }
                    }
                }

                // maximum increase depends on caught fish
                int maxIncreaseBy = (int)Math.Min(Math.Atan(fishCaught / 500.0) * 100, maxIncrease);
                Logger.Debug($"Current luck: {farmer.LuckLevel}, Daily luck: {farmer.DailyLuck}");
                double luckEffect = Math.Min(maxLowerBoundRation, farmer.LuckLevel / (double)maxAffectingLuck);
                // add daily luck (can be negative!)
                luckEffect = Math.Max(0, Math.Min(1, luckEffect + farmer.DailyLuck));
                Logger.Debug($"max increase: {maxIncreaseBy}, luck effect -> {luckEffect}");
                // actual increase is a random value between 0 and maxIncreaseBy shifted by the current luck level
                int increaseBy = EffectHelper.Random.Next((int)(maxIncreaseBy * luckEffect), maxIncreaseBy);

                int newHeight = Math.Min(currentHeight + increaseBy, maxBobberBarHeight);
                bobberBarHeight.SetValue(newHeight);
                Logger.Debug($"increased bobberBarHeight from {currentHeight} to {newHeight} (+{increaseBy}, #fish: {fishCaught})");

                // adjust bobber bar starting pos
                EffectHelper.ModHelper.Reflection.GetField <int>(bobberBar, "bobberBarPos").SetValue(bobberBarSlotTop - newHeight);
            }
        }
Exemple #25
0
 private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.OldMenu != null && fishCaughtDialogue != null)
     {
         DialogueBox db = (e.OldMenu as DialogueBox);
         if (db != null)
         {
             Dialogue d = (Dialogue)typeof(DialogueBox).GetField("characterDialogue", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(db);
             if (d != null && d.Equals(fishCaughtDialogue))
             {
                 foreach (StardewValley.Object fish in fishCaught)
                 {
                     buffOwner.addItemToInventory(fish);
                 }
                 fishCaughtDialogue = null;
                 fishCaught.Clear();
                 //buffGranter.faceTowardFarmerTimer = 0;
                 //buffGranter.movementPause = 0;
             }
         }
     }
 }
Exemple #26
0
 public static void OnNewMenuOpened(object Sender, StardewModdingAPI.Events.MenuChangedEventArgs args)
 {
     if (args.NewMenu != null)
     {
         if (args.NewMenu is ShopMenu)
         {
             ShopMenu menu = (args.NewMenu as ShopMenu);
             if (menu.portraitPerson != null)
             {
                 string npcName = menu.portraitPerson.Name;
                 if (npcName.Equals("Robin"))
                 {
                     AddItemsToRobinsShop(menu);
                 }
                 else if (npcName.Equals("Clint"))
                 {
                     AddOreToClintsShop(menu);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Recreates the farmhand's inventory even when they are offline.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void RecreateFarmhandInventory(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            if (e.NewMenu != null)
            {
                ModCore.log(e.NewMenu.GetType());

                if (e.NewMenu.GetType() == typeof(StardewValley.Menus.ItemGrabMenu))
                {
                    if (Game1.player.currentLocation is Cabin)
                    {
                        //ModCore.log("Let's get processing!");
                        List <KeyValuePair <int, Item> > addition = new List <KeyValuePair <int, Item> >();
                        for (int i = 0; i < (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory.Count; i++)
                        {
                            Item I = (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[i];
                            if (I is Chest && I.Name != "Chest")
                            {
                                //ModCore.log("Found a custom object!");
                                Item cObj = ModCore.Serializer.DeserializeFromFarmhandInventory(I.Name);
                                if (cObj == null)
                                {
                                    continue;
                                }
                                addition.Add(new KeyValuePair <int, Item>(i, cObj));
                            }
                        }

                        foreach (KeyValuePair <int, Item> pair in addition)
                        {
                            (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory[pair.Key] = pair.Value;
                        }

                        (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu = new InventoryMenu((Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.xPositionOnScreen, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.yPositionOnScreen, true, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.highlightMethod, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.capacity, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.rows, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.horizontalGap, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.verticalGap, (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.drawSlots);
                        (Game1.activeClickableMenu as ItemGrabMenu).populateClickableComponentList();
                        (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.populateClickableComponentList();
                    }
                }
            }
        }
        /// <summary>
        /// Stops Marnie's portrait from appearing in non-Marnie animal shops after animal purchasing
        /// And removes specified animals from Marnie's store
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
        {
            //this block fixes marnie's portrait popping up after purchasing an animal
            if (e.OldMenu is PurchaseAnimalsMenu && e.NewMenu is DialogueBox && SourceLocation != null)
            {
                var animalPurchaseMessage = ((DialogueBox)e.NewMenu).getCurrentString();

                //go away marnie we don't want you
                Game1.exitActiveMenu();

                //display the animal purchase message without Marnie's face
                Game1.activeClickableMenu = new DialogueBox(animalPurchaseMessage);
            }

            //TODO: deprecate this once FAVR is out
            //this is the vanilla Marnie menu for us to exclude animals from
            if (e.NewMenu is PurchaseAnimalsMenu && SourceLocation == null &&
                !_changedMarnieStock && AnimalShop.ExcludeFromMarnie.Count > 0)
            {
                //close the current menu to open our own
                Game1.exitActiveMenu();
                var allAnimalsStock = StardewValley.Utility.getPurchaseAnimalStock();
                _changedMarnieStock = true;

                //removes all animals on the exclusion list
                var newAnimalStock = (from animal in allAnimalsStock
                                      where !AnimalShop.ExcludeFromMarnie.Contains(animal.Name)
                                      select animal).ToList();
                Game1.activeClickableMenu = new PurchaseAnimalsMenu(newAnimalStock);
            }

            //idk why some menus have a habit of warping the player a tile to the left ocassionally
            //so im just gonna warp them back to their original location eh
            if (e.NewMenu == null && _playerPos != Vector2.Zero)
            {
                Game1.player.position.Set(_playerPos);
            }
        }
Exemple #29
0
 private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     // This hook is to remove our custom hats from the regular Hatmouse shop before the player has visited the festival
     // It is not terribly easy to identify the shop as belonging to Hatmouse so we will remove them from any shop in the Forest
     // To make hats available after visitng festival, could add condition: !Game1.player.mailReceived.Contains("ShadowFestivalVisited"
     if (e.NewMenu != null &&
         e.NewMenu is ShopMenu shop &&
         Game1.currentLocation.Name.Equals("Forest")
         )
     {
         Dictionary <ISalable, int[]> shopStock = Helper.Reflection.GetField <Dictionary <ISalable, int[]> >(shop, "itemPriceAndStock").GetValue();
         List <ISalable> shopForSale            = Helper.Reflection.GetField <List <ISalable> >(shop, "forSale").GetValue();
         foreach (ISalable item in shopStock.Keys.ToArray())
         {
             //Monitor.VerboseLog($"Checking item {item.Name}");
             if (item is Hat hat && (Data.CalmingHats.Contains(hat.Name) || Data.OtherHats.Contains(hat.Name)))
             {
                 Monitor.Log($"Removing {hat.Name} from forest shop.");
                 shopStock.Remove(item);
                 shopForSale.Remove(item);
             }
         }
     }
 }
 private void Display_MenuChanged(object sender, StardewModdingAPI.Events.MenuChangedEventArgs e)
 {
     if (e.OldMenu != null)
     {
         DialogueBox db = (e.OldMenu as DialogueBox);
         if (db != null)
         {
             Dialogue d = (Dialogue)typeof(DialogueBox).GetField("characterDialogue", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(db);
             if (d != null && d.speaker != null && d.speaker.Equals(stateMachine.companion) &&
                 d.Equals(stateMachine.recruitDialogue))
             {
                 if (Game1.timeOfDay < 2200 &&
                     stateMachine.manager.farmer.dialogueQuestionsAnswered.Contains(CompanionsManager.recruitYesID))
                 {
                     stateMachine.Recruit();
                 }
                 else
                 {
                     stateMachine.Reject();
                 }
             }
         }
     }
 }