Exemple #1
0
        public CustomOrderBoard(string board_type = "", Texture2D customTexture = null)
            : base(0, 0, 0, 0, showUpperRightCloseButton: true)
        {
            SpecialOrder.UpdateAvailableSpecialOrders(force_refresh: false);
            this.boardType = board_type;

            if (customTexture != null)
            {
                this._billboardTexture = customTexture;
            }
            else
            {
                this._billboardTexture = Game1.temporaryContent.Load <Texture2D>("LooseSprites\\SpecialOrdersBoard");
            }

            base.width  = 1352;
            base.height = 792;
            Vector2 center = Utility.getTopLeftPositionForCenteringOnScreen(base.width, base.height);

            base.xPositionOnScreen = (int)center.X;
            base.yPositionOnScreen = (int)center.Y;
            Rectangle leftButtonBounds = new Rectangle(
                x: base.xPositionOnScreen + (base.width / 4) - 128, y: base.yPositionOnScreen + base.height - 128,
                width: (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).X + 24,
                height: (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).Y + 24
                );

            this.acceptLeftQuestButton = new ClickableComponent(leftButtonBounds, "")
            {
                myID            = 0,
                leftNeighborID  = -99998,
                rightNeighborID = -99998,
                upNeighborID    = -99998,
                downNeighborID  = -99998
            };
            Rectangle rightButtonBOunds = new Rectangle(
                x: base.xPositionOnScreen + base.width * 3 / 4 - 128,
                y: base.yPositionOnScreen + base.height - 128,
                width: (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).X + 24,
                height: (int)Game1.dialogueFont.MeasureString(Game1.content.LoadString("Strings\\UI:AcceptQuest")).Y + 24
                );

            this.acceptRightQuestButton = new ClickableComponent(rightButtonBOunds, "")
            {
                myID            = 1,
                leftNeighborID  = -99998,
                rightNeighborID = -99998,
                upNeighborID    = -99998,
                downNeighborID  = -99998
            };
            this.leftOrder             = Game1.player.team.GetAvailableSpecialOrder(0, this.GetOrderType());
            this.rightOrder            = Game1.player.team.GetAvailableSpecialOrder(1, this.GetOrderType());
            base.upperRightCloseButton = new ClickableTextureComponent(
                bounds: new Rectangle(base.xPositionOnScreen + base.width - 20, base.yPositionOnScreen, 48, 48),
                texture: Game1.mouseCursors,
                sourceRect: new Rectangle(337, 494, 12, 12),
                scale: 4f
                );

            Game1.playSound("bigSelect");
            this.UpdateButtons();

            if (Game1.options.SnappyMenus)
            {
                base.populateClickableComponentList();
                this.snapToDefaultClickableComponent();
            }
        }
        public ExpandedFridgeMenu(ExpandedFridgeHub fridgeHub) : base(InventoryMenu.highlightAllItems, true, true, 0, 0)
        {
            this.fridgeHub = fridgeHub;

            {
                int i      = 0;
                int labelX = this.xPositionOnScreen + Game1.tileSize / 2;
                int labelY = (int)(this.yPositionOnScreen + Game1.tileSize * 3.3F);

                foreach (Chest c in fridgeHub.connectedChests)
                {
                    if (c == fridgeHub.selectedChest)
                    {
                        this.selectedTabIndex = i;
                        this.selectedTab      = new ClickableComponent(new Rectangle(labelX + Game1.tileSize * i++, labelY, Game1.tileSize, Game1.tileSize), (i).ToString(), (i).ToString());
                        this.selectedTabColor = c.playerChoiceColor.Value;
                    }
                    else
                    {
                        this.chestTabs.Add(new ClickableComponent(new Rectangle(labelX + Game1.tileSize * i++, labelY, Game1.tileSize, Game1.tileSize), (i).ToString(), (i).ToString()));
                        this.chestTabsColors.Add(c.playerChoiceColor.Value);
                    }
                }
            }

            this.inventory.showGrayedOutSlots = true;
            this.sourceItem = fridgeHub.selectedChest;

            {
                this.chestColorPicker = new DiscreteColorPicker(this.xPositionOnScreen, this.yPositionOnScreen - 64 - IClickableMenu.borderWidth * 2, 0, (Item) new Chest(true));
                this.chestColorPicker.colorSelection = this.chestColorPicker.getSelectionFromColor((Color)((NetFieldBase <Color, NetColor>)fridgeHub.selectedChest.playerChoiceColor));
                (this.chestColorPicker.itemToDrawColored as Chest).playerChoiceColor.Value = this.chestColorPicker.getColorFromSelection(this.chestColorPicker.colorSelection);
                ClickableTextureComponent textureComponent = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + 64 + 20, 64, 64), Game1.mouseCursors, new Rectangle(119, 469, 16, 16), 4f, false);
                textureComponent.hoverText      = Game1.content.LoadString("Strings\\UI:Toggle_ColorPicker");
                textureComponent.myID           = 27346;
                textureComponent.downNeighborID = 106;//5948;
                textureComponent.leftNeighborID = 11;
                this.colorPickerToggleButton    = textureComponent;
            }

            this.ItemsToGrabMenu = new InventoryMenu(this.xPositionOnScreen + 32, this.yPositionOnScreen, false, this.fridgeHub.selectedChest.items, InventoryMenu.highlightAllItems, -1, 3, 0, 0, true);

            if (Game1.options.SnappyMenus)
            {
                this.ItemsToGrabMenu.populateClickableComponentList();
                for (int index = 0; index < this.ItemsToGrabMenu.inventory.Count; ++index)
                {
                    if (this.ItemsToGrabMenu.inventory[index] != null)
                    {
                        this.ItemsToGrabMenu.inventory[index].myID            += 53910;
                        this.ItemsToGrabMenu.inventory[index].upNeighborID    += 53910;
                        this.ItemsToGrabMenu.inventory[index].rightNeighborID += 53910;
                        this.ItemsToGrabMenu.inventory[index].downNeighborID   = -7777;
                        this.ItemsToGrabMenu.inventory[index].leftNeighborID  += 53910;
                        this.ItemsToGrabMenu.inventory[index].fullyImmutable   = true;
                    }
                }
            }

            {
                ClickableTextureComponent textureComponent = new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen + this.width, this.yPositionOnScreen + this.height / 3 - 64, 64, 64), "", Game1.content.LoadString("Strings\\UI:ItemGrab_Organize"), Game1.mouseCursors, new Rectangle(162, 440, 16, 16), 4f, false);
                textureComponent.myID           = 106;
                textureComponent.upNeighborID   = 27346;
                textureComponent.downNeighborID = 5948;
                this.organizeButton             = textureComponent;
            }

            if ((Game1.isAnyGamePadButtonBeingPressed() || !Game1.lastCursorMotionWasMouse) && (this.ItemsToGrabMenu.actualInventory.Count > 0 && Game1.activeClickableMenu == null))
            {
                Game1.setMousePosition(this.inventory.inventory[0].bounds.Center);
            }
            if (!Game1.options.snappyMenus || !Game1.options.gamepadControls)
            {
                return;
            }

            this.discreteColorPickerCC = new List <ClickableComponent>();
            for (int index = 0; index < this.chestColorPicker.totalColors; ++index)
            {
                this.discreteColorPickerCC.Add(new ClickableComponent(new Rectangle(this.chestColorPicker.xPositionOnScreen + IClickableMenu.borderWidth / 2 + index * 9 * 4, this.chestColorPicker.yPositionOnScreen + IClickableMenu.borderWidth / 2, 36, 28), "")
                {
                    myID            = index + 4343,
                    rightNeighborID = index < this.chestColorPicker.totalColors - 1 ? index + 4343 + 1 : -1,
                    leftNeighborID  = index > 0 ? index + 4343 - 1 : -1,
                    downNeighborID  = this.ItemsToGrabMenu == null || this.ItemsToGrabMenu.inventory.Count <= 0 ? 0 : 53910
                });
            }

            for (int index = 0; index < 12; ++index)
            {
                if (this.inventory != null && this.inventory.inventory != null && this.inventory.inventory.Count >= 12)
                {
                    this.inventory.inventory[index].upNeighborID = (this.discreteColorPickerCC == null || this.ItemsToGrabMenu == null || this.ItemsToGrabMenu.inventory.Count > index ? (this.ItemsToGrabMenu.inventory.Count > index ? 53910 + index : 53910) : 4343);
                }
                if (this.discreteColorPickerCC != null && this.ItemsToGrabMenu != null && this.ItemsToGrabMenu.inventory.Count > index)
                {
                    this.ItemsToGrabMenu.inventory[index].upNeighborID = 4343;
                }
            }

            for (int index = 0; index < 36; ++index)
            {
                if (this.inventory != null && this.inventory.inventory != null && this.inventory.inventory.Count > index)
                {
                    this.inventory.inventory[index].upNeighborID        = -7777;
                    this.inventory.inventory[index].upNeighborImmutable = true;
                }
            }

            if (this.trashCan != null && this.inventory.inventory.Count >= 12 && this.inventory.inventory[11] != null)
            {
                this.inventory.inventory[11].rightNeighborID = 5948;
            }
            if (this.trashCan != null)
            {
                this.trashCan.leftNeighborID = 11;
            }
            if (this.okButton != null)
            {
                this.okButton.leftNeighborID = 11;
            }

            this.populateClickableComponentList();
            this.snapToDefaultClickableComponent();
        }
        private void MoveCursorInDirectionNew(CursorDirection direction)
        {
            if (this.currentlySnappedComponent == null && this.allClickableComponents != null && this.allClickableComponents.Count <ClickableComponent>() > 0)
            {
                this.snapToDefaultClickableComponent();
                if (this.currentlySnappedComponent == null)
                {
                    this.currentlySnappedComponent = this.allClickableComponents.First <ClickableComponent>();
                }
            }
            if (this.currentlySnappedComponent == null)
            {
                return;
            }

            ClickableComponent snappedComponent = this.currentlySnappedComponent;

            switch (direction)
            {
            case CursorDirection.North:
                if (this.currentlySnappedComponent.upNeighborID == -99999)
                {
                    this.snapToDefaultClickableComponent();
                }
                else if (this.currentlySnappedComponent.upNeighborID == -7777)
                {
                    this.customSnapBehavior(0, this.currentlySnappedComponent.region, this.currentlySnappedComponent.myID);
                }
                else
                {
                    this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.upNeighborID);
                }
                if (this.currentlySnappedComponent != null && (snappedComponent == null || snappedComponent.upNeighborID != -7777) && (!this.currentlySnappedComponent.downNeighborImmutable && !this.currentlySnappedComponent.fullyImmutable))
                {
                    this.currentlySnappedComponent.downNeighborID = snappedComponent.myID;
                }
                if (this.currentlySnappedComponent == null)
                {
                    this.noSnappedComponentFound(0, snappedComponent.region, snappedComponent.myID);
                    break;
                }
                break;

            case CursorDirection.Right:
                if (this.currentlySnappedComponent.rightNeighborID == -99999)
                {
                    this.snapToDefaultClickableComponent();
                }
                else if (this.currentlySnappedComponent.rightNeighborID == -7777)
                {
                    this.customSnapBehavior(1, this.currentlySnappedComponent.region, this.currentlySnappedComponent.myID);
                }

                // Code added: Sets the correct snapped component (first lost book) when the [Lost Books] sidetab is selected
                // and the player presses the [Right] button to snap to a book item. Previously, the snapped component was set to
                // the component with ID = 0 in the collections page. The first item with ID = 0 is the first item in the [Shipped] tab
                // and has the wrong item offset. As a result, continous right-snapping or below snapping would fail to snap to the correct
                // [Lost Book].
                else if (this.currentlySnappedComponent.myID >= region_sideTabShipped &&
                         this.currentlySnappedComponent.myID <= region_sideTabLostBooks &&
                         ModEntry.CommonServices.ReflectionHelper.GetField <int>(this, "currentTab").GetValue() == lostBooksTabPageIndex)
                {
                    this.currentlySnappedComponent = this.getComponentWithID(LostBooksTab_ItemBaseId);
                }

                // Code added: Sets the correct snapped component (first lost book) when a sidetab other than [Lost Books] is selected
                // and the player presses the [Right] button to snap to an item while the [Lost Books] item is snapped.
                // Without this code the snapped item will be treated as a [Lost Book] (with its non-standard item offset).
                // Since the item offset is the same for every sidetab other than [Lost Books], we simply set the currently snapped item
                // to the first item with ID = 0 which is the first item for every original sidetab.
                else if (this.currentlySnappedComponent.myID == region_sideTabLostBooks &&
                         ModEntry.CommonServices.ReflectionHelper.GetField <int>(this, "currentTab").GetValue() != lostBooksTabPageIndex)
                {
                    this.currentlySnappedComponent = this.getComponentWithID(0);
                }

                else
                {
                    this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.rightNeighborID);
                }
                if (this.currentlySnappedComponent != null && (snappedComponent == null || snappedComponent.rightNeighborID != -7777) && (!this.currentlySnappedComponent.leftNeighborImmutable && !this.currentlySnappedComponent.fullyImmutable))
                {
                    this.currentlySnappedComponent.leftNeighborID = snappedComponent.myID;
                }
                if (this.currentlySnappedComponent == null && snappedComponent.tryDefaultIfNoRightNeighborExists)
                {
                    this.snapToDefaultClickableComponent();
                    break;
                }
                if (this.currentlySnappedComponent == null)
                {
                    this.noSnappedComponentFound(1, snappedComponent.region, snappedComponent.myID);
                    break;
                }
                break;

            case CursorDirection.South:
                if (this.currentlySnappedComponent.downNeighborID == -99999)
                {
                    this.snapToDefaultClickableComponent();
                }
                else if (this.currentlySnappedComponent.downNeighborID == -7777)
                {
                    this.customSnapBehavior(2, this.currentlySnappedComponent.region, this.currentlySnappedComponent.myID);
                }
                else
                {
                    this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.downNeighborID);
                }
                if (this.currentlySnappedComponent != null && (snappedComponent == null || snappedComponent.downNeighborID != -7777) && (!this.currentlySnappedComponent.upNeighborImmutable && !this.currentlySnappedComponent.fullyImmutable))
                {
                    this.currentlySnappedComponent.upNeighborID = snappedComponent.myID;
                }
                if (this.currentlySnappedComponent == null && snappedComponent.tryDefaultIfNoDownNeighborExists)
                {
                    this.snapToDefaultClickableComponent();
                    break;
                }
                if (this.currentlySnappedComponent == null)
                {
                    this.noSnappedComponentFound(2, snappedComponent.region, snappedComponent.myID);
                    break;
                }
                break;

            case CursorDirection.Left:
                if (this.currentlySnappedComponent.leftNeighborID == -99999)
                {
                    this.snapToDefaultClickableComponent();
                }
                else if (this.currentlySnappedComponent.leftNeighborID == -7777)
                {
                    this.customSnapBehavior(3, this.currentlySnappedComponent.region, this.currentlySnappedComponent.myID);
                }
                else
                {
                    //this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.leftNeighborID);

                    // Addd code: This addition makes sure that the cursor will snap to the selected sidetab (and not the first tab)
                    // when the player presses [Left] when on the leftmost column of a collections page.
                    var currentTab = ModEntry.CommonServices.ReflectionHelper.GetField <int>(this, "currentTab").GetValue();
                    if (this.currentlySnappedComponent.leftNeighborID >= sideTabs_FirstIndex &&
                        this.currentlySnappedComponent.leftNeighborID <= sideTabs_FirstIndex + secretNotesTab &&
                        this.currentlySnappedComponent.leftNeighborID != sideTabs_FirstIndex + currentTab)
                    {
                        //var currentTab = ModEntry.CommonServices.ReflectionHelper.GetField<int>(this, "currentTab").GetValue();

                        this.currentlySnappedComponent.leftNeighborID = sideTabs_FirstIndex + currentTab;
                        this.currentlySnappedComponent = this.getComponentWithID(sideTabs_FirstIndex + currentTab);
                    }
                    else
                    {
                        this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.leftNeighborID);
                    }
                }

                if (this.currentlySnappedComponent != null && (snappedComponent == null || snappedComponent.leftNeighborID != -7777) && (!this.currentlySnappedComponent.rightNeighborImmutable && !this.currentlySnappedComponent.fullyImmutable))
                {
                    this.currentlySnappedComponent.rightNeighborID = snappedComponent.myID;
                }
                if (this.currentlySnappedComponent == null)
                {
                    this.noSnappedComponentFound(3, snappedComponent.region, snappedComponent.myID);
                    break;
                }
                break;
            }

            if (this.currentlySnappedComponent != null && snappedComponent != null && this.currentlySnappedComponent.region != snappedComponent.region)
            {
                this.actionOnRegionChange(snappedComponent.region, this.currentlySnappedComponent.region);
            }

            if (this.currentlySnappedComponent == null)
            {
                this.currentlySnappedComponent = snappedComponent;
            }

            this.snapCursorToCurrentSnappedComponent();
            Game1.playSound("shiny4");
        }
