Ejemplo n.º 1
0
        /// <summary>Draw tooltip for ingredients if cursor is hovering over them.</summary>
        /// <param name="__instance">The instance of the bundle menu.</param>
        /// <param name="b">The sprite batch.</param>
        public static void Postfix_draw(JunimoNoteMenu __instance, SpriteBatch b)
        {
            try
            {
                if (__instance.ingredientList == null || ingredientHoverText == null || ingredientHoverTitle == null)
                {
                    return;
                }

                int x = (int)input.GetCursorPosition().ScreenPixels.X, y = (int)input.GetCursorPosition().ScreenPixels.Y;
                for (int i = 0; i < __instance.ingredientList.Count; i++)
                {
                    if (__instance.ingredientList[i].bounds.Contains(x, y))
                    {
                        if (i >= ingredientHoverText.Length || i >= ingredientHoverTitle.Length)
                        {
                            continue;
                        }

                        IClickableMenu.drawToolTip(b, ingredientHoverText[i], ingredientHoverTitle[i], null);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Log("Error in draw: " + e.Message + Environment.NewLine + e.StackTrace);
            }
        }
Ejemplo n.º 2
0
 private void DrawHoverText(SpriteBatch b)
 {
     if (!string.IsNullOrEmpty(HoverText))
     {
         IClickableMenu.drawToolTip(b, HoveredItem?.getDescription() ?? HoverText, HoverText, HoveredItem);
     }
 }
Ejemplo n.º 3
0
 public void drawToolTip(SpriteBatch b)
 {
     if (this.displayItem != null)
     {
         IClickableMenu.drawToolTip(b, this.hoverText, this.hoverTitle, this.displayItem, false, -1, 0, -1, -1, (CraftingRecipe)null, -1);
     }
 }
Ejemplo n.º 4
0
 //This is run after drawing everything else in InventoryPage. Use for drawing hover text (on top of everything)
 public static void PostDraw(SpriteBatch spriteBatch)
 {
     if (drawHoverText)
     {
         IClickableMenu.drawToolTip(spriteBatch, button.hoverText, "", null, false, -1, 0, -1, -1, null, -1);
     }
 }
 public void drawToolTip(SpriteBatch b)
 {
     if (this.displayTrashedItem && this.trashedItem.item != null)
     {
         IClickableMenu.drawToolTip(b, this.trashedItem.item.getDescription(), this.trashedItem.item.DisplayName, this.trashedItem.item, false, -1, 0, -1, -1, (CraftingRecipe)null, -1);
     }
 }
Ejemplo n.º 6
0
        public override void draw(SpriteBatch b)
        {
            b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.6f);
            base.draw(b, drawUpperPortion: true, drawDescriptionArea: true, 50, 160, 255);
            b.Draw(dyeTexture, new Vector2(xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth / 2 - 4, yPositionOnScreen + IClickableMenu.spaceToClearTopBorder), new Rectangle(0, 0, 142, 80), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.87f);
            for (int j = 0; j < _slotDrawPositions.Count; j++)
            {
                if (j >= inventory.actualInventory.Count || inventory.actualInventory[j] == null || !_highlightDictionary.ContainsKey(inventory.actualInventory[j]))
                {
                    continue;
                }
                int index = _highlightDictionary[inventory.actualInventory[j]];
                if (index >= 0)
                {
                    Color color = GetColorForPot(index);
                    if (_hoveredPotIndex == -1 && HighlightItems(inventory.actualInventory[j]))
                    {
                        b.Draw(dyeTexture, _slotDrawPositions[j], new Rectangle(32, 96, 32, 32), color, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.1f);
                    }
                }
            }
            dyeButton.draw(b, Color.White * (CanDye() ? 1f : 0.55f), 0.96f);
            dyeButton.drawItem(b, 16, 16);
            string  make_result_text    = Game1.content.LoadString("Strings\\UI:DyePot_WillDye");
            Vector2 dyed_items_position = _dyedClothesDisplayPosition;

            Utility.drawTextWithColoredShadow(position: new Vector2(dyed_items_position.X - Game1.smallFont.MeasureString(make_result_text).X / 2f, (float)(int)dyed_items_position.Y - Game1.smallFont.MeasureString(make_result_text).Y), b: b, text: make_result_text, font: Game1.smallFont, color: Game1.textColor * 0.75f, shadowColor: Color.Black * 0.2f);
            foreach (ClickableTextureComponent dyedClothesDisplay in dyedClothesDisplays)
            {
                dyedClothesDisplay.drawItem(b);
            }
            for (int i = 0; i < dyePots.Count; i++)
            {
                dyePots[i].drawItem(b, 0, -16);
                if (_dyeDropAnimationFrames[i] >= 0)
                {
                    Color color2 = GetColorForPot(i);
                    b.Draw(dyeTexture, new Vector2(dyePots[i].bounds.X, dyePots[i].bounds.Y - 12), new Rectangle(_dyeDropAnimationFrames[i] / 50 * 16, 128, 16, 16), color2, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.87f);
                }
                dyePots[i].draw(b);
            }
            if (!hoverText.Equals(""))
            {
                IClickableMenu.drawHoverText(b, hoverText, Game1.smallFont, (heldItem != null) ? 32 : 0, (heldItem != null) ? 32 : 0);
            }
            else if (hoveredItem != null)
            {
                IClickableMenu.drawToolTip(b, hoveredItem.getDescription(), hoveredItem.DisplayName, hoveredItem, heldItem != null);
            }
            if (heldItem != null)
            {
                heldItem.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 8, Game1.getOldMouseY() + 8), 1f);
            }
            if (!Game1.options.hardwareCursor)
            {
                drawMouse(b);
            }
        }
Ejemplo n.º 7
0
 private void drawOptionsButton(SpriteBatch b)
 {
     _optionsButtom.draw(b);
     _optionsButtom.tryHover(Game1.getMouseX(), Game1.getMouseY());
     if (_optionsButtom.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
     {
         IClickableMenu.drawToolTip(b, _optionsButtom.hoverText, _optionsButtom.name, null);
     }
 }
Ejemplo n.º 8
0
 public void drawToolTip(SpriteBatch b)
 {
     //If an item is hovered, shows its tooltip.
     if (this.hoverItem == null)
     {
         return;
     }
     IClickableMenu.drawToolTip(b, this.hoverItem.getDescription(), this.hoverItem.Name, this.hoverItem);
     this.hoverItem = null;
 }
Ejemplo n.º 9
0
        public override void draw(SpriteBatch b)
        {
            // darken the background
            b.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.uiViewport.Width, Game1.uiViewport.Height), Color.Black * 0.5f);

            base.draw(b, drawUpperPortion: false, drawDescriptionArea: false);

            // draw the bot inventory
            Rectangle invR = botInventoryBounds();

            Game1.drawDialogueBox(invR.X, invR.Y, invR.Width, invR.Height, speaker: false, drawOnlyBox: true);
            botInventoryMenu.draw(b);

            // draw the console
            Rectangle consoleR = consoleBounds();

            Game1.drawDialogueBox(consoleR.X, consoleR.Y, consoleR.Width, consoleR.Height, speaker: false, drawOnlyBox: true);
            bot.shell.console.draw(b);

/*
 *                      if (poof != null)
 *                      {
 *                              poof.draw(b, localPosition: true);
 *                      }
 *                      foreach (TransferredItemSprite transferredItemSprite in _transferredItemSprites)
 *                      {
 *                              transferredItemSprite.Draw(b);
 *                      }
 */
            if (hoverText != null && hoveredItem == null)
            {
                if (hoverAmount > 0)
                {
                    IClickableMenu.drawToolTip(b, hoverText, "", null, heldItem: true, -1, 0, -1, -1, null, hoverAmount);
                }
                else
                {
                    IClickableMenu.drawHoverText(b, hoverText, Game1.smallFont);
                }
            }
            if (hoveredItem != null)
            {
                IClickableMenu.drawToolTip(b, hoveredItem.getDescription(), hoveredItem.DisplayName, hoveredItem, heldItem != null);
            }
            else if (hoveredItem != null && botInventoryMenu != null)
            {
                IClickableMenu.drawToolTip(b, botInventoryMenu.descriptionText, botInventoryMenu.descriptionTitle, hoveredItem, heldItem != null);
            }
            if (heldItem != null)
            {
                heldItem.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 8, Game1.getOldMouseY() + 8), 1f);
            }
            Game1.mouseCursorTransparency = 1f;
            drawMouse(b);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Event handler to render the hover tooltip to the screen after the rest of the SpriteBatch is drawn.
        /// </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, used to access the SpriteBatch.</param>
        private void Display_RenderedActiveMenu(object sender, StardewModdingAPI.Events.RenderedActiveMenuEventArgs e)
        {
            GameMenu menu = Game1.activeClickableMenu as GameMenu;

            if (menu != null && menu.currentTab == 0)
            {
                if (hoverText != "")
                {
                    IClickableMenu.drawToolTip(e.SpriteBatch, this.hoverText, "", null);
                }
            }
        }
Ejemplo n.º 11
0
        // Token: 0x06001038 RID: 4152 RVA: 0x0014F864 File Offset: 0x0014DA64
        public override void draw(SpriteBatch b)
        {
            if (Game1.activeClickableMenu != null)
            {
                return;
            }
            int arg_143_0 = this.yPositionOnScreen;

            if (Game1.options.pinToolbarToggle)
            {
                this.yPositionOnScreen = Game1.viewport.Height;
                this.transparency      = Math.Min(1f, this.transparency + 0.075f);
                if (Game1.GlobalToLocal(Game1.viewport, new Vector2((float)Game1.player.GetBoundingBox().Center.X, (float)Game1.player.GetBoundingBox().Center.Y)).Y > (float)(Game1.viewport.Height - Game1.tileSize * 3))
                {
                    this.transparency = Math.Max(0.33f, this.transparency - 0.15f);
                }
            }
            else
            {
                this.yPositionOnScreen = ((Game1.GlobalToLocal(Game1.viewport, new Vector2((float)Game1.player.GetBoundingBox().Center.X, (float)Game1.player.GetBoundingBox().Center.Y)).Y > (float)(Game1.viewport.Height / 2 + Game1.tileSize)) ? (Game1.tileSize + Game1.tileSize * 3 / 4) : Game1.viewport.Height);
            }
            if (arg_143_0 != this.yPositionOnScreen)
            {
                for (int i = 0; i < 12; i++)
                {
                    this.buttons[i].bounds.Y = this.yPositionOnScreen - Game1.tileSize * 3 / 2 + 8;
                }
            }
            IClickableMenu.drawTextureBox(b, Game1.menuTexture, this.toolbarTextSource, Game1.viewport.Width / 2 - Game1.tileSize * 12 / 2 - Game1.pixelZoom * 4, this.yPositionOnScreen - Game1.tileSize * 3 / 2 - Game1.pixelZoom * 2, Game1.tileSize * 12 + Game1.tileSize / 2, Game1.tileSize + Game1.tileSize / 2, Color.White * this.transparency, 1f, false);
            for (int j = 0; j < 12; j++)
            {
                Vector2 toDraw = new Vector2((float)(Game1.viewport.Width / 2 - Game1.tileSize * 12 / 2 + j * Game1.tileSize), (float)(this.yPositionOnScreen - Game1.tileSize * 3 / 2 + 8));
                b.Draw(Game1.menuTexture, toDraw, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, (Game1.player.CurrentToolIndex == j) ? 56 : 10, -1, -1)), Color.White * this.transparency);
                string strToDraw = (j == 9) ? "0" : ((j == 10) ? "-" : ((j == 11) ? "=" : string.Concat(j + 1)));
                b.DrawString(Game1.tinyFont, strToDraw, toDraw + new Vector2(4f, -8f), Color.DimGray * this.transparency);
            }
            for (int k = 0; k < 12; k++)
            {
                this.buttons[k].scale = Math.Max(1f, this.buttons[k].scale - 0.025f);
                Vector2 toDraw2 = new Vector2((float)(Game1.viewport.Width / 2 - Game1.tileSize * 12 / 2 + k * Game1.tileSize), (float)(this.yPositionOnScreen - Game1.tileSize * 3 / 2 + 8));
                if (Game1.player.items.Count > k && Game1.player.items.ElementAt(k) != null)
                {
                    Game1.player.items[k].drawInMenu(b, toDraw2, (Game1.player.CurrentToolIndex == k) ? 0.9f : (this.buttons.ElementAt(k).scale * 0.8f), this.transparency, 0.88f);
                }
            }
            if (this.hoverItem != null)
            {
                IClickableMenu.drawToolTip(b, this.hoverItem.getDescription(), this.hoverItem.Name, this.hoverItem, false, -1, 0, -1, -1, null, -1);
                this.hoverItem = null;
            }
        }
