Ejemplo n.º 1
0
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            base.receiveLeftClick(x, y, !this.destroyItemOnClick);
            if (ItemsToGrabMenu.isWithinBounds(x, y) == false)
            {
                //Log.AsyncC("AWESOME");
                bool f = Util.isInventoryFull(this.ItemsToGrabMenu.actualInventory);
                if (f == false)
                {
                    this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                    Util.addItemToOtherInventory(this.ItemsToGrabMenu.actualInventory, this.heldItem);
                    Log.AsyncG("not full");
                }
                else
                {
                    // this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                    // Util.addItemToInventorySilently(this.heldItem);
                }
                // this.ItemsToGrabMenu.inventory.Add(new ClickableComponent(new Rectangle(ItemsToGrabMenu.xPositionOnScreen + ItemsToGrabMenu.actualInventory.Count-1 % (this.capacity / this.ItemsToGrabMenu.rows) * Game1.tileSize + this.ItemsToGrabMenu.horizontalGap * (ItemsToGrabMenu.actualInventory.Count-1 % (this.capacity / this.ItemsToGrabMenu.rows)), ItemsToGrabMenu.yPositionOnScreen + ItemsToGrabMenu.actualInventory.Count-1 / (this.capacity / this.ItemsToGrabMenu.rows) * (Game1.tileSize + this.ItemsToGrabMenu.verticalGap) + (ItemsToGrabMenu.actualInventory.Count-1 / (this.capacity / this.ItemsToGrabMenu.rows) - 1) * Game1.pixelZoom -  (Game1.tileSize / 5), Game1.tileSize, Game1.tileSize), string.Concat(ItemsToGrabMenu.actualInventory.Count-1)));
                if (this.okButton.containsPoint(x, y) == false && this.organizeButton.containsPoint(x, y) == false && f == false)
                {
                    //
                    Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
                    Game1.playSound("Ship");
                }
                if (this.organizeButton.containsPoint(x, y))
                {
                    ItemGrabMenu.organizeItemsInList(this.ItemsToGrabMenu.actualInventory);
                }
            }
            else
            {
                if (Util.isInventoryFull(this.ItemsToGrabMenu.actualInventory) == true)
                {
                    Item i = new StardewValley.Object();
                    Item j = new StardewValley.Object();
                    j = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                    i = this.heldItem;


                    Util.addItemToInventorySilently(j);
                    // this.heldItem = null;

                    foreach (ClickableComponent current in ItemsToGrabMenu.inventory)
                    {
                        if (current.containsPoint(x, y))
                        {
                            int num = Convert.ToInt32(current.name);
                            //   Log.AsyncO(num);
                            this.ItemsToGrabMenu.actualInventory.RemoveAt(num);
                            //  Log.AsyncO("Remaining " + ItemsToGrabMenu.actualInventory.Count);
                        }
                    }
                    //   j=  this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                    Util.addItemToOtherInventory(this.ItemsToGrabMenu.actualInventory, i);
                    Log.AsyncG("item swap");
                    Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
                    Game1.playSound("Ship");
                    this.heldItem = null;
                    return;
                }



                this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                Util.addItemToInventoryElseDrop(this.heldItem);
                this.heldItem = null;

                foreach (ClickableComponent current in ItemsToGrabMenu.inventory)
                {
                    if (current.containsPoint(x, y))
                    {
                        int num = Convert.ToInt32(current.name);
                        //   Log.AsyncO(num);
                        this.ItemsToGrabMenu.actualInventory.RemoveAt(num);
                        //  Log.AsyncO("Remaining " + ItemsToGrabMenu.actualInventory.Count);
                    }
                }
                Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
                Game1.playSound("Ship");
            }
            return;

            if (this.shippingBin && this.lastShippedHolder.containsPoint(x, y))
            {
                if (Game1.getFarm().lastItemShipped != null && Game1.player.addItemToInventoryBool(Game1.getFarm().lastItemShipped, false))
                {
                    Game1.playSound("coin");
                    Game1.getFarm().shippingBin.Remove(Game1.getFarm().lastItemShipped);
                    Game1.getFarm().lastItemShipped = null;
                    if (Game1.player.ActiveObject != null)
                    {
                        Game1.player.showCarrying();
                        Game1.player.Halt();
                    }
                }
                return;
            }
            if (this.chestColorPicker != null)
            {
                this.chestColorPicker.receiveLeftClick(x, y, true);
                if (this.sourceItem != null && this.sourceItem is Chest)
                {
                    (this.sourceItem as Chest).playerChoiceColor = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection);
                }
            }
            if (this.colorPickerToggleButton != null && this.colorPickerToggleButton.containsPoint(x, y))
            {
                Game1.player.showChestColorPicker = !Game1.player.showChestColorPicker;
                this.chestColorPicker.visible     = Game1.player.showChestColorPicker;
                Game1.soundBank.PlayCue("drumkit6");
            }
            if (this.heldItem == null && this.showReceivingMenu)
            {
                this.heldItem = this.ItemsToGrabMenu.leftClick(x, y, this.heldItem, false);
                //  Log.AsyncC("YAY");



                if (this.heldItem != null && this.behaviorOnItemGrab != null)
                {
                    this.behaviorOnItemGrab(this.heldItem, Game1.player);
                    if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu)
                    {
                        (Game1.activeClickableMenu as ItemGrabMenu).setSourceItem(this.sourceItem);
                    }
                }
                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))
                {
                    this.heldItem = null;
                    Game1.playSound("coin");
                }
            }
            else if ((this.reverseGrab || this.behaviorFunction != null) && this.isWithinBounds(x, y))
            {
                this.behaviorFunction(this.heldItem, Game1.player);
                if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemGrabMenu)
                {
                    (Game1.activeClickableMenu as ItemGrabMenu).setSourceItem(this.sourceItem);
                }
                if (this.destroyItemOnClick)
                {
                    this.heldItem = null;
                    return;
                }
            }
            if (this.organizeButton != null && this.organizeButton.containsPoint(x, y))
            {
                ItemGrabMenu.organizeItemsInList(this.ItemsToGrabMenu.actualInventory);
                Game1.activeClickableMenu = new ItemGrabMenu(this.ItemsToGrabMenu.actualInventory, this.Rows, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), this.behaviorFunction, null, this.behaviorOnItemGrab, false, true, true, true, true, this.source, this.sourceItem);
                Game1.playSound("Ship");
                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;
            }
        }