Exemple #4
0
 public NewAnimalQueryMenu(CustomFarmAnimal animal) : base(Game1.viewport.Width / 2 - width / 2, Game1.viewport.Height / 2 - height / 2, width, height, false)
 {
     Game1.player.Halt();
     Game1.player.faceGeneralDirection(animal.position, 0);
     NewAnimalQueryMenu.width  = Game1.tileSize * 6;
     NewAnimalQueryMenu.height = Game1.tileSize * 8;
     this.animal         = animal;
     this.textBox        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
     this.textBox.X      = Game1.viewport.Width / 2 - Game1.tileSize * 2 - 12;
     this.textBox.Y      = this.yPositionOnScreen - 4 + Game1.tileSize * 2;
     this.textBox.Width  = Game1.tileSize * 4;
     this.textBox.Height = Game1.tileSize * 3;
     this.textBoxCC      = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X, this.textBox.Y, this.textBox.Width, Game1.tileSize), "")
     {
         myID           = 110,
         downNeighborID = 104
     };
     this.textBox.Text = animal.displayName;
     Game1.keyboardDispatcher.Subscriber = this.textBox;
     this.textBox.Selected = false;
     if (animal.parentId != -1L)
     {
         FarmAnimal farmAnimal = Utility.getAnimal(animal.parentId);
         if (farmAnimal != null)
         {
             this.parentName = farmAnimal.displayName;
         }
     }
     if (animal.sound != null && Game1.soundBank != null)
     {
         Cue expr_1B2 = Game1.soundBank.GetCue(animal.sound);
         expr_1B2.SetVariable("Pitch", (float)(1200 + Game1.random.Next(-200, 201)));
         expr_1B2.Play();
     }
     this.okButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false)
     {
         myID         = 101,
         upNeighborID = 103
     };
     this.sellButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(0, 384, 16, 16), 4f, false)
     {
         myID           = 103,
         downNeighborID = 101,
         upNeighborID   = 104
     };
     this.moveHomeButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 4 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(16, 384, 16, 16), 4f, false)
     {
         myID           = 104,
         downNeighborID = 103,
         upNeighborID   = 110
     };
     if (!animal.isBaby() && !animal.isCoopDweller())
     {
         allowReproductionButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + width + Game1.pixelZoom * 4, yPositionOnScreen + height - Game1.tileSize * 2 - borderWidth + Game1.pixelZoom * 2, Game1.pixelZoom * 9, Game1.pixelZoom * 9), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(animal.allowReproduction ? 128 : 137, 393, 9, 9), 4f, false)
         {
             myID = 106
         };
     }
     this.love = new ClickableTextureComponent(Math.Round((double)animal.friendshipTowardFarmer, 0) / 10.0 + "<", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + Game1.tileSize / 2 + 16, this.yPositionOnScreen - Game1.tileSize / 2 + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 4 - Game1.tileSize / 2, AnimalQueryMenu.width - Game1.tileSize * 2, Game1.tileSize), null, "Friendship", Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(172, 512, 16, 16), 4f, false)
     {
         myID = 102
     };
     this.loveHover = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + Game1.tileSize * 3 - Game1.tileSize / 2, AnimalQueryMenu.width, Game1.tileSize), "Friendship")
     {
         myID = 109
     };
     this.fullnessLevel = (double)((float)animal.fullness / 255f);
     if (animal.home != null && animal.home.indoors != null)
     {
         int num = animal.home.indoors.numberOfObjectsWithName("Hay");
         if (num > 0)
         {
             int count = (animal.home.indoors as AnimalHouse).animalsThatLiveHere.Count;
             this.fullnessLevel = Math.Min(1.0, this.fullnessLevel + (double)num / (double)count);
         }
     }
     else
     {
         Utility.fixAllAnimals();
     }
     this.happinessLevel = (double)((float)animal.happiness / 255f);
     this.loveLevel      = (double)((float)animal.friendshipTowardFarmer / 1000f);
     if (Game1.options.SnappyMenus)
     {
         base.populateClickableComponentList();
         this.snapToDefaultClickableComponent();
     }
 }
        /******************
        * Override methods
        ******************/

        /// <summary>The method invoked when the player left-clicks on the menu.</summary>
        /// <param name="x">The X-position of the cursor.</param>
        /// <param name="y">The Y-position of the cursor.</param>
        /// <param name="playSound">Whether to enable sound.</param>
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            // Implementation derived mostly from ShopMenu
            base.receiveLeftClick(x, y, playSound);
            if (Game1.activeClickableMenu == null)
            {
                return;
            }

            // scrolling related widgets
            if (DownArrow.containsPoint(x, y) && LowestVisibleIndex < MaxScrollIndex()) // not bottom of list
            {
                DownArrowPressed();
                Game1.playSound("shwip");
            }
            else if (UpArrow.containsPoint(x, y) && LowestVisibleIndex > 0) // not top of list
            {
                UpArrowPressed();
                Game1.playSound("shwip");
            }
            else if (ScrollBar.containsPoint(x, y))
            {
                IsScrolling = true;
            }
            else if (!DownArrow.containsPoint(x, y) &&
                     x > xPositionOnScreen + width &&
                     (x < xPositionOnScreen + width + 128 &&
                      y > yPositionOnScreen) &&
                     y < yPositionOnScreen + height)
            {
                IsScrolling = true;
                leftClickHeld(x, y);
                releaseLeftClick(x, y);
            }

            // play or stop buttons
            else if (PlayButton.containsPoint(x, y) && SelectedIndex >= 0)
            {
                PlayButtonPressed();
                Game1.playSound("select");
            }
            else if (StopButton != null && StopButton.containsPoint(x, y))
            {
                StopButtonPressed();
                Game1.playSound("select");
            }
            // and now random button
            else if (RandomButton != null && RandomButton.containsPoint(x, y))
            {
                RandomButtonPressed();
                Game1.playSound("select");
            }

            // option select (give 'em the mixup)
            else
            {
                // first tabs
                for (int i = 0; i < SortTabs.Count; ++i)
                {
                    ClickableComponent sort_tab = SortTabs[i];
                    if (sort_tab.containsPoint(x, y))
                    {
                        SelectedTab = i;
                        SortOptions();
                        RepositionTabs();
                        UpdateVisibleOptions();
                        SetScrollBarToLowestVisibleIndex();
                        Game1.playSound("shwip");
                    }
                }
                // then actual options
                for (int i = 0; i < VisibleOptions.Count; ++i)
                {
                    ClickableComponent visible_option = VisibleOptions[i];
                    if (visible_option.containsPoint(x, y))
                    {
                        // repeat selection
                        if (LowestVisibleIndex + i == SelectedIndex)
                        {
                            //Monitor.Log("Playing a song: " + Options[SelectedIndex]);
                            if (visible_option.name != Options[SelectedIndex])
                            {
                                Monitor.Log("The song on the button does not match the one being played!", LogLevel.Error);
                            }
                            PlayButtonPressed();
                            Game1.playSound("select");
                        }

                        // new selection
                        else
                        {
                            SelectedIndex = LowestVisibleIndex + i;
                            Game1.playSound("shiny4");
                        }
                    }
                }
            }
        }
Exemple #6
0
        private SettingsMenu(ModEntry parent, int currentIndex = 0) :
            base(Game1.viewport.Width / 2 - Game1.tileSize * 10 / 2,
                 Game1.viewport.Height / 2 - Game1.tileSize * 8 / 2,
                 Game1.tileSize * 10,
                 Game1.tileSize * 8,
                 true)
        {
            _parent       = parent;
            _currentIndex = currentIndex;

            Game1.playSound("bigSelect");

            upperRightCloseButton.bounds = new Rectangle(xPositionOnScreen + width + Game1.pixelZoom * 4,
                                                         yPositionOnScreen - Game1.pixelZoom * 20, Game1.pixelZoom * 12, Game1.pixelZoom * 12);

            upperRightCloseButton.myID           = 100;
            upperRightCloseButton.downNeighborID = 0;

            // Initialize UI components
            _upArrow = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width + Game1.tileSize / 4, yPositionOnScreen, Game1.pixelZoom * 11,
                              Game1.pixelZoom * 12), Game1.mouseCursors, new Rectangle(421, 459, 11, 12), Game1.pixelZoom);
            _downArrow = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width + Game1.tileSize / 4,
                              yPositionOnScreen + height - Game1.pixelZoom * 12, Game1.pixelZoom * 11, Game1.pixelZoom * 12),
                Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom);
            _scrollBar = new ClickableTextureComponent(
                new Rectangle(_upArrow.bounds.X + Game1.pixelZoom * 3,
                              _upArrow.bounds.Y + _upArrow.bounds.Height + Game1.pixelZoom, Game1.pixelZoom * 6,
                              Game1.pixelZoom * 10), Game1.mouseCursors, new Rectangle(435, 463, 6, 10), Game1.pixelZoom);
            _scrollBarRunner = new Rectangle(_scrollBar.bounds.X, _scrollBar.bounds.Y, _scrollBar.bounds.Width,
                                             height - _upArrow.bounds.Height * 2 - Game1.pixelZoom * 3);

            for (var i = 0; i < ItemsPerPage; ++i)
            {
                var clickableComponent = new ClickableComponent(new Rectangle(xPositionOnScreen,
                                                                              yPositionOnScreen + _yMargin + (height - Game1.tileSize / 2) / ItemsPerPage * i, width,
                                                                              (height - _yMargin * 2) / ItemsPerPage), i.ToString())
                {
                    myID           = i,
                    fullyImmutable = true,
                    upNeighborID   = i > 0 ? i - 1 : -7777,
                    downNeighborID = i < ItemsPerPage - 1 ? i + 1 : -7777
                };
                _slots.Add(clickableComponent);
            }

            // Add options
            _options.Add(new InputListener("Open Report Key", OptionsEnum.OpenReportKey, _slots[0].bounds.Width,
                                           parent.Config));
            _options.Add(new InputListener("Open Settings Key", OptionsEnum.OpenSettings, _slots[0].bounds.Width,
                                           parent.Config));
            _options.Add(new InputListener("Toggle Bubbles Key", OptionsEnum.ToggleBubbles, _slots[0].bounds.Width,
                                           _parent.Config));
            _options.Add(new Checkbox("Show report button", OptionsEnum.ShowReportButton, parent.Config));
            _options.Add(new Checkbox("Display bubbles", OptionsEnum.DisplayBubbles, parent.Config, true,
                                      _slots[0].bounds.Width));
            _options.Add(new Checkbox("Show detailed info", OptionsEnum.ShowDetailedInfo, parent.Config));
            _options.Add(new OptionsElement("Report:"));
            _options.Add(new Checkbox("New recipe on TV", OptionsEnum.NewRecipeOnTv, parent.Config));
            _options.Add(new Checkbox("Birthdays", OptionsEnum.Birthdays, parent.Config));
            _options.Add(new Checkbox("Traveling merchant in town", OptionsEnum.TravelingMerchant, parent.Config));
            _options.Add(new Checkbox("Unwatered crops", OptionsEnum.UnwateredCrops, parent.Config));
            _options.Add(new Checkbox("Unharvested crops", OptionsEnum.UnharvestedCrops, parent.Config));
            _options.Add(new Checkbox("Dead crops", OptionsEnum.DeadCrops, parent.Config));
            _options.Add(new QualityOption("Fruits in trees", OptionsEnum.FruitTrees, parent.Config, 0, 3));
            _options.Add(new Checkbox("Unpetted pet", OptionsEnum.UnpettedPet, parent.Config));
            _options.Add(new Checkbox("Unfilled pet bowl", OptionsEnum.UnfilledPetBowl, parent.Config));
            _options.Add(new Checkbox("Unpetted animals", OptionsEnum.UnpettedAnimals, parent.Config));
            // Animal products
            _options.Add(new Checkbox("Animal products:", OptionsEnum.AllAnimalProducts, parent.Config));
            _options.Add(new Checkbox("Cow milk", OptionsEnum.CowMilk, parent.Config, 1));
            _options.Add(new Checkbox("Goat milk", OptionsEnum.GoatMilk, parent.Config, 1));
            _options.Add(new Checkbox("Sheep wool", OptionsEnum.SheepWool, parent.Config, 1));
            _options.Add(new Checkbox("Chicken egg", OptionsEnum.ChickenEgg, parent.Config, 1));
            _options.Add(new Checkbox("Dinosaur egg", OptionsEnum.DinosaurEgg, parent.Config, 1));
            _options.Add(new Checkbox("Duck egg", OptionsEnum.DuckEgg, parent.Config, 1));
            _options.Add(new Checkbox("Duck feather", OptionsEnum.DuckFeather, parent.Config, 1));
            _options.Add(new Checkbox("Rabbit's wool", OptionsEnum.RabbitsWool, parent.Config, 1));
            _options.Add(new Checkbox("Rabbit's foot", OptionsEnum.RabbitsFoot, parent.Config, 1));
            _options.Add(new Checkbox("Truffle", OptionsEnum.Truffle, parent.Config, 1));
            _options.Add(new Checkbox("Slime ball", OptionsEnum.SlimeBall, parent.Config, 1));
            // Other configs
            _options.Add(new Checkbox("Missing hay", OptionsEnum.MissingHay, parent.Config));
            _options.Add(new Checkbox("Items in farm cave", OptionsEnum.FarmCave, parent.Config));
            _options.Add(new Checkbox("Uncollected crabpots", OptionsEnum.UncollectedCrabpots, parent.Config));
            _options.Add(new Checkbox("Not baited crabpots", OptionsEnum.NotBaitedCrabpots, parent.Config));
            // Machines
            _options.Add(new Checkbox("Machines:", OptionsEnum.AllMachines, parent.Config));
            _options.Add(new Checkbox("Bee house", OptionsEnum.BeeHouse, parent.Config, 1));
            _options.Add(new QualityOption("Cask", OptionsEnum.Cask, _parent.Config, 1));
            _options.Add(new Checkbox("Charcoal Kiln", OptionsEnum.CharcoalKiln, parent.Config, 1));
            _options.Add(new Checkbox("Cheese Press", OptionsEnum.CheesePress, parent.Config, 1));
            _options.Add(new Checkbox("Crystalarium", OptionsEnum.Crystalarium, parent.Config, 1));
            _options.Add(new Checkbox("Furnace", OptionsEnum.Furnace, parent.Config, 1));
            _options.Add(new Checkbox("Keg", OptionsEnum.Keg, parent.Config, 1));
            _options.Add(new Checkbox("Lightning Rod", OptionsEnum.LightningRod, parent.Config, 1));
            _options.Add(new Checkbox("Loom", OptionsEnum.Loom, parent.Config, 1));
            _options.Add(new Checkbox("Mayonnaise Machine", OptionsEnum.MayonnaiseMachine, parent.Config, 1));
            _options.Add(new Checkbox("Oil Maker", OptionsEnum.OilMaker, parent.Config, 1));
            _options.Add(new Checkbox("Preserves Jar", OptionsEnum.PreservesJar, parent.Config, 1));
            _options.Add(new Checkbox("Recycling Machine", OptionsEnum.RecyclingMachine, parent.Config, 1));
            _options.Add(new Checkbox("Seed Maker", OptionsEnum.SeedMaker, parent.Config, 1));
            _options.Add(new Checkbox("Slime Egg-Press", OptionsEnum.SlimeEggPress, parent.Config, 1));
            _options.Add(new Checkbox("Soda Machine", OptionsEnum.SodaMachine, parent.Config, 1));
            _options.Add(
                new Checkbox("Statue Of Endless Fortune", OptionsEnum.StatueOfEndlessFortune, parent.Config, 1));
            _options.Add(new Checkbox("Statue Of Perfection", OptionsEnum.StatueOfPerfection, parent.Config, 1));
            _options.Add(new Checkbox("Tapper", OptionsEnum.Tapper, parent.Config, 1));
            _options.Add(new Checkbox("Worm bin", OptionsEnum.WormBin, parent.Config, 1));

            ReportConfigChanged += SettingsMenu_ReportConfigChanged;

            if (!Game1.options.snappyMenus || !Game1.options.gamepadControls)
            {
                return;
            }
            allClickableComponents = new List <ClickableComponent>(_slots)
            {
                upperRightCloseButton
            };
            currentlySnappedComponent = allClickableComponents[0];
            snapCursorToCurrentSnappedComponent();
        }