Ejemplo n.º 12
0
        public void onRenderedActiveMenu(object _sender,
                                         RenderedActiveMenuEventArgs e)
        {
            if (!shouldRender)
            {
                return;
            }
            var trueMenu = this.trueMenu;

            // Draw the label.
            string  label    = Helper.Translation.Get("PregnancyRole");
            Vector2 position = new Vector2
                                   (trueMenu.xPositionOnScreen + offset.X -
                                   Game1.smallFont.MeasureString(label).X + 4 - 64,
                                   trueMenu.yPositionOnScreen + offset.Y + 8);

            e.SpriteBatch.DrawString(Game1.smallFont, label, position,
                                     Game1.textColor);

            // Draw the dropdown.
            dropdown.draw(e.SpriteBatch,
                          trueMenu.xPositionOnScreen,
                          trueMenu.yPositionOnScreen);

            // Raise any hovertext back over the label and dropdown.
            string hoverText   = this.hoverText ?? "";
            string hoverTitle  = this.hoverTitle ?? "";
            Item   hoveredItem = this.hoveredItem;

            if (hoveredItem != null)
            {
                if (!Game1.options.snappyMenus &&
                    !Game1.options.gamepadControls &&
                    Game1.lastCursorMotionWasMouse)
                {
                    IClickableMenu.drawToolTip(e.SpriteBatch,
                                               hoveredItem.getDescription(), hoveredItem.DisplayName,
                                               hoveredItem);
                }
            }
            else if (hoverText.Length > 0)
            {
                IClickableMenu.drawHoverText(e.SpriteBatch, hoverText,
                                             Game1.smallFont, 0, 0, -1,
                                             (hoverTitle.Length > 0) ? hoverTitle : null);
            }

            // Raise the mouse cursor back over everything.
            trueMenu.drawMouse(e.SpriteBatch);
        }
Ejemplo n.º 13
0
 private void DrawHoverText(SpriteBatch b)
 {
     if (!string.IsNullOrEmpty(HoverText))
     {
         if (HoveredItem != null)
         {
             IClickableMenu.drawToolTip(b, HoveredItem.getDescription(), HoverText, HoveredItem);
         }
         else
         {
             IClickableMenu.drawHoverText(Game1.spriteBatch, HoverText, Game1.dialogueFont);
         }
     }
 }
Ejemplo n.º 14
0
 public override void draw(SpriteBatch b)
 {
     foreach (ClickableTextureComponent value2 in sideTabs.Values)
     {
         value2.draw(b);
     }
     if (currentPage > 0)
     {
         backButton.draw(b);
     }
     if (currentPage < collections[currentTab].Count - 1)
     {
         forwardButton.draw(b);
     }
     b.End();
     b.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
     foreach (ClickableTextureComponent c in collections[currentTab][currentPage])
     {
         bool drawColor      = Convert.ToBoolean(c.name.Split(' ')[1]);
         bool drawColorFaded = currentTab == 4 && Convert.ToBoolean(c.name.Split(' ')[2]);
         c.draw(b, drawColorFaded ? (Color.DimGray * 0.4f) : (drawColor ? Color.White : (Color.Black * 0.2f)), 0.86f);
         if (currentTab == 5 && drawColor)
         {
             int StarPos = new Random(Convert.ToInt32(c.name.Split(' ')[0])).Next(12);
             b.Draw(Game1.mouseCursors, new Vector2(c.bounds.X + 16 + 16, c.bounds.Y + 20 + 16), new Rectangle(256 + StarPos % 6 * 64 / 2, 128 + StarPos / 6 * 64 / 2, 32, 32), Color.White, 0f, new Vector2(16f, 16f), c.scale, SpriteEffects.None, 0.88f);
         }
     }
     b.End();
     b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
     if (hoverItem != null)
     {
         IClickableMenu.drawToolTip(b, hoverItem.getDescription(), hoverItem.DisplayName, hoverItem, heldItem: false, -1, 0, -1, -1, hoverCraftingRecipe);
     }
     else if (!hoverText.Equals(""))
     {
         IClickableMenu.drawHoverText(b, hoverText, Game1.smallFont, 0, 0, value);
         if (secretNoteImage != -1)
         {
             IClickableMenu.drawTextureBox(b, Game1.getOldMouseX(), Game1.getOldMouseY() + 64 + 32, 288, 288, Color.White);
             b.Draw(secretNoteImageTexture, new Vector2(Game1.getOldMouseX() + 16, Game1.getOldMouseY() + 64 + 32 + 16), new Rectangle(secretNoteImage * 64 % secretNoteImageTexture.Width, secretNoteImage * 64 / secretNoteImageTexture.Width * 64, 64, 64), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.865f);
         }
     }
     if (letterviewerSubMenu != null)
     {
         letterviewerSubMenu.draw(b);
     }
 }
Ejemplo n.º 15
0
        public override void draw(SpriteBatch b)
        {
            bool ignoreTitleSafe2 = false;

            ignoreTitleSafe2 = true;
            Game1.drawDialogueBox(xPositionOnScreen, yPositionOnScreen, width, height, speaker: false, drawOnlyBox: true, null, objectDialogueWithPortrait: false, ignoreTitleSafe2);
            b.End();
            Rectangle cached_scissor_rect = b.GraphicsDevice.ScissorRectangle;

            b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, new RasterizerState
            {
                ScissorTestEnable = true
            });
            b.GraphicsDevice.ScissorRectangle = scrollView;
            foreach (ClickableTextureComponent component in recipeComponents)
            {
                if (component.visible)
                {
                    drawHorizontalPartition(b, component.bounds.Bottom - 32, small: true);
                    KeyValuePair <Item, Item> kvp = _recipeLookup[component.name];
                    component.draw(b);
                    kvp.Key.drawInMenu(b, new Vector2(component.bounds.X, component.bounds.Y), 1f);
                    if (_recipeColors.ContainsKey(component.name))
                    {
                        int size = 24;
                        b.Draw(Game1.staminaRect, new Rectangle(scrollView.Left + scrollView.Width / 2 - size / 2, component.bounds.Center.Y - size / 2, size, size), _recipeColors[component.name]);
                    }
                    if (kvp.Value != null)
                    {
                        kvp.Value.drawInMenu(b, new Vector2(scrollView.Left + scrollView.Width - 128, component.bounds.Y), 1f);
                    }
                }
            }
            b.End();
            b.GraphicsDevice.ScissorRectangle = cached_scissor_rect;
            b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
            okButton.draw(b);
            drawMouse(b);
            if (hoveredItem != null)
            {
                Utility.drawTextWithShadow(b, metadata, Game1.smallFont, new Vector2(xPositionOnScreen + IClickableMenu.borderWidth, yPositionOnScreen + height - 64), Color.Black);
                if (!Game1.oldKBState.IsKeyDown(Keys.LeftShift))
                {
                    IClickableMenu.drawToolTip(b, hoveredItem.getDescription(), hoveredItem.DisplayName, hoveredItem);
                }
            }
        }
        /// <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);
            }
        }
Ejemplo n.º 17
0
        public override void draw(SpriteBatch b)
        {
            if (this._standaloneMenu)
            {
                Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true, (string)null, false, true, -1, -1, -1);
            }
            this.drawHorizontalPartition(b, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 256, false, -1, -1, -1);
            this.inventory.draw(b);
            if (this.trashCan != null)
            {
                this.trashCan.draw(b);
                b.Draw(Game1.mouseCursors, new Vector2((float)(this.trashCan.bounds.X + 60), (float)(this.trashCan.bounds.Y + 40)), new Rectangle?(new Rectangle(564 + Game1.player.trashCanLevel * 18, 129, 18, 10)), Color.White, this.trashCanLidRotation, new Vector2(16f, 10f), 4f, SpriteEffects.None, 0.86f);
            }
            b.End();
            b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
            foreach (ClickableTextureComponent key in this.pagesOfCraftingRecipes[this.currentCraftingPage].Keys)
            {
                if (key.hoverText.Equals("ghosted"))
                {
                    key.draw(b, Color.Black * 0.35f, 0.89f, 0);
                }
                else if (!this.pagesOfCraftingRecipes[this.currentCraftingPage][key].doesFarmerHaveIngredientsInInventory(this.getContainerContents()))
                {
                    key.draw(b, Color.LightGray * 0.4f, 0.89f, 0);
                    if (this.pagesOfCraftingRecipes[this.currentCraftingPage][key].numberProducedPerCraft > 1)
                    {
                        NumberSprite.draw(this.pagesOfCraftingRecipes[this.currentCraftingPage][key].numberProducedPerCraft, b, new Vector2((float)(key.bounds.X + 64 - 2), (float)(key.bounds.Y + 64 - 2)), Color.LightGray * 0.75f, (float)(0.5 * ((double)key.scale / 4.0)), 0.97f, 1f, 0, 0);
                    }
                }
                else
                {
                    key.draw(b);
                    if (this.pagesOfCraftingRecipes[this.currentCraftingPage][key].numberProducedPerCraft > 1)
                    {
                        NumberSprite.draw(this.pagesOfCraftingRecipes[this.currentCraftingPage][key].numberProducedPerCraft, b, new Vector2((float)(key.bounds.X + 64 - 2), (float)(key.bounds.Y + 64 - 2)), Color.White, (float)(0.5 * ((double)key.scale / 4.0)), 0.97f, 1f, 0, 0);
                    }
                }
            }
            b.End();
            b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
            if (this.hoverItem != null)
            {
                IClickableMenu.drawToolTip(b, this.hoverText, this.hoverTitle, this.hoverItem, this.heldItem != null, -1, 0, -1, -1, (CraftingRecipe)null, -1);
            }
            else if (!string.IsNullOrEmpty(this.hoverText))
            {
                if (this.hoverAmount > 0)
                {
                    IClickableMenu.drawToolTip(b, this.hoverText, this.hoverTitle, (Item)null, true, -1, 0, -1, -1, (CraftingRecipe)null, this.hoverAmount);
                }
                else
                {
                    IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, this.heldItem != null ? 64 : 0, this.heldItem != null ? 64 : 0, -1, (string)null, -1, (string[])null, (Item)null, 0, -1, -1, -1, -1, 1f, (CraftingRecipe)null, (IList <Item>)null);
                }
            }
            if (this.heldItem != null)
            {
                this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + 16), (float)(Game1.getOldMouseY() + 16)), 1f);
            }
            base.draw(b);
            if (this.downButton != null && this.currentCraftingPage < this.pagesOfCraftingRecipes.Count - 1)
            {
                this.downButton.draw(b);
            }
            if (this.upButton != null && this.currentCraftingPage > 0)
            {
                this.upButton.draw(b);
            }
            if (this._standaloneMenu)
            {
                Game1.mouseCursorTransparency = 1f;
                this.drawMouse(b);
            }
            if (this.hoverRecipe == null)
            {
                return;
            }
            SpriteBatch b1          = b;
            SpriteFont  smallFont   = Game1.smallFont;
            int         xOffset     = this.heldItem != null ? 48 : 0;
            int         yOffset     = this.heldItem != null ? 48 : 0;
            string      displayName = this.hoverRecipe.DisplayName;

            string[] buffIconsToDisplay;
            if (this.cooking && this.lastCookingHover != null)
            {
                if (Game1.objectInformation[(int)((NetFieldBase <int, NetInt>)(this.lastCookingHover as StardewValley.Object).parentSheetIndex)].Split('/').Length > 7)
                {
                    buffIconsToDisplay = Game1.objectInformation[(int)((NetFieldBase <int, NetInt>)(this.lastCookingHover as StardewValley.Object).parentSheetIndex)].Split('/')[7].Split(' ');
                    goto label_35;
                }
            }
            buffIconsToDisplay = (string[])null;
label_35:
            Item lastCookingHover = this.lastCookingHover;
            CraftingRecipe hoverRecipe       = this.hoverRecipe;
            IList <Item>   containerContents = this.getContainerContents();

            IClickableMenu.drawHoverText(b1, " ", smallFont, xOffset, yOffset, -1, displayName, -1, buffIconsToDisplay, lastCookingHover, 0, -1, -1, -1, -1, 1f, hoverRecipe, containerContents);
        }
Ejemplo n.º 18
0
        /// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen.</summary>
