Beispiel #1
0
 // Render dim background layer
 public static void OnRenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
 {
     if (Game1.activeClickableMenu is FrameworkMenu)
     {
         e.SpriteBatch.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.4f);
     }
 }
Beispiel #2
0
 public void RenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
 {
     if (Game1.activeClickableMenu is CharacterCustomization)
     {
         this.RenderingActiveMenu_CharacterCustomization(sender, e);
     }
 }
        private void OnRenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
        {
            // Ignore if player hasn't loaded a save yet
            if (!Context.IsWorldReady || Game1.activeClickableMenu == null)
            {
                return;
            }

            if (!(Game1.activeClickableMenu is StardewValley.Menus.NamingMenu))
            {
                return;
            }

            StardewValley.Menus.NamingMenu namingMenu = Game1.activeClickableMenu as StardewValley.Menus.NamingMenu;

            if (namingMenu.GetType() == typeof(StardewValley.Menus.NamingMenu))
            {
                Player player = new Player(Game1.player, this.Helper);

                // Set up everything else
                BlueConfig    blueConfig      = new BlueConfig(player.HasSeenEvent(BlueVariation.EVENT_ID));
                BlueVariation blueFarmAnimals = new BlueVariation(blueConfig);

                Dictionary <string, List <string> > farmAnimals = this.Config.GetFarmAnimalTypes();
                BreedFarmAnimalConfig breedFarmAnimalConfig     = new BreedFarmAnimalConfig(farmAnimals, blueFarmAnimals, this.Config.RandomizeNewbornFromCategory, this.Config.RandomizeHatchlingFromCategory, this.Config.IgnoreParentProduceCheck);
                BreedFarmAnimal       breedFarmAnimal           = new BreedFarmAnimal(player, breedFarmAnimalConfig);

                NameFarmAnimalMenu nameFarmAnimalMenu = new NameFarmAnimalMenu(namingMenu, breedFarmAnimal);

                nameFarmAnimalMenu.HandleChange();
            }
        }
Beispiel #4
0
 private void Display_RenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
 {
     if (!(h.Reflection.GetField <Color>(typeof(Game1), "textColor").GetValue() == new Color(255, 255, 255)))
     {
         writeColors(h);
     }
 }
Beispiel #5
0
        private void Display_RenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
        {
            // Ignore if player hasn't loaded a save yet
            if (!Context.IsWorldReady || Game1.activeClickableMenu == null)
            {
                return;
            }

            StardewValley.Menus.NamingMenu namingMenu = Game1.activeClickableMenu as StardewValley.Menus.NamingMenu;

            if (namingMenu == null)
            {
                return;
            }

            if (namingMenu.GetType() != typeof(StardewValley.Menus.NamingMenu))
            {
                return;
            }

            List <string>         loadedTypes           = this.Config.GetFarmAnimalTypes();
            BreedFarmAnimalConfig breedFarmAnimalConfig = new BreedFarmAnimalConfig(loadedTypes, this.BlueFarmAnimals);
            BreedFarmAnimal       breedFarmAnimal       = new BreedFarmAnimal(this.Player, breedFarmAnimalConfig);

            NameFarmAnimalMenu nameFarmAnimalMenu = new NameFarmAnimalMenu(namingMenu, breedFarmAnimal);

            nameFarmAnimalMenu.HandleChange();
        }
Beispiel #6
0
        public void RenderingActiveMenu_CharacterCustomization(object sender, RenderingActiveMenuEventArgs e)
        {
            Type type = typeof(CharacterCustomization);
            CharacterCustomization activeMenu = Game1.activeClickableMenu as CharacterCustomization;

            TextBox nameBox     = LazyHelper.GetInstanceField(type, activeMenu, "nameBox") as TextBox;
            TextBox farmNameBox = LazyHelper.GetInstanceField(type, activeMenu, "farmnameBox") as TextBox;
            TextBox favThingBox = LazyHelper.GetInstanceField(type, activeMenu, "favThingBox") as TextBox;

            if (!nameBox.Selected && String.IsNullOrWhiteSpace(nameBox.Text))
            {
                nameBox.Text = "Player";
            }
            Game1.player.Name = nameBox.Text;

            if (!farmNameBox.Selected && String.IsNullOrWhiteSpace(farmNameBox.Text))
            {
                farmNameBox.Text = "Farm";
            }

            if (!favThingBox.Selected && String.IsNullOrWhiteSpace(favThingBox.Text))
            {
                favThingBox.Text = "Bananas";
            }
        }