Exemple #7
0
        public AddTaskMenu(ITranslationHelper translation) : base(0, 0, 612, 64)
        {
            xPositionOnScreen = (Game1.uiViewport.Width / 2) - (width / 2);
            yPositionOnScreen = (Game1.uiViewport.Height / 2) - (height / 2);

            _translation  = translation;
            _taskParser   = new TaskParser(translation);
            _previousText = "";
            _hoverText    = "";

            optionsButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen - 88, yPositionOnScreen - 6, 64, 64),
                DeluxeJournalMod.UiTexture,
                new Rectangle(16, 80, 16, 16),
                4f)
            {
                myID            = 100,
                downNeighborID  = SNAP_AUTOMATIC,
                rightNeighborID = SNAP_AUTOMATIC
            };

            closeTipButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + 444, yPositionOnScreen + height + 18, 24, 24),
                Game1.mouseCursors,
                new Rectangle(337, 494, 12, 12),
                2f)
            {
                myID            = 101,
                upNeighborID    = 0,
                downNeighborID  = SNAP_AUTOMATIC,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC,
                visible         = false
            };

            cancelButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width + 32, yPositionOnScreen - 6, 64, 64),
                DeluxeJournalMod.UiTexture,
                new Rectangle(0, 80, 16, 16),
                4f)
            {
                myID           = 102,
                downNeighborID = SNAP_AUTOMATIC,
                leftNeighborID = SNAP_AUTOMATIC
            };

            okButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width - 36, yPositionOnScreen + height + 18, 64, 64),
                DeluxeJournalMod.UiTexture,
                new Rectangle(32, 80, 16, 16),
                4f)
            {
                myID           = 103,
                upNeighborID   = 0,
                leftNeighborID = SNAP_AUTOMATIC
            };

            smartOkButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width - 108, okButton.bounds.Y, 64, 64),
                DeluxeJournalMod.UiTexture,
                new Rectangle(48, 80, 16, 16),
                4f)
            {
                myID            = 104,
                upNeighborID    = 0,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC
            };

            smartItemIcon = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + 60, okButton.bounds.Y, 56, 56),
                DeluxeJournalMod.UiTexture,
                new Rectangle(14, 110, 14, 14),
                4f)
            {
                myID            = 105,
                upNeighborID    = 0,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC,
                visible         = false
            };

            smartNPCIcon = new ClickableTextureComponent(
                smartItemIcon.bounds,
                DeluxeJournalMod.UiTexture,
                new Rectangle(0, 110, 14, 14),
                4f)
            {
                myID            = 106,
                upNeighborID    = 0,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC,
                visible         = false
            };

            smartNameIcon = new ClickableTextureComponent(
                smartItemIcon.bounds,
                DeluxeJournalMod.UiTexture,
                new Rectangle(28, 110, 14, 14),
                4f)
            {
                myID            = 107,
                upNeighborID    = 0,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC,
                visible         = false
            };

            smartTypeIconCC = new ClickableComponent(new Rectangle(xPositionOnScreen, okButton.bounds.Y, 56, 56), "")
            {
                myID            = 108,
                upNeighborID    = 0,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC,
                visible         = false
            };

            _textBox = new SideScrollingTextBox(null, null, Game1.dialogueFont, Game1.textColor)
            {
                X        = xPositionOnScreen,
                Y        = yPositionOnScreen,
                Width    = width,
                Height   = 192,
                Selected = true
            };

            textBoxCC = new ClickableComponent(new Rectangle(_textBox.X, _textBox.Y, _textBox.Width, 64), "")
            {
                myID            = 0,
                downNeighborID  = SNAP_AUTOMATIC,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC
            };

            Game1.playSound("shwip");

            exitFunction = OnExit;
        }
        public SearchMenu(Farmer who, string appearanceFilter, HandMirrorMenu callbackMenu) : base(0, 0, 832, 576, showUpperRightCloseButton: true)
        {
            // Set up menu structure
            if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ko || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.fr)
            {
                base.height += 64;
            }

            Vector2 topLeft = Utility.getTopLeftPositionForCenteringOnScreen(base.width, base.height);

            base.xPositionOnScreen = (int)topLeft.X;
            base.yPositionOnScreen = (int)topLeft.Y;

            // Populate the texture selection components
            var appearancePacks = FashionSense.textureManager.GetAllAppearanceModels();

            switch (appearanceFilter)
            {
            case HandMirrorMenu.HAIR_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is HairContentPack).ToList();
                break;

            case HandMirrorMenu.ACCESSORY_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is AccessoryContentPack).ToList();
                break;

            case HandMirrorMenu.HAT_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is HatContentPack).ToList();
                break;

            case HandMirrorMenu.SHIRT_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is ShirtContentPack).ToList();
                break;

            case HandMirrorMenu.PANTS_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is PantsContentPack).ToList();
                break;

            case HandMirrorMenu.SLEEVES_FILTER_BUTTON:
                appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is SleevesContentPack).ToList();

                if (callbackMenu.GetCurrentFeatureSlotKey() == ModDataKeys.CUSTOM_SHOES_ID)
                {
                    appearancePacks = FashionSense.textureManager.GetAllAppearanceModels().Where(m => m is ShoesContentPack).ToList();
                }
                break;
            }

            for (int m = 0; m < appearancePacks.Count; m++)
            {
                filteredTextureOptions.Add(appearancePacks[m]);
                cachedTextureOptions.Add(appearancePacks[m]);
            }

            _displayFarmer    = who;
            _appearanceFilter = appearanceFilter;
            _callbackMenu     = callbackMenu;

            var drawingScale     = 4f;
            var widthOffsetScale = 3;
            var sourceRect       = new Rectangle(0, 0, Game1.daybg.Width, Game1.daybg.Height);

            for (int r = 0; r < _maxRows; r++)
            {
                for (int c = 0; c < _texturesPerRow; c++)
                {
                    var componentId = c + r * _texturesPerRow;
                    availableTextures.Add(new ClickableTextureComponent(new Rectangle(32 + base.xPositionOnScreen + IClickableMenu.borderWidth + componentId % _texturesPerRow * 64 * widthOffsetScale, base.yPositionOnScreen + sourceRect.Height / 2 + componentId + (r * sourceRect.Height) + (r > 0 ? 64 : 0) - 32, sourceRect.Width, sourceRect.Height), null, new Rectangle(), drawingScale, false)
                    {
                        myID            = componentId,
                        downNeighborID  = componentId + _texturesPerRow,
                        upNeighborID    = r >= _texturesPerRow ? componentId - _texturesPerRow : -1,
                        rightNeighborID = c == 5 ? 9997 : componentId + 1,
                        leftNeighborID  = c > 0 ? componentId - 1 : 9998
                    });

                    var fakeFarmer = _displayFarmer.CreateFakeEventFarmer();
                    fakeFarmer.faceDirection(who.facingDirection);
                    foreach (var key in _displayFarmer.modData.Keys)
                    {
                        fakeFarmer.modData[key] = _displayFarmer.modData[key];
                    }
                    fakeFarmers.Add(fakeFarmer);
                }
            }
            UpdateDisplayFarmers();

            backButton = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen - 64, base.yPositionOnScreen + 8, 48, 44), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f)
            {
                myID            = 9998,
                rightNeighborID = 0
            };
            forwardButton = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen + base.width + 64 - 48, base.yPositionOnScreen + base.height - 48, 48, 44), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f)
            {
                myID = 9997
            };

            // Textbox related
            var xTextbox = base.xPositionOnScreen + 64 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + 320;
            var yTextbox = base.yPositionOnScreen - 58;

            _searchBox = new TextBox(Game1.content.Load <Texture2D>("LooseSprites\\textBox"), null, Game1.smallFont, Game1.textColor)
            {
                X          = xTextbox,
                Y          = yTextbox,
                Width      = 384,
                limitWidth = false,
                Text       = String.Empty
            };

            _searchBoxCC = new ClickableComponent(new Rectangle(xTextbox, yTextbox, 192, 48), "")
            {
                myID            = 9999,
                upNeighborID    = -99998,
                leftNeighborID  = -99998,
                rightNeighborID = -99998,
                downNeighborID  = -99998
            };
            Game1.keyboardDispatcher.Subscriber = _searchBox;
            _searchBox.Selected = true;

            queryButton = new ClickableTextureComponent(new Rectangle(xTextbox - 32, base.yPositionOnScreen - 48, 48, 44), Game1.mouseCursors, new Rectangle(208, 320, 16, 16), 2f)
            {
                myID = -1
            };

            // Call snap functions
            if (Game1.options.SnappyMenus)
            {
                base.populateClickableComponentList();
                snapToDefaultClickableComponent();
            }
        }
Exemple #9
0
        public void UpdateInventory()
        {
            foreach (var category in this.recipes.Keys)
            {
                this.recipes[category].Clear();
                this.recipes[category].Add(new Dictionary <ClickableTextureComponent, CraftingRecipe>());
            }

            var indexMap = new Dictionary <ItemCategory, int>();
            var pageMap  = new Dictionary <ItemCategory, int>();

            var spaceBetweenCraftingIcons = Game1.tileSize / 4;

            this.totalIconSize = Game1.tileSize + spaceBetweenCraftingIcons;
            this.maxItemsInRow = (this.width - IClickableMenu.spaceToClearSideBorder - IClickableMenu.borderWidth) / this.totalIconSize - 1;
            var xPad = Game1.tileSize / 8;

            this.selectables = new ClickableComponent[maxItemsInRow * ROWS];

            int id = 200;

            for (int row = 0; row < ROWS; row++)
            {
                for (int column = 0; column < maxItemsInRow; column++)
                {
                    var x = this.pageX + xPad + column * (Game1.tileSize + spaceBetweenCraftingIcons);
                    var y = this.pageY + row * (Game1.tileSize * 2 + spaceBetweenCraftingIcons);

                    var c = new ClickableComponent(new Rectangle(x, y, Game1.tileSize, Game1.tileSize), "");
                    c.myID            = id;
                    c.upNeighborID    = id - maxItemsInRow;
                    c.rightNeighborID = id + 1;
                    c.downNeighborID  = id + maxItemsInRow;
                    c.leftNeighborID  = id - 1;

                    this.selectables[column + row * maxItemsInRow] = c;

                    id += 1;
                }
            }

            foreach (var recipeName in CraftingRecipe.craftingRecipes.Keys)
            {
                var recipe = new CraftingRecipe(recipeName, false);
                var item   = recipe.createItem();

                var category = this.categoryManager.GetItemCategory(item);

                if (!indexMap.ContainsKey(category))
                {
                    indexMap.Add(category, 0);
                }

                if (!pageMap.ContainsKey(category))
                {
                    pageMap.Add(category, 0);
                }

                if (indexMap[category] >= maxItemsInRow * ROWS)
                {
                    pageMap[category] += 1;
                    indexMap[category] = 0;

                    this.recipes[category].Add(new Dictionary <ClickableTextureComponent, CraftingRecipe>());
                }

                var column = indexMap[category] % maxItemsInRow;
                var row    = indexMap[category] / maxItemsInRow;

                var x = this.pageX + xPad + column * (Game1.tileSize + spaceBetweenCraftingIcons);
                var y = this.pageY + row * (Game1.tileSize * 2 + spaceBetweenCraftingIcons);

                var hoverText = Game1.player.craftingRecipes.ContainsKey(recipeName) ? (
                    recipe.doesFarmerHaveIngredientsInInventory() ? AVAILABLE : UNAVAILABLE)
                    : UNKNOWN;

                var c = new ClickableTextureComponent("",
                                                      new Rectangle(x, y, Game1.tileSize, recipe.bigCraftable ? (Game1.tileSize * 2) : Game1.tileSize),
                                                      null,
                                                      hoverText,
                                                      recipe.bigCraftable ? Game1.bigCraftableSpriteSheet : Game1.objectSpriteSheet,
                                                      recipe.bigCraftable ? Game1.getArbitrarySourceRect(
                                                          Game1.bigCraftableSpriteSheet,
                                                          16, 32,
                                                          recipe.getIndexOfMenuView())
                    : Game1.getSourceRectForStandardTileSheet(
                                                          Game1.objectSpriteSheet,
                                                          recipe.getIndexOfMenuView(), 16, 16),
                                                      (float)Game1.pixelZoom,
                                                      false);

                this.recipes[category][pageMap[category]].Add(c, recipe);

                indexMap[category] += 1;
            }

            this.UpdateScrollButtons();
        }
        public TaskOptionsMenu(ITranslationHelper translation) : base(0, 0, 864, 576)
        {
            xPositionOnScreen = (Game1.uiViewport.Width / 2) - (width / 2);
            yPositionOnScreen = (Game1.uiViewport.Height / 2) - (height / 2);

            _translation      = translation;
            _textBoxTexture   = Game1.content.Load <Texture2D>("LooseSprites\\textBox");
            _optionHeld       = null;
            _taskFactory      = null;
            _task             = null;
            _selectedTaskID   = TaskTypes.Basic;
            _restoreChildMenu = false;
            _hoverText        = "";

            _fixedContentBounds       = default;
            _fixedContentBounds.X     = xPositionOnScreen + spaceToClearSideBorder + 28;
            _fixedContentBounds.Y     = yPositionOnScreen + spaceToClearTopBorder + 16;
            _fixedContentBounds.Width = width - (_fixedContentBounds.X - xPositionOnScreen) * 2;

            _parameterIcons     = new Dictionary <int, ClickableTextureComponent>();
            _parameterTextBoxes = new Dictionary <int, TaskParameterTextBox>();
            parameterTextBoxCCs = new List <ClickableComponent>();
            typeIcons           = new List <ClickableComponent>();

            _nameTextBox = new SideScrollingTextBox(_textBoxTexture, null, Game1.smallFont, Game1.textColor)
            {
                X     = _fixedContentBounds.X + LabelWidth,
                Y     = _fixedContentBounds.Y,
                Width = _fixedContentBounds.Width - LabelWidth
            };

            _renewPeriodDropDown = CreateTranslatedDropDown("ui.tasks.options.renew", 0, VerticalSpacing, true);
            _weekdaysDropDown    = CreateTranslatedDropDown("weekdays", _renewPeriodDropDown.bounds.Width + 8, VerticalSpacing, false);
            _seasonsDropDown     = CreateTranslatedDropDown("seasons", _renewPeriodDropDown.bounds.Width + 8, VerticalSpacing, false);
            _daysDropDown        = new OptionsNumericDropDown(string.Empty, 1, 28, OptionsNumericDropDown.WrapStyle.Horizontal, 7, _renewPeriodDropDown.bounds.Right + 8, _renewPeriodDropDown.bounds.Y);

            nameTextBoxCC = new ClickableComponent(new Rectangle(_nameTextBox.X, _nameTextBox.Y, _nameTextBox.Width, _nameTextBox.Height), "")
            {
                myID            = 100,
                downNeighborID  = 101,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC
            };

            renewPeriodDropDownCC = new ClickableComponent(_renewPeriodDropDown.bounds, "")
            {
                myID            = 101,
                upNeighborID    = SNAP_AUTOMATIC,
                downNeighborID  = CUSTOM_SNAP_BEHAVIOR,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC
            };

            weekdaysDropDownCC = new ClickableComponent(_weekdaysDropDown.bounds, "")
            {
                myID            = 102,
                upNeighborID    = SNAP_AUTOMATIC,
                downNeighborID  = CUSTOM_SNAP_BEHAVIOR,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC
            };

            daysDropDownCC = new ClickableComponent(_daysDropDown.bounds, "")
            {
                myID            = 103,
                upNeighborID    = SNAP_AUTOMATIC,
                downNeighborID  = CUSTOM_SNAP_BEHAVIOR,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC
            };

            seasonsDropDownCC = new ClickableComponent(_seasonsDropDown.bounds, "")
            {
                myID            = 104,
                upNeighborID    = SNAP_AUTOMATIC,
                downNeighborID  = CUSTOM_SNAP_BEHAVIOR,
                rightNeighborID = SNAP_AUTOMATIC,
                leftNeighborID  = SNAP_AUTOMATIC
            };

            Rectangle iconBounds = new Rectangle(0, 0, 56, 56);
            int       offset     = 0;
            int       i          = 0;

            foreach (string id in TaskRegistry.Keys)
            {
                iconBounds.X = _fixedContentBounds.X + LabelWidth + 12 + (offset % 512);
                iconBounds.Y = _fixedContentBounds.Y + 20 + VerticalSpacing * (2 + (offset / 512));

                typeIcons.Add(new ClickableComponent(iconBounds, id)
                {
                    myID            = i,
                    upNeighborID    = SNAP_AUTOMATIC,
                    downNeighborID  = SNAP_AUTOMATIC,
                    rightNeighborID = SNAP_AUTOMATIC,
                    leftNeighborID  = SNAP_AUTOMATIC
                });

                offset += 64;
                i++;
            }

            _fixedContentBounds.Height = typeIcons.Last().bounds.Y + VerticalSpacing + 4 - _fixedContentBounds.Y;
            height = _fixedContentBounds.Bottom + BottomGap - xPositionOnScreen;

            backButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen - 64, _fixedContentBounds.Y + 12, 64, 32),
                Game1.mouseCursors,
                new Rectangle(352, 495, 12, 11),
                4f)
            {
                myID            = 105,
                downNeighborID  = 0,
                rightNeighborID = SNAP_AUTOMATIC
            };

            cancelButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width - 12, _fixedContentBounds.Y, 64, 64),
                DeluxeJournalMod.UiTexture,
                new Rectangle(0, 80, 16, 16),
                4f)
            {
                myID           = 106,
                leftNeighborID = SNAP_AUTOMATIC
            };

            okButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width - 100, yPositionOnScreen + height - 4, 64, 64),
                DeluxeJournalMod.UiTexture,
                new Rectangle(32, 80, 16, 16),
                4f)
            {
                myID            = 107,
                upNeighborID    = CUSTOM_SNAP_BEHAVIOR,
                rightNeighborID = SNAP_AUTOMATIC
            };

            Game1.playSound("shwip");

            exitFunction = OnExit;
        }
        private static void SetUpPositionsPostfix(CharacterCustomization __instance, List <ClickableComponent> ___labels, ClickableComponent ___accLabel, List <ClickableComponent> ___leftSelectionButtons, List <ClickableComponent> ___rightSelectionButtons)
        {
            if (__instance.source != Source.NewGame)
            {
                return;
            }

            // Assign the required modData keys, if required
            if (!Game1.player.modData.ContainsKey(ModDataKeys.CUSTOM_HAIR_ID))
            {
                Game1.player.modData[ModDataKeys.CUSTOM_HAIR_ID] = null;
            }

            ___leftSelectionButtons.Add(new ClickableTextureComponent("start_with_hand_mirror", new Rectangle(__instance.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + 280 - 48 + IClickableMenu.borderWidth, ___leftSelectionButtons.First(b => b.name == "Acc").bounds.Y, 36, 36), null, _helper.Translation.Get("ui.fashion_sense.start_with_hand_mirror"), Game1.mouseCursors, new Rectangle(227, 425, 9, 9), 4f)
            {
                myID            = 516,
                upNeighborID    = -99998,
                leftNeighborID  = -99998,
                rightNeighborID = -99998,
                downNeighborID  = -99998
            });
        }
Exemple #12
0
 public void RemoveTab(ClickableComponent tab)
 {
     this.tabs.Remove(tab);
 }
Exemple #13
0
 public void AddTab(ClickableComponent tab)
 {
     this.tabs.Add(tab);
 }