/// <param name="sender">The event sender.</param>
/// <param name="e">The event arguments.</param>
        private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e)
        {
            // draw shop harvest prices
            if (Game1.activeClickableMenu is ShopMenu menu)
            {
                if (typeof(ShopMenu).GetField("hoveredItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(menu) is Item hoverItem)
                {
                    String text             = string.Empty;
                    bool   itemHasPriceInfo = Tools.GetTruePrice(hoverItem) > 0;

                    if (hoverItem is StardewValley.Object &&
                        (hoverItem as StardewValley.Object).Type == "Seeds" &&
                        itemHasPriceInfo &&
                        hoverItem.Name != "Mixed Seeds" &&
                        hoverItem.Name != "Winter Seeds")
                    {
                        StardewValley.Object temp =
                            new StardewValley.Object(
                                new Debris(
                                    new Crop(
                                        hoverItem.ParentSheetIndex,
                                        0,
                                        0)
                                    .indexOfHarvest.Value,
                                    Game1.player.position,
                                    Game1.player.position).chunkType.Value,
                                1);
                        text = "    " + temp.Price;
                    }

                    Item heldItem = typeof(ShopMenu).GetField("heldItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(menu) as Item;
                    if (heldItem == null)
                    {
                        int value = 0;
                        switch (hoverItem.ParentSheetIndex)
                        {
                        case 628: value = 50; break;

                        case 629: value = 80; break;

                        case 630:
                        case 633: value = 100; break;

                        case 631:
                        case 632: value = 140; break;
                        }

                        if (value > 0)
                        {
                            text = "    " + value;
                        }

                        if (text != "" &&
                            (hoverItem as StardewValley.Object).Type == "Seeds")
                        {
                            String textToRender = _helper.SafeGetString(
                                LanguageKeys.HarvestPrice);
                            int xPosition = menu.xPositionOnScreen - 30;
                            int yPosition = menu.yPositionOnScreen + 580;
                            IClickableMenu.drawTextureBox(
                                Game1.spriteBatch,
                                xPosition + 20,
                                yPosition - 52,
                                264,
                                108,
                                Color.White);
                            Game1.spriteBatch.DrawString(
                                Game1.dialogueFont,
                                textToRender,
                                new Vector2(xPosition + 30, yPosition - 38),
                                Color.Black * 0.2f);
                            Game1.spriteBatch.DrawString(
                                Game1.dialogueFont,
                                textToRender,
                                new Vector2(xPosition + 32, yPosition - 40),
                                Color.Black * 0.8f);
                            xPosition += 80;

                            Game1.spriteBatch.Draw(
                                Game1.mouseCursors,
                                new Vector2(xPosition, yPosition),
                                new Rectangle(60, 428, 10, 10),
                                Color.White,
                                0,
                                Vector2.Zero,
                                Game1.pixelZoom,
                                SpriteEffects.None,
                                0.85f);

                            Game1.spriteBatch.Draw(
                                Game1.debrisSpriteSheet,
                                new Vector2(xPosition + 32, yPosition + 10),
                                Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 8, 16, 16),
                                Color.White,
                                0,
                                new Vector2(8, 8),
                                4,
                                SpriteEffects.None,
                                0.95f);

                            Game1.spriteBatch.DrawString(
                                Game1.dialogueFont,
                                text,
                                new Vector2(xPosition - 2, yPosition + 6),
                                Color.Black * 0.2f);

                            Game1.spriteBatch.DrawString(
                                Game1.dialogueFont,
                                text,
                                new Vector2(xPosition, yPosition + 4),
                                Color.Black * 0.8f);

                            String           hoverText  = _helper.Reflection.GetField <String>(menu, "hoverText").GetValue();
                            String           hoverTitle = _helper.Reflection.GetField <String>(menu, "boldTitleText").GetValue();
                            Item             hoverItem2 = _helper.Reflection.GetField <Item>(menu, "hoveredItem").GetValue();
                            int              currency   = _helper.Reflection.GetField <int>(menu, "currency").GetValue();
                            int              hoverPrice = _helper.Reflection.GetField <int>(menu, "hoverPrice").GetValue();
                            IReflectedMethod getHoveredItemExtraItemIndex  = _helper.Reflection.GetMethod(menu, "getHoveredItemExtraItemIndex");
                            IReflectedMethod getHoveredItemExtraItemAmount = _helper.Reflection.GetMethod(menu, "getHoveredItemExtraItemAmount");

                            IClickableMenu.drawToolTip(
                                Game1.spriteBatch,
                                hoverText,
                                hoverTitle,
                                hoverItem2,
                                heldItem != null,
                                -1,
                                currency,
                                getHoveredItemExtraItemIndex.Invoke <int>(new object[0]),
                                getHoveredItemExtraItemAmount.Invoke <int>(new object[0]),
                                null,
                                hoverPrice);
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
 public override void draw(SpriteBatch b)
 {
     if (this.drawBG)
     {
         b.Draw(Game1.fadeToBlackRect, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.Black * 0.5f);
     }
     base.draw(b, false, false);
     if (this.showReceivingMenu)
     {
         b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 16 * Game1.pixelZoom), (float)(this.yPositionOnScreen + this.height / 2 + Game1.tileSize + Game1.pixelZoom * 4)), new Rectangle?(new Rectangle(16, 368, 12, 16)), Color.White, 4.712389f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
         b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 16 * Game1.pixelZoom), (float)(this.yPositionOnScreen + this.height / 2 + Game1.tileSize - Game1.pixelZoom * 4)), new Rectangle?(new Rectangle(21, 368, 11, 16)), Color.White, 4.712389f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
         b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 10 * Game1.pixelZoom), (float)(this.yPositionOnScreen + this.height / 2 + Game1.tileSize - Game1.pixelZoom * 11)), new Rectangle?(new Rectangle(4, 372, 8, 11)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
         if (this.source != 0)
         {
             b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 18 * Game1.pixelZoom), (float)(this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 4)), new Rectangle?(new Rectangle(16, 368, 12, 16)), Color.White, 4.712389f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
             b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 18 * Game1.pixelZoom), (float)(this.yPositionOnScreen + Game1.tileSize - Game1.pixelZoom * 4)), new Rectangle?(new Rectangle(21, 368, 11, 16)), Color.White, 4.712389f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
             Rectangle value = new Rectangle(127, 412, 10, 11);
             int       num   = this.source;
             if (num != 2)
             {
                 if (num == 3)
                 {
                     value.X += 10;
                 }
             }
             else
             {
                 value.X += 20;
             }
             b.Draw(Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen - 13 * Game1.pixelZoom), (float)(this.yPositionOnScreen + Game1.tileSize - Game1.pixelZoom * 11)), new Rectangle?(value), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
         }
         Game1.drawDialogueBox(this.ItemsToGrabMenu.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder, this.ItemsToGrabMenu.yPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder, this.ItemsToGrabMenu.width + IClickableMenu.borderWidth * 2 + IClickableMenu.spaceToClearSideBorder * 2, this.ItemsToGrabMenu.height + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth * 2, false, true, null, false);
         this.ItemsToGrabMenu.draw(b);
     }
     else if (this.message != null)
     {
         Game1.drawDialogueBox(Game1.viewport.Width / 2, this.ItemsToGrabMenu.yPositionOnScreen + this.ItemsToGrabMenu.height / 2, false, false, this.message);
     }
     if (this.poof != null)
     {
         this.poof.draw(b, true, 0, 0);
     }
     if (this.shippingBin && Game1.getFarm().lastItemShipped != null)
     {
         this.lastShippedHolder.draw(b);
         Game1.getFarm().lastItemShipped.drawInMenu(b, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * 4), (float)(this.lastShippedHolder.bounds.Y + Game1.pixelZoom * 4)), 1f);
         b.Draw(Game1.mouseCursors, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * -2), (float)(this.lastShippedHolder.bounds.Bottom - Game1.pixelZoom * 25)), new Rectangle?(new Rectangle(325, 448, 5, 14)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
         b.Draw(Game1.mouseCursors, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * 21), (float)(this.lastShippedHolder.bounds.Bottom - Game1.pixelZoom * 25)), new Rectangle?(new Rectangle(325, 448, 5, 14)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
         b.Draw(Game1.mouseCursors, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * -2), (float)(this.lastShippedHolder.bounds.Bottom - Game1.pixelZoom * 11)), new Rectangle?(new Rectangle(325, 452, 5, 13)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
         b.Draw(Game1.mouseCursors, new Vector2((float)(this.lastShippedHolder.bounds.X + Game1.pixelZoom * 21), (float)(this.lastShippedHolder.bounds.Bottom - Game1.pixelZoom * 11)), new Rectangle?(new Rectangle(325, 452, 5, 13)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, 1f);
     }
     if (this.colorPickerToggleButton != null)
     {
         this.colorPickerToggleButton.draw(b);
     }
     else if (this.specialButton != null)
     {
         this.specialButton.draw(b);
     }
     if (this.chestColorPicker != null)
     {
         this.chestColorPicker.draw(b);
     }
     if (this.organizeButton != null)
     {
         this.organizeButton.draw(b);
     }
     if (this.hoverText != null && (this.hoveredItem == null || this.hoveredItem == null || this.ItemsToGrabMenu == null))
     {
         IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, 0, 0, -1, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null);
     }
     if (this.hoveredItem != null)
     {
         IClickableMenu.drawToolTip(b, this.hoveredItem.getDescription(), this.hoveredItem.DisplayName, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, null, -1);
     }
     else if (this.hoveredItem != null && this.ItemsToGrabMenu != null)
     {
         IClickableMenu.drawToolTip(b, this.ItemsToGrabMenu.descriptionText, this.ItemsToGrabMenu.descriptionTitle, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, null, -1);
     }
     if (this.heldItem != null)
     {
         this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + 8), (float)(Game1.getOldMouseY() + 8)), 1f);
     }
     Game1.mouseCursorTransparency = 1f;
     base.drawMouse(b);
 }