Beispiel #7
0
 /// <summary>
 /// Draw the icon
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnRenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
 {
     if (!Context.IsWorldReady)
     {
         return;
     }
     ChestController.DrawFridgeIcon();
 }
Beispiel #8
0
 private void OnRenderingActiveMenu(object?sender, RenderingActiveMenuEventArgs e)
 {
     // Hijack vanilla QuestLog and replace it with DeluxeJournalMenu before rendering
     if (Game1.activeClickableMenu is QuestLog && PageManager != null)
     {
         Game1.activeClickableMenu = new DeluxeJournalMenu(PageManager);
     }
 }
        private void RenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
        {
            // Only render shrooms on the billboard
            if (!(Game1.activeClickableMenu is Billboard menu))
            {
                return;
            }

            // Try to get the calendar field
            if (!(Helper.Reflection.GetField <List <ClickableTextureComponent> >(menu, nameof(Billboard.calendarDays))
                  ?.GetValue() is List <ClickableTextureComponent> calendarDays))
            {
                return;
            }

            // Get the current hover text
            var hoverField = Helper.Reflection.GetField <string>(menu, "hoverText");
            var hoverText  = hoverField.GetValue();

            // Make sure the current hover text doesn't already have mushroom information
            if (hoverText.ToLower().Contains("shrooms"))
            {
                return;
            }

            // Update the hover text
            var mouseX = Game1.getMouseX();
            var mouseY = Game1.getMouseY();

            for (var day = 1; day <= 28; day++)
            {
                // Check if the mouse is over the current calendar day
                var component = calendarDays[day - 1];
                if (!component.bounds.Contains(mouseX, mouseY))
                {
                    continue;
                }

                // Add any mushroom text
                var shrooms = GetShroomLayers(day - Game1.dayOfMonth);
                if (hoverText.Length > 0)
                {
                    hoverText += "\n";
                }
                if (shrooms.Count > 0)
                {
                    hoverText += "Shrooms: " + string.Join(", ", shrooms);
                }
                else
                {
                    hoverText += "No shrooms";
                }
                break;
            }

            hoverField.SetValue(hoverText);
        }
Beispiel #10
0
    private void OnRenderingActiveMenu(object?sender, RenderingActiveMenuEventArgs e)
    {
        if (Context.ScreenId != ScreenID)
        {
            return;
        }

        PreDrawUI(e.SpriteBatch);
    }
 private void onRenderingActiveMenu(object _sender,
                                    RenderingActiveMenuEventArgs _e)
 {
     // When active, prevent the normal software cursor from being drawn
     // by the menu.
     if (active && !Game1.options.hardwareCursor)
     {
         Game1.mouseCursorTransparency = 0f;
     }
 }
Beispiel #12
0
 private void Display_RenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
 {
     if (Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).currentTab == GameMenu.socialTab)
     {
         Rectangle rect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen - xOffset, Game1.activeClickableMenu.yPositionOnScreen, buttonTexture.Width * 4, buttonTexture.Height * 4);
         if (rect.Contains(Game1.getMousePosition()))
         {
             (Game1.activeClickableMenu as GameMenu).hoverText = Helper.Translation.Get($"sort-{Config.CurrentSort}");
         }
     }
 }