Exemple #14
0
        /*********
        ** Public methods
        *********/
        public CheatsMenu(int x, int y, int width, int height, int tabIndex)
            : base(x, y, width, height)
        {
            this.Title    = new ClickableComponent(new Rectangle(this.xPositionOnScreen + width / 2, this.yPositionOnScreen, Game1.tileSize * 4, Game1.tileSize), "CJB Cheats Menu");
            this.TabIndex = tabIndex;

            {
                int i           = 0;
                int labelX      = (int)(this.xPositionOnScreen - Game1.tileSize * 4.8f);
                int labelY      = (int)(this.yPositionOnScreen + Game1.tileSize * 1.5f);
                int labelHeight = (int)(Game1.tileSize * 0.9F);

                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Player & Tools"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Farm & Fishing"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Skills"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Weather"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Relationships"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Warp Locations"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), "Time"));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i, Game1.tileSize * 5, Game1.tileSize), "Controls"));
            }

            this.UpArrow         = new ClickableTextureComponent("up-arrow", new Rectangle(this.xPositionOnScreen + width + Game1.tileSize / 4, this.yPositionOnScreen + Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 459, 11, 12), Game1.pixelZoom);
            this.DownArrow       = new ClickableTextureComponent("down-arrow", new Rectangle(this.xPositionOnScreen + width + Game1.tileSize / 4, this.yPositionOnScreen + height - Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom);
            this.Scrollbar       = new ClickableTextureComponent("scrollbar", new Rectangle(this.UpArrow.bounds.X + Game1.pixelZoom * 3, this.UpArrow.bounds.Y + this.UpArrow.bounds.Height + Game1.pixelZoom, 6 * Game1.pixelZoom, 10 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(435, 463, 6, 10), Game1.pixelZoom);
            this.ScrollbarRunner = new Rectangle(this.Scrollbar.bounds.X, this.UpArrow.bounds.Y + this.UpArrow.bounds.Height + Game1.pixelZoom, this.Scrollbar.bounds.Width, height - Game1.tileSize * 2 - this.UpArrow.bounds.Height - Game1.pixelZoom * 2);
            for (int i = 0; i < CheatsMenu.ItemsPerPage; i++)
            {
                this.OptionSlots.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4, this.yPositionOnScreen + Game1.tileSize * 5 / 4 + Game1.pixelZoom + i * ((height - Game1.tileSize * 2) / CheatsMenu.ItemsPerPage), width - Game1.tileSize / 2, (height - Game1.tileSize * 2) / CheatsMenu.ItemsPerPage + Game1.pixelZoom), string.Concat(i)));
            }

            switch (this.TabIndex)
            {
            case 0:
                this.Options.Add(new OptionsElement("Player:"));
                this.Options.Add(new CheatsOptionsCheckbox("Infinite Stamina", 1));
                this.Options.Add(new CheatsOptionsCheckbox("Infinite Health", 2));
                this.Options.Add(new CheatsOptionsCheckbox("Increased Movement Speed", 0));
                this.Options.Add(new CheatsOptionsSlider("Move Speed", 0, 10));
                this.Options.Add(new CheatsOptionsCheckbox("One Hit Kill", 6));
                this.Options.Add(new CheatsOptionsCheckbox("Max Daily Luck", 7));

                this.Options.Add(new OptionsElement("Tools:"));
                this.Options.Add(new CheatsOptionsCheckbox("Infinite Water in Can", 3));
                this.Options.Add(new CheatsOptionsCheckbox("One Hit Break", 15));
                this.Options.Add(new CheatsOptionsCheckbox("Harvest With Sickle (no XP gain)", 22));

                this.Options.Add(new OptionsElement("Money:"));
                this.Options.Add(new CheatsOptionsInputListener("Add 100g", 2, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Add 1000g", 3, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Add 10000g", 4, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Add 100000g", 5, this.OptionSlots[0].bounds.Width));

                this.Options.Add(new OptionsElement("Casino Coins:"));
                this.Options.Add(new CheatsOptionsInputListener("Add 100", 6, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Add 1000", 7, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Add 10000", 8, this.OptionSlots[0].bounds.Width));
                break;

            case 1:
                this.Options.Add(new OptionsElement("Farm:"));
                this.Options.Add(new CheatsOptionsInputListener("Water All Fields", 9, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsCheckbox("Durable Fences", 13));
                this.Options.Add(new CheatsOptionsCheckbox("Instant Build", 18));
                this.Options.Add(new CheatsOptionsCheckbox("Always Auto-Feed", 19));
                this.Options.Add(new CheatsOptionsCheckbox("Infinite Hay", 20));

                this.Options.Add(new OptionsElement("Fishing:"));
                this.Options.Add(new CheatsOptionsCheckbox("Instant Catch", 4));
                this.Options.Add(new CheatsOptionsCheckbox("Instant Bite", 16));
                this.Options.Add(new CheatsOptionsCheckbox("Always Throw Max Distance", 5));
                this.Options.Add(new CheatsOptionsCheckbox("Always Treasure", 14));
                this.Options.Add(new CheatsOptionsCheckbox("Durable Tackles", 21));

                this.Options.Add(new OptionsElement("Fast Machine Processing:"));
                this.Options.Add(new CheatsOptionsCheckbox("Cask", 118));
                this.Options.Add(new CheatsOptionsCheckbox("Furnace", 100));
                this.Options.Add(new CheatsOptionsCheckbox("Recycling Machine", 101));
                this.Options.Add(new CheatsOptionsCheckbox("Crystalarium", 102));
                this.Options.Add(new CheatsOptionsCheckbox("Incubator", 103));
                this.Options.Add(new CheatsOptionsCheckbox("Slime Incubator", 104));
                this.Options.Add(new CheatsOptionsCheckbox("Keg", 105));
                this.Options.Add(new CheatsOptionsCheckbox("Preserves Jar", 106));
                this.Options.Add(new CheatsOptionsCheckbox("Cheese Press", 107));
                this.Options.Add(new CheatsOptionsCheckbox("Mayonnaise Machine", 108));
                this.Options.Add(new CheatsOptionsCheckbox("Loom", 109));
                this.Options.Add(new CheatsOptionsCheckbox("Oil Maker", 110));
                this.Options.Add(new CheatsOptionsCheckbox("Seed Maker", 111));
                this.Options.Add(new CheatsOptionsCheckbox("Charcoal Kiln", 112));
                this.Options.Add(new CheatsOptionsCheckbox("Slime Egg-Press", 113));
                this.Options.Add(new CheatsOptionsCheckbox("Tapper", 116));
                this.Options.Add(new CheatsOptionsCheckbox("Lightning Rod", 117));
                this.Options.Add(new CheatsOptionsCheckbox("Bee House", 114));
                this.Options.Add(new CheatsOptionsCheckbox("Mushroom Box", 115));
                this.Options.Add(new CheatsOptionsCheckbox("Worm Bin", 119));
                break;

            case 2:
                this.Options.Add(new OptionsElement("Skills:"));
                this.Options.Add(new CheatsOptionsInputListener("Incr. Farming Lvl", 200, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Incr. Mining Lvl", 201, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Incr. Foraging Lvl", 202, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Incr. Fishing Lvl", 203, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Incr. Combat Lvl", 204, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("RESET SKILLS!", 205, this.OptionSlots[0].bounds.Width));
                break;

            case 3:
                this.Options.Add(new OptionsElement("Weather Next Day:"));
                this.Options.Add(new CheatsOptionsElement("Current: ", 1));
                this.Options.Add(new CheatsOptionsInputListener("Sunny", 10, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Raining", 11, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Lightning", 12, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Snowing", 13, this.OptionSlots[0].bounds.Width));
                break;

            case 4:
                this.Options.Add(new OptionsElement("Relationships:"));
                this.Options.Add(new CheatsOptionsCheckbox("Give Gift Anytime", 9));
                this.Options.Add(new CheatsOptionsCheckbox("No Friendship Decay", 17));
                this.Options.Add(new OptionsElement("Friends:"));

                foreach (NPC npc in Utility.getAllCharacters().OrderBy(p => p.name))
                {
                    if ((npc.name != "Sandy" || Game1.player.mailReceived.Contains("ccVault")) && npc.name != "???" && npc.name != "Bouncer" && npc.name != "Marlon" && npc.name != "Gil" && npc.name != "Gunther" && !npc.IsMonster && !(npc is Horse) && !(npc is Pet))
                    {
                        if (Game1.player.friendships.ContainsKey(npc.name))
                        {
                            this.Options.Add(new CheatsOptionsNPCSlider(npc, 9999));
                        }
                    }
                }
                break;

            case 5:
                this.Options.Add(new OptionsElement("Warp to:"));
                this.Options.Add(new CheatsOptionsInputListener("Farm", 100, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Pierre's", 101, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Blacksmith", 102, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Archaeology Office", 103, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Saloon", 104, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Community Center", 105, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Carpenter", 106, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Guild", 107, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Ranch", 113, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Mines", 109, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Willy", 110, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Wizard", 114, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Hats", 115, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Desert", 112, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Sandy", 119, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Casino", 120, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Quarry", 108, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("New Beach", 111, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Secret Forest", 116, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Sewer", 117, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Bathhouse", 118, this.OptionSlots[0].bounds.Width));
                break;

            case 6:
                this.Options.Add(new OptionsElement("Time:"));
                this.Options.Add(new CheatsOptionsCheckbox("Freeze Time Inside", 10));
                this.Options.Add(new CheatsOptionsCheckbox("Freeze Time Caves", 12));
                this.Options.Add(new CheatsOptionsCheckbox("Freeze Time Everywhere", 11));
                this.Options.Add(new CheatsOptionsSlider("Time", 10, 20, -1, -1, 100));
                break;

            case 7:
                this.Options.Add(new OptionsElement("Controls:"));
                this.Options.Add(new CheatsOptionsInputListener("Open Menu", 1000, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Freeze Time", 1001, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Grow Tree", 1002, this.OptionSlots[0].bounds.Width));
                this.Options.Add(new CheatsOptionsInputListener("Grow Crops", 1003, this.OptionSlots[0].bounds.Width));
                break;
            }
            this.SetScrollBarToCurrentIndex();
        }
Exemple #15
0
        /*
         * public LevelUpMenu()
         *  : base(Game1.viewport.Width / 2 - 384, Game1.viewport.Height / 2 - 256, 768, 512, false)
         * {
         *  this.width = 768;
         *  this.height = 512;
         *  ClickableTextureComponent textureComponent = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - 64 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
         *  textureComponent.myID = 101;
         *  this.okButton = textureComponent;
         *  if (!Game1.options.SnappyMenus)
         *      return;
         *  this.populateClickableComponentList();
         *  this.snapToDefaultClickableComponent();
         * }*/

        // Constructor changed: int skill -> string skillName
        public SkillLevelUpMenu(string skillName, int level)
            : base(Game1.viewport.Width / 2 - 384, Game1.viewport.Height / 2 - 256, 768, 512, false)
        {
            this.timerBeforeStart = 250;
            this.isActive         = true;
            this.width            = 960;
            this.height           = 512;
            ClickableTextureComponent textureComponent = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - 64 - IClickableMenu.borderWidth, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);

            textureComponent.myID = 101;
            this.okButton         = textureComponent;
            this.newCraftingRecipes.Clear();
            this.extraInfoForLevel.Clear();
            Game1.player.completelyStopAnimatingOrDoingAction();
            this.informationUp       = true;
            this.isProfessionChooser = false;
            this.currentLevel        = level;
            this.currentSkill        = skillName;

            /*if (level == 10)
             * {
             *  Game1.getSteamAchievement("Achievement_SingularTalent");
             *  if ((int)((NetFieldBase<int, NetInt>)Game1.player.farmingLevel) == 10 && (int)((NetFieldBase<int, NetInt>)Game1.player.miningLevel) == 10 && ((int)((NetFieldBase<int, NetInt>)Game1.player.fishingLevel) == 10 && (int)((NetFieldBase<int, NetInt>)Game1.player.foragingLevel) == 10) && (int)((NetFieldBase<int, NetInt>)Game1.player.combatLevel) == 10)
             *      Game1.getSteamAchievement("Achievement_MasterOfTheFiveWays");
             *  if (skill == 0)
             *      Game1.addMailForTomorrow("marnieAutoGrabber", false, false);
             * }
             */
            this.title             = Game1.content.LoadString("Strings\\UI:LevelUp_Title", (object)this.currentLevel, (object)Skills.skills[currentSkill].Name);
            this.extraInfoForLevel = this.getExtraInfoForLevel(this.currentSkill, this.currentLevel);

            /*
             * switch (this.currentSkill)
             * {
             *  case 0:
             *      this.sourceRectForLevelIcon = new Rectangle(0, 0, 16, 16);
             *      break;
             *  case 1:
             *      this.sourceRectForLevelIcon = new Rectangle(16, 0, 16, 16);
             *      break;
             *  case 2:
             *      this.sourceRectForLevelIcon = new Rectangle(80, 0, 16, 16);
             *      break;
             *  case 3:
             *      this.sourceRectForLevelIcon = new Rectangle(32, 0, 16, 16);
             *      break;
             *  case 4:
             *      this.sourceRectForLevelIcon = new Rectangle(128, 16, 16, 16);
             *      break;
             *  case 5:
             *      this.sourceRectForLevelIcon = new Rectangle(64, 0, 16, 16);
             *      break;
             * }
             */
            var skill = Skills.skills[skillName];

            profPair = null;
            foreach (var pair in skill.ProfessionsForLevels)
            {
                if (pair.Level == currentLevel && (pair.Requires == null || Game1.player.professions.Contains(pair.Requires.GetVanillaId())))
                {
                    profPair = pair;
                    break;
                }
            }
            if (profPair != null)
            {
                this.professionsToChoose.Clear();
                this.isProfessionChooser = true;
            }

            /*
             * if ((this.currentLevel == 5 || this.currentLevel == 10) && this.currentSkill != 5)
             * {
             *  this.professionsToChoose.Clear();
             *  this.isProfessionChooser = true;
             * }
             */
            /*
             * int num = 0;
             * foreach (KeyValuePair<string, string> craftingRecipe in CraftingRecipe.craftingRecipes)
             * {
             *  string str = craftingRecipe.Value.Split('/')[4];
             *  if (str.Contains(Farmer.getSkillNameFromIndex(this.currentSkill)) && str.Contains(string.Concat((object)this.currentLevel)))
             *  {
             *      this.newCraftingRecipes.Add(new CraftingRecipe(craftingRecipe.Key, false));
             *      if (!Game1.player.craftingRecipes.ContainsKey(craftingRecipe.Key))
             *          Game1.player.craftingRecipes.Add(craftingRecipe.Key, 0);
             *      num += this.newCraftingRecipes.Last<CraftingRecipe>().bigCraftable ? 128 : 64;
             *  }
             * }
             * foreach (KeyValuePair<string, string> cookingRecipe in CraftingRecipe.cookingRecipes)
             * {
             *  string str = cookingRecipe.Value.Split('/')[3];
             *  if (str.Contains(Farmer.getSkillNameFromIndex(this.currentSkill)) && str.Contains(string.Concat((object)this.currentLevel)))
             *  {
             *      this.newCraftingRecipes.Add(new CraftingRecipe(cookingRecipe.Key, true));
             *      if (!Game1.player.cookingRecipes.ContainsKey(cookingRecipe.Key))
             *      {
             *          Game1.player.cookingRecipes.Add(cookingRecipe.Key, 0);
             *          if (!Game1.player.hasOrWillReceiveMail("robinKitchenLetter"))
             *              Game1.mailbox.Add("robinKitchenLetter");
             *      }
             *      num += this.newCraftingRecipes.Last<CraftingRecipe>().bigCraftable ? 128 : 64;
             *  }
             * }
             * this.height = num + 256 + this.extraInfoForLevel.Count * 64 * 3 / 4;
             */
            Game1.player.freezePause = 100;
            this.gameWindowSizeChanged(Rectangle.Empty, Rectangle.Empty);
            if (!Game1.options.SnappyMenus)
            {
                return;
            }
            if (this.isProfessionChooser)
            {
                this.leftProfession = new ClickableComponent(new Rectangle(this.xPositionOnScreen, this.yPositionOnScreen + 128, this.width / 2, this.height), "")
                {
                    myID            = 102,
                    rightNeighborID = 103
                };
                this.rightProfession = new ClickableComponent(new Rectangle(this.width / 2 + this.xPositionOnScreen, this.yPositionOnScreen + 128, this.width / 2, this.height), "")
                {
                    myID           = 103,
                    leftNeighborID = 102
                };
            }
            this.populateClickableComponentList();
            this.snapToDefaultClickableComponent();
        }
Exemple #16
0
        public BetterCraftingPage(ModEntry betterCrafting, CategoryData categoryData, Nullable <ItemCategory> defaultCategory)
            : base(Game1.activeClickableMenu.xPositionOnScreen, Game1.activeClickableMenu.yPositionOnScreen, Game1.activeClickableMenu.width, Game1.activeClickableMenu.height)
        {
            this.betterCrafting = betterCrafting;

            this.categoryManager = new CategoryManager(betterCrafting.Monitor, categoryData);

            this.inventory = new InventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth,
                                               this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4,
                                               false);
            this.inventory.showGrayedOutSlots = true;

            this.pageX = this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth - Game1.tileSize / 4;
            this.pageY = this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth - Game1.tileSize / 4;

            if (defaultCategory.HasValue)
            {
                this.selectedCategory = defaultCategory.Value;
            }
            else
            {
                this.selectedCategory = this.categoryManager.GetDefaultItemCategory();
            }
            this.recipePage = 0;

            this.recipes    = new Dictionary <ItemCategory, List <Dictionary <ClickableTextureComponent, CraftingRecipe> > >();
            this.categories = new Dictionary <ClickableComponent, ItemCategory>();

            int catIndex = 0;

            var categorySpacing = Game1.tileSize / 6;
            var tabPad          = Game1.tileSize + Game1.tileSize / 4;

            int id = 0;

            foreach (ItemCategory category in this.categoryManager.GetItemCategories())
            {
                this.recipes.Add(category, new List <Dictionary <ClickableTextureComponent, CraftingRecipe> >());

                var catName = this.categoryManager.GetItemCategoryName(category);

                var nameSize = Game1.smallFont.MeasureString(catName);

                var width  = nameSize.X + Game1.tileSize / 2;
                var height = nameSize.Y + Game1.tileSize / 4;

                var x = this.xPositionOnScreen - width;
                var y = this.yPositionOnScreen + tabPad + catIndex * (height + categorySpacing);

                var c = new ClickableComponent(
                    new Rectangle((int)x, (int)y, (int)width, (int)height),
                    category.Equals(this.selectedCategory) ? UNAVAILABLE : AVAILABLE, catName);
                c.myID           = id;
                c.upNeighborID   = id - 1;
                c.downNeighborID = id + 1;

                this.categories.Add(c, category);

                catIndex += 1;
                id       += 1;
            }

            this.trashCan = new ClickableTextureComponent(
                new Rectangle(
                    this.xPositionOnScreen + width + 4,
                    this.yPositionOnScreen + height - Game1.tileSize * 3 - Game1.tileSize / 2 - IClickableMenu.borderWidth - 104,
                    Game1.tileSize, 104),
                Game1.mouseCursors,
                new Rectangle(669, 261, 16, 26),
                (float)Game1.pixelZoom, false);

            this.throwComp = new ClickableComponent(
                new Rectangle(
                    this.xPositionOnScreen + width + 4,
                    this.yPositionOnScreen + height - Game1.tileSize * 3 - IClickableMenu.borderWidth,
                    Game1.tileSize, Game1.tileSize),
                "");

            this.oldButton = new ClickableTextureComponent("",
                                                           new Rectangle(
                                                               this.xPositionOnScreen + width,
                                                               this.yPositionOnScreen + height / 3 - Game1.tileSize + Game1.pixelZoom * 2,
                                                               Game1.tileSize,
                                                               Game1.tileSize),
                                                           "",
                                                           "Old Crafting Menu",
                                                           Game1.mouseCursors,
                                                           new Rectangle(162, 440, 16, 16),
                                                           (float)Game1.pixelZoom, false);

            this.UpdateInventory();
        }
        public override void ButtonPressed(SButton button)
        {
            GameMenu menu = stardewMenu as GameMenu;

            if (Inputs.IsGameMenuInventoryButton(button))
            {
                menu.changeTab(GameMenu.inventoryTab);
                SetMenuItemsForTab();
            }
            else if (Inputs.IsGameMenuSkillsButton(button))
            {
                menu.changeTab(GameMenu.skillsTab);
                SetMenuItemsForTab();
            }
            else if (Inputs.IsGameMenuSocialButton(button))
            {
                menu.changeTab(GameMenu.socialTab);
                SetMenuItemsForTab();
            }
            else if (Inputs.IsGameMenuMapButton(button))
            {
                menu.changeTab(GameMenu.mapTab);
                SetMenuItemsForTab();
            }
            else if (Inputs.IsGameMenuCraftingButton(button))
            {
                menu.changeTab(GameMenu.craftingTab);
                SetMenuItemsForTab();
            }
            else if (Inputs.IsGameMenuCollectionsButton(button))
            {
                menu.changeTab(GameMenu.collectionsTab);
                SetMenuItemsForTab();
            }
            else if (Inputs.IsGameMenuOptionsButton(button))
            {
                menu.changeTab(GameMenu.optionsTab);
                SetMenuItemsForTab();
            }
            else if (Inputs.IsGameMenuExitButton(button))
            {
                menu.changeTab(GameMenu.exitTab);
                SetMenuItemsForTab();
            }
            else if (Inputs.IsMenuEscapeButton(button))
            {
                menu.exitThisMenu();
                ModEntry.GetHelper().Input.Suppress(button);
            }
            else if (menu.GetCurrentPage() is SocialPage socialPage && (Inputs.IsMenuNextButton(button) || Inputs.IsMenuPrevButton(button)))
            {
                base.ButtonPressed(button);
                if (Inputs.IsMenuNextButton(button))
                {
                    ClickableComponent oldComp = socialPage.getCurrentlySnappedComponent();
                    socialPage.applyMovementKey(2);
                    if (oldComp == socialPage.getCurrentlySnappedComponent())
                    {
                        socialPage.setCurrentlySnappedComponentTo(socialPage.characterSlots[0].myID);
                        ModEntry.GetHelper().Reflection.GetMethod(socialPage, "_SelectSlot").Invoke(socialPage.getCurrentlySnappedComponent());
                    }
                }
                else if (Inputs.IsMenuPrevButton(button))
                {
                    //ClickableComponent oldComp = socialPage.getCurrentlySnappedComponent();
                    socialPage.applyMovementKey(0);
                    if (menu.tabs[GameMenu.socialTab] == menu.getCurrentlySnappedComponent())
                    {
                        socialPage.setCurrentlySnappedComponentTo(socialPage.characterSlots[socialPage.characterSlots.Count - 1].myID);
                        ModEntry.GetHelper().Reflection.GetMethod(socialPage, "_SelectSlot").Invoke(socialPage.getCurrentlySnappedComponent());
                    }
                }
            }
        public CookingMenu(
            int x,
            int y,
            int width,
            int height,
            bool cooking                     = true,
            bool standalone_menu             = true,
            List <Chest> material_containers = null)
            : base(x, y, width, height, false)
        {
            this.inventory = new InventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + 320 - 16, false, (IList <Item>)null, (InventoryMenu.highlightThisItem)null, -1, 3, 0, 0, true);
            this.inventory.showGrayedOutSlots   = true;
            this.currentPageClickableComponents = new List <ClickableComponent>();
            foreach (ClickableComponent clickableComponent in this.inventory.GetBorder(InventoryMenu.BorderSide.Top))
            {
                clickableComponent.upNeighborID = -99998;
            }
            this._materialContainers = material_containers;
            List <Chest> materialContainers = this._materialContainers;

            this.initializeUpperRightCloseButton();
            ClickableTextureComponent textureComponent1 = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + width + 4, this.yPositionOnScreen + height - 192 - 32 - IClickableMenu.borderWidth - 104, 64, 104), Game1.mouseCursors, new Rectangle(564 + Game1.player.trashCanLevel * 18, 102, 18, 26), 4f, false);

            textureComponent1.myID       = 106;
            this.trashCan                = textureComponent1;
            this.dropItemInvisibleButton = new ClickableComponent(new Rectangle(this.xPositionOnScreen - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - 64, this.trashCan.bounds.Y, 64, 64), "")
            {
                myID            = 107,
                rightNeighborID = 0
            };
            List <string> playerRecipes = new List <string>();

            Game1.playSound("bigSelect");

            if (ModEntry.Config.EnableAllCookingRecipies)
            {
                foreach (string key in CraftingRecipe.cookingRecipes.Keys)
                {
                    playerRecipes.Add(key);
                }
            }
            else
            {
                foreach (string key in ModEntry.Config.Recipes)
                {
                    if (CraftingRecipe.cookingRecipes.ContainsKey(key))
                    {
                        playerRecipes.Add(key);
                    }
                    else
                    {
                        ModEntry.monitor.Log($"The cooking recipe for \"{key}\" was not found. It will not be added to the cooking menu.", LogLevel.Info);
                    }
                }
            }



            playerRecipes.Sort((Comparison <string>)((a, b) =>
            {
                int num1 = -1;
                int num2 = -1;
                if (a != null && CraftingRecipe.cookingRecipes.ContainsKey(a))
                {
                    string[] strArray = CraftingRecipe.cookingRecipes[a].Split('/');
                    int result;
                    if (strArray.Length > 2 && int.TryParse(strArray[2], out result))
                    {
                        num1 = result;
                    }
                }
                if (b != null && CraftingRecipe.cookingRecipes.ContainsKey(b))
                {
                    string[] strArray = CraftingRecipe.cookingRecipes[b].Split('/');
                    int result;
                    if (strArray.Length > 2 && int.TryParse(strArray[2], out result))
                    {
                        num2 = result;
                    }
                }
                return(num1.CompareTo(num2));
            }));

            this.layoutRecipes(playerRecipes);
            if (this.pagesOfCraftingRecipes.Count > 1)
            {
                ClickableTextureComponent textureComponent2 = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + 768 + 32, this.craftingPageY(), 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 12, -1, -1), 0.8f, false);
                textureComponent2.myID            = 88;
                textureComponent2.downNeighborID  = 89;
                textureComponent2.rightNeighborID = 106;
                textureComponent2.leftNeighborID  = -99998;
                this.upButton = textureComponent2;
                ClickableTextureComponent textureComponent3 = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + 768 + 32, this.craftingPageY() + 192 + 32, 64, 64), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 11, -1, -1), 0.8f, false);
                textureComponent3.myID            = 89;
                textureComponent3.upNeighborID    = 88;
                textureComponent3.rightNeighborID = 106;
                textureComponent3.leftNeighborID  = -99998;
                this.downButton = textureComponent3;
            }
            this._UpdateCurrentPageButtons();
            if (!Game1.options.SnappyMenus)
            {
                return;
            }
            this.snapToDefaultClickableComponent();
        }