Ejemplo n.º 20
0
        public override void draw(SpriteBatch b)
        {
            // Fade the area
            b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f);

            // Draw the main box, along with the money box
            Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, speaker: false, drawOnlyBox: true, r: 80, g: 123, b: 186);
            Game1.dayTimeMoneyBox.drawMoneyBox(b);

            // See if we're checking out
            if (isCheckingOut)
            {
                b.Draw(JojaResources.GetJojaCheckoutBackground(), new Rectangle(this.xPositionOnScreen + IClickableMenu.borderWidth - 8, this.yPositionOnScreen + IClickableMenu.borderWidth + 56, this.width - (IClickableMenu.borderWidth * 2) + 16, this.height - 128), new Rectangle(0, 0, 150, 200), Color.White);

                // Draw cancel button
                cancelButton.draw(b);

                // Draw item icon, name and quantity
                int subTotal        = 0;
                int stackCount      = 0;
                int uniqueItemCount = 1;

                int   rowStart    = scale == 1f ? 120 : 140;
                int   rowSpacing  = scale == 1f ? 45 : 40;
                float textScale   = scale == 1f ? 1f : 0.5f;
                float itemScaling = scale == 1f ? 0.5f : 0.4f;
                foreach (ISalable item in itemsInCart.Keys)
                {
                    // Draw item
                    item.Stack = itemsInCart[item][1];
                    item.drawInMenu(b, GetScaledVector(80, rowStart + (rowSpacing * uniqueItemCount)), itemScaling, 1f, 0.9f, StackDrawType.Hide, Color.White, drawShadow: false);

                    // Draw name / quantity and price
                    Utility.drawTextWithShadow(b, $"{item.DisplayName} x{item.Stack}", Game1.dialogueFont, new Vector2(this.xPositionOnScreen + this.width / 4, GetScaledYCoordinate(rowStart + 10 + (rowSpacing * uniqueItemCount))), Color.White, textScale, 0.5f, numShadows: 0, shadowIntensity: 0);

                    int stackCost = item.Stack * itemsInCart[item][0];
                    Utility.drawTextWithShadow(b, stackCost + "g", Game1.dialogueFont, new Vector2((int)(this.xPositionOnScreen + this.width - this.width / 6 - IClickableMenu.borderWidth), GetScaledYCoordinate(rowStart + 10 + (rowSpacing * uniqueItemCount))), item == randomSaleItem ? Color.Cyan : Color.White, textScale, 0.5f, numShadows: 0, shadowIntensity: 0);

                    stackCount += item.Stack;
                    subTotal   += stackCost;
                    uniqueItemCount++;
                }

                // Check if purchased item(s) contain Joja Prime, if so offer free shipping
                bool isPurchasingPrimeShipping = itemsInCart.Any(i => (i.Key as Item).ParentSheetIndex == JojaItems.GetJojaPrimeMembershipID()) ? true : false;

                // Draw the shipping options (free 2 day or next day with fee)
                Utility.drawTextWithShadow(b, "Options", Game1.dialogueFont, new Vector2(this.xPositionOnScreen + 85 * scale, (this.yPositionOnScreen + this.height - this.height / 3) - 20 * scale), Color.White, scale, 0.6f, numShadows: 0, shadowIntensity: 0);
                IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(403, 373, 9, 9), this.twoDayShippingButton.bounds.X, this.twoDayShippingButton.bounds.Y, this.twoDayShippingButton.bounds.Width, this.twoDayShippingButton.bounds.Height, isNextDayShipping ? Color.White : Color.Gray, scale * 4f * twoDayShippingButton.scale, false);
                Utility.drawTextWithShadow(b, "Two Day (Free)", Game1.dialogueFont, new Vector2(this.twoDayShippingButton.bounds.X + 12 * scale, this.twoDayShippingButton.bounds.Y + (LocalizedContentManager.CurrentLanguageLatin ? 16 : 12) * scale), Game1.textColor * (isNextDayShipping ? 1f : 0.25f), textScale, -1f, 0, 0, 0, 0);

                string nextDayShippingText = hasPrimeShipping || isPurchasingPrimeShipping ? $"Next Day (Free)" : $"Next Day (+{nextDayShippingFee}%)";
                IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(403, 373, 9, 9), this.nextDayShippingButton.bounds.X, this.nextDayShippingButton.bounds.Y, this.nextDayShippingButton.bounds.Width, this.nextDayShippingButton.bounds.Height, isNextDayShipping ? Color.Gray : Color.White, scale * 4f * nextDayShippingButton.scale, false);
                Utility.drawTextWithShadow(b, nextDayShippingText, Game1.dialogueFont, new Vector2(this.nextDayShippingButton.bounds.X + 12 * scale, this.nextDayShippingButton.bounds.Y + (LocalizedContentManager.CurrentLanguageLatin ? 16 : 12) * scale), Game1.textColor * (isNextDayShipping ? 0.25f : 1f), textScale, -1f, 0, 0, 0, 0);

                // Draw the subtotal
                //Utility.drawTextWithShadow(b, $"Subtotal:", Game1.dialogueFont, GetScaledVector(this.width - SpriteText.getWidthOfString($"Subtotal:{subTotal}g") - 50, this.height - 320), Color.LightGray, scale, 0.6f, numShadows: 0, shadowIntensity: 0);
                //Utility.drawTextWithShadow(b, $"{subTotal}g", Game1.dialogueFont, GetScaledVector(this.width - SpriteText.getWidthOfString($"{subTotal}g") - 75, this.height - 320), Color.LightGray, scale, 0.6f, numShadows: 0, shadowIntensity: 0);

                // Draw the shipping costs
                int    shippingCosts    = isNextDayShipping && !hasPrimeShipping && !isPurchasingPrimeShipping ? subTotal / nextDayShippingFee : 0;
                string shippingCostText = shippingCosts == 0 ? "FREE" : $"{shippingCosts}g";
                Utility.drawTextWithShadow(b, $"Shipping:", Game1.dialogueFont, new Vector2(this.xPositionOnScreen + this.width / 2 + 20 * scale, (this.yPositionOnScreen + this.height - this.height / 3) - 20 * scale), Color.White, scale, 0.6f, numShadows: 0, shadowIntensity: 0);
                Utility.drawTextWithShadow(b, shippingCostText, Game1.dialogueFont, new Vector2(this.xPositionOnScreen + this.width - SpriteText.getWidthOfString(shippingCostText) * scale - (shippingCostText == "FREE" ? 75 * scale : 25), (this.yPositionOnScreen + this.height - this.height / 3) - 20 * scale), Color.White, scale, 0.6f, numShadows: 0, shadowIntensity: 0);

                // Draw the total
                int total = subTotal + shippingCosts;
                Utility.drawTextWithShadow(b, $"Total:", Game1.dialogueFont, new Vector2(this.xPositionOnScreen + 85 * scale, this.purchaseButton.bounds.Y + (LocalizedContentManager.CurrentLanguageLatin ? 16 : 12) * scale), Color.Gold, scale, 0.6f, numShadows: 0, shadowIntensity: 0);
                Utility.drawTextWithShadow(b, $"{total}g", Game1.dialogueFont, new Vector2(this.xPositionOnScreen + (85 * scale + SpriteText.getWidthOfString($"Total:") * scale), this.purchaseButton.bounds.Y + (LocalizedContentManager.CurrentLanguageLatin ? 16 : 12) * scale), Color.Gold, scale, 0.6f, numShadows: 0, shadowIntensity: 0);

                // Draw the purchase button
                canAffordOrder = total <= Game1.player.Money ? true : false;
                IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(403, 373, 9, 9), this.purchaseButton.bounds.X, this.purchaseButton.bounds.Y, this.purchaseButton.bounds.Width, this.purchaseButton.bounds.Height, canAffordOrder ? Color.White : Color.Gray, scale * 4f * purchaseButton.scale, false);
                Utility.drawTextWithShadow(b, $"Purchase Order", Game1.dialogueFont, new Vector2(this.purchaseButton.bounds.X + 12 * scale, this.purchaseButton.bounds.Y + (LocalizedContentManager.CurrentLanguageLatin ? 16 : 12) * scale), Game1.textColor * (canAffordOrder ? 1f : 0.25f), textScale, -1f, 0, 0, 0, 0);

                // Draw the mouse
                this.drawMouse(b);

                return;
            }

            // Draw the custom store BG
            // this.width - (IClickableMenu.borderWidth * 2) - 12 to account for width shift, this.height - 128 due to drawDialogueBox method adding 128 to height
            b.Draw(JojaResources.GetJojaSiteBackground(), new Rectangle(this.xPositionOnScreen + IClickableMenu.borderWidth - 8, this.yPositionOnScreen + IClickableMenu.borderWidth + 56, this.width - (IClickableMenu.borderWidth * 2) + 16, this.height - 128), new Rectangle(0, 0, 150, 200), Color.White);
            IClickableMenu.drawTextureBox(b, sourceSheet, new Rectangle(13, 64, 3, 3), this.xPositionOnScreen + IClickableMenu.borderWidth - 8, this.yPositionOnScreen + IClickableMenu.borderWidth + 56, this.width - (IClickableMenu.borderWidth * 2) + 16, (int)(70 * scale), Color.White, 1f, drawShadow: false);

            // Draw the current unique amount of items in cart
            cartQuantity = drawCartQuantity(sourceSheet, new Rectangle(0, 41, 5, 7));
            cartQuantity.draw(b);

            // Draw the usage instructions
            //IClickableMenu.drawTextureBox(b, sourceSheet, new Rectangle(144, 576, 76, 64), this.xPositionOnScreen + 100, this.yPositionOnScreen + 600, 76, 64, Color.White, scale, drawShadow: false);
            //SpriteText.drawString(b, "to order", this.xPositionOnScreen + 100, this.yPositionOnScreen + 600, 999999, -1, 999999, 1f, 0.88f, junimoText: false, -1, "", 4);
            //SpriteText.drawString(b, "to remove", (this.xPositionOnScreen + this.width) - SpriteText.getWidthOfString("Right Click to remove"), this.yPositionOnScreen + 600, 999999, -1, 999999, 1f, 0.88f, junimoText: false, -1, "", 4);

            // Draw the general clickables
            foreach (ClickableTextureComponent clickable in clickables)
            {
                clickable.draw(b);
            }

            // Draw the checkout button
            checkoutButton.draw(b, itemsInCart.Count > 0 ? Color.White : Color.Black, 0.99f);

            // Draw the scroll bar
            IClickableMenu.drawTextureBox(b, sourceSheet, new Rectangle(0, 74, 6, 6), scrollBarRunner.X, scrollBarRunner.Y, scrollBarRunner.Width, scrollBarRunner.Height, Color.White, 4f, drawShadow: false);
            scrollBar.draw(b);

            // Draw the sale button
            randomSaleButton.draw(b);

            if (randomSaleItem is Furniture)
            {
                (randomSaleItem as Furniture).drawInMenu(b, new Vector2(randomSaleButton.bounds.Center.X - (25 * scale) + (scale == 1f ? -7 : -13), randomSaleButton.bounds.Center.Y - (25 * scale) + (scale == 1f ? -8 : -19)), 0.75f, 1f, 0.9f, StackDrawType.Hide, Color.White, drawShadow: false);
            }
            else if (randomSaleItem is Wallpaper)
            {
                if ((randomSaleItem as Wallpaper).isFloor)
                {
                    (randomSaleItem as Wallpaper).drawInMenu(b, new Vector2(randomSaleButton.bounds.Center.X - (25 * scale) + (scale == 1f ? -7 : -11), randomSaleButton.bounds.Center.Y - (25 * scale) + (scale == 1f ? -8 : -2)), 0.6f, 1f, 0.9f, StackDrawType.Hide, Color.White, drawShadow: false);
                }
                else
                {
                    (randomSaleItem as Wallpaper).drawInMenu(b, new Vector2(randomSaleButton.bounds.Center.X - (25 * scale) + (scale == 1f ? -7 : -14), randomSaleButton.bounds.Center.Y - (25 * scale) + (scale == 1f ? -8 : -7)), 0.6f, 1f, 0.9f, StackDrawType.Hide, Color.White, drawShadow: false);
                }
            }
            else
            {
                randomSaleItem.drawInMenu(b, new Vector2(randomSaleButton.bounds.Center.X - (25 * scale) + (scale == 1f ? -2 : -8), randomSaleButton.bounds.Center.Y - (25 * scale) + (scale == 1f ? -2 : -9)), 0.6f, 1f, 0.9f, StackDrawType.Hide, Color.White, drawShadow: false);
            }
            //randomSaleItem.drawInMenu(b, new Vector2(randomSaleButton.bounds.Center.X - 25 * scale, randomSaleButton.bounds.Center.Y - 25 * scale), scale * 0.5f, 1f, 0.9f, StackDrawType.Hide, Color.White, drawShadow: false);

            // Draw the individual store buttons
            foreach (ClickableComponent button in forSaleButtons)
            {
                int buttonPosition = forSaleButtons.IndexOf(button) + (currentItemIndex * 2);
                if (buttonPosition >= forSale.Count)
                {
                    continue;
                }

                // Draw the button grid
                IClickableMenu.drawTextureBox(b, sourceSheet, new Rectangle(0, 48, 15, 15), button.bounds.X, button.bounds.Y, button.bounds.Width, button.bounds.Height, Color.White, scale * 4f, drawShadow: false);

                // Get the quantity that is in the cart (if any)
                int currentlyInCart = 0;
                if (itemsInCart.ContainsKey(forSale[buttonPosition]))
                {
                    currentlyInCart = itemsInCart[forSale[buttonPosition]][1];
                }

                // Draw the item for sale
                float itemScale   = scale == 1f ? 1f : 0.6f;
                Item  itemForSale = forSale[buttonPosition] as Item;
                if (itemForSale is Furniture)
                {
                    (itemForSale as Furniture).drawInMenu(b, new Vector2(button.bounds.X + (button.bounds.Width / 12 * itemScale) + (itemScale == 1f ? 0 : -5), button.bounds.Y + (button.bounds.Height / 8 * itemScale) + (itemScale == 1f ? 2 : -5)), itemScale, 1f, 0.9f, StackDrawType.Hide, Color.White * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.25f), drawShadow: false);
                }
                else if (itemForSale is Wallpaper)
                {
                    (itemForSale as Wallpaper).drawInMenu(b, new Vector2(button.bounds.X + (button.bounds.Width / 12 * itemScale) + (itemScale == 1f ? 0 : -5), button.bounds.Y + (button.bounds.Height / 8 * itemScale) + (itemScale == 1f ? 2 : -5)), itemScale, 1f, 0.9f, StackDrawType.Hide, Color.White * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.25f), drawShadow: false);
                }
                else
                {
                    itemForSale.drawInMenu(b, new Vector2(button.bounds.X + (button.bounds.Width / 12 * itemScale), button.bounds.Y + (button.bounds.Height / 8 * itemScale) + (itemScale == 1f ? 2 : -2)), itemScale, 1f, 0.9f, StackDrawType.Hide, Color.White * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.25f), drawShadow: false);
                }

                // Draw the quantity in the cart
                Utility.drawTextWithShadow(b, $"In Cart: {currentlyInCart}", Game1.dialogueFont, new Vector2(button.bounds.X + (button.bounds.Width / 4) + 15 * scale, button.bounds.Y + 10), Color.White * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.5f), scale == 1f ? 0.9f : 0.5f, 0.88f, numShadows: 0, shadowIntensity: 0);

                // Check if item is on sale, if so then add visual marker
                float coinScale = scale == 1f ? 3.75f : 2f;
                float textScale = scale == 1f ? 0.9f : 0.5f;
                if (itemForSale == randomSaleItem)
                {
                    // Draw the (discounted) price
                    string price = ((int)(itemPriceAndStock[itemForSale][0] - (itemPriceAndStock[itemForSale][0] * randomSalePercentageOff))).ToString();
                    Utility.drawTextWithShadow(b, "-" + (randomSalePercentageOff * 100) + "%", Game1.dialogueFont, new Vector2(button.bounds.X + (button.bounds.Width / 4) + 15 * scale, button.bounds.Y + button.bounds.Height - (SpriteText.getHeightOfString("-" + (randomSalePercentageOff * 100) + "%") * textScale) - (6 * scale)), Color.Cyan * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.5f), textScale, 0.6f, numShadows: 0, shadowIntensity: 0);
                    Utility.drawTextWithShadow(b, price, Game1.dialogueFont, new Vector2(button.bounds.X + button.bounds.Width - (SpriteText.getWidthOfString(price) * textScale) - (9 * coinScale) - (6 * scale), button.bounds.Y + button.bounds.Height - (SpriteText.getHeightOfString(price) * textScale) - (6 * scale)), Color.Cyan * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.5f), textScale, 0.6f, numShadows: 0, shadowIntensity: 0);
                    Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2(button.bounds.X + button.bounds.Width - (9 * coinScale) - (10 * scale), button.bounds.Y + button.bounds.Height - (10 * coinScale) - (7 * scale)), new Rectangle(193, 373, 9, 10), Color.White * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.25f), 0f, Vector2.Zero, coinScale, flipped: false, 1f, -1, -1, 0f);

                    // Draw sale marker
                    Utility.drawWithShadow(b, sourceSheet, new Vector2(button.bounds.Right - (14 * scale * 3f) - (12 * scale), button.bounds.Y + (12 * scale)), new Rectangle(0, 80, 14, 7), Color.White, 0f, Vector2.Zero, scale * 3f, flipped: false, 1f, -1, -1, 0f);
                }
                else
                {
                    // Draw the price
                    string price = itemPriceAndStock[itemForSale][0].ToString();
                    Utility.drawTextWithShadow(b, price, Game1.dialogueFont, new Vector2(button.bounds.X + button.bounds.Width - (SpriteText.getWidthOfString(price) * textScale) - (9 * coinScale) - (6 * scale), button.bounds.Y + button.bounds.Height - (SpriteText.getHeightOfString(price) * textScale) - (6 * scale)), new Color(251, 249, 78) * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.5f), textScale, 0.6f, numShadows: 0, shadowIntensity: 0);
                    Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2(button.bounds.X + button.bounds.Width - (9 * coinScale) - (10 * scale), button.bounds.Y + button.bounds.Height - (10 * coinScale) - (7 * scale)), new Rectangle(193, 373, 9, 10), Color.White * (itemsInCart.Count < maxUniqueCartItems || currentlyInCart > 0 ? 1f : 0.25f), 0f, Vector2.Zero, coinScale, flipped: false, 1f, -1, -1, 0f);
                }
            }

            // Draw the tooltip
            if (!this.hoverText.Equals(""))
            {
                if (this.hoveredItem is StardewValley.Object && (bool)(this.hoveredItem as StardewValley.Object).isRecipe)
                {
                    IClickableMenu.drawToolTip(b, " ", this.boldTitleText, this.hoveredItem as Item, false, -1, 0, -1, -1, new CraftingRecipe(this.hoveredItem.Name.Replace(" Recipe", "")), (this.hoverPrice > 0) ? this.hoverPrice : (-1));
                }
                else
                {
                    IClickableMenu.drawToolTip(b, this.hoverText, this.boldTitleText, this.hoveredItem as Item, false, -1, 0, -1, -1, null, (this.hoverPrice > 0) ? this.hoverPrice : (-1));
                }
            }

            this.upperRightCloseButton.draw(b);
            this.drawMouse(b);
        }
