Exemple #1
0
        public override void receiveRightClick(int x, int y, bool playSound = true)
        {
            if (!this.AllowRightClick)
            {
                return;
            }
            base.receiveRightClick(x, y, false);

            if (this.HeldItem == null && this.ShowReceivingMenu)
            {
                this.HeldItem = this.ItemsToGrabMenu.RightClick(x, y, this.HeldItem, false);
                if (this.HeldItem != null)
                {
                    BehaviorOnItemGrab?.Invoke(this.HeldItem, Game1.player);
                }
                if (this.HeldItem is Object && (this.HeldItem as Object).parentSheetIndex == 326)
                {
                    this.HeldItem = null;
                    Game1.player.canUnderstandDwarves = true;
                    this.Poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2(x - x % Game1.tileSize + Game1.tileSize / 4, y - y % Game1.tileSize + Game1.tileSize / 4), false, false);
                    Game1.playSound("fireball");
                    return;
                }
                if (this.HeldItem is Object recipe && recipe.isRecipe)
                {
                    string key = recipe.Name.Substring(0, recipe.Name.IndexOf("Recipe") - 1);
                    try
                    {
                        if (recipe.category == -7)
                        {
                            Game1.player.cookingRecipes.Add(key, 0);
                        }
                        else
                        {
                            Game1.player.craftingRecipes.Add(key, 0);
                        }
                        this.Poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2(x - x % Game1.tileSize + Game1.tileSize / 4, y - y % Game1.tileSize + Game1.tileSize / 4), false, false);
                        Game1.playSound("newRecipe");
                    }
                    catch { }
                    this.HeldItem = null;
                    return;
                }
                if (Game1.player.addItemToInventoryBool(this.HeldItem))
                {
                    CJB.RemoveLastHudMessage();
                    this.HeldItem = null;
                    Game1.playSound("coin");
                }
            }
            else if (this.ReverseGrab)
            {
                this.BehaviorFunction(this.HeldItem, Game1.player);
                if (this.DestroyItemOnClick)
                {
                    this.HeldItem = null;
                }
            }
        }
Exemple #2
0
 public override void receiveRightClick(int x, int y, bool playSound = true)
 {
     if (!this.allowRightClick)
     {
         return;
     }
     base.receiveRightClick(x, y, playSound && this.playRightClickSound);
     if (this.heldItem == null && this.showReceivingMenu)
     {
         this.heldItem = this.ItemsToGrabMenu.rightClick(x, y, this.heldItem, false);
         if (this.heldItem != null && this.behaviorOnItemGrab != null)
         {
             this.behaviorOnItemGrab(this.heldItem, Game1.player);
         }
         if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 326)
         {
             this.heldItem = null;
             Game1.player.canUnderstandDwarves = true;
             this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
             Game1.playSound("fireball");
             return;
         }
         if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).isRecipe)
         {
             string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
             try {
                 if ((this.heldItem as StardewValley.Object).category == -7)
                 {
                     Game1.player.cookingRecipes.Add(key, 0);
                 }
                 else
                 {
                     Game1.player.craftingRecipes.Add(key, 0);
                 }
                 this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                 Game1.playSound("newRecipe");
             } catch (Exception) {
             }
             this.heldItem = null;
             return;
         }
         if (Game1.player.addItemToInventoryBool(this.heldItem, false))
         {
             CJB.removeLastHudMessage();
             this.heldItem = null;
             Game1.playSound("coin");
             return;
         }
     }
     else if (this.reverseGrab)
     {
         this.behaviorFunction(this.heldItem, Game1.player);
         if (this.destroyItemOnClick)
         {
             this.heldItem = null;
         }
     }
 }
Exemple #3
0
        public override void draw(SpriteBatch b)
        {
            if (!Game1.options.showMenuBackground)
            {
                b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.4f);
            }
            this.draw(b, false, false);
            if (this.showReceivingMenu)
            {
                CJB.drawTextBox(title.bounds.X, title.bounds.Y, Game1.borderFont, title.name, true, 1, 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);
                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);
            }
        }
Exemple #4
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            base.receiveLeftClick(x, y, !this.destroyItemOnClick);

            if (this.heldItem == null)
            {
                if (this.upArrow.bounds.Contains(x, y))
                {
                    if (this.ItemsToGrabMenu != null)
                    {
                        this.ItemsToGrabMenu.receiveScrollWheelAction(1);
                    }
                }

                if (this.downArrow.bounds.Contains(x, y))
                {
                    if (this.ItemsToGrabMenu != null)
                    {
                        this.ItemsToGrabMenu.receiveScrollWheelAction(-1);
                    }
                }
            }
            if (this.heldItem == null && this.showReceivingMenu)
            {
                this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                if (this.heldItem != null && this.behaviorOnItemGrab != null)
                {
                    this.behaviorOnItemGrab(this.heldItem, Game1.player);
                }
                if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 326)
                {
                    this.heldItem = null;
                    Game1.player.canUnderstandDwarves = true;
                    this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                    Game1.playSound("fireball");
                }
                else if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).parentSheetIndex == 102)
                {
                    this.heldItem = null;
                    Game1.player.foundArtifact(102, 1);
                    this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                    Game1.playSound("fireball");
                }
                else if (this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).isRecipe)
                {
                    string key = this.heldItem.Name.Substring(0, this.heldItem.Name.IndexOf("Recipe") - 1);
                    try {
                        if ((this.heldItem as StardewValley.Object).category == -7)
                        {
                            Game1.player.cookingRecipes.Add(key, 0);
                        }
                        else
                        {
                            Game1.player.craftingRecipes.Add(key, 0);
                        }
                        this.poof = new TemporaryAnimatedSprite(Game1.animations, new Rectangle(0, 320, 64, 64), 50f, 8, 0, new Vector2((float)(x - x % Game1.tileSize + Game1.tileSize / 4), (float)(y - y % Game1.tileSize + Game1.tileSize / 4)), false, false);
                        Game1.playSound("newRecipe");
                    } catch (Exception) {
                    }
                    this.heldItem = null;
                }
                else if (Game1.player.addItemToInventoryBool(this.heldItem, false))
                {
                    CJB.removeLastHudMessage();
                    this.heldItem = null;
                    Game1.playSound("coin");
                }
            }
            else if ((this.reverseGrab || this.behaviorFunction != null) && this.isWithinBounds(x, y))
            {
                this.behaviorFunction(this.heldItem, Game1.player);
                if (this.destroyItemOnClick)
                {
                    this.heldItem = null;
                    return;
                }
            }
            if (this.heldItem != null && !this.isWithinBounds(x, y) && this.heldItem.canBeTrashed())
            {
                Game1.playSound("throwDownITem");
                Game1.createItemDebris(this.heldItem, Game1.player.getStandingPosition(), Game1.player.FacingDirection);
                this.heldItem = null;
            }
        }