Beispiel #13
0
        private static void Display_RenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
        {
            CarpenterMenu carpenterMenu = (CarpenterMenu)Game1.activeClickableMenu;
            bool          onFarm        = Helper.Reflection.GetField <bool>(carpenterMenu, "onFarm").GetValue();

            if (onFarm)
            {
                return;
            }

            int X = Game1.getMouseX();
            int Y = Game1.getMouseY();

            moneyButton.tryHover(X, Y);
            if (moneyButton.containsPoint(X, Y))
            {
                Helper.Reflection.GetField <string>(carpenterMenu, "hoverText").SetValue(moneyButtonEnabled ? hoverTextOff : hoverTextOn);
            }
        }
        private static void OnRenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
        {
            if (mobileApi.GetRunningApp() != modID)
            {
                return;
            }

            // Draw the background on the phone while the app is running
            if (mobileApi.GetPhoneRotated())
            {
                // Horizontal phone
                e.SpriteBatch.Draw(JojaResources.GetJojaMobileHorzBackground(), mobileApi.GetScreenRectangle(), new Rectangle(0, 0, 200, 150), Color.White);
            }
            else
            {
                // Vertical phone
                e.SpriteBatch.Draw(JojaResources.GetJojaMobileVertBackground(), mobileApi.GetScreenRectangle(), new Rectangle(0, 0, 150, 200), Color.White);
            }
        }