Ejemplo n.º 21
0
        public override void draw(SpriteBatch b)
        {
            base.drawHorizontalPartition(b, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4);

            var currentPage = this.GetCurrentPage();

            foreach (var c in currentPage.Keys)
            {
                if (c.hoverText.Equals(AVAILABLE))
                {
                    c.draw(b, Color.White, 0.89f);
                }
                else if (c.hoverText.Equals(UNKNOWN))
                {
                    c.draw(b, new Color(0f, 0f, 0f, 0.1f), 0.89f);
                }
                else
                {
                    c.draw(b, Color.Gray * 0.4f, 0.89f);
                }
            }

            foreach (var c in this.categories.Keys)
            {
                var boxColor  = Color.White;
                var textColor = Game1.textColor;

                if (c.name.Equals(UNAVAILABLE))
                {
                    boxColor = Color.Gray;
                }

                IClickableMenu.drawTextureBox(b,
                                              Game1.menuTexture,
                                              new Rectangle(0, 256, 60, 60),
                                              c.bounds.X,
                                              c.bounds.Y,
                                              c.bounds.Width,
                                              c.bounds.Height + Game1.tileSize / 16,
                                              boxColor);

                b.DrawString(Game1.smallFont,
                             c.label,
                             new Vector2(c.bounds.X + Game1.tileSize / 4, c.bounds.Y + Game1.tileSize / 4),
                             textColor);
            }

            if (this.upButton != null)
            {
                this.upButton.draw(b);
            }
            if (this.downButton != null)
            {
                this.downButton.draw(b);
            }

            this.inventory.draw(b);

            this.oldButton.draw(b, this.readyToClose() ? Color.White : Color.Gray, 0.89f);

            this.trashCan.draw(b);
            b.Draw(
                Game1.mouseCursors,
                new Vector2((float)(this.trashCan.bounds.X + 60), (float)(this.trashCan.bounds.Y + 40)),
                new Rectangle(686, 256, 18, 10),
                Color.White,
                this.trashCanLidRotation,
                new Vector2(16f, 10f),
                Game1.pixelZoom,
                SpriteEffects.None,
                0.86f);

            base.drawMouse(b);

            if (this.hoverItem != null)
            {
                IClickableMenu.drawToolTip(
                    b,
                    this.hoverText,
                    this.hoverTitle,
                    this.hoverItem,
                    this.heldItem != null);
            }
            else if (this.hoverText != null)
            {
                IClickableMenu.drawHoverText(b,
                                             this.hoverText,
                                             Game1.smallFont,
                                             (this.heldItem != null) ? Game1.tileSize : 0,
                                             (this.heldItem != null) ? Game1.tileSize : 0);
            }

            if (this.heldItem != null)
            {
                this.heldItem.drawInMenu(b,
                                         new Vector2(
                                             (float)(Game1.getOldMouseX() + Game1.tileSize / 4),
                                             (float)(Game1.getOldMouseY() + Game1.tileSize / 4)),
                                         1f);
            }

            if (this.hoverRecipe != null)
            {
                IClickableMenu.drawHoverText(b,
                                             " ",
                                             Game1.smallFont,
                                             Game1.tileSize * 3 / 4,
                                             Game1.tileSize * 3 / 4,
                                             -1,
                                             this.hoverRecipe.name,
                                             -1,
                                             null,
                                             null, 0, -1, -1, -1, -1, 1f, this.hoverRecipe);
            }
            else if (this.categoryText != null)
            {
                IClickableMenu.drawHoverText(b, this.categoryText, Game1.smallFont);
            }
        }
 // Token: 0x06000E1D RID: 3613 RVA: 0x0011FC48 File Offset: 0x0011DE48
 public override void draw(SpriteBatch b)
 {
     if (this.cooking)
     {
         Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true, null, false);
     }
     base.drawHorizontalPartition(b, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 4 * Game1.tileSize, false);
     this.inventory.draw(b);
     if (this.trashCan != null)
     {
         this.trashCan.draw(b);
         b.Draw(Game1.mouseCursors, new Vector2((float)(this.trashCan.bounds.X + 60), (float)(this.trashCan.bounds.Y + 40)), new Rectangle?(new Rectangle(686, 256, 18, 10)), Color.White, this.trashCanLidRotation, new Vector2(16f, 10f), (float)Game1.pixelZoom, SpriteEffects.None, 0.86f);
     }
     b.End();
     b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null);
     foreach (ClickableTextureComponent c in this.pagesOfCraftingRecipes[this.currentCraftingPage].Keys)
     {
         if (c.hoverText.Equals("ghosted"))
         {
             c.draw(b, Color.Black * 0.35f, 0.89f);
         }
         else if (!this.pagesOfCraftingRecipes[this.currentCraftingPage][c].doesFarmerHaveIngredientsInInventory(this.cooking ? Utility.getHomeOfFarmer(Game1.player).fridge.items : null))
         {
             c.draw(b, Color.LightGray * 0.4f, 0.89f);
         }
         else
         {
             c.draw(b);
             if (this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft > 1)
             {
                 NumberSprite.draw(this.pagesOfCraftingRecipes[this.currentCraftingPage][c].numberProducedPerCraft, b, new Vector2((float)(c.bounds.X + Game1.tileSize - 2), (float)(c.bounds.Y + Game1.tileSize - 2)), Color.Red, 0.5f * (c.scale / (float)Game1.pixelZoom), 0.97f, 1f, 0, 0);
             }
         }
     }
     b.End();
     b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
     if (this.hoverItem != null)
     {
         IClickableMenu.drawToolTip(b, this.hoverText, this.hoverTitle, this.hoverItem, this.heldItem != null, -1, 0, -1, -1, null, -1);
     }
     else if (this.hoverText != null)
     {
         IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, (this.heldItem != null) ? Game1.tileSize : 0, (this.heldItem != null) ? Game1.tileSize : 0, -1, null, -1, null, null, 0, -1, -1, -1, -1, 1f, null);
     }
     if (this.heldItem != null)
     {
         this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + Game1.tileSize / 4), (float)(Game1.getOldMouseY() + Game1.tileSize / 4)), 1f);
     }
     base.draw(b);
     if (this.downButton != null && this.currentCraftingPage < this.pagesOfCraftingRecipes.Count - 1)
     {
         this.downButton.draw(b);
     }
     if (this.upButton != null && this.currentCraftingPage > 0)
     {
         this.upButton.draw(b);
     }
     if (this.cooking)
     {
         base.drawMouse(b);
     }
     if (this.hoverRecipe != null)
     {
         IClickableMenu.drawHoverText(b, " ", Game1.smallFont, (this.heldItem != null) ? (Game1.tileSize * 3 / 4) : 0, (this.heldItem != null) ? (Game1.tileSize * 3 / 4) : 0, -1, this.hoverRecipe.name, -1, (this.cooking && this.lastCookingHover != null && Game1.objectInformation[(this.lastCookingHover as Object).parentSheetIndex].Split(new char[]
         {
             '/'
         }).Length >= 7) ? Game1.objectInformation[(this.lastCookingHover as Object).parentSheetIndex].Split(new char[]
         {
             '/'
         })[6].Split(new char[]
         {
             ' '
         }) : null, this.lastCookingHover, 0, -1, -1, -1, -1, 1f, this.hoverRecipe);
     }
 }
Ejemplo n.º 23
0
        public override void draw(SpriteBatch b)
        {
            drawHorizontalPartition(b, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 192);
            inventory.draw(b);
            foreach (ClickableComponent c in equipmentIcons)
            {
                switch (c.name)
                {
                case "Hat":
                    if (Game1.player.hat.Value != null)
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10), Color.White);
                        Game1.player.hat.Value.drawInMenu(b, new Vector2(c.bounds.X, c.bounds.Y), c.scale, 1f, 0.866f, StackDrawType.Hide);
                    }
                    else
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 42), Color.White);
                    }
                    break;

                case "Right Ring":
                    if (Game1.player.rightRing.Value != null)
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10), Color.White);
                        Game1.player.rightRing.Value.drawInMenu(b, new Vector2(c.bounds.X, c.bounds.Y), c.scale);
                    }
                    else
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 41), Color.White);
                    }
                    break;

                case "Left Ring":
                    if (Game1.player.leftRing.Value != null)
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10), Color.White);
                        Game1.player.leftRing.Value.drawInMenu(b, new Vector2(c.bounds.X, c.bounds.Y), c.scale);
                    }
                    else
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 41), Color.White);
                    }
                    break;

                case "Boots":
                    if (Game1.player.boots.Value != null)
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10), Color.White);
                        Game1.player.boots.Value.drawInMenu(b, new Vector2(c.bounds.X, c.bounds.Y), c.scale);
                    }
                    else
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 40), Color.White);
                    }
                    break;

                case "Shirt":
                    if (Game1.player.shirtItem.Value != null)
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10), Color.White);
                        Game1.player.shirtItem.Value.drawInMenu(b, new Vector2(c.bounds.X, c.bounds.Y), c.scale);
                    }
                    else
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 69), Color.White);
                    }
                    break;

                case "Pants":
                    if (Game1.player.pantsItem.Value != null)
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10), Color.White);
                        Game1.player.pantsItem.Value.drawInMenu(b, new Vector2(c.bounds.X, c.bounds.Y), c.scale);
                    }
                    else
                    {
                        b.Draw(Game1.menuTexture, c.bounds, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 68), Color.White);
                    }
                    break;
                }
            }
            b.Draw((Game1.timeOfDay >= 1900) ? Game1.nightbg : Game1.daybg, new Vector2(xPositionOnScreen + 192 - 64 - 8, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 256 - 8), Color.White);
            FarmerRenderer.isDrawingForUI = true;
            Game1.player.FarmerRenderer.draw(b, new FarmerSprite.AnimationFrame(0, Game1.player.bathingClothes ? 108 : 0, secondaryArm: false, flip: false), Game1.player.bathingClothes ? 108 : 0, new Rectangle(0, Game1.player.bathingClothes ? 576 : 0, 16, 32), new Vector2(xPositionOnScreen + 192 - 8 - 32, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 320 - 32 - 8), Vector2.Zero, 0.8f, 2, Color.White, 0f, 1f, Game1.player);
            if (Game1.timeOfDay >= 1900)
            {
                Game1.player.FarmerRenderer.draw(b, new FarmerSprite.AnimationFrame(0, Game1.player.bathingClothes ? 108 : 0, secondaryArm: false, flip: false), Game1.player.bathingClothes ? 108 : 0, new Rectangle(0, Game1.player.bathingClothes ? 576 : 0, 16, 32), new Vector2(xPositionOnScreen + 192 - 8 - 32, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 320 - 32 - 8), Vector2.Zero, 0.8f, 2, Color.DarkBlue * 0.3f, 0f, 1f, Game1.player);
            }
            FarmerRenderer.isDrawingForUI = false;
            Utility.drawTextWithShadow(b, Game1.player.Name, Game1.dialogueFont, new Vector2((float)(xPositionOnScreen + 192 - 8) - Game1.dialogueFont.MeasureString(Game1.player.Name).X / 2f, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 448 + 8), Game1.textColor);
            float  offset   = 32f;
            string farmName = Game1.content.LoadString("Strings\\UI:Inventory_FarmName", Game1.player.farmName);

            Utility.drawTextWithShadow(b, farmName, Game1.dialogueFont, new Vector2((float)xPositionOnScreen + offset + 512f + 32f - Game1.dialogueFont.MeasureString(farmName).X / 2f, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 256 + 4), Game1.textColor);
            string currentFunds = Game1.content.LoadString("Strings\\UI:Inventory_CurrentFunds" + (Game1.player.useSeparateWallets ? "_Separate" : ""), Utility.getNumberWithCommas(Game1.player.Money));

            Utility.drawTextWithShadow(b, currentFunds, Game1.dialogueFont, new Vector2((float)xPositionOnScreen + offset + 512f + 32f - Game1.dialogueFont.MeasureString(currentFunds).X / 2f, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 320), Game1.textColor);
            string totalEarnings = Game1.content.LoadString("Strings\\UI:Inventory_TotalEarnings" + (Game1.player.useSeparateWallets ? "_Separate" : ""), Utility.getNumberWithCommas((int)Game1.player.totalMoneyEarned));

            Utility.drawTextWithShadow(b, totalEarnings, Game1.dialogueFont, new Vector2((float)xPositionOnScreen + offset + 512f + 32f - Game1.dialogueFont.MeasureString(totalEarnings).X / 2f, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 384 - 4), Game1.textColor);
            Pet    pet_character = Game1.MasterPlayer.getPet();
            string pet_name      = Game1.MasterPlayer.getPetDisplayName();

            if (pet_character != null)
            {
                Utility.drawTextWithShadow(b, pet_name, Game1.dialogueFont, new Vector2((float)xPositionOnScreen + offset + 320f + Math.Max(64f, Game1.dialogueFont.MeasureString(Game1.player.Name).X / 2f), yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 448 + 8), Game1.textColor);
                Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)xPositionOnScreen + offset + 256f + Math.Max(64f, Game1.dialogueFont.MeasureString(Game1.player.Name).X / 2f), yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 448 - 4), new Rectangle(160 + ((!Game1.MasterPlayer.catPerson) ? 48 : 0) + pet_character.whichBreed.Value * 16, 208, 16, 16), Color.White, 0f, Vector2.Zero, 4f);
            }
            if (Game1.player.horseName.Value != null && Game1.player.horseName.Value != "")
            {
                Utility.drawTextWithShadow(b, Game1.player.horseName.Value, Game1.dialogueFont, new Vector2((float)xPositionOnScreen + offset + 384f + Math.Max(64f, Game1.dialogueFont.MeasureString(Game1.player.Name).X / 2f) + ((pet_name != null) ? Math.Max(64f, Game1.dialogueFont.MeasureString(pet_name).X) : 0f), yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 448 + 8), Game1.textColor);
                Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)xPositionOnScreen + offset + 320f + 8f + Math.Max(64f, Game1.dialogueFont.MeasureString(Game1.player.Name).X / 2f) + ((pet_name != null) ? Math.Max(64f, Game1.dialogueFont.MeasureString(pet_name).X) : 0f), yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 448 - 4), new Rectangle(193, 192, 16, 16), Color.White, 0f, Vector2.Zero, 4f);
            }
            _ = xPositionOnScreen;
            _ = width / 3;
            if (organizeButton != null)
            {
                organizeButton.draw(b);
            }
            trashCan.draw(b);
            b.Draw(Game1.mouseCursors, new Vector2(trashCan.bounds.X + 60, trashCan.bounds.Y + 40), new Rectangle(564 + Game1.player.trashCanLevel * 18, 129, 18, 10), Color.White, trashCanLidRotation, new Vector2(16f, 10f), 4f, SpriteEffects.None, 0.86f);
            if (checkHeldItem())
            {
                Game1.player.CursorSlotItem.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 16, Game1.getOldMouseY() + 16), 1f);
            }
            if (hoverText != null && !hoverText.Equals(""))
            {
                if (hoverAmount > 0)
                {
                    IClickableMenu.drawToolTip(b, hoverText, hoverTitle, null, heldItem: true, -1, 0, -1, -1, null, hoverAmount);
                }
                else
                {
                    IClickableMenu.drawToolTip(b, hoverText, hoverTitle, hoveredItem, checkHeldItem());
                }
            }
            if (junimoNoteIcon != null)
            {
                junimoNoteIcon.draw(b);
            }
        }
