/// <summary>
        /// This mod shows an icon when the traveling merchant is in town
        /// </summary>
        public void toggleShowTravelingMerchant()
        {
            GraphicsEvents.OnPreRenderHudEvent -= drawTravelingMerchant;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_TRAVELING_MERCHANT) == true)
            {
                GraphicsEvents.OnPreRenderHudEvent += drawTravelingMerchant;
            }
        }
        /// <summary>
        /// This mod draws a birthday icon when its a townsfolk birthday
        /// </summary>
        internal void toggleOption()
        {
            GraphicsEvents.OnPreRenderHudEvent -= drawBirthdayIcon;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_BIRTHDAY_ICON))
            {
                GraphicsEvents.OnPreRenderHudEvent += drawBirthdayIcon;
            }
        }
Exemple #3
0
        /// <summary>
        /// This mod displays crop time and barrel times when a button is pressed
        /// </summary>
        internal void toggleOption()
        {
            GraphicsEvents.OnPreRenderHudEventNoCheck -= drawHoverTooltip;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_CROP_AND_BARREL_TOOLTIP_ON_HOVER))
            {
                GraphicsEvents.OnPreRenderHudEventNoCheck += drawHoverTooltip;
            }
        }
        /// <summary>
        /// Toggles the level up animation on or off
        /// </summary>
        public void togglLevelUpAnimation()
        {
            PlayerEvents.LeveledUp -= onLevelUp;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_LEVEL_UP_ANIMATION))
            {
                PlayerEvents.LeveledUp += onLevelUp;
            }
        }
Exemple #5
0
        /// <summary>
        /// Draws a box on the shop menus that display the harvest price of the highlighted seed or fruit tree
        /// </summary>
        internal void toggleOption()
        {
            GraphicsEvents.OnPostRenderGuiEvent -= drawShopHarvestPrices;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_HARVEST_PRICES_IN_SHOP))
            {
                GraphicsEvents.OnPostRenderGuiEvent += drawShopHarvestPrices;
            }
        }