Beispiel #15
0
        private void OnRenderingActiveMenu(object sender, RenderingActiveMenuEventArgs renderingActiveMenuEventArgs)
        {
            try
            {
                if (Game1.activeClickableMenu is GameMenu gameMenu)
                {
                    ReplaceAll(
                        gameMenu.pages,
                        page => page is StardewValley.Menus.InventoryPage and not InventoryPage,
                        page => new InventoryPage(this, page.xPositionOnScreen, page.yPositionOnScreen, page.width, page.height));
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to replace Inventory Page:\n{ex}", LogLevel.Error);
            }

            Helper.Events.Display.RenderingActiveMenu -= OnRenderingActiveMenu;
            Helper.Events.Display.RenderedActiveMenu  += OnRenderedActiveMenu;
        }
 /// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised before that menu is drawn to the screen. This includes the game's internal menus like the title screen. Content drawn to the sprite batch at this point will appear under the menu.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 protected virtual void OnRenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
 {
 }
Beispiel #17
0
        /// <summary>
        /// Changes the NPC sprites according to the selected cycle type
        /// </summary>
        private void OnRenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
        {
            if (Game1.activeClickableMenu == null || !(Game1.activeClickableMenu is Billboard billboard))
            {
                return;
            }

            if (currentCycle < spriteCycleTicks)
            {
                currentCycle++;
            }

            // Get the calendarDays component, it will be null if we're looking at the questboard
            List <ClickableTextureComponent> days = billboard.calendarDays;

            if (days == null)
            {
                return;
            }

            List <int> listOfDays = bdHelper.GetDays(Game1.currentSeason, true);

            switch (cycleType)
            {
            case CycleType.Always:
                if (currentCycle == spriteCycleTicks)
                {
                    for (int i = 0; i < listOfDays.Count; i++)
                    {
                        try
                        {
                            days[listOfDays[i] - 1].texture = bdHelper.GetSprite(Game1.currentSeason, listOfDays[i], true);
                        }
                        catch
                        {
                            // Generic error for now.
                            Monitor.Log("There was a problem with parsing the birthday data", LogLevel.Error);
                        }
                    }

                    // Reset the cycle
                    currentCycle = 0;
                }
                break;

            case CycleType.Hover:
                if (currentCycle == spriteCycleTicks)
                {
                    for (int i = 0; i < listOfDays.Count; i++)
                    {
                        if (days[listOfDays[i] - 1].containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                        {
                            days[listOfDays[i] - 1].texture = bdHelper.GetSprite(Game1.currentSeason, listOfDays[i], true);
                        }
                    }

                    // Reset the cycle
                    currentCycle = 0;
                }
                break;

            case CycleType.Click:
                if (clickedDay != -1 && listOfDays.Contains(clickedDay))
                {
                    days[clickedDay - 1].texture = bdHelper.GetSprite(Game1.currentSeason, clickedDay, true);
                    clickedDay = -1;
                }
                break;

            default:
                Monitor.Log("Unknown cycle type encountered in OnRenderingActiveMenu", LogLevel.Error);
                break;
            }
        }
Beispiel #18
0
        /// Draws the custom overlay for the inventory menu.
        private void DrawBeforeActiveMenu(object sender, RenderingActiveMenuEventArgs e)
        {
            // never allow an ItemGrabMenu to render its background while we are drawing FridgeMenu, it will do it instead.
            if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu && (Game1.activeClickableMenu as ItemGrabMenu).drawBG)
            {
                (Game1.activeClickableMenu as ItemGrabMenu).drawBG = false;
            }
            e.SpriteBatch.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * 0.5f);

            // if flagged, update tabs colors
            if (_updateTabColors)
            {
                _updateTabColors = false;
                _fridgeTabsColors.Clear();
                foreach (var c in _fridges)
                {
                    _fridgeTabsColors.Add(c.playerChoiceColor);
                }
            }

            // draw tabs
            int i = 1;

            for (int index = _rootTab; index < _fridgeTabs.Count && i++ <= 12; index++)
            {
                ClickableComponent tab = _fridgeTabs[index];

                int width  = Game1.tileSize / 2;
                int height = width;

                int xpos = tab.bounds.X - (_rootTab * Game1.tileSize);

                IClickableMenu.drawTextureBox(e.SpriteBatch, Game1.menuTexture, new Rectangle(0, 256, 60, 60), xpos, tab.bounds.Y, tab.bounds.Width, tab.bounds.Height, _selectedTab == index ? Color.White : new Color(0.3f, 0.3f, 0.3f, 1f), 1, false);
                Color tabCol = index == 0 ? Color.BurlyWood : _fridgeTabsColors[index] == Color.Black ? Color.BurlyWood : _fridgeTabsColors[index];
                e.SpriteBatch.Draw(Game1.staminaRect, new Rectangle(xpos + colorOffsetX, tab.bounds.Y + colorOffsetY, (int)(tab.bounds.Width * colorSizeModX), (int)(tab.bounds.Height * colorSizeModY)), tabCol);
                if (index == 0)
                {
                    const float scaleSize           = 2f;
                    Rectangle   rectForBigCraftable = Object.getSourceRectForBigCraftable(Utilities.MiniFridgeSheetIndex);
                    rectForBigCraftable.Height -= 16;
                    e.SpriteBatch.Draw(Game1.bigCraftableSpriteSheet, new Vector2(xpos + 32f, tab.bounds.Y + 32f + 21f), new Microsoft.Xna.Framework.Rectangle?(rectForBigCraftable), Color.White, 0.0f, new Vector2(8f, 16f), scaleSize, SpriteEffects.None, 1);
                }
                else
                {
                    int digit = int.Parse(tab.label);
                    if (digit < 10)
                    {
                        Utility.drawTinyDigits(digit, e.SpriteBatch, new Vector2(xpos + textOffsetX, tab.bounds.Y + textOffsetY), 4f, 1f, Color.White);
                    }
                    else
                    {
                        Utility.drawTinyDigits(digit, e.SpriteBatch, new Vector2(xpos + textOffsetX - 10, tab.bounds.Y + textOffsetY), 4f, 1f, Color.White);
                    }
                }

                if (_selectedTab != index)
                {
                    e.SpriteBatch.Draw(Game1.staminaRect, new Rectangle(xpos + colorOffsetX, tab.bounds.Y + colorOffsetY, (int)(tab.bounds.Width * colorSizeModX), (int)(tab.bounds.Height * colorSizeModY)), new Color(0, 0, 0, 0.4f));
                }
            }

            // draw arrows if too many fridges
            if (_fridges.Count > 12)
            {
                if (_rootTab > 0)
                {
                    _leftArrowButton.draw(e.SpriteBatch);
                }
                if (_rootTab + 12 < _fridges.Count)
                {
                    _rightArrowButton.draw(e.SpriteBatch);
                }
            }
        }
Beispiel #19
0
 private void Display_RenderingActiveMenu(object sender, RenderingActiveMenuEventArgs e)
 {
 }