Ejemplo n.º 24
0
        public override void draw(SpriteBatch b)
        {
            if (!Game1.options.showMenuBackground)
            {
                b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.8f);
            }
            textBox.Draw(b);
            this.draw(b, false, false);
            if (this.showReceivingMenu)
            {
                CJB.drawTextBox(title.bounds.X, title.bounds.Y, Game1.borderFont, title.name, true, 2, 1.0f);
                Game1.drawDialogueBox(this.ItemsToGrabMenu.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder, this.ItemsToGrabMenu.yPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder, this.ItemsToGrabMenu.width + IClickableMenu.borderWidth * 2 + IClickableMenu.spaceToClearSideBorder * 2, this.ItemsToGrabMenu.height + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth * 2, false, true, (string)null, false);
                this.ItemsToGrabMenu.draw(b);
                for (int i = 0; i < tabs.Count(); i++)
                {
                    ClickableComponent current = tabs[i];
                    CJB.drawTextBox(current.bounds.X + current.bounds.Width, current.bounds.Y, Game1.smallFont, current.name, true, 2, tab == i ? 1F : 0.7F);
                }

                CJB.drawTextBox(sortButton.bounds.X, sortButton.bounds.Y, Game1.smallFont, sortButton.name, true, 0, 1F);
                CJB.drawTextBox(qualityButton.bounds.X, qualityButton.bounds.Y, Game1.smallFont, qualityButton.name, true, 0, 1F);

                this.upArrow.draw(b);
                this.downArrow.draw(b);
            }

            if (this.poof != null)
            {
                this.poof.draw(b, true, 0, 0);
            }
            if (this.hoverText != null && (this.hoveredItem == null || this.hoveredItem == null || this.ItemsToGrabMenu == null))
            {
                IClickableMenu.drawHoverText(b, this.hoverText, Game1.smallFont, 0, 0, -1, (string)null, -1, (string[])null, (Item)null, 0, -1, -1, -1, -1, 1f, (CraftingRecipe)null);
            }
            if (this.hoveredItem != null)
            {
                IClickableMenu.drawToolTip(b, this.hoveredItem.getDescription(), this.hoveredItem.Name, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, (CraftingRecipe)null, -1);
            }
            else if (this.hoveredItem != null && this.ItemsToGrabMenu != null)
            {
                IClickableMenu.drawToolTip(b, this.ItemsToGrabMenu.descriptionText, this.ItemsToGrabMenu.descriptionTitle, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, (CraftingRecipe)null, -1);
            }
            if (this.heldItem != null)
            {
                this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + 8), (float)(Game1.getOldMouseY() + 8)), 1f);
            }

            if (hoveredItem is StardewValley.Object)
            {
                StardewValley.Object o = hoveredItem as StardewValley.Object;
                if (o.stack > 1)
                {
                    drawHoverTextBox(b, Game1.smallFont, o.sellToStorePrice(), o.stack);
                }
                else
                {
                    drawHoverTextBox(b, Game1.smallFont, o.sellToStorePrice());
                }
            }
            else if (hoveredItem != null)
            {
                if (hoveredItem.Stack > 1)
                {
                    drawHoverTextBox(b, Game1.smallFont, (hoveredItem.salePrice() / 2), hoveredItem.Stack);
                }
                else
                {
                    drawHoverTextBox(b, Game1.smallFont, hoveredItem.salePrice());
                }
            }
            if (!Game1.options.hardwareCursor)
            {
                b.Draw(Game1.mouseCursors, new Vector2((float)Game1.getOldMouseX(), (float)Game1.getOldMouseY()), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 0, 16, 16)), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom + Game1.dialogueButtonScale / 150f, SpriteEffects.None, 1f);
            }
        }
Ejemplo n.º 25
0
        public override void draw(SpriteBatch b)
        {
            this.drawHorizontalPartition(b, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 3 * Game1.tileSize, false);
            this.inventory.draw(b);
            foreach (ClickableComponent equipmentIcon in this.equipmentIcons)
            {
                string name = equipmentIcon.name;
                if (!(name == "Hat"))
                {
                    if (!(name == "Right Ring"))
                    {
                        if (!(name == "Left Ring"))
                        {
                            if (name == "Boots")
                            {
                                if (Game1.player.boots != null)
                                {
                                    b.Draw(Game1.menuTexture, equipmentIcon.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1)), Color.White);
                                    Game1.player.boots.drawInMenu(b, new Vector2((float)equipmentIcon.bounds.X, (float)equipmentIcon.bounds.Y), equipmentIcon.scale);
                                }
                                else
                                {
                                    b.Draw(Game1.menuTexture, equipmentIcon.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 40, -1, -1)), Color.White);
                                }
                            }
                        }
                        else if (Game1.player.leftRing != null)
                        {
                            b.Draw(Game1.menuTexture, equipmentIcon.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1)), Color.White);
                            Game1.player.leftRing.drawInMenu(b, new Vector2((float)equipmentIcon.bounds.X, (float)equipmentIcon.bounds.Y), equipmentIcon.scale);
                        }
                        else
                        {
                            b.Draw(Game1.menuTexture, equipmentIcon.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 41, -1, -1)), Color.White);
                        }
                    }
                    else if (Game1.player.rightRing != null)
                    {
                        b.Draw(Game1.menuTexture, equipmentIcon.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1)), Color.White);
                        Game1.player.rightRing.drawInMenu(b, new Vector2((float)equipmentIcon.bounds.X, (float)equipmentIcon.bounds.Y), equipmentIcon.scale);
                    }
                    else
                    {
                        b.Draw(Game1.menuTexture, equipmentIcon.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 41, -1, -1)), Color.White);
                    }
                }
                else if (Game1.player.hat != null)
                {
                    b.Draw(Game1.menuTexture, equipmentIcon.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 10, -1, -1)), Color.White);
                    Game1.player.hat.drawInMenu(b, new Vector2((float)equipmentIcon.bounds.X, (float)equipmentIcon.bounds.Y), equipmentIcon.scale, 1f, 0.866f, false);
                }
                else
                {
                    b.Draw(Game1.menuTexture, equipmentIcon.bounds, new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, 42, -1, -1)), Color.White);
                }
            }
            b.Draw(Game1.timeOfDay >= 1900 ? Game1.nightbg : Game1.daybg, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 3 - Game1.tileSize), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 4 * Game1.tileSize - 8)), Color.White);
            Game1.player.FarmerRenderer.draw(b, new FarmerSprite.AnimationFrame(0, Game1.player.bathingClothes ? 108 : 0, false, false, (AnimatedSprite.endOfAnimationBehavior)null, false), Game1.player.bathingClothes ? 108 : 0, new Rectangle(0, Game1.player.bathingClothes ? 576 : 0, 16, 32), new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 3 - Game1.tileSize / 2), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 5 * Game1.tileSize - Game1.tileSize / 2)), Vector2.Zero, 0.8f, 2, Color.White, 0.0f, 1f, Game1.player);
            if (Game1.timeOfDay >= 1900)
            {
                Game1.player.FarmerRenderer.draw(b, new FarmerSprite.AnimationFrame(0, 0, false, false, (AnimatedSprite.endOfAnimationBehavior)null, false), 0, new Rectangle(0, 0, 16, 32), new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 3 - Game1.tileSize / 2), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 5 * Game1.tileSize - Game1.tileSize / 2)), Vector2.Zero, 0.8f, 2, Color.DarkBlue * 0.3f, 0.0f, 1f, Game1.player);
            }
            Utility.drawTextWithShadow(b, Game1.player.name, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 3) - Math.Min((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize + Game1.pixelZoom * 2)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3);
            string text1 = Game1.content.LoadString("Strings\\UI:Inventory_FarmName", (object)Game1.player.farmName);

            Utility.drawTextWithShadow(b, text1, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 8 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(text1).X / 2f, (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 4 * Game1.tileSize + Game1.pixelZoom)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3);
            string text2 = Game1.content.LoadString("Strings\\UI:Inventory_CurrentFunds", (object)Utility.getNumberWithCommas(Game1.player.Money));

            Utility.drawTextWithShadow(b, text2, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 8 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(text2).X / 2f, (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 5 * Game1.tileSize)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3);
            string text3 = Game1.content.LoadString("Strings\\UI:Inventory_TotalEarnings", (object)Utility.getNumberWithCommas((int)Game1.player.totalMoneyEarned));

            Utility.drawTextWithShadow(b, text3, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 8 + Game1.tileSize / 2) - Game1.dialogueFont.MeasureString(text3).X / 2f, (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 6 * Game1.tileSize - Game1.pixelZoom)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3);
            if (Game1.player.hasPet())
            {
                string petDisplayName = Game1.player.getPetDisplayName();
                Utility.drawTextWithShadow(b, petDisplayName, Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 5) + Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize + Game1.pixelZoom * 2)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3);
                Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)(this.xPositionOnScreen + Game1.tileSize * 4) + Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize - Game1.pixelZoom)), new Rectangle(160 + (Game1.player.catPerson ? 0 : 16), 192, 16, 16), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, false, -1f, -1, -1, 0.35f);
            }
            if (this.horseName.Length > 0)
            {
                Utility.drawTextWithShadow(b, this.horseName, Game1.dialogueFont, new Vector2((float)((double)(this.xPositionOnScreen + Game1.tileSize * 6) + (double)Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f) + (Game1.player.getPetDisplayName() != null ? (double)Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.getPetDisplayName()).X) : 0.0)), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize + Game1.pixelZoom * 2)), Game1.textColor, 1f, -1f, -1, -1, 1f, 3);
                Utility.drawWithShadow(b, Game1.mouseCursors, new Vector2((float)((double)(this.xPositionOnScreen + Game1.tileSize * 5 + Game1.pixelZoom * 2) + (double)Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.name).X / 2f) + (Game1.player.getPetDisplayName() != null ? (double)Math.Max((float)Game1.tileSize, Game1.dialogueFont.MeasureString(Game1.player.getPetDisplayName()).X) : 0.0)), (float)(this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 7 * Game1.tileSize - Game1.pixelZoom)), new Rectangle(193, 192, 16, 16), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, false, -1f, -1, -1, 0.35f);
            }
            int positionOnScreen = this.xPositionOnScreen;
            int num       = this.width / 3;
            int tileSize1 = Game1.tileSize;
            int tileSize2 = Game1.tileSize;

            if (this.organizeButton != null)
            {
                this.organizeButton.draw(b);
            }
            this.trashCan.draw(b);
            b.Draw(Game1.mouseCursors, new Vector2((float)(this.trashCan.bounds.X + 60), (float)(this.trashCan.bounds.Y + 40)), new Rectangle?(new Rectangle(686, 256, 18, 10)), Color.White, this.trashCanLidRotation, new Vector2(16f, 10f), (float)Game1.pixelZoom, SpriteEffects.None, 0.86f);
            if (this.heldItem != null)
            {
                this.heldItem.drawInMenu(b, new Vector2((float)(Game1.getOldMouseX() + 16), (float)(Game1.getOldMouseY() + 16)), 1f);
            }
            if (this.hoverText == null || this.hoverText.Equals(""))
            {
                return;
            }
            IClickableMenu.drawToolTip(b, this.hoverText, this.hoverTitle, this.hoveredItem, this.heldItem != null, -1, 0, -1, -1, (CraftingRecipe)null, -1);
        }