Exemple #6
0
        /// <summary>
        /// Attaches the delegates that handle the button click and draw method of the tab
        /// </summary>
        private void MenuOpened(object sender, EventArgsClickableMenuChanged e)
        {
            // copied from MenuClosed
            GraphicsEvents.OnPostRenderGuiEvent -= RenderTab;
            GraphicsEvents.OnPreRenderGuiEvent  -= HandleJunimo;

            if (this.tab != null)
            {
                this.tab.RemoveListeners();
                this.tab = null;
            }

            if (this.page != null)
            {
                if (e.PriorMenu is GameMenu)
                {
                    List <IClickableMenu> oldpages = ModEntry.helper.Reflection.GetField <List <IClickableMenu> >((e.PriorMenu as GameMenu), "pages").GetValue();
                    oldpages.Remove(this.page);
                }

                this.page.RemoveListeners(true);
                this.page             = null;
                ModSettings.pageIndex = null;
            }

            if (!(e.NewMenu is GameMenu))
            {
                this.tab              = null;
                this.page             = null;
                ModSettings.pageIndex = null;
                return;
            }

            GameMenu menu = (GameMenu)e.NewMenu;
            List <IClickableMenu> pages = ModEntry.helper.Reflection.GetField <List <IClickableMenu> >(menu, "pages").GetValue();

            var options = pages.Find(x => { return(x is OptionsPage); });
            int width   = options.width;

            //List<ClickableComponent> tabs = ModEntry.helper.Reflection.GetPrivateField<List<ClickableComponent>>(menu, "tabs").GetValue();

            this.page             = new ModOptionsPage(this, menu.xPositionOnScreen, menu.yPositionOnScreen, width, menu.height);
            ModSettings.pageIndex = pages.Count;
            pages.Add(page);

            bool infoSuiteInstalled = Mod.Helper.ModRegistry.IsLoaded("Cdaragorn.UiInfoSuite");
            int  tabLocation        = infoSuiteInstalled ? 9 : 11;

            this.tab = new ModOptionsTab(this, new Rectangle(menu.xPositionOnScreen + Game1.tileSize * tabLocation, menu.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize));

            GraphicsEvents.OnPostRenderGuiEvent -= RenderTab;
            GraphicsEvents.OnPostRenderGuiEvent += RenderTab;
            GraphicsEvents.OnPreRenderGuiEvent  -= HandleJunimo;
            GraphicsEvents.OnPreRenderGuiEvent  += HandleJunimo;
        }
        /// <summary>
        /// Displays a partial heart fill between heart levels on the social page
        /// </summary>
        public void toggleVisibleHearts()
        {
            GraphicsEvents.OnPostRenderGuiEvent -= drawHeartFills;
            MenuEvents.MenuChanged -= OnMenuChange;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_HEART_FILLS))
            {
                MenuEvents.MenuChanged += OnMenuChange;
                GraphicsEvents.OnPostRenderGuiEvent += drawHeartFills;
            }
        }
        /// <summary>
        /// This mod displays a customizable range for sprinklers and scarecrows
        /// </summary>
        internal void toggleOption()
        {
            GraphicsEvents.OnPostRenderEvent -= drawTileOutlines;
            GameEvents.FourthUpdateTick      -= checkDrawTileOutlines;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_SPRINKLER_SCARECROW_RANGE))
            {
                GraphicsEvents.OnPostRenderEvent += drawTileOutlines;
                GameEvents.FourthUpdateTick      += checkDrawTileOutlines;
            }
        }
        /// <summary>
        /// This mod displays a button in GameMenu to show billboard and calendar anywhere
        /// </summary>
        internal void toggleOption()
        {
            GraphicsEvents.OnPostRenderGuiEvent -= renderButtons;
            GraphicsEvents.OnPreRenderGuiEvent  -= removeDefaultTooltips;
            ControlEvents.MouseChanged          -= onBilboardIconClick;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.DISPLAY_CALENDAR_AND_BILLBOARD))
            {
                GraphicsEvents.OnPostRenderGuiEvent += renderButtons;
                GraphicsEvents.OnPreRenderGuiEvent  += removeDefaultTooltips;
                ControlEvents.MouseChanged          += onBilboardIconClick;
            }
        }
        /// <summary>
        /// This mod displays a hand icon periodically when a pet needs to be pet.
        /// This mod also displays an icon above the head of animals that are ready to produce a product
        /// </summary>
        internal void toggleOption()
        {
            timer.Stop();
            LocationEvents.CurrentLocationChanged -= onLocationChange;
            GraphicsEvents.OnPreRenderHudEvent    -= drawAnimalHasProduct;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_ANIMALS_NEED_PETS))
            {
                timer.Start();
                LocationEvents.CurrentLocationChanged += onLocationChange;
                GraphicsEvents.OnPreRenderHudEvent    += drawAnimalHasProduct;
            }
        }
 /// <summary>
 /// Displays the exp bar
 /// </summary>
 private void displayExperienceBar()
 {
     if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.ALLOW_EXPERIENCE_BAR_TO_FADE_OUT) == true)
     {
         timerToDissapear.Interval = TIME_BEFORE_EXPERIENCE_BAR_FADE;
         timerToDissapear.Start();
         shouldDrawExperienceBar = true;
     }
     else
     {
         timerToDissapear.Stop();
         shouldDrawExperienceBar = true;
     }
 }
        /// <summary>
        /// Removes default tooltips to allow drawing standard tooltips over the billboard icon only if better tooltips are not showing
        /// </summary>
        private void removeDefaultTooltips(object sender, EventArgs e)
        {
            if (Game1.activeClickableMenu is GameMenu == false)
            {
                return;
            }

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_EXTRA_ITEM_INFORMATION) == false)
            {
                var pages         = (List <IClickableMenu>) typeof(GameMenu).GetField("pages", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Game1.activeClickableMenu);
                var inventoryPage = ( InventoryPage )pages[GameMenu.inventoryTab];
                hoverText = ( string )typeof(InventoryPage).GetField("hoverText", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(inventoryPage);
                typeof(InventoryPage).GetField("hoverText", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(inventoryPage, "");
            }
        }
        /// <summary>
        /// This mod displays mugshots of townsfolk on the map.
        /// </summary>
        public void toggleShowNPCLocationOnMap()
        {
            onMenuChange(null, null);
            GraphicsEvents.OnPostRenderGuiEvent -= drawNPCLocationsOnMap;
            GraphicsEvents.OnPostRenderGuiEvent -= drawSocialPageOptions;
            ControlEvents.MouseChanged          -= handleClickForSocialPage;
            MenuEvents.MenuChanged -= onMenuChange;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_LOCATION_Of_TOWNSPEOPLE))
            {
                GraphicsEvents.OnPostRenderGuiEvent += drawNPCLocationsOnMap;
                GraphicsEvents.OnPostRenderGuiEvent += drawSocialPageOptions;
                ControlEvents.MouseChanged          += handleClickForSocialPage;
                MenuEvents.MenuChanged += onMenuChange;
            }
        }
        /// <summary>
        /// Draws the billboard button below the inventory screen
        /// </summary>
        private void renderButtons(object sender, EventArgs e)
        {
            if ((Game1.activeClickableMenu is GameMenu) == false)
            {
                return;
            }

            if ((Game1.activeClickableMenu as GameMenu).currentTab != GameMenu.inventoryTab)
            {
                return;
            }

            // Set button position
            showBillboardButton.bounds.X = Game1.activeClickableMenu.xPositionOnScreen + Game1.activeClickableMenu.width - 160;
            showBillboardButton.bounds.Y = Game1.activeClickableMenu.yPositionOnScreen + Game1.activeClickableMenu.height - 300;

            showBillboardButton.draw(Game1.spriteBatch);

            if (showBillboardButton.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
            {
                string tooltip;
                if (Game1.getMouseX() < showBillboardButton.bounds.X + (showBillboardButton.bounds.Width / 2))
                {
                    tooltip = "Calendar";
                }
                else
                {
                    tooltip = "Billboard";
                }

                IClickableMenu.drawHoverText(Game1.spriteBatch, tooltip, Game1.dialogueFont);
            }

            // Redraw tooltips if advanced tooltips are not showing
            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_EXTRA_ITEM_INFORMATION) == false)
            {
                var pages         = (List <IClickableMenu>) typeof(GameMenu).GetField("pages", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Game1.activeClickableMenu);
                var inventoryPage = ( InventoryPage )pages[GameMenu.inventoryTab];
                var hoverTitle    = ( string )typeof(InventoryPage).GetField("hoverTitle", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(inventoryPage);
                var hoveredItem   = ( Item )typeof(InventoryPage).GetField("hoveredItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(inventoryPage);
                var heldItem      = ( Item )typeof(InventoryPage).GetField("heldItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(inventoryPage);
                IClickableMenu.drawToolTip(Game1.spriteBatch, hoverText, hoverTitle, hoveredItem, heldItem != null, -1, 0, -1, -1, ( CraftingRecipe )null, -1);
            }
        }
        /// <summary>
        /// This mod displays an improved tooltip
        /// </summary>
        public void toggleOption()
        {
            PlayerEvents.InventoryChanged       -= populateRequiredBundled;
            GraphicsEvents.OnPostRenderEvent    -= drawAdvancedToolipForMenu;
            GraphicsEvents.OnPostRenderHudEvent -= drawAdvancedToolipForToolbar;
            GraphicsEvents.OnPreRenderEvent     -= getHoverItem;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_EXTRA_ITEM_INFORMATION))
            {
                // Load bundle data
                communityCenter = ( CommunityCenter )Game1.getLocationFromName("CommunityCenter");
                bundleData      = Game1.content.Load <Dictionary <string, string> >("Data\\Bundles");

                // Parse data to easily work with bundle data
                populateRequiredBundled(null, null);

                PlayerEvents.InventoryChanged       += populateRequiredBundled;
                GraphicsEvents.OnPostRenderEvent    += drawAdvancedToolipForMenu;
                GraphicsEvents.OnPostRenderHudEvent += drawAdvancedToolipForToolbar;
                GraphicsEvents.OnPreRenderEvent     += getHoverItem;
            }
        }