Ejemplo n.º 2
0
 public override void receiveLeftClick(int x, int y, bool playSound = true)
 {
     foreach (ClickableComponent current in this.equipmentIcons)
     {
         if (current.containsPoint(x, y))
         {
             bool   flag = this.heldItem == null;
             string name = current.name;
             if (!(name == "Hat"))
             {
                 if (!(name == "Left Ring"))
                 {
                     if (!(name == "Right Ring"))
                     {
                         if (name == "Boots")
                         {
                             if (this.heldItem == null || this.heldItem is Boots)
                             {
                                 Boots boots = (Boots)this.heldItem;
                                 this.heldItem      = Game1.player.boots;
                                 Game1.player.boots = boots;
                                 if (this.heldItem != null)
                                 {
                                     (this.heldItem as Boots).onUnequip();
                                 }
                                 if (Game1.player.boots != null)
                                 {
                                     Game1.player.boots.onEquip();
                                 }
                                 if (this.heldItem == null)
                                 {
                                     Game1.playSound("sandyStep");
                                     DelayedAction.playSoundAfterDelay("sandyStep", 150);
                                 }
                                 else
                                 {
                                     Game1.playSound("dwop");
                                 }
                             }
                         }
                     }
                     else if (this.heldItem == null || this.heldItem is Ring)
                     {
                         Ring rightRing = (Ring)this.heldItem;
                         this.heldItem          = Game1.player.rightRing;
                         Game1.player.rightRing = rightRing;
                         if (this.heldItem != null)
                         {
                             (this.heldItem as Ring).onUnequip(Game1.player);
                         }
                         if (Game1.player.rightRing != null)
                         {
                             Game1.player.rightRing.onEquip(Game1.player);
                         }
                         if (this.heldItem == null)
                         {
                             Game1.playSound("crit");
                         }
                         else
                         {
                             Game1.playSound("dwop");
                         }
                     }
                 }
                 else if (this.heldItem == null || this.heldItem is Ring)
                 {
                     Ring leftRing = (Ring)this.heldItem;
                     this.heldItem         = Game1.player.leftRing;
                     Game1.player.leftRing = leftRing;
                     if (this.heldItem != null)
                     {
                         (this.heldItem as Ring).onUnequip(Game1.player);
                     }
                     if (Game1.player.leftRing != null)
                     {
                         Game1.player.leftRing.onEquip(Game1.player);
                     }
                     if (this.heldItem == null)
                     {
                         Game1.playSound("crit");
                     }
                     else
                     {
                         Game1.playSound("dwop");
                     }
                 }
             }
             else if (this.heldItem == null || this.heldItem is Hat)
             {
                 Hat hat = (Hat)this.heldItem;
                 this.heldItem    = Game1.player.hat;
                 Game1.player.hat = hat;
                 if (this.heldItem == null)
                 {
                     Game1.playSound("grassyStep");
                 }
                 else
                 {
                     Game1.playSound("dwop");
                 }
             }
             if (flag && this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
             {
                 for (int i = 0; i < Game1.player.items.Count; i++)
                 {
                     if (Game1.player.items[i] == null || Game1.player.items[i].canStackWith(this.heldItem))
                     {
                         if (Game1.player.CurrentToolIndex == i && this.heldItem != null)
                         {
                             this.heldItem.actionWhenBeingHeld(Game1.player);
                         }
                         this.heldItem = Utility.addItemToInventory(this.heldItem, i, this.inventory.actualInventory, null);
                         if (Game1.player.CurrentToolIndex == i && this.heldItem != null)
                         {
                             this.heldItem.actionWhenStopBeingHeld(Game1.player);
                         }
                         Game1.playSound("stoneStep");
                         return;
                     }
                 }
             }
         }
     }
     this.heldItem = this.inventory.leftClick(x, y, this.heldItem, !Game1.oldKBState.IsKeyDown(Keys.LeftShift));
     if (this.heldItem != null && this.heldItem is StardewValley.Object && (this.heldItem as StardewValley.Object).ParentSheetIndex == 434)
     {
         Game1.playSound("smallSelect");
         Game1.playerEatObject(this.heldItem as StardewValley.Object, true);
         this.heldItem = null;
         Game1.exitActiveMenu();
     }
     else if (this.heldItem != null && Game1.oldKBState.IsKeyDown(Keys.LeftShift))
     {
         if (this.heldItem is Ring)
         {
             if (Game1.player.leftRing == null)
             {
                 Game1.player.leftRing = (this.heldItem as Ring);
                 (this.heldItem as Ring).onEquip(Game1.player);
                 this.heldItem = null;
                 Game1.playSound("crit");
                 return;
             }
             if (Game1.player.rightRing == null)
             {
                 Game1.player.rightRing = (this.heldItem as Ring);
                 (this.heldItem as Ring).onEquip(Game1.player);
                 this.heldItem = null;
                 Game1.playSound("crit");
                 return;
             }
         }
         else if (this.heldItem is Hat)
         {
             if (Game1.player.hat == null)
             {
                 Game1.player.hat = (this.heldItem as Hat);
                 Game1.playSound("grassyStep");
                 this.heldItem = null;
                 return;
             }
         }
         else if (this.heldItem is Boots && Game1.player.boots == null)
         {
             Game1.player.boots = (this.heldItem as Boots);
             (this.heldItem as Boots).onEquip();
             Game1.playSound("sandyStep");
             DelayedAction.playSoundAfterDelay("sandyStep", 150);
             this.heldItem = null;
             return;
         }
         if (this.inventory.getInventoryPositionOfClick(x, y) >= 12)
         {
             for (int j = 0; j < 12; j++)
             {
                 if (Game1.player.items[j] == null || Game1.player.items[j].canStackWith(this.heldItem))
                 {
                     if (Game1.player.CurrentToolIndex == j && this.heldItem != null)
                     {
                         this.heldItem.actionWhenBeingHeld(Game1.player);
                     }
                     this.heldItem = Utility.addItemToInventory(this.heldItem, j, this.inventory.actualInventory, null);
                     if (this.heldItem != null)
                     {
                         this.heldItem.actionWhenStopBeingHeld(Game1.player);
                     }
                     Game1.playSound("stoneStep");
                     return;
                 }
             }
         }
     }
     if (this.portrait.containsPoint(x, y))
     {
         this.portrait.name = (this.portrait.name.Equals("32") ? "8" : "32");
     }
     if (this.heldItem != null && this.trashCan.containsPoint(x, y) && this.heldItem.canBeTrashed())
     {
         if (this.heldItem is StardewValley.Object && Game1.player.specialItems.Contains((this.heldItem as StardewValley.Object).parentSheetIndex))
         {
             Game1.player.specialItems.Remove((this.heldItem as StardewValley.Object).parentSheetIndex);
         }
         this.heldItem = null;
         Game1.playSound("trashcan");
     }
     else 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;
     }
     if (this.organizeButton != null && this.organizeButton.containsPoint(x, y))
     {
         ItemGrabMenu.organizeItemsInList(Game1.player.items);
         Game1.playSound("Ship");
     }
 }