Ejemplo n.º 26
0
        private void drawShopHarvestPrices(object sender, EventArgs e)
        {
            if (Game1.activeClickableMenu is ShopMenu == false)
            {
                return;
            }

            var shopMenu  = ( ShopMenu )Game1.activeClickableMenu;
            var hoverItem = ( Item )typeof(ShopMenu).GetField("hoveredItem", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public).GetValue(shopMenu);

            if (hoverItem == null)
            {
                return;
            }

            string sellForAmount = "";
            string harvestPrice  = "";

            int truePrice = ItemRolloverInformation.getTruePrice(hoverItem);

            if (truePrice > 0 && hoverItem.Name != "Scythe")
            {
                sellForAmount = "\n  " + truePrice / 2;

                if (hoverItem.canStackWith(hoverItem) && hoverItem.getStack() > 1)
                {
                    sellForAmount += $" ({ truePrice / 2 * hoverItem.getStack() })";
                }
            }

            // Adds the price of the fully grown crop to the display text only if it is a seed
            if (hoverItem is StardewValley.Object && ((StardewValley.Object)hoverItem).type == "Seeds" && sellForAmount != "")
            {
                if (hoverItem.Name != "Mixed Seeds" || hoverItem.Name != "Winter Seeds")
                {
                    var crop   = new Crop(hoverItem.parentSheetIndex, 0, 0);
                    var debris = new Debris(crop.indexOfHarvest, Game1.player.position, Game1.player.position);
                    var item   = new StardewValley.Object(debris.chunkType, 1);
                    harvestPrice += $"    { item.price }";
                }
            }

            // Draws harvest info for seeds in shop
            if (Game1.activeClickableMenu is ShopMenu)
            {
                // Don't draw if holding an item
                Item heldItem = ( Item )typeof(ShopMenu).GetField("heldItem", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(Game1.activeClickableMenu);
                if (heldItem != null)
                {
                    return;
                }

                bool isSapling = false;

                // Handle cases for fruit trees
                switch (hoverItem.parentSheetIndex)
                {
                case 630:     // orange
                    harvestPrice = "    100";
                    isSapling    = true;
                    break;

                case 628:     // apricot
                    harvestPrice = "    50";
                    isSapling    = true;
                    break;

                case 629:     // cherry
                    harvestPrice = "    80";
                    isSapling    = true;
                    break;

                case 633:     // apple
                    harvestPrice = "    100";
                    isSapling    = true;
                    break;

                case 631:     // peach
                    harvestPrice = "    140";
                    isSapling    = true;
                    break;

                case 632:     // pomegranate
                    harvestPrice = "    140";
                    isSapling    = true;
                    break;

                default:
                    break;
                }

                // Only draw seeds or sapling info
                if (harvestPrice != "" && (((StardewValley.Object)hoverItem).type == "Seeds" || isSapling))
                {
                    int positionX = Game1.activeClickableMenu.xPositionOnScreen - 30;
                    int positionY = Game1.activeClickableMenu.yPositionOnScreen + 580;

                    // Box
                    IClickableMenu.drawTextureBox(Game1.spriteBatch, positionX + 20, positionY - 52, 264, 108, Color.White);
                    //Game1.drawDialogueBox( positionX, positionY - 100, 220, 176, false, true );

                    // Text "HArvest price"
                    Game1.spriteBatch.DrawString(Game1.dialogueFont, "Harvest price", new Vector2(positionX + 30, positionY - 38), Color.Black * 0.2f);
                    Game1.spriteBatch.DrawString(Game1.dialogueFont, "Harvest price", new Vector2(positionX + 32, positionY - 40), Color.Black * 0.8f);

                    int shopIconPositionX = positionX + 80;

                    // Harvest icon
                    var spriteRectangle = new Rectangle(60, 428, 10, 10);
                    Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2(shopIconPositionX, positionY), spriteRectangle, Color.White, 0.0f, Vector2.Zero, ( float )Game1.pixelZoom, SpriteEffects.None, 0.85f);

                    // Mini coin icon
                    Game1.spriteBatch.Draw(Game1.debrisSpriteSheet, new Vector2(shopIconPositionX + 32, positionY + 10), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 8, 16, 16)), Color.White, 0f, new Vector2(8f, 8f), ( float )4f, SpriteEffects.None, 0.95f);

                    // Actual harvest price
                    Game1.spriteBatch.DrawString(Game1.dialogueFont, harvestPrice, new Vector2(shopIconPositionX - 2, positionY + 6), Color.Black * 0.2f);
                    Game1.spriteBatch.DrawString(Game1.dialogueFont, harvestPrice, new Vector2(shopIconPositionX, positionY + 4), Color.Black * 0.8f);

                    // Redraw tooltip
                    var hoverText     = ModEntry.helper.Reflection.GetPrivateField <string>(shopMenu, "hoverText").GetValue();
                    var boldTitleText = ModEntry.helper.Reflection.GetPrivateField <string>(shopMenu, "boldTitleText").GetValue();
                    var hoveredItem   = ModEntry.helper.Reflection.GetPrivateField <Item>(shopMenu, "hoveredItem").GetValue();
                    var currency      = ModEntry.helper.Reflection.GetPrivateField <int>(shopMenu, "currency").GetValue();
                    var hoverPrice    = ModEntry.helper.Reflection.GetPrivateField <int>(shopMenu, "hoverPrice").GetValue();
                    var getHoveredItemExtraItemIndex  = ModEntry.helper.Reflection.GetPrivateMethod(shopMenu, "getHoveredItemExtraItemIndex");
                    var getHoveredItemExtraItemAmount = ModEntry.helper.Reflection.GetPrivateMethod(shopMenu, "getHoveredItemExtraItemAmount");
                    IClickableMenu.drawToolTip(Game1.spriteBatch, hoverText, boldTitleText, hoveredItem, heldItem != null, -1, currency, getHoveredItemExtraItemIndex.Invoke <int>(), getHoveredItemExtraItemAmount.Invoke <int>(), null, hoverPrice);
                }

                return;
            }
        }
Ejemplo n.º 27
0
        public override void draw(SpriteBatch b)
        {
            if (Game1.activeClickableMenu != null)
            {
                return;
            }
            bool    alignTop2       = false;
            Point   playerGlobalPos = Game1.player.GetBoundingBox().Center;
            Vector2 playerLocalVec  = Game1.GlobalToLocal(globalPosition: new Vector2(playerGlobalPos.X, playerGlobalPos.Y), viewport: Game1.viewport);

            if (Game1.options.pinToolbarToggle)
            {
                alignTop2    = false;
                transparency = Math.Min(1f, transparency + 0.075f);
                if (playerLocalVec.Y > (float)(Game1.viewport.Height - 192))
                {
                    transparency = Math.Max(0.33f, transparency - 0.15f);
                }
            }
            else
            {
                alignTop2    = ((playerLocalVec.Y > (float)(Game1.viewport.Height / 2 + 64)) ? true : false);
                transparency = 1f;
            }
            int margin = Utility.makeSafeMarginY(8);
            int num    = yPositionOnScreen;

            if (!alignTop2)
            {
                yPositionOnScreen  = Game1.viewport.Height;
                yPositionOnScreen += 8;
                yPositionOnScreen -= margin;
            }
            else
            {
                yPositionOnScreen  = 112;
                yPositionOnScreen -= 8;
                yPositionOnScreen += margin;
            }
            if (num != yPositionOnScreen)
            {
                for (int k = 0; k < 12; k++)
                {
                    buttons[k].bounds.Y = yPositionOnScreen - 96 + 8;
                }
            }
            IClickableMenu.drawTextureBox(b, Game1.menuTexture, toolbarTextSource, Game1.viewport.Width / 2 - 384 - 16, yPositionOnScreen - 96 - 8, 800, 96, Color.White * transparency, 1f, drawShadow: false);
            for (int j = 0; j < 12; j++)
            {
                Vector2 toDraw = new Vector2(Game1.viewport.Width / 2 - 384 + j * 64, yPositionOnScreen - 96 + 8);
                b.Draw(Game1.menuTexture, toDraw, Game1.getSourceRectForStandardTileSheet(Game1.menuTexture, (Game1.player.CurrentToolIndex == j) ? 56 : 10), Color.White * transparency);
                object obj;
                switch (j)
                {
                default:
                    obj = string.Concat(j + 1);
                    break;

                case 11:
                    obj = "=";
                    break;

                case 10:
                    obj = "-";
                    break;

                case 9:
                    obj = "0";
                    break;
                }
                string strToDraw = (string)obj;
                b.DrawString(Game1.tinyFont, strToDraw, toDraw + new Vector2(4f, -8f), Color.DimGray * transparency);
            }
            for (int i = 0; i < 12; i++)
            {
                buttons[i].scale = Math.Max(1f, buttons[i].scale - 0.025f);
                Vector2 toDraw2 = new Vector2(Game1.viewport.Width / 2 - 384 + i * 64, yPositionOnScreen - 96 + 8);
                if (Game1.player.items.Count > i && Game1.player.items.ElementAt(i) != null)
                {
                    Game1.player.items[i].drawInMenu(b, toDraw2, (Game1.player.CurrentToolIndex == i) ? 0.9f : (buttons.ElementAt(i).scale * 0.8f), transparency, 0.88f);
                }
            }
            if (hoverItem != null)
            {
                IClickableMenu.drawToolTip(b, hoverItem.getDescription(), hoverItem.DisplayName, hoverItem);
                hoverItem = null;
            }
        }