Exemple #19
0
        /*********
        ** Public methods
        *********/
        public CheatsMenu(MenuTab tabIndex, ModConfig config, Cheats cheats, ITranslationHelper i18n)
            : base(Game1.viewport.Width / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2)
        {
            this.Config            = config;
            this.Cheats            = cheats;
            this.TranslationHelper = i18n;

            this.Title      = new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width / 2, this.yPositionOnScreen, Game1.tileSize * 4, Game1.tileSize), i18n.Get("title"));
            this.CurrentTab = tabIndex;

            {
                int i           = 0;
                int labelX      = (int)(this.xPositionOnScreen - Game1.tileSize * 4.8f);
                int labelY      = (int)(this.yPositionOnScreen + Game1.tileSize * 1.5f);
                int labelHeight = (int)(Game1.tileSize * 0.9F);

                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.PlayerAndTools.ToString(), i18n.Get("tabs.player-and-tools")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.FarmAndFishing.ToString(), i18n.Get("tabs.farm-and-fishing")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Skills.ToString(), i18n.Get("tabs.skills")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Weather.ToString(), i18n.Get("tabs.weather")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Relationships.ToString(), i18n.Get("tabs.relationships")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.WarpLocations.ToString(), i18n.Get("tabs.warp")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Time.ToString(), i18n.Get("tabs.time")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i, Game1.tileSize * 5, Game1.tileSize), MenuTab.Controls.ToString(), i18n.Get("tabs.controls")));
            }

            this.UpArrow         = new ClickableTextureComponent("up-arrow", new Rectangle(this.xPositionOnScreen + this.width + Game1.tileSize / 4, this.yPositionOnScreen + Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 459, 11, 12), Game1.pixelZoom);
            this.DownArrow       = new ClickableTextureComponent("down-arrow", new Rectangle(this.xPositionOnScreen + this.width + Game1.tileSize / 4, this.yPositionOnScreen + this.height - Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom);
            this.Scrollbar       = new ClickableTextureComponent("scrollbar", new Rectangle(this.UpArrow.bounds.X + Game1.pixelZoom * 3, this.UpArrow.bounds.Y + this.UpArrow.bounds.Height + Game1.pixelZoom, 6 * Game1.pixelZoom, 10 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(435, 463, 6, 10), Game1.pixelZoom);
            this.ScrollbarRunner = new Rectangle(this.Scrollbar.bounds.X, this.UpArrow.bounds.Y + this.UpArrow.bounds.Height + Game1.pixelZoom, this.Scrollbar.bounds.Width, this.height - Game1.tileSize * 2 - this.UpArrow.bounds.Height - Game1.pixelZoom * 2);
            for (int i = 0; i < CheatsMenu.ItemsPerPage; i++)
            {
                this.OptionSlots.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4, this.yPositionOnScreen + Game1.tileSize * 5 / 4 + Game1.pixelZoom + i * ((this.height - Game1.tileSize * 2) / CheatsMenu.ItemsPerPage), this.width - Game1.tileSize / 2, (this.height - Game1.tileSize * 2) / CheatsMenu.ItemsPerPage + Game1.pixelZoom), string.Concat(i)));
            }

            switch (this.CurrentTab)
            {
            case MenuTab.PlayerAndTools:
                this.Options.Add(new OptionsElement($"{i18n.Get("player.title")}:"));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("player.infinite-stamina"), config.InfiniteStamina, value => config.InfiniteStamina             = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("player.infinite-health"), config.InfiniteHealth, value => config.InfiniteHealth                = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("player.increased-movement-speed"), config.IncreasedMovement, value => config.IncreasedMovement = value));
                this.Options.Add(new CheatsOptionsSlider(i18n.Get("player.movement-speed"), this.Config.MoveSpeed, 10, value => this.Config.MoveSpeed               = value, disabled: () => this.Config.IncreasedMovement));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("player.one-hit-kill"), config.OneHitKill, value => config.OneHitKill       = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("player.max-daily-luck"), config.MaxDailyLuck, value => config.MaxDailyLuck = value));

                this.Options.Add(new OptionsElement($"{i18n.Get("tools.title")}:"));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("tools.infinite-water"), config.InfiniteWateringCan, value => config.InfiniteWateringCan = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("tools.one-hit-break"), config.OneHitBreak, value => config.OneHitBreak           = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("tools.harvest-with-sickle"), config.HarvestSickle, value => config.HarvestSickle = value));

                this.Options.Add(new OptionsElement($"{i18n.Get("money.title")}:"));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("money.add-amount", new { amount = 100 }), 2, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("money.add-amount", new { amount = 1000 }), 3, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("money.add-amount", new { amount = 10000 }), 4, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("money.add-amount", new { amount = 100000 }), 5, this.OptionSlots[0].bounds.Width, config, cheats, i18n));

                this.Options.Add(new OptionsElement($"{i18n.Get("casino-coins.title")}:"));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("casino-coins.add-amount", new { amount = 100 }), 6, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("casino-coins.add-amount", new { amount = 1000 }), 7, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("casino-coins.add-amount", new { amount = 10000 }), 8, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                break;

            case MenuTab.FarmAndFishing:
                this.Options.Add(new OptionsElement($"{i18n.Get("farm.title")}:"));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("farm.water-all-fields"), 9, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("farm.durable-fences"), config.DurableFences, value => config.DurableFences = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("farm.instant-build"), config.InstantBuild, value => config.InstantBuild    = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("farm.always-auto-feed"), config.AutoFeed, value => config.AutoFeed         = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("farm.infinite-hay"), config.InfiniteHay, value => config.InfiniteHay       = value));

                this.Options.Add(new OptionsElement($"{i18n.Get("fishing.title")}:"));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fishing.instant-catch"), config.InstantCatch, value => config.InstantCatch = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fishing.instant-bite"), config.InstantBite, value => config.InstantBite    = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fishing.always-throw-max-distance"), config.ThrowBobberMax, value => config.ThrowBobberMax = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fishing.always-treasure"), config.AlwaysTreasure, value => config.AlwaysTreasure           = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fishing.durable-tackles"), config.DurableTackles, value => config.DurableTackles           = value));

                this.Options.Add(new OptionsElement($"{i18n.Get("fast-machines.title")}:"));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.cask"), config.FastCask, value => config.FastCask          = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.furnace"), config.FastFurnace, value => config.FastFurnace = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.recycling-machine"), config.FastRecyclingMachine, value => config.FastRecyclingMachine = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.crystalarium"), config.FastCrystalarium, value => config.FastCrystalarium        = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.incubator"), config.FastIncubator, value => config.FastIncubator                 = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.slime-incubator"), config.FastSlimeIncubator, value => config.FastSlimeIncubator = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.keg"), config.FastKeg, value => config.FastKeg = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.preserves-jar"), config.FastPreservesJar, value => config.FastPreservesJar = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.cheese-press"), config.FastCheesePress, value => config.FastCheesePress    = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.mayonnaise-machine"), config.FastMayonnaiseMachine, value => config.FastMayonnaiseMachine = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.loom"), config.FastLoom, value => config.FastLoom = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.oil-maker"), config.FastOilMaker, value => config.FastOilMaker                 = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.seed-maker"), config.FastSeedMaker, value => config.FastSeedMaker              = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.charcoal-kiln"), config.FastCharcoalKiln, value => config.FastCharcoalKiln     = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.slime-egg-press"), config.FastSlimeEggPress, value => config.FastSlimeEggPress = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.tapper"), config.FastTapper, value => config.FastTapper = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.lightning-rod"), config.FastLightningRod, value => config.FastLightningRod = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.bee-house"), config.FastBeeHouse, value => config.FastBeeHouse             = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.mushroom-box"), config.FastMushroomBox, value => config.FastMushroomBox    = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.worm-bin"), config.FastWormBin, value => config.FastWormBin        = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("fast-machines.fruit-trees"), config.FastFruitTree, value => config.FastFruitTree = value));
                break;

            case MenuTab.Skills:
                this.Options.Add(new OptionsElement($"{i18n.Get("skills.title")}:"));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-farming"), 200, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-mining"), 201, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-foraging"), 202, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-fishing"), 203, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-combat"), 204, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.reset"), 205, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new OptionsElement($"{i18n.Get("professions.title")}:"));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.combat.fighter"), this.GetProfession(SFarmer.fighter), value => this.SetProfession(SFarmer.fighter, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.combat.scout"), this.GetProfession(SFarmer.scout), value => this.SetProfession(SFarmer.scout, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.combat.acrobat"), this.GetProfession(SFarmer.acrobat), value => this.SetProfession(SFarmer.acrobat, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.combat.brute"), this.GetProfession(SFarmer.brute), value => this.SetProfession(SFarmer.brute, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.combat.defender"), this.GetProfession(SFarmer.defender), value => this.SetProfession(SFarmer.defender, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.combat.desperado"), this.GetProfession(SFarmer.desperado), value => this.SetProfession(SFarmer.desperado, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.farming.rancher"), this.GetProfession(SFarmer.rancher), value => this.SetProfession(SFarmer.rancher, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.farming.tiller"), this.GetProfession(SFarmer.tiller), value => this.SetProfession(SFarmer.tiller, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.farming.agriculturist"), this.GetProfession(SFarmer.agriculturist), value => this.SetProfession(SFarmer.agriculturist, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.farming.artisan"), this.GetProfession(SFarmer.artisan), value => this.SetProfession(SFarmer.artisan, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.farming.coopmaster"), this.GetProfession(SFarmer.butcher), value => this.SetProfession(SFarmer.butcher, value)));     // butcher = coopmaster
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.farming.shepherd"), this.GetProfession(SFarmer.shepherd), value => this.SetProfession(SFarmer.shepherd, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.fishing.fisher"), this.GetProfession(SFarmer.fisher), value => this.SetProfession(SFarmer.fisher, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.fishing.trapper"), this.GetProfession(SFarmer.trapper), value => this.SetProfession(SFarmer.trapper, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.fishing.angler"), this.GetProfession(SFarmer.angler), value => this.SetProfession(SFarmer.angler, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.fishing.luremaster"), this.GetProfession(SFarmer.baitmaster), value => this.SetProfession(SFarmer.baitmaster, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.fishing.mariner"), this.GetProfession(SFarmer.mariner), value => this.SetProfession(SFarmer.mariner, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.fishing.pirate"), this.GetProfession(SFarmer.pirate), value => this.SetProfession(SFarmer.pirate, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.foraging.forester"), this.GetProfession(SFarmer.forester), value => this.SetProfession(SFarmer.forester, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.foraging.gatherer"), this.GetProfession(SFarmer.gatherer), value => this.SetProfession(SFarmer.gatherer, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.foraging.botanist"), this.GetProfession(SFarmer.botanist), value => this.SetProfession(SFarmer.botanist, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.foraging.lumberjack"), this.GetProfession(SFarmer.lumberjack), value => this.SetProfession(SFarmer.lumberjack, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.foraging.tapper"), this.GetProfession(SFarmer.tapper), value => this.SetProfession(SFarmer.tapper, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.foraging.tracker"), this.GetProfession(SFarmer.tracker), value => this.SetProfession(SFarmer.tracker, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.mining.geologist"), this.GetProfession(SFarmer.geologist), value => this.SetProfession(SFarmer.geologist, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.mining.miner"), this.GetProfession(SFarmer.miner), value => this.SetProfession(SFarmer.miner, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.mining.blacksmith"), this.GetProfession(SFarmer.blacksmith), value => this.SetProfession(SFarmer.blacksmith, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.mining.excavator"), this.GetProfession(SFarmer.excavator), value => this.SetProfession(SFarmer.excavator, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.mining.gemologist"), this.GetProfession(SFarmer.gemologist), value => this.SetProfession(SFarmer.gemologist, value)));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.mining.prospector"), this.GetProfession(SFarmer.burrower), value => this.SetProfession(SFarmer.burrower, value)));     // burrower = prospector
                break;

            case MenuTab.Weather:
                this.Options.Add(new OptionsElement($"{i18n.Get("weather.title")}:"));
                this.Options.Add(new CheatsOptionsWeatherElement($"{i18n.Get("weather.current")}", () => CJB.GetWeatherNexDay(i18n)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("weather.sunny"), 10, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("weather.raining"), 11, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("weather.lightning"), 12, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("weather.snowing"), 13, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                break;

            case MenuTab.Relationships:
                this.Options.Add(new OptionsElement($"{i18n.Get("relationships.title")}:"));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("relationships.give-gifts-anytime"), config.AlwaysGiveGift, value => config.AlwaysGiveGift = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("relationships.no-decay"), config.NoFriendshipDecay, value => config.NoFriendshipDecay     = value));
                this.Options.Add(new OptionsElement($"{i18n.Get("relationships.friends")}:"));

                foreach (NPC npc in Utility.getAllCharacters().OrderBy(p => p.name))
                {
                    if (!Game1.player.friendships.ContainsKey(npc.name) || (npc.name == "Sandy" && !Game1.player.mailReceived.Contains("ccVault")) || npc.name == "???" || npc.name == "Bouncer" || npc.name == "Marlon" || npc.name == "Gil" || npc.name == "Gunther" || npc.IsMonster || npc is Horse || npc is Pet)
                    {
                        continue;
                    }

                    this.Options.Add(new CheatsOptionsNPCSlider(npc));
                }
                break;

            case MenuTab.WarpLocations:
                this.Options.Add(new OptionsElement($"{i18n.Get("warp.title")}:"));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.farm"), 100, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.pierre-shop"), 101, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.blacksmith"), 102, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.museum"), 103, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.saloon"), 104, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.community-center"), 105, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.carpenter"), 106, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.adventurers-guild"), 107, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.ranch"), 113, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.mines"), 109, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.willy-shop"), 110, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.wizard-tower"), 114, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.hats"), 115, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.desert"), 112, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.sandy-shop"), 119, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.casino"), 120, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.quarry"), 108, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.new-beach"), 111, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.secret-woods"), 116, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.sewer"), 117, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.bathhouse"), 118, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                break;

            case MenuTab.Time:
                this.Options.Add(new OptionsElement($"{i18n.Get("time.title")}:"));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("time.freeze-inside"), config.FreezeTimeInside, value => config.FreezeTimeInside = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("time.freeze-caves"), config.FreezeTimeCaves, value => config.FreezeTimeCaves    = value));
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("time.freeze-everywhere"), config.FreezeTime, value => config.FreezeTime         = value));
                this.Options.Add(new CheatsOptionsSlider(i18n.Get("time.time"), (Game1.timeOfDay - 600) / 100, 19, value => this.SafelySetTime((value * 100) + 600), width: 100, format: value => Game1.getTimeOfDayString((value * 100) + 600)));
                break;

            case MenuTab.Controls:
                this.Options.Add(new OptionsElement($"{i18n.Get("controls.title")}:"));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("controls.open-menu"), 1000, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("controls.freeze-time"), 1001, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("controls.grow-tree"), 1002, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("controls.grow-crops"), 1003, this.OptionSlots[0].bounds.Width, config, cheats, i18n));
                break;
            }
            this.SetScrollBarToCurrentIndex();
        }