Exemple #16
0
        /// <summary>
        /// Removes the delegates that handle the button click and draw method of the tab
        /// </summary>
        private void MenuClosed(object sender, EventArgsClickableMenuClosed e)
        {
            GraphicsEvents.OnPostRenderGuiEvent -= RenderTab;
            GraphicsEvents.OnPreRenderGuiEvent  -= HandleJunimo;

            if (this.tab != null)
            {
                this.tab.RemoveListeners();
                this.tab = null;
            }

            if (this.page != null)
            {
                if (e.PriorMenu is GameMenu)
                {
                    List <IClickableMenu> pages = ModEntry.helper.Reflection.GetField <List <IClickableMenu> >((e.PriorMenu as GameMenu), "pages").GetValue();
                    pages.Remove(this.page);
                }

                this.page.RemoveListeners(true);
                this.page             = null;
                ModSettings.pageIndex = null;
            }
        }
        /// <summary>
        /// Pauses the game, shows Level Up text and plays a chime, and unpauses after some time;
        /// </summary>
        internal void onLevelUp(object sender, EventArgsLevelUp e)
        {
            // Fix firing on new day. Exp can never be gained in FarmHouse
            if (Game1.currentLocation.name == "FarmHouse")
            {
                return;
            }

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_LEVEL_UP_ANIMATION) == false)
            {
                return;
            }

            switch (e.Type)
            {
            case EventArgsLevelUp.LevelType.Combat:
                levelUpIconRectangle = new Rectangle(120, 428, 10, 10);
                break;

            case EventArgsLevelUp.LevelType.Farming:
                levelUpIconRectangle = new Rectangle(10, 428, 10, 10);
                break;

            case EventArgsLevelUp.LevelType.Fishing:
                levelUpIconRectangle = new Rectangle(20, 428, 10, 10);
                break;

            case EventArgsLevelUp.LevelType.Foraging:
                levelUpIconRectangle = new Rectangle(60, 428, 10, 10);
                break;

            case EventArgsLevelUp.LevelType.Mining:
                levelUpIconRectangle = new Rectangle(30, 428, 10, 10);
                break;
            }

            shouldDrawLevelUp = true;

            timerToDissapear.Interval = TIME_BEFORE_EXPERIENCE_BAR_FADE;
            timerToDissapear.Start();
            shouldDrawExperienceBar = true;


            float prevAmbientVolume = Game1.options.ambientVolumeLevel;
            float prevMusicVolume   = Game1.options.musicVolumeLevel;

            // Play sound if loaded
            if (se != null)
            {
                if (prevMusicVolume > 0.01f)
                {
                    se.Volume = Math.Min(1, (prevMusicVolume + 0.3f));
                }
                else
                {
                    se.Volume = 0;
                }
            }

            Task.Factory.StartNew(() => {
                System.Threading.Thread.Sleep(100);

                Game1.musicCategory.SetVolume(Math.Max(0, Game1.options.musicVolumeLevel - 0.3f));
                Game1.ambientCategory.SetVolume(Math.Max(0, Game1.options.ambientVolumeLevel - 0.3f));

                if (se != null)
                {
                    se.Play();
                }
            });

            Task.Factory.StartNew(() => {
                System.Threading.Thread.Sleep(lengthOfLevelUpPause);
                shouldDrawLevelUp = false;


                Game1.musicCategory.SetVolume(prevMusicVolume);
                Game1.ambientCategory.SetVolume(prevAmbientVolume);
            });
        }
        /// <summary>
        /// Draw all experience displays
        /// </summary>
        internal void onPreRenderEvent(object sender, EventArgs e)
        {
            if (Game1.eventUp)
            {
                return;
            }

            Item currentItem = Game1.player.CurrentItem;

            var spriteRectangle = new Rectangle(10, 428, 10, 10);
            int currentLevel    = 0;

            // Display exp type depending on item
            if (currentItem is FishingRod)
            {
                currentLevelIndex = 1;
                spriteRectangle   = new Rectangle(20, 428, 10, 10);
                currentLevel      = Game1.player.fishingLevel;
            }
            else if (currentItem is Axe)
            {
                currentLevelIndex = 2;
                spriteRectangle   = new Rectangle(60, 428, 10, 10);
                currentLevel      = Game1.player.foragingLevel;
            }
            else if (currentItem is Pickaxe)
            {
                currentLevelIndex = 3;
                spriteRectangle   = new Rectangle(30, 428, 10, 10);
                currentLevel      = Game1.player.miningLevel;
            }
            else if (currentItem is MeleeWeapon && currentItem.Name != "Scythe")
            {
                currentLevelIndex = 4;
                spriteRectangle   = new Rectangle(120, 428, 10, 10);
                currentLevel      = Game1.player.combatLevel;


                // If primary item is not selected
                // Display farming exp or foraging exp depending on current location
            }
            else
            {
                if (Game1.currentLocation is Farm)
                {
                    currentLevelIndex = 0;
                    spriteRectangle   = new Rectangle(10, 428, 10, 10);
                    currentLevel      = Game1.player.farmingLevel;
                }
                else
                {
                    currentLevelIndex = 2;
                    spriteRectangle   = new Rectangle(60, 428, 10, 10);
                    currentLevel      = Game1.player.foragingLevel;
                }
            }

            levelOfCurrentlyDisplayedExp = currentLevel;

            if (levelOfCurrentlyDisplayedExp > 9)
            {
                return;
            }

            // Sets the exp for next level and the exp that has already been obtained based on current level
            int expRequiredToLevel = getExperienceRequiredToLevel(levelOfCurrentlyDisplayedExp);
            int expAlreadyEarnedFromPreviousLevels = getExperienceGainedFromPreviousLevels(levelOfCurrentlyDisplayedExp);

            float nextExp = Game1.player.experiencePoints[currentLevelIndex] - expAlreadyEarnedFromPreviousLevels;

            // Show experience bar if item has changed
            if (previousItem != currentItem)
            {
                displayExperienceBar();

                // Show experience bar and exp gain if exp is gained
            }
            else if (currentExp != nextExp)
            {
                displayExperienceBar();

                if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_EXP_GAIN) == true && (nextExp - currentExp) > 0)
                {
                    expPointDisplays.Add(new ExpPointDisplay(nextExp - currentExp, Game1.player.getLocalPosition(Game1.viewport)));
                }
            }

            previousItem = currentItem;
            currentExp   = nextExp;

            if (ModOptionsPage.getCheckboxValue(ModOptionsPage.Setting.SHOW_EXPERIENCE_BAR) == false || shouldDrawExperienceBar == false || levelOfCurrentlyDisplayedExp == 10)
            {
                return;
            }

            int   barWidth  = Convert.ToInt32((currentExp / (expRequiredToLevel - expAlreadyEarnedFromPreviousLevels)) * maxBarWidth);
            float positionX = Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Left;

            // Shift display if game view has black borders
            if (Game1.isOutdoorMapSmallerThanViewport())
            {
                int   currentMapSize = (Game1.currentLocation.map.Layers[0].LayerWidth * Game1.tileSize);
                float blackSpace     = Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Right - currentMapSize;
                positionX = positionX + (blackSpace / 2);
            }

            // Border
            Game1.drawDialogueBox((int)positionX, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 160, 240, 160, false, true);

            // Experience fill
            Game1.spriteBatch.Draw(Game1.staminaRect, new Rectangle((int)positionX + 32, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 63, barWidth, 31), expFillColor);
            Game1.spriteBatch.Draw(Game1.staminaRect, new Rectangle((int)positionX + 32, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 63, Math.Min(4, barWidth), 31), Color.LightGray);
            Game1.spriteBatch.Draw(Game1.staminaRect, new Rectangle((int)positionX + 32, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 63, barWidth, 4), Color.LightGray);
            Game1.spriteBatch.Draw(Game1.staminaRect, new Rectangle((int)positionX + 32, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 36, barWidth, 4), Color.LightGray);


            // Hacky way to handle a mouseover
            // Draw experience gained this level and amount needed for next level
            test = new ClickableTextureComponent("", new Rectangle(( int )positionX - 36, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 80, 260, 100), "", "", Game1.mouseCursors, new Rectangle(0, 0, 0, 0), Game1.pixelZoom);
            if (test.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
            {
                Game1.drawWithBorder($"{currentExp}/{  expRequiredToLevel - expAlreadyEarnedFromPreviousLevels}", Color.Black, Color.White, new Vector2(positionX + 33, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 66));

                // Draw Level and icon
            }
            else
            {
                // Icon
                Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2(( int )positionX + 54, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 62), spriteRectangle, iconColor, 0.0f, Vector2.Zero, 2.9f, SpriteEffects.None, 0.85f);

                // Draw current Level
                Game1.drawWithBorder($"{currentLevel}", Color.Black * 0.6f, Color.Azure, new Vector2(positionX + 33, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 66));
            }

            // Level Up display
            if (shouldDrawLevelUp)
            {
                // Icon
                Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2(Game1.player.getLocalPosition(Game1.viewport).X - 74, Game1.player.getLocalPosition(Game1.viewport).Y - 130), levelUpIconRectangle, iconColor, 0.0f, Vector2.Zero, ( float )Game1.pixelZoom, SpriteEffects.None, 0.85f);
                // Text
                Game1.drawWithBorder("Level Up", Color.DarkSlateGray, Color.PaleTurquoise, new Vector2(Game1.player.getLocalPosition(Game1.viewport).X - 28, Game1.player.getLocalPosition(Game1.viewport).Y - 130));
            }

            foreach (ExpPointDisplay experienceDisplay in expPointDisplays)
            {
                experienceDisplay.draw();
            }

            for (int i = expPointDisplays.Count - 1; i >= 0; i--)
            {
                if (expPointDisplays[i].isInvisible())
                {
                    expPointDisplays.RemoveAt(i);
                }
                else
                {
                    expPointDisplays[i].draw();
                }
            }
        }