Ejemplo n.º 28
0
 public override void draw(SpriteBatch b)
 {
     if (_standaloneMenu)
     {
         Game1.drawDialogueBox(xPositionOnScreen, yPositionOnScreen, width, height, speaker: false, drawOnlyBox: true);
     }
     drawHorizontalPartition(b, yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 256);
     inventory.draw(b);
     if (trashCan != null)
     {
         trashCan.draw(b);
         b.Draw(Game1.mouseCursors, new Vector2(trashCan.bounds.X + 60, trashCan.bounds.Y + 40), new Rectangle(564 + Game1.player.trashCanLevel * 18, 129, 18, 10), Color.White, trashCanLidRotation, new Vector2(16f, 10f), 4f, SpriteEffects.None, 0.86f);
     }
     b.End();
     b.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
     foreach (ClickableTextureComponent c in pagesOfCraftingRecipes[currentCraftingPage].Keys)
     {
         if (c.hoverText.Equals("ghosted"))
         {
             c.draw(b, Color.Black * 0.35f, 0.89f);
         }
         else if (!pagesOfCraftingRecipes[currentCraftingPage][c].doesFarmerHaveIngredientsInInventory(getContainerContents()))
         {
             c.draw(b, Color.DimGray * 0.4f, 0.89f);
             if (pagesOfCraftingRecipes[currentCraftingPage][c].numberProducedPerCraft > 1)
             {
                 NumberSprite.draw(pagesOfCraftingRecipes[currentCraftingPage][c].numberProducedPerCraft, b, new Vector2(c.bounds.X + 64 - 2, c.bounds.Y + 64 - 2), Color.LightGray * 0.75f, 0.5f * (c.scale / 4f), 0.97f, 1f, 0);
             }
         }
         else
         {
             c.draw(b);
             if (pagesOfCraftingRecipes[currentCraftingPage][c].numberProducedPerCraft > 1)
             {
                 NumberSprite.draw(pagesOfCraftingRecipes[currentCraftingPage][c].numberProducedPerCraft, b, new Vector2(c.bounds.X + 64 - 2, c.bounds.Y + 64 - 2), Color.White, 0.5f * (c.scale / 4f), 0.97f, 1f, 0);
             }
         }
     }
     b.End();
     b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
     if (hoverItem != null)
     {
         IClickableMenu.drawToolTip(b, hoverText, hoverTitle, hoverItem, heldItem != null);
     }
     else if (!string.IsNullOrEmpty(hoverText))
     {
         if (hoverAmount > 0)
         {
             IClickableMenu.drawToolTip(b, hoverText, hoverTitle, null, heldItem: true, -1, 0, -1, -1, null, hoverAmount);
         }
         else
         {
             IClickableMenu.drawHoverText(b, hoverText, Game1.smallFont, (heldItem != null) ? 64 : 0, (heldItem != null) ? 64 : 0);
         }
     }
     if (heldItem != null)
     {
         heldItem.drawInMenu(b, new Vector2(Game1.getOldMouseX() + 16, Game1.getOldMouseY() + 16), 1f);
     }
     base.draw(b);
     if (downButton != null && currentCraftingPage < pagesOfCraftingRecipes.Count - 1)
     {
         downButton.draw(b);
     }
     if (upButton != null && currentCraftingPage > 0)
     {
         upButton.draw(b);
     }
     if (_standaloneMenu)
     {
         Game1.mouseCursorTransparency = 1f;
         drawMouse(b);
     }
     if (hoverRecipe != null)
     {
         IClickableMenu.drawHoverText(b, " ", Game1.smallFont, (heldItem != null) ? 48 : 0, (heldItem != null) ? 48 : 0, -1, hoverRecipe.DisplayName + ((hoverRecipe.numberProducedPerCraft > 1) ? (" x" + hoverRecipe.numberProducedPerCraft) : ""), -1, (cooking && lastCookingHover != null && Game1.objectInformation[(lastCookingHover as Object).parentSheetIndex].Split('/').Length > 7) ? Game1.objectInformation[(lastCookingHover as Object).parentSheetIndex].Split('/')[7].Split(' ') : null, lastCookingHover, 0, -1, -1, -1, -1, 1f, hoverRecipe, getContainerContents());
     }
 }
Ejemplo n.º 29
0
        private void drawGridLayout()
        {
            var       forSale           = Helper.Reflection.GetField <List <ISalable> >(shop, "forSale").GetValue();
            var       itemPriceAndStock = Helper.Reflection.GetField <Dictionary <ISalable, int[]> >(shop, "itemPriceAndStock").GetValue();
            var       currency          = Helper.Reflection.GetField <int>(shop, "currency").GetValue();
            var       animations        = Helper.Reflection.GetField <List <TemporaryAnimatedSprite> >(shop, "animations").GetValue();
            var       poof             = Helper.Reflection.GetField <TemporaryAnimatedSprite>(shop, "poof").GetValue();
            var       heldItem         = Helper.Reflection.GetField <Item>(shop, "heldItem").GetValue();
            var       currentItemIndex = Helper.Reflection.GetField <int>(shop, "currentItemIndex").GetValue();
            var       scrollBar        = Helper.Reflection.GetField <ClickableTextureComponent>(shop, "scrollBar").GetValue();
            var       scrollBarRunner  = Helper.Reflection.GetField <Rectangle>(shop, "scrollBarRunner").GetValue();
            const int UNIT_WIDTH       = 160;
            const int UNIT_HEIGHT      = 144;
            int       unitsWide        = (shop.width - 32) / UNIT_WIDTH;
            ISalable  hover            = null;

            //IClickableMenu.drawTextureBox(Game1.spriteBatch, Game1.mouseCursors, new Rectangle(384, 373, 18, 18), shop.xPositionOnScreen + shop.width - shop.inventory.width - 32 - 24, shop.yPositionOnScreen + shop.height - 256 + 40, shop.inventory.width + 56, shop.height - 448 + 20, Color.White, 4f, true);
            IClickableMenu.drawTextureBox(Game1.spriteBatch, Game1.mouseCursors, new Rectangle(384, 373, 18, 18), shop.xPositionOnScreen, shop.yPositionOnScreen, shop.width, shop.height - 256 + 32 + 4, Color.White, 4f, true);
            for (int i = currentItemIndex * unitsWide; i < forSale.Count && i < currentItemIndex * unitsWide + unitsWide * 3; ++i)
            {
                int       ix   = i % unitsWide;
                int       iy   = i / unitsWide;
                Rectangle rect = new Rectangle(shop.xPositionOnScreen + 16 + ix * UNIT_WIDTH, shop.yPositionOnScreen + 16 + iy * UNIT_HEIGHT - currentItemIndex * UNIT_HEIGHT, UNIT_WIDTH, UNIT_HEIGHT);
                IClickableMenu.drawTextureBox(Game1.spriteBatch, Game1.mouseCursors, new Rectangle(384, 396, 15, 15), rect.X, rect.Y, rect.Width, rect.Height, rect.Contains(Game1.getOldMouseX(), Game1.getOldMouseY()) ? Color.Wheat : Color.White, 4f, false);
                forSale[i].drawInMenu(Game1.spriteBatch, new Vector2(rect.X + 48, rect.Y + 16), 1f, 1, 1, StackDrawType.Draw, Color.White, true);
                int price    = itemPriceAndStock[forSale[i]][0];
                var priceStr = price.ToString();
                SpriteText.drawString(Game1.spriteBatch, priceStr, rect.Right - SpriteText.getWidthOfString(priceStr) - 16, rect.Y + 80, alpha: ShopMenu.getPlayerCurrencyAmount(Game1.player, currency) >= price ? 1f : 0.5f);
                //Utility.drawWithShadow(Game1.spriteBatch, Game1.mouseCursors, new Vector2(rect.Right - 16, rect.Y + 80), new Rectangle(193 + currency * 9, 373, 9, 10), Color.White, 0, Vector2.Zero, 1, layerDepth: 1);
                if (rect.Contains(Game1.getOldMouseX(), Game1.getOldMouseY()))
                {
                    hover = forSale[i];
                }
            }
            if (forSale.Count == 0)
            {
                SpriteText.drawString(Game1.spriteBatch, Game1.content.LoadString("Strings\\StringsFromCSFiles:ShopMenu.cs.11583"), shop.xPositionOnScreen + shop.width / 2 - SpriteText.getWidthOfString(Game1.content.LoadString("Strings\\StringsFromCSFiles:ShopMenu.cs.11583"), 999999) / 2, shop.yPositionOnScreen + shop.height / 2 - 128, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1);
            }
            //shop.inventory.draw(Game1.spriteBatch);
            // Moved currency here so above doesn't draw over it
            //if (currency == 0)
            //    Game1.dayTimeMoneyBox.drawMoneyBox(Game1.spriteBatch, shop.xPositionOnScreen - 36, shop.yPositionOnScreen + shop.height - shop.inventory.height + 48);
            for (int index = animations.Count - 1; index >= 0; --index)
            {
                if (animations[index].update(Game1.currentGameTime))
                {
                    animations.RemoveAt(index);
                }
                else
                {
                    animations[index].draw(Game1.spriteBatch, true, 0, 0, 1f);
                }
            }
            if (poof != null)
            {
                poof.draw(Game1.spriteBatch, false, 0, 0, 1f);
            }
            // arrows already drawn
            if (forSale.Count > 18)
            {
                IClickableMenu.drawTextureBox(Game1.spriteBatch, Game1.mouseCursors, new Rectangle(403, 383, 6, 6), scrollBarRunner.X, scrollBarRunner.Y, scrollBarRunner.Width, scrollBarRunner.Height, Color.White, 4f, true);
                scrollBar.draw(Game1.spriteBatch);
            }
            if (hover != null)
            {
                string hoverText     = hover.getDescription();
                string boldTitleText = hover.DisplayName;
                int    hoverPrice    = itemPriceAndStock == null || !itemPriceAndStock.ContainsKey(hover) ? hover.salePrice() : itemPriceAndStock[hover][0];
                int    getHoveredItemExtraItemIndex = -1;
                if (itemPriceAndStock != null && hover != null && (itemPriceAndStock.ContainsKey(hover) && itemPriceAndStock[hover].Length > 2))
                {
                    getHoveredItemExtraItemIndex = itemPriceAndStock[hover][2];
                }
                int getHoveredItemExtraItemAmount = 5;
                IClickableMenu.drawToolTip(Game1.spriteBatch, hoverText, boldTitleText, (Item)hover, heldItem != null, -1, currency, getHoveredItemExtraItemIndex, getHoveredItemExtraItemAmount, (CraftingRecipe)null, hoverPrice);
            }
            if (heldItem != null)
            {
                heldItem.drawInMenu(Game1.spriteBatch, new Vector2((float)(Game1.getOldMouseX() + 8), (float)(Game1.getOldMouseY() + 8)), 1f);
            }
            // some other stuff I don't think matters?
        }
Ejemplo n.º 30
0
        public override void draw(SpriteBatch b)
        {
            this.UpdateInventory();

            var currentPage = this.GetCurrentPage();

            foreach (var c in currentPage.Keys)
            {
                if (c.hoverText.Equals(AVAILABLE))
                {
                    c.draw(b, Color.White, 0.89f);
                    if (currentPage[c].numberProducedPerCraft > 1)
                    {
                        NumberSprite.draw(currentPage[c].numberProducedPerCraft, b, new Vector2((float)(c.bounds.X + 64 - 2), (float)(c.bounds.Y + 64 - 2)), Color.Red, (float)(0.5 * ((double)c.scale / 4.0)), 0.97f, 1f, 0, 0);
                    }
                }
                else if (c.hoverText.Equals(UNKNOWN))
                {
                    c.draw(b, new Color(0f, 0f, 0f, 0.1f), 0.89f);
                }
                else
                {
                    c.draw(b, Color.Gray * 0.4f, 0.89f);
                }
            }

            foreach (var c in this.categories.Keys)
            {
                var boxColor  = Color.White;
                var textColor = Game1.textColor;

                if (c.name.Equals(UNAVAILABLE))
                {
                    boxColor = Color.Gray;
                }

                IClickableMenu.drawTextureBox(b,
                                              Game1.menuTexture,
                                              new Rectangle(0, 256, 60, 60),
                                              c.bounds.X,
                                              c.bounds.Y,
                                              c.bounds.Width,
                                              c.bounds.Height + Game1.tileSize / 16,
                                              boxColor);

                b.DrawString(Game1.smallFont,
                             c.label,
                             new Vector2(c.bounds.X + Game1.tileSize / 4, c.bounds.Y + Game1.tileSize / 4),
                             textColor);
            }

            if (this.upButton != null)
            {
                this.upButton.draw(b);
            }
            if (this.downButton != null)
            {
                this.downButton.draw(b);
            }

            this.inventory.draw(b);

            this.oldButton.draw(b, this.readyToClose() ? Color.White : Color.Gray, 0.89f);

            this.trashCan.draw(b);
            b.Draw(
                Game1.mouseCursors,
                new Vector2(this.trashCan.bounds.X + 60, this.trashCan.bounds.Y + 40),
                new Rectangle(564 + Game1.player.trashCanLevel * 18, 129, 18, 10),
                Color.White,
                this.trashCanLidRotation,
                new Vector2(16f, 10f),
                4f,
                SpriteEffects.None,
                0.86f);

            if (this.hoverItem != null)
            {
                IClickableMenu.drawToolTip(
                    b,
                    this.hoverText,
                    this.hoverTitle,
                    this.hoverItem,
                    this.heldItem != null);
            }
            else if (this.hoverText != null)
            {
                IClickableMenu.drawHoverText(b,
                                             this.hoverText,
                                             Game1.smallFont,
                                             (this.heldItem != null) ? Game1.tileSize : 0,
                                             (this.heldItem != null) ? Game1.tileSize : 0);
            }

            if (this.heldItem != null)
            {
                this.heldItem.drawInMenu(b,
                                         new Vector2(
                                             Game1.getOldMouseX() + Game1.tileSize / 4,
                                             Game1.getOldMouseY() + Game1.tileSize / 4),
                                         1f);
            }

            if (this.hoverRecipe != null)
            {
                IEnumerable <Item> extraItems = this._materialContainers?.SelectMany(chest => chest.items);
                IClickableMenu.drawHoverText(b,
                                             " ",
                                             Game1.smallFont,
                                             Game1.tileSize * 3 / 4,
                                             Game1.tileSize * 3 / 4,
                                             -1,
                                             this.hoverRecipe.name,
                                             -1,
                                             null,
                                             null, 0, -1, -1, -1, -1, 1f, this.hoverRecipe, extraItems?.ToList());
            }
            else if (this.categoryText != null)
            {
                IClickableMenu.drawHoverText(b, this.categoryText, Game1.smallFont);
            }
        }