Exemple #20
0
        /// <inheritdoc />
        public override ISubject GetSubject(IClickableMenu menu, int cursorX, int cursorY)
        {
            IClickableMenu targetMenu = (menu as GameMenu)?.GetCurrentPage() ?? menu;

            switch (targetMenu)
            {
            /****
            ** GameMenu
            ****/
            // skills tab
            case SkillsPage _:
                return(this.BuildSubject(Game1.player));

            // profile tab
            case ProfileMenu profileMenu:
                if (profileMenu.hoveredItem == null)
                {
                    if (profileMenu.GetCharacter() is NPC npc)
                    {
                        return(this.Codex.GetByEntity(npc));
                    }
                }
                break;

            // social tab
            case SocialPage socialPage:
            {
                // get villagers on current page
                int scrollOffset = this.Reflection.GetField <int>(socialPage, "slotPosition").GetValue();
                ClickableTextureComponent[] entries = this.Reflection
                                                      .GetField <List <ClickableTextureComponent> >(socialPage, "sprites")
                                                      .GetValue()
                                                      .Skip(scrollOffset)
                                                      .ToArray();

                // find hovered villager
                ClickableTextureComponent entry = entries.FirstOrDefault(p => p.containsPoint(cursorX, cursorY));
                if (entry != null)
                {
                    int    index    = Array.IndexOf(entries, entry) + scrollOffset;
                    object socialID = this.Reflection.GetField <List <object> >(socialPage, "names").GetValue()[index];
                    if (socialID is long playerID)
                    {
                        Farmer player = Game1.getFarmer(playerID);
                        return(this.BuildSubject(player));
                    }
                    else if (socialID is string villagerName)
                    {
                        NPC npc = this.GameHelper.GetAllCharacters().FirstOrDefault(p => p.isVillager() && p.Name == villagerName);
                        if (npc != null)
                        {
                            return(this.BuildSubject(npc));
                        }
                    }
                }
            }
            break;


            /****
            ** Other menus
            ****/
            // calendar
            case Billboard billboard when billboard.calendarDays != null:     // Billboard used for both calendar and 'help wanted'
            {
                // get target day
                int selectedDay = -1;
                for (int i = 0; i < billboard.calendarDays.Count; i++)
                {
                    if (billboard.calendarDays[i].containsPoint(cursorX, cursorY))
                    {
                        selectedDay = i + 1;
                        break;
                    }
                }
                if (selectedDay == -1)
                {
                    return(null);
                }

                // get villager with a birthday on that date
                NPC target = this.GameHelper.GetAllCharacters().FirstOrDefault(p => p.Birthday_Season == Game1.currentSeason && p.Birthday_Day == selectedDay);
                if (target != null)
                {
                    return(this.BuildSubject(target));
                }
            }
            break;

            // load menu
            case TitleMenu _ when TitleMenu.subMenu is LoadGameMenu loadMenu:
            {
                ClickableComponent button = loadMenu.slotButtons.FirstOrDefault(p => p.containsPoint(cursorX, cursorY));
                if (button != null)
                {
                    int index = this.Reflection.GetField <int>(loadMenu, "currentItemIndex").GetValue() + int.Parse(button.name);
                    var slots = this.Reflection.GetProperty <List <LoadGameMenu.MenuSlot> >(loadMenu, "MenuSlots").GetValue();
                    LoadGameMenu.SaveFileSlot slot = slots[index] as LoadGameMenu.SaveFileSlot;
                    if (slot?.Farmer != null)
                    {
                        return(new FarmerSubject(this.GameHelper, slot.Farmer, isLoadMenu: true));
                    }
                }
            }
            break;
            }

            return(null);
        }
Exemple #21
0
        // Map menu that uses modified map page and modified component locations for hover
        public ModMapPage(
            HashSet <CharacterMarker> npcMarkers,
            Dictionary <string, bool> conditionalNpcs,
            Dictionary <long, CharacterMarker> farmerMarkers,
            Dictionary <string, KeyValuePair <string, Vector2> > farmBuildings,
            Texture2D buildingMarkers,
            ModCustomizations customizations
            ) : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2,
                     Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2,
                     600 + IClickableMenu.borderWidth * 2)
        {
            this.NpcMarkers      = npcMarkers;
            this.ConditionalNpcs = conditionalNpcs;
            this.FarmerMarkers   = farmerMarkers;
            this.FarmBuildings   = farmBuildings;
            this.BuildingMarkers = buildingMarkers;
            this.Customizations  = customizations;

            Vector2 center = Utility.getTopLeftPositionForCenteringOnScreen(ModMain.Map.Bounds.Width * 4, 720);

            drawPamHouseUpgrade  = Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade");
            drawMovieTheaterJoja = Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheaterJoja");
            drawMovieTheater     = Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheater");
            mapX = (int)center.X;
            mapY = (int)center.Y;

            var regionRects = RegionRects().ToList();

            for (int i = 0; i < regionRects.Count; i++)
            {
                var rect         = regionRects.ElementAtOrDefault(i);
                var locationName = rect.Key;

                // Special cases where the name is not an ingame location
                switch (locationName)
                {
                case "Spa":
                    locationName = "BathHouse_Entry";
                    break;

                case "SewerPipe":
                    locationName = "Sewer";
                    break;

                default:
                    break;
                }

                var locVector = ModMain.LocationToMap(locationName);

                this.points[i].bounds = new Rectangle(
                    // Snaps the cursor to the center instead of bottom right (default)
                    (int)(mapX + locVector.X - rect.Value.Width / 2),
                    (int)(mapY + locVector.Y - rect.Value.Height / 2),
                    rect.Value.Width,
                    rect.Value.Height
                    );
            }

            var customTooltips = Customizations.Tooltips.ToList();

            foreach (var tooltip in customTooltips)
            {
                var vanillaTooltip = this.points.Find(x => x.name == tooltip.name);
                var customTooltip  = new ClickableComponent(new Rectangle(
                                                                mapX + tooltip.bounds.X,
                                                                mapY + tooltip.bounds.Y,
                                                                tooltip.bounds.Width,
                                                                tooltip.bounds.Height
                                                                ), tooltip.name);

                // Replace vanilla with custom
                if (vanillaTooltip != null)
                {
                    vanillaTooltip = customTooltip;
                }
                else
                // If new custom location, add it
                {
                    this.points.Add(customTooltip);
                }
            }

            // If two tooltip areas overlap, the one earlier in the list takes precendence
            // Reversing order allows custom tooltips to take precendence
            this.points.Reverse();
        }
Exemple #22
0
        private static void JunimoNoteCustomButtons(JunimoNoteMenu __instance, Bundle ___currentPageBundle, int signal, bool isLeftShiftPressed = false)
        {
            try
            {
                switch (signal)
                {
                case 0:     // For ingredient list
                {
                    if (___currentPageBundle.ingredients.Count >= 0)
                    {
                        currentIngredientListItem = currentIngredientListItem + (isLeftShiftPressed ? -1 : 1);
                        if (currentIngredientListItem >= ___currentPageBundle.ingredients.Count)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentIngredientListItem = ___currentPageBundle.ingredients.Count - 1;
                            }
                            else
                            {
                                currentIngredientListItem = 0;
                            }
                        }

                        if (currentIngredientListItem < 0)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentIngredientListItem = ___currentPageBundle.ingredients.Count - 1;
                            }
                            else
                            {
                                currentIngredientListItem = 0;
                            }
                        }

                        ClickableTextureComponent   c          = __instance.ingredientList[currentIngredientListItem];
                        BundleIngredientDescription ingredient = ___currentPageBundle.ingredients[currentIngredientListItem];

                        Item item      = new StardewValley.Object(ingredient.index, ingredient.stack, isRecipe: false, -1, ingredient.quality);
                        bool completed = false;
                        if (___currentPageBundle != null && ___currentPageBundle.ingredients != null && currentIngredientListItem < ___currentPageBundle.ingredients.Count && ___currentPageBundle.ingredients[currentIngredientListItem].completed)
                        {
                            completed = true;
                        }

                        string toSpeak = item.DisplayName;

                        if (!completed)
                        {
                            int quality = ingredient.quality;
                            if (quality == 1)
                            {
                                toSpeak = $"Silver quality {toSpeak}";
                            }
                            else if (quality == 2 || quality == 3)
                            {
                                toSpeak = $"Gold quality {toSpeak}";
                            }
                            else if (quality >= 4)
                            {
                                toSpeak = $"Iridium quality {toSpeak}";
                            }

                            toSpeak = $"{ingredient.stack} {toSpeak}";
                        }

                        if (completed)
                        {
                            toSpeak = $"Completed {toSpeak}";
                        }

                        c.snapMouseCursorToCenter();
                        MainClass.ScreenReader.Say(toSpeak, true);
                    }
                }
                break;

                case 1:     // For input slot list
                {
                    if (__instance.ingredientSlots.Count >= 0)
                    {
                        currentIngredientInputSlot = currentIngredientInputSlot + (isLeftShiftPressed ? -1 : 1);
                        if (currentIngredientInputSlot >= __instance.ingredientSlots.Count)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentIngredientInputSlot = __instance.ingredientSlots.Count - 1;
                            }
                            else
                            {
                                currentIngredientInputSlot = 0;
                            }
                        }

                        if (currentIngredientInputSlot < 0)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentIngredientInputSlot = __instance.ingredientSlots.Count - 1;
                            }
                            else
                            {
                                currentIngredientInputSlot = 0;
                            }
                        }

                        ClickableTextureComponent c = __instance.ingredientSlots[currentIngredientInputSlot];
                        Item   item = c.item;
                        string toSpeak;

                        if (item == null)
                        {
                            toSpeak = $"Input Slot {currentIngredientInputSlot + 1}";
                        }
                        else
                        {
                            toSpeak = item.DisplayName;
                        }

                        c.snapMouseCursorToCenter();
                        MainClass.ScreenReader.Say(toSpeak, true);
                    }
                }
                break;

                case 2:     // For inventory slots
                {
                    if (__instance.inventory != null && __instance.inventory.actualInventory.Count >= 0)
                    {
                        int prevSlotIndex = currentInventorySlot;
                        currentInventorySlot = currentInventorySlot + (isLeftShiftPressed ? -1 : 1);
                        if (currentInventorySlot >= __instance.inventory.actualInventory.Count)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentInventorySlot = __instance.inventory.actualInventory.Count - 1;
                            }
                            else
                            {
                                currentInventorySlot = 0;
                            }
                        }

                        if (currentInventorySlot < 0)
                        {
                            if (isLeftShiftPressed)
                            {
                                currentInventorySlot = __instance.inventory.actualInventory.Count - 1;
                            }
                            else
                            {
                                currentInventorySlot = 0;
                            }
                        }

                        Item item            = __instance.inventory.actualInventory[currentInventorySlot];
                        ClickableComponent c = __instance.inventory.inventory[currentInventorySlot];
                        string             toSpeak;
                        if (item != null)
                        {
                            toSpeak = item.DisplayName;

                            if ((item as StardewValley.Object) != null)
                            {
                                int quality = ((StardewValley.Object)item).Quality;
                                if (quality == 1)
                                {
                                    toSpeak = $"Silver quality {toSpeak}";
                                }
                                else if (quality == 2 || quality == 3)
                                {
                                    toSpeak = $"Gold quality {toSpeak}";
                                }
                                else if (quality >= 4)
                                {
                                    toSpeak = $"Iridium quality {toSpeak}";
                                }
                            }
                            toSpeak = $"{item.Stack} {toSpeak}";
                        }
                        else
                        {
                            toSpeak = "Empty Slot";
                        }
                        c.snapMouseCursorToCenter();
                        MainClass.ScreenReader.Say(toSpeak, true);
                    }
                }
                break;
                }
            }
            catch (Exception e)
            {
                MainClass.ErrorLog($"Unable to narrate Text:\n{e.Message}\n{e.StackTrace}");
            }
        }
Exemple #23
0
        public AccessCharacterCreationMenu(StardewValley.Menus.CharacterCustomization characterCustomization) : base(characterCustomization)
        {
            TextBox GetTextBox(string name) =>
            ModEntry.GetHelper().Reflection.GetField <TextBox>(characterCustomization, name).GetValue();

            MenuItem menuItem;

            foreach (var button in characterCustomization.genderButtons)
            {
                menuItem              = MenuItem.MenuItemFromComponent(button, characterCustomization);
                menuItem.Label        = button.name;
                menuItem.TextOnAction = "Gender set to " + menuItem.Label;
                AddItem(menuItem);
            }

            menuItem       = MenuTextBox.MenuTextBoxFromComponent(characterCustomization.nameBoxCC, GetTextBox("nameBox"), characterCustomization);
            menuItem.Label = "Character name";
            AddItem(menuItem);
            menuItem              = MenuTextBox.MenuTextBoxFromComponent(characterCustomization.farmnameBoxCC, GetTextBox("farmnameBox"), characterCustomization);
            menuItem.Label        = "Farm name";
            menuItem.TextOnAction = "farm";
            AddItem(menuItem);
            menuItem       = MenuTextBox.MenuTextBoxFromComponent(characterCustomization.favThingBoxCC, GetTextBox("favThingBox"), characterCustomization);
            menuItem.Label = "Favourite thing";
            AddItem(menuItem);

            ClickableComponent catButton = null;

            foreach (ClickableComponent comp in characterCustomization.rightSelectionButtons)
            {
                if (comp.name.Equals("Pet"))
                {
                    catButton = comp;
                }
            }
            if (catButton != null)
            {
                MenuItem petButton = MenuItem.MenuItemFromComponent(catButton, characterCustomization);
                petButton.Label = "change pet";
                petButton.speakOnClickAction -= petButton.DefaultSpeakOnClickAction;
                string breedToString()
                {
                    if (Game1.player.catPerson)
                    {
                        switch (Game1.player.whichPetBreed)
                        {
                        case 0: return("orange cat");

                        case 1: return("grey cat");

                        case 2: return("yellow cat");

                        default: return("unknown");
                        }
                    }
                    else
                    {
                        switch (Game1.player.whichPetBreed)
                        {
                        case 0: return("Laprador Retriever");

                        case 1: return("German Shepherd");

                        case 2: return("Bloodhound");

                        default: return("unknown");
                        }
                    }
                }

                petButton.speakOnClickAction += () => { TextToSpeech.Speak("selected " + breedToString() + " as pet"); };
                AddItem(petButton);
            }
            else
            {
                ModEntry.Log("couldn't find pet button", LogLevel.Error);
            }


            menuItem       = MenuItem.MenuItemFromComponent(characterCustomization.skipIntroButton, characterCustomization);
            menuItem.Label = "skip intro";
            menuItem.speakOnClickAction -= menuItem.DefaultSpeakOnClickAction;
            menuItem.speakOnClickAction += () =>
            {
                bool skipIntro = ModEntry.GetHelper().Reflection.GetField <bool>(characterCustomization, "skipIntro").GetValue();
                TextToSpeech.Speak(skipIntro ? "skipping intro" : "playing intro");
            };
            AddItem(menuItem);

            foreach (ClickableTextureComponent comp in characterCustomization.farmTypeButtons)
            {
                menuItem              = MenuItem.MenuItemFromComponent(comp, characterCustomization);
                menuItem.Label        = comp.name + " farm type";
                menuItem.TextOnAction = "selected " + comp.name + " farm type";
                menuItem.Description  = comp.hoverText.Split('_')[1];
                AddItem(menuItem);
            }

            menuItem       = MenuItem.MenuItemFromComponent(characterCustomization.okButton, characterCustomization);
            menuItem.Label = "start game";
            menuItem.speakOnClickAction -= menuItem.DefaultSpeakOnClickAction;
            menuItem.speakOnClickAction += () =>
            {
                if (characterCustomization.canLeaveMenu())
                {
                    TextToSpeech.Speak("starting new game");
                }
                else
                {
                    TextToSpeech.Speak("enter character name, farm name, and favourite thing first");
                }
            };
            AddItem(menuItem);

            menuItem              = MenuItem.MenuItemFromComponent(characterCustomization.backButton, StardewValley.Game1.activeClickableMenu);
            menuItem.Label        = "back to title";
            menuItem.TextOnAction = AccessTitleMenu.Title();
            AddItem(menuItem);
        }
Exemple #24
0
        /// <summary>Get metadata for a menu element at the specified position.</summary>
        /// <param name="menu">The active menu.</param>
        /// <param name="cursorPos">The cursor's viewport-relative coordinates.</param>
        public ISubject GetSubjectFrom(IClickableMenu menu, Vector2 cursorPos)
        {
            switch (menu)
            {
            // calendar
            case Billboard billboard:
            {
                // get target day
                int selectedDay = -1;
                for (int i = 0; i < billboard.calendarDays.Count; i++)
                {
                    if (billboard.calendarDays[i].containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        selectedDay = i + 1;
                        break;
                    }
                }
                if (selectedDay == -1)
                {
                    return(null);
                }

                // get villager with a birthday on that date
                NPC target = this.GameHelper.GetAllCharacters().FirstOrDefault(p => p.Birthday_Season == Game1.currentSeason && p.Birthday_Day == selectedDay);
                if (target != null)
                {
                    return(new CharacterSubject(this.GameHelper, target, TargetType.Villager, this.Metadata, this.Translations, this.Reflection));
                }
            }
            break;

            // chest
            case MenuWithInventory inventoryMenu:
            {
                Item item = inventoryMenu.hoveredItem;
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // inventory
            case GameMenu gameMenu:
            {
                List <IClickableMenu> tabs   = this.Reflection.GetField <List <IClickableMenu> >(gameMenu, "pages").GetValue();
                IClickableMenu        curTab = tabs[gameMenu.currentTab];
                switch (curTab)
                {
                case InventoryPage _:
                {
                    Item item = this.Reflection.GetField <Item>(curTab, "hoveredItem").GetValue();
                    if (item != null)
                    {
                        return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                    }
                }
                break;

                case CraftingPage _:
                {
                    Item item = this.Reflection.GetField <Item>(curTab, "hoverItem").GetValue();
                    if (item != null)
                    {
                        return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                    }
                }
                break;

                case SocialPage _:
                {
                    // get villagers on current page
                    int scrollOffset = this.Reflection.GetField <int>(curTab, "slotPosition").GetValue();
                    ClickableTextureComponent[] entries = this.Reflection
                                                          .GetField <List <ClickableTextureComponent> >(curTab, "sprites")
                                                          .GetValue()
                                                          .Skip(scrollOffset)
                                                          .ToArray();

                    // find hovered villager
                    ClickableTextureComponent entry = entries.FirstOrDefault(p => p.containsPoint((int)cursorPos.X, (int)cursorPos.Y));
                    if (entry != null)
                    {
                        int    index    = Array.IndexOf(entries, entry) + scrollOffset;
                        object socialID = this.Reflection.GetField <List <object> >(curTab, "names").GetValue()[index];
                        if (socialID is long playerID)
                        {
                            Farmer player = Game1.getFarmer(playerID);
                            return(new FarmerSubject(this.GameHelper, player, this.Translations, this.Reflection));
                        }
                        else if (socialID is string villagerName)
                        {
                            NPC npc = this.GameHelper.GetAllCharacters().FirstOrDefault(p => p.isVillager() && p.Name == villagerName);
                            if (npc != null)
                            {
                                return(new CharacterSubject(this.GameHelper, npc, TargetType.Villager, this.Metadata, this.Translations, this.Reflection));
                            }
                        }
                    }
                }
                break;
                }
            }
            break;

            // Community Center bundle menu
            case JunimoNoteMenu bundleMenu:
            {
                // hovered inventory item
                {
                    Item item = this.Reflection.GetField <Item>(menu, "hoveredItem").GetValue();
                    if (item != null)
                    {
                        return(new ItemSubject(this.GameHelper, this.Translations, item.getOne(), ObjectContext.Inventory, knownQuality: true));
                    }
                }

                // list of required ingredients
                for (int i = 0; i < bundleMenu.ingredientList.Count; i++)
                {
                    if (bundleMenu.ingredientList[i].containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        Bundle bundle     = this.Reflection.GetField <Bundle>(bundleMenu, "currentPageBundle").GetValue();
                        var    ingredient = bundle.ingredients[i];
                        var    item       = this.GameHelper.GetObjectBySpriteIndex(ingredient.index, ingredient.stack);
                        item.Quality = ingredient.quality;
                        return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                    }
                }

                // list of submitted ingredients
                foreach (ClickableTextureComponent slot in bundleMenu.ingredientSlots)
                {
                    if (slot.item != null && slot.containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        return(new ItemSubject(this.GameHelper, this.Translations, slot.item, ObjectContext.Inventory, knownQuality: true));
                    }
                }
            }
            break;

            // kitchen
            case CraftingPage _:
            {
                CraftingRecipe recipe = this.Reflection.GetField <CraftingRecipe>(menu, "hoverRecipe").GetValue();
                if (recipe != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, recipe.createItem(), ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;


            // shop
            case ShopMenu _:
            {
                Item item = this.Reflection.GetField <Item>(menu, "hoveredItem").GetValue();
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item.getOne(), ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // toolbar
            case Toolbar _:
            {
                // find hovered slot
                List <ClickableComponent> slots       = this.Reflection.GetField <List <ClickableComponent> >(menu, "buttons").GetValue();
                ClickableComponent        hoveredSlot = slots.FirstOrDefault(slot => slot.containsPoint((int)cursorPos.X, (int)cursorPos.Y));
                if (hoveredSlot == null)
                {
                    return(null);
                }

                // get inventory index
                int index = slots.IndexOf(hoveredSlot);
                if (index < 0 || index > Game1.player.Items.Count - 1)
                {
                    return(null);
                }

                // get hovered item
                Item item = Game1.player.Items[index];
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item.getOne(), ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // by convention (for mod support)
            default:
            {
                Item item = this.Reflection.GetField <Item>(menu, "HoveredItem", required: false)?.GetValue();        // ChestsAnywhere
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;
            }

            return(null);
        }
        /// <summary>Draw the menu to the screen.</summary>
        /// <param name="b">The sprite batch.</param>
        public override void draw(SpriteBatch b)
        {
            // Implementation derived from ChooseFromListMenu

            // from ShopMenu: draw menuBackground if enabled
            if (Game1.options.showMenuBackground)
            {
                base.drawBackground(b);
            }
            else
            {
                b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.4f); // 0.4 is default(?); used in GameMenu
            }

            // draw menu box
            drawTextureBox(
                b,
                xPositionOnScreen,
                yPositionOnScreen,
                width,
                height,
                Color.White);

            // draw options' submenu box
            drawTextureBox(
                b,
                Game1.mouseCursors,
                new Rectangle(384, 373, 18, 18),    // shopMenu's nail corners
                VisibleOptionsXPositionOnScreen,
                VisibleOptionsYPositionOnScreen,
                _longestNameWidth + _textureBoxBorderWidth * 2,
                _visibleOptionsHeight + _textureBoxBorderWidth * 2,
                Color.White,
                4f,
                false);

            // draw menu title
            StardewValley.BellsAndWhistles.SpriteText.drawStringWithScrollCenteredAt(
                b,
                Game1.content.LoadString(
                    "Strings\\UI:JukeboxMenu_Title"),
                xPositionOnScreen + width / 2,
                yPositionOnScreen - _spacingPixels);

            // draw "Currently Playing:"
            String cur_play = GetTranslation("BetterJukeboxMenu:Currently_Playing");

            Utility.drawTextWithShadow(
                b,
                cur_play,
                Game1.dialogueFont,
                new Vector2(
                    xPositionOnScreen + width / 2 - Game1.dialogueFont.MeasureString(cur_play).X / 2f,
                    yPositionOnScreen + _spacingPixels),
                Game1.textColor);

            // draw the name of the active song
            String song_name;

            if (PlayingIndex > -1)
            {
                song_name = Utility.getSongTitleFromCueName(Options[PlayingIndex]);
            }
            else
            {
                if (IsRandom)
                {
                    song_name = Utility.getSongTitleFromCueName(Game1.player.currentLocation.randomMiniJukeboxTrack.Value);
                }
                else
                {
                    song_name = Utility.getSongTitleFromCueName("turn_off");
                }
            }

            Utility.drawTextWithShadow(
                b,
                song_name,
                Game1.dialogueFont,
                new Vector2(
                    xPositionOnScreen + width / 2 - Game1.dialogueFont.MeasureString(song_name).X / 2f,
                    yPositionOnScreen + _spacingPixels + Game1.dialogueFont.MeasureString(cur_play).Y * 1.25f),
                Game1.textColor);

            //StardewValley.BellsAndWhistles.SpriteText.drawStringHorizontallyCenteredAt(
            //    b,
            //    song_name,
            //    xPositionOnScreen + width / 2,
            //    yPositionOnScreen + _spacingPixels * 3 / 2 + (int) Game1.dialogueFont.MeasureString(cur_play).Y);

            // draw the list of VisibleOptions
            // derived from forSale section of ShopMenu.draw()
            for (int i = 0; i < VisibleOptions.Count; ++i)
            {
                // don't draw if LowestVisibleIndex is incorrect
                if (LowestVisibleIndex + i >= Options.Count)
                {
                    Monitor.LogOnce("Ceased drawing options because LowestVisibleIndex is incorrectly high!", LogLevel.Error);
                    break;  // not continue because will continue to be incorrect
                }

                ClickableComponent button = VisibleOptions[i];

                // determining button colour; priority: selected - hovered (and not dragging scrollbar) - not hovered
                Color button_colour;
                if (LowestVisibleIndex + i == SelectedIndex)
                {
                    button_colour = Color.Peru; // probably looks fine
                }
                else if (button.containsPoint(Game1.getOldMouseX(), Game1.getOldMouseY()) && !IsScrolling)
                {
                    button_colour = Color.Wheat;
                }
                else
                {
                    button_colour = Color.White;
                }

                // drawing the box around each option
                drawTextureBox(
                    b,
                    Game1.mouseCursors,
                    new Rectangle(384, 396, 15, 15),            // box shape w/ elaborate corners
                    button.bounds.X,
                    button.bounds.Y,
                    button.bounds.Width,
                    button.bounds.Height,
                    button_colour,
                    4f,
                    false);

                // drawing option name
                string cue_name = Options[LowestVisibleIndex + i];

                song_name = Utility.getSongTitleFromCueName(cue_name);

                if (_showInternalId)    // left align song_name, right align cue_name
                {
                    if (cue_name.Equals(song_name))
                    {
                    }
                    else
                    {
                        Utility.drawTextWithShadow(
                            b,
                            song_name,
                            Game1.dialogueFont,
                            new Vector2(
                                button.bounds.X + _textureBoxBorderWidth,
                                button.bounds.Y + button.bounds.Height / 2 - Game1.dialogueFont.MeasureString(song_name).Y / 2f),
                            Game1.textColor);
                    }

                    Utility.drawTextWithShadow(
                        b,
                        cue_name,
                        Game1.dialogueFont,
                        new Vector2(
                            button.bounds.X + button.bounds.Width - Game1.dialogueFont.MeasureString(cue_name).X - _textureBoxBorderWidth,
                            button.bounds.Y + button.bounds.Height / 2 - Game1.dialogueFont.MeasureString(cue_name).Y / 2f),
                        Game1.textColor);
                }
                else // center text
                {
                    Utility.drawTextWithShadow(
                        b,
                        song_name,
                        Game1.dialogueFont,
                        new Vector2(
                            button.bounds.X + button.bounds.Width / 2 - Game1.dialogueFont.MeasureString(song_name).X / 2f,
                            button.bounds.Y + button.bounds.Height / 2 - Game1.dialogueFont.MeasureString(song_name).Y / 2f),
                        Game1.textColor);
                }
            }

            // draw the play and stop buttons
            PlayButton.draw(b);
            StopButton?.draw(b);
            // and the random button
            if (RandomButton != null)
            {
                RandomButton.draw(b);
                // draw check/cross
                if (IsRandom)
                {
                    b.Draw(ChatBox.emojiTexture,
                           new Vector2(RandomButton.bounds.X + 6 * 4,
                                       RandomButton.bounds.Y + 6 * 4),
                           new Rectangle(117, 81, 9, 9),
                           Color.White,
                           0f,
                           Vector2.Zero,
                           4f,
                           SpriteEffects.None,
                           0.99f);
                }
                else
                {
                    b.Draw(ChatBox.emojiTexture,
                           new Vector2(RandomButton.bounds.X + 6 * 4,
                                       RandomButton.bounds.Y + 6 * 4),
                           new Rectangle(45, 81, 9, 9),
                           Color.White,
                           0f,
                           Vector2.Zero,
                           4f,
                           SpriteEffects.None,
                           0.99f);
                }
            }

            // draw the SortTabs
            for (int i = 0; i < SortTabs.Count; ++i)
            {
                SortTabs[i].draw(b);
            }

            // draw the scrolling elements
            if (VisibleOptions.Count >= Options.Count)
            {
            }
            else
            {
                UpArrow.draw(b);
                DownArrow.draw(b);

                // copied from ShopMenu.draw()
                drawTextureBox(
                    b,
                    Game1.mouseCursors,
                    new Rectangle(403, 383, 6, 6),
                    ScrollBarRunner.X,
                    ScrollBarRunner.Y,
                    ScrollBarRunner.Width,
                    ScrollBarRunner.Height,
                    Color.White,
                    4f);
                ScrollBar.draw(b);
            }

            // from ShopMenu: draw tooltip (hover)
            if (!HoverText.Equals(""))
            {
                IClickableMenu.drawHoverText(b, HoverText, Game1.smallFont);
            }

            // draw the upper right close button
            base.draw(b);

            // draw cursor
            drawMouse(b);
        }
 public NewPurchaseAnimalsMenu(List <StardewValley.Object> stock) : base(Game1.viewport.Width / 2 - NewPurchaseAnimalsMenu.menuWidth / 2 - IClickableMenu.borderWidth * 2, Game1.viewport.Height / 2 - NewPurchaseAnimalsMenu.menuHeight - IClickableMenu.borderWidth * 2, NewPurchaseAnimalsMenu.menuWidth + IClickableMenu.borderWidth * 2, NewPurchaseAnimalsMenu.menuHeight + IClickableMenu.borderWidth, false)
 {
     this.height += Game1.tileSize;
     for (int i = 0; i < stock.Count; i++)
     {
         this.animalsToPurchase.Add(new ClickableTextureComponent(string.Concat(stock[i].salePrice()), new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + IClickableMenu.borderWidth + i % 3 * Game1.tileSize * 2, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth / 2 + i / 3 * (Game1.tileSize + Game1.tileSize / 3), Game1.tileSize * 2, Game1.tileSize), null, stock[i].Name, Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(i % 3 * 16 * 2, 448 + i / 3 * 16, 32, 16), 4f, stock[i].type == null)
         {
             item            = stock[i],
             myID            = i,
             rightNeighborID = ((i % 3 == 2) ? -1 : (i + 1)),
             leftNeighborID  = ((i % 3 == 0) ? -1 : (i - 1)),
             downNeighborID  = i + 3,
             upNeighborID    = i - 3
         });
     }
     this.okButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + 4, this.yPositionOnScreen + this.height - Game1.tileSize - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47, -1, -1), 1f, false)
     {
         myID           = 101,
         upNeighborID   = 103,
         leftNeighborID = 103
     };
     this.randomButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + Game1.tileSize * 4 / 5 + Game1.tileSize, Game1.viewport.Height / 2, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(381, 361, 10, 10), (float)Game1.pixelZoom, false)
     {
         myID            = 103,
         downNeighborID  = 101,
         rightNeighborID = 101
     };
     PurchaseAnimalsMenu.menuHeight = Game1.tileSize * 5;
     PurchaseAnimalsMenu.menuWidth  = Game1.tileSize * 7;
     this.textBox        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
     this.textBox.X      = Game1.viewport.Width / 2 - Game1.tileSize * 3;
     this.textBox.Y      = Game1.viewport.Height / 2;
     this.textBox.Width  = Game1.tileSize * 4;
     this.textBox.Height = Game1.tileSize * 3;
     this.e         = new TextBoxEvent(this.textBoxEnter);
     this.textBoxCC = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X, this.textBox.Y, 192, 48), "")
     {
         myID            = 104,
         rightNeighborID = 102,
         downNeighborID  = 101
     };
     this.randomButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X + this.textBox.Width + Game1.tileSize + Game1.tileSize * 3 / 4 - Game1.pixelZoom * 2, Game1.viewport.Height / 2 + Game1.pixelZoom, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(381, 361, 10, 10), (float)Game1.pixelZoom, false)
     {
         myID            = 103,
         leftNeighborID  = 102,
         downNeighborID  = 101,
         rightNeighborID = 101
     };
     this.doneNamingButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.textBox.X + this.textBox.Width + Game1.tileSize / 2 + Game1.pixelZoom, Game1.viewport.Height / 2 - Game1.pixelZoom * 2, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false)
     {
         myID            = 102,
         rightNeighborID = 103,
         leftNeighborID  = 104,
         downNeighborID  = 101
     };
     if (Game1.options.SnappyMenus)
     {
         base.populateClickableComponentList();
         this.snapToDefaultClickableComponent();
     }
 }
Exemple #27
0
        /// <summary>Get metadata for a menu element at the specified position.</summary>
        /// <param name="menu">The active menu.</param>
        /// <param name="cursorPos">The cursor's viewport-relative coordinates.</param>
        public ISubject GetSubjectFrom(IClickableMenu menu, Vector2 cursorPos)
        {
            IClickableMenu targetMenu =
                (menu as GameMenu)?.GetCurrentPage()
                ?? menu;

            switch (targetMenu)
            {
            // calendar
            case Billboard billboard:
            {
                // get target day
                int selectedDay = -1;
                for (int i = 0; i < billboard.calendarDays.Count; i++)
                {
                    if (billboard.calendarDays[i].containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        selectedDay = i + 1;
                        break;
                    }
                }
                if (selectedDay == -1)
                {
                    return(null);
                }

                // get villager with a birthday on that date
                NPC target = this.GameHelper.GetAllCharacters().FirstOrDefault(p => p.Birthday_Season == Game1.currentSeason && p.Birthday_Day == selectedDay);
                if (target != null)
                {
                    return(new CharacterSubject(this.GameHelper, target, TargetType.Villager, this.Metadata, this.Translations, this.Reflection));
                }
            }
            break;

            // chest
            case MenuWithInventory inventoryMenu:
            {
                Item item = inventoryMenu.hoveredItem;
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // inventory
            case InventoryPage inventory:
            {
                Item item = this.Reflection.GetField <Item>(inventory, "hoveredItem").GetValue();
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // collections menu
            // derived from CollectionsPage::performHoverAction
            case CollectionsPage collectionsTab:
            {
                int currentTab = this.Reflection.GetField <int>(collectionsTab, "currentTab").GetValue();
                if (currentTab == CollectionsPage.achievementsTab || currentTab == CollectionsPage.secretNotesTab || currentTab == CollectionsPage.lettersTab)
                {
                    break;
                }

                int currentPage = this.Reflection.GetField <int>(collectionsTab, "currentPage").GetValue();

                foreach (ClickableTextureComponent component in collectionsTab.collections[currentTab][currentPage])
                {
                    if (component.containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        int     itemID = Convert.ToInt32(component.name.Split(' ')[0]);
                        SObject obj    = new SObject(itemID, 1);
                        return(new ItemSubject(this.GameHelper, this.Translations, obj, ObjectContext.Inventory, knownQuality: false));
                    }
                }
            }
            break;

            // cooking or crafting menu
            case CraftingPage crafting:
            {
                // player inventory item
                Item item = this.Reflection.GetField <Item>(crafting, "hoverItem").GetValue();
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }

                // crafting recipe
                CraftingRecipe recipe = this.Reflection.GetField <CraftingRecipe>(crafting, "hoverRecipe").GetValue();
                if (recipe != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, recipe.createItem(), ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // social tab
            case SocialPage socialPage:
            {
                // get villagers on current page
                int scrollOffset = this.Reflection.GetField <int>(socialPage, "slotPosition").GetValue();
                ClickableTextureComponent[] entries = this.Reflection
                                                      .GetField <List <ClickableTextureComponent> >(socialPage, "sprites")
                                                      .GetValue()
                                                      .Skip(scrollOffset)
                                                      .ToArray();

                // find hovered villager
                ClickableTextureComponent entry = entries.FirstOrDefault(p => p.containsPoint((int)cursorPos.X, (int)cursorPos.Y));
                if (entry != null)
                {
                    int    index    = Array.IndexOf(entries, entry) + scrollOffset;
                    object socialID = this.Reflection.GetField <List <object> >(socialPage, "names").GetValue()[index];
                    if (socialID is long playerID)
                    {
                        Farmer player = Game1.getFarmer(playerID);
                        return(new FarmerSubject(this.GameHelper, player, this.Translations));
                    }
                    else if (socialID is string villagerName)
                    {
                        NPC npc = this.GameHelper.GetAllCharacters().FirstOrDefault(p => p.isVillager() && p.Name == villagerName);
                        if (npc != null)
                        {
                            return(new CharacterSubject(this.GameHelper, npc, TargetType.Villager, this.Metadata, this.Translations, this.Reflection));
                        }
                    }
                }
            }
            break;

            // Community Center bundle menu
            case JunimoNoteMenu bundleMenu:
            {
                // hovered inventory item
                {
                    Item item = this.Reflection.GetField <Item>(menu, "hoveredItem").GetValue();
                    if (item != null)
                    {
                        return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                    }
                }

                // list of required ingredients
                for (int i = 0; i < bundleMenu.ingredientList.Count; i++)
                {
                    if (bundleMenu.ingredientList[i].containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        Bundle bundle     = this.Reflection.GetField <Bundle>(bundleMenu, "currentPageBundle").GetValue();
                        var    ingredient = bundle.ingredients[i];
                        var    item       = this.GameHelper.GetObjectBySpriteIndex(ingredient.index, ingredient.stack);
                        item.Quality = ingredient.quality;
                        return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                    }
                }

                // list of submitted ingredients
                foreach (ClickableTextureComponent slot in bundleMenu.ingredientSlots)
                {
                    if (slot.item != null && slot.containsPoint((int)cursorPos.X, (int)cursorPos.Y))
                    {
                        return(new ItemSubject(this.GameHelper, this.Translations, slot.item, ObjectContext.Inventory, knownQuality: true));
                    }
                }
            }
            break;

            // load menu
            case TitleMenu _ when TitleMenu.subMenu is LoadGameMenu loadMenu:
            {
                ClickableComponent button = loadMenu.slotButtons.FirstOrDefault(p => p.containsPoint((int)cursorPos.X, (int)cursorPos.Y));
                if (button != null)
                {
                    int index = this.Reflection.GetField <int>(loadMenu, "currentItemIndex").GetValue() + int.Parse(button.name);
                    var slots = this.Reflection.GetProperty <List <LoadGameMenu.MenuSlot> >(loadMenu, "MenuSlots").GetValue();
                    LoadGameMenu.SaveFileSlot slot = slots[index] as LoadGameMenu.SaveFileSlot;
                    if (slot?.Farmer != null)
                    {
                        return(new FarmerSubject(this.GameHelper, slot.Farmer, this.Translations, isLoadMenu: true));
                    }
                }
            }
            break;

            // shop
            case ShopMenu shopMenu:
            {
                ISalable entry = shopMenu.hoveredItem;
                if (entry is Item item)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // toolbar
            case Toolbar _:
            {
                // find hovered slot
                List <ClickableComponent> slots       = this.Reflection.GetField <List <ClickableComponent> >(menu, "buttons").GetValue();
                ClickableComponent        hoveredSlot = slots.FirstOrDefault(slot => slot.containsPoint((int)cursorPos.X, (int)cursorPos.Y));
                if (hoveredSlot == null)
                {
                    return(null);
                }

                // get inventory index
                int index = slots.IndexOf(hoveredSlot);
                if (index < 0 || index > Game1.player.Items.Count - 1)
                {
                    return(null);
                }

                // get hovered item
                Item item = Game1.player.Items[index];
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;

            // by convention (for mod support)
            default:
            {
                Item item = this.Reflection.GetField <Item>(menu, "HoveredItem", required: false)?.GetValue();        // ChestsAnywhere
                if (item != null)
                {
                    return(new ItemSubject(this.GameHelper, this.Translations, item, ObjectContext.Inventory, knownQuality: true));
                }
            }
            break;
            }

            return(null);
        }
Exemple #28
0
 public NewLoadMenu() : base(Game1.viewport.Width / 2 - (1100 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 1100 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, false)
 {
     this.backButton = new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(Game1.viewport.Width + -198 - 48, Game1.viewport.Height - 81 - 24, 198, 81), "")
     {
         myID           = 81114,
         upNeighborID   = 801,
         leftNeighborID = 801
     };
     this.upArrow = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + Game1.tileSize / 4, this.yPositionOnScreen + Game1.tileSize / 4, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(421, 459, 11, 12), (float)Game1.pixelZoom, false)
     {
         myID           = 800,
         downNeighborID = 801,
         leftNeighborID = 100
     };
     this.downArrow = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width + Game1.tileSize / 4, this.yPositionOnScreen + this.height - Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(421, 472, 11, 12), (float)Game1.pixelZoom, false)
     {
         myID            = 801,
         upNeighborID    = 800,
         leftNeighborID  = 103,
         rightNeighborID = 81114,
         downNeighborID  = 81114
     };
     this.scrollBar       = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.upArrow.bounds.X + Game1.pixelZoom * 3, this.upArrow.bounds.Y + this.upArrow.bounds.Height + Game1.pixelZoom, 6 * Game1.pixelZoom, 10 * Game1.pixelZoom), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(435, 463, 6, 10), (float)Game1.pixelZoom, false);
     this.scrollBarRunner = new Microsoft.Xna.Framework.Rectangle(this.scrollBar.bounds.X, this.upArrow.bounds.Y + this.upArrow.bounds.Height + Game1.pixelZoom, this.scrollBar.bounds.Width, this.height - Game1.tileSize - this.upArrow.bounds.Height - Game1.pixelZoom * 7);
     this.okDeleteButton  = new ClickableTextureComponent(Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.10992", new object[0]), new Microsoft.Xna.Framework.Rectangle((int)Utility.getTopLeftPositionForCenteringOnScreen(Game1.tileSize, Game1.tileSize, 0, 0).X - Game1.tileSize, (int)Utility.getTopLeftPositionForCenteringOnScreen(Game1.tileSize, Game1.tileSize, 0, 0).Y + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false)
     {
         myID            = 802,
         rightNeighborID = 803
     };
     this.cancelDeleteButton = new ClickableTextureComponent(Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.10993", new object[0]), new Microsoft.Xna.Framework.Rectangle((int)Utility.getTopLeftPositionForCenteringOnScreen(Game1.tileSize, Game1.tileSize, 0, 0).X + Game1.tileSize, (int)Utility.getTopLeftPositionForCenteringOnScreen(Game1.tileSize, Game1.tileSize, 0, 0).Y + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47, -1, -1), 1f, false)
     {
         myID           = 803,
         leftNeighborID = 802
     };
     for (int i = 0; i < 4; i++)
     {
         this.gamesToLoadButton.Add(new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + Game1.tileSize / 4, this.yPositionOnScreen + Game1.tileSize / 4 + i * (this.height / 4), this.width - Game1.tileSize / 2, this.height / 4 + Game1.pixelZoom), string.Concat(i))
         {
             myID            = i,
             downNeighborID  = (i < 3 ? i + 1 : -7777),
             upNeighborID    = (i > 0 ? i - 1 : -7777),
             rightNeighborID = i + 100
         });
         this.deleteButtons.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize - Game1.pixelZoom, this.yPositionOnScreen + Game1.tileSize / 2 + Game1.pixelZoom + i * (this.height / 4), 12 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.10994", new object[0]), Game1.mouseCursors, new Microsoft.Xna.Framework.Rectangle(322, 498, 12, 12), (float)Game1.pixelZoom * 3f / 4f, false)
         {
             myID            = i + 100,
             leftNeighborID  = i,
             downNeighborID  = i + 1 + 100,
             upNeighborID    = i - 1 + 100,
             rightNeighborID = (i < 2 ? 800 : 801)
         });
     }
     if (Util.UsingMono)
     {
         Log.debug("Mono, doing alternate loading test?");
         this._initTaskMonoDebug = new Task <List <SFarmer> >((Func <List <SFarmer> >)(() =>
         {
             Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
             Log.debug("Task started");
             return(FindSaveGames());
         }));
         this._initTaskMonoDebug.Start();
         Log.debug("Started it");
     }
     if (Game1.options.snappyMenus && Game1.options.gamepadControls)
     {
         base.populateClickableComponentList();
         this.snapToDefaultClickableComponent();
     }
 }
        // Change: Added functionality to read a lost book.
        public override void receiveLeftClick(int x, int y, bool playSound = true)
        {
            var currentTabRef  = ModEntry.CommonServices.ReflectionHelper.GetField <int>(this, "currentTab");
            var currentPageRef = ModEntry.CommonServices.ReflectionHelper.GetField <int>(this, "currentPage");

            int currentTab  = currentTabRef.GetValue();
            int currentPage = currentPageRef.GetValue();

            for (int index = 0; index < this.sideTabs.Count; ++index)
            {
                if (this.sideTabs[index].containsPoint(x, y) && currentTab != index)
                {
                    Game1.playSound("smallSelect");
                    this.sideTabs[currentTab].bounds.X -= CollectionsPage.widthToMoveActiveTab;

                    currentTabRef.SetValue(index);
                    currentPageRef.SetValue(0);
                    currentTab  = index;
                    currentPage = 0;

                    this.sideTabs[index].bounds.X += CollectionsPage.widthToMoveActiveTab;

                    // On tab switch, we set the currently snapped element to the tab element
                    currentlySnappedComponent = this.sideTabs[index];

                    if (index == lostBooksTabPageIndex)
                    {
                        currentlySnappedComponent.rightNeighborID = LostBooksTab_ItemBaseId;
                    }
                    else
                    {
                        currentlySnappedComponent.rightNeighborID = 0;
                    }

                    return;
                }
            }

            // Open a book when it has been clicked by the player.
            if (currentTab == lostBooksTabPageIndex)
            {
                foreach (ClickableTextureComponent textureComponent in collections[lostBooksTabPageIndex][currentPage])
                {
                    if (textureComponent.containsPoint(x, y))
                    {
                        // Only open a book if it has already been found by the player.
                        if (int.TryParse(textureComponent.name.Split(' ')[2], out int index) &&
                            index <= LibraryMuseumHelper.LibraryBooks)
                        {
                            string message = Game1.content.LoadString("Strings\\Notes:" + index).Replace('\n', '^');
                            Game1.drawLetterMessage(message);

                            // Preserve the currently clicked book so it can be re-set as the snapped item
                            snappedItem = textureComponent;
                        }
                        return;
                    }
                }
            }

            if (currentPage > 0 && this.backButton.containsPoint(x, y))
            {
                --currentPage;
                currentPageRef.SetValue(currentPage);

                Game1.playSound("shwip");
                this.backButton.scale = this.backButton.baseScale;
                if (Game1.options.snappyMenus && Game1.options.gamepadControls && currentPage == 0)
                {
                    this.currentlySnappedComponent = (ClickableComponent)this.forwardButton;
                    Game1.setMousePosition(this.currentlySnappedComponent.bounds.Center);
                }
            }

            if (currentPage >= this.collections[currentTab].Count - 1 || !this.forwardButton.containsPoint(x, y))
            {
                return;
            }

            ++currentPage;
            currentPageRef.SetValue(currentPage);

            Game1.playSound("shwip");
            this.forwardButton.scale = this.forwardButton.baseScale;
            if (!Game1.options.snappyMenus || !Game1.options.gamepadControls || currentPage != this.collections[currentTab].Count - 1)
            {
                return;
            }

            this.currentlySnappedComponent = (ClickableComponent)this.backButton;
            Game1.setMousePosition(this.currentlySnappedComponent.bounds.Center);
        }
        public override void draw(SpriteBatch b)
        {
            // dialog background
            Game1.drawDialogueBox(xPositionOnScreen, yPositionOnScreen, width,
                                  height, false, true);

            // PromptLabel
            float promptWidth  = Game1.smallFont.MeasureString(promptMessage).X;
            float promptOffset = (promptLabel.bounds.Width - promptWidth) / 2;

            Utility.drawTextWithShadow(b, promptMessage, Game1.smallFont,
                                       new Vector2(promptLabel.bounds.X + promptOffset, promptLabel.bounds.Y),
                                       Game1.textColor);

            // DateLabel
            string dateText   = date.Localize();
            float  dateWidth  = DateFont.MeasureString(dateText).X;
            float  dateOffset = (dateLabel.bounds.Width - dateWidth) / 2;

            Utility.drawTextWithShadow(b, dateText, DateFont,
                                       new Vector2(dateLabel.bounds.X + dateOffset, dateLabel.bounds.Y),
                                       Game1.textColor);

            // Calendar
            calendar.draw(b);

            // WeekLabels
            for (int i = 0; i < weekLabels.Count; ++i)
            {
                ClickableComponent label = weekLabels[i];
                string             text  = (i % 4 + 1).ToString();
                SpriteText.drawStringHorizontallyCenteredAt(b, text,
                                                            label.bounds.X, label.bounds.Y, junimoText: true);
            }

            // DayButtons
            for (int i = 0; i < dayButtons.Count; ++i)
            {
                ClickableTextureComponent button = dayButtons[i];
                Vector2   position   = new Vector2(button.bounds.X, button.bounds.Y);
                Rectangle sourceRect = new Rectangle(button.sourceRect.X +
                                                     ((i == selectedDay) ? 24 : (i == hoverButton) ? 12 : 0),
                                                     button.sourceRect.Y, button.sourceRect.Width,
                                                     button.sourceRect.Height);
                Vector2 origin = new Vector2(button.sourceRect.Width / 2,
                                             button.sourceRect.Height / 2);
                double angle = 2 * Math.PI * (i + 0.5) / 112.0;
                b.Draw(button.texture, position, sourceRect, Color.White,
                       (float)angle, origin, CalendarScale, SpriteEffects.None,
                       0.86f + (float)button.bounds.Y / 20000f);
            }

            // SeasonSprites
            foreach (ClickableTextureComponent sprite in seasonSprites)
            {
                sprite.draw(b);
            }

            // PrevButton, NextButton, ScryButton
            foreach (ClickableTextureComponent button in otherButtons)
            {
                button.draw(b);
            }

            // SeasonDebris
            foreach (WeatherDebris debris in seasonDebris)
            {
                debris.draw(b);
            }

            // DaySparkles
            foreach (TemporaryAnimatedSprite sparkle in daySparkles)
            {
                sparkle.draw(b, true);
            }

            // hover text
            if (hoverText != null)
            {
                drawHoverText(b, hoverText, Game1.smallFont);
            }

            // mouse cursor
            if (!Game1.options.hardwareCursor)
            {
                drawMouse(b);
            }
        }