public override void performHoverAction(int x, int y)
        {
            okButton.tryHover(x, y);
            for (int i = 0; i < optionSlots.Count; i++)
            {
                if (currentItemIndex >= 0 && currentItemIndex + i < options.Count && options[currentItemIndex + i].bounds.Contains(x - optionSlots[i].bounds.X, y - optionSlots[i].bounds.Y))
                {
                    Game1.SetFreeCursorDrag();
                    break;
                }
            }
            if (scrollBarBounds.Contains(x, y))
            {
                Game1.SetFreeCursorDrag();
            }
            if (GameMenu.forcePreventClose)
            {
                return;
            }
            hoverText = "";
            int hovered_index = -1;

            if (!IsDropdownActive())
            {
                for (int j = 0; j < optionSlots.Count; j++)
                {
                    if (optionSlots[j].containsPoint(x, y) && j + currentItemIndex < options.Count && hoverText == "")
                    {
                        hovered_index = j + currentItemIndex;
                    }
                }
            }
            if (_lastHoveredIndex != hovered_index)
            {
                _lastHoveredIndex = hovered_index;
                _hoverDuration    = 0;
            }
            else
            {
                _hoverDuration += (int)Game1.currentGameTime.ElapsedGameTime.TotalMilliseconds;
            }
            if (_lastHoveredIndex >= 0 && _hoverDuration >= 500)
            {
                OptionsElement option = options[_lastHoveredIndex];
                if (tooltips.ContainsKey(option))
                {
                    hoverText = tooltips[option];
                }
            }
            upArrow.tryHover(x, y);
            downArrow.tryHover(x, y);
            scrollBar.tryHover(x, y);
            _ = scrolling;
        }
Exemple #2
0
        public OptionsPage(int x, int y, int width, int height)
            : base(x, y, width, height)
        {
            upArrow         = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + width + 16, yPositionOnScreen + 64, 44, 48), Game1.mouseCursors, new Rectangle(421, 459, 11, 12), 4f);
            downArrow       = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + width + 16, yPositionOnScreen + height - 64, 44, 48), Game1.mouseCursors, new Rectangle(421, 472, 11, 12), 4f);
            scrollBar       = new ClickableTextureComponent(new Rectangle(upArrow.bounds.X + 12, upArrow.bounds.Y + upArrow.bounds.Height + 4, 24, 40), Game1.mouseCursors, new Rectangle(435, 463, 6, 10), 4f);
            scrollBarRunner = new Rectangle(scrollBar.bounds.X, upArrow.bounds.Y + upArrow.bounds.Height + 4, scrollBar.bounds.Width, height - 128 - upArrow.bounds.Height - 8);
            for (int i = 0; i < 7; i++)
            {
                optionSlots.Add(new ClickableComponent(new Rectangle(xPositionOnScreen + 16, yPositionOnScreen + 80 + 4 + i * ((height - 128) / 7) + 16, width - 32, (height - 128) / 7 + 4), string.Concat(i))
                {
                    myID           = i,
                    downNeighborID = ((i < 6) ? (i + 1) : (-7777)),
                    upNeighborID   = ((i > 0) ? (i - 1) : (-7777)),
                    fullyImmutable = true
                });
            }
            options.Add(new OptionsElement(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11233")));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11234"), 0));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11235"), 7));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11236"), 8));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11237"), 11));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11238"), 12));
            if (Game1.game1.IsMainInstance)
            {
                options.Add(new OptionsDropDown(Game1.content.LoadString("Strings\\UI:Options_GamepadMode"), 38));
            }
            options.Add(new OptionsDropDown(Game1.content.LoadString("Strings\\UI:Options_StowingMode"), 28));
            options.Add(new OptionsDropDown(Game1.content.LoadString("Strings\\UI:Options_SlingshotMode"), 41));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11239"), 27));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11240"), 14));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\UI:Options_GamepadStyleMenus"), 29));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\UI:Options_ShowAdvancedCraftingInformation"), 34));
            bool show_local_coop_options = false;

            if (Game1.game1.IsMainInstance && Game1.game1.IsLocalCoopJoinable())
            {
                show_local_coop_options = true;
            }
            if (Game1.multiplayerMode == 2 || show_local_coop_options)
            {
                options.Add(new OptionsElement(Game1.content.LoadString("Strings\\UI:OptionsPage_MultiplayerSection")));
            }
            if (Game1.multiplayerMode == 2 && Game1.server != null && !Game1.server.IsLocalMultiplayerInitiatedServer())
            {
                options.Add(new OptionsDropDown(Game1.content.LoadString("Strings\\UI:GameMenu_ServerMode"), 31));
                options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\UI:OptionsPage_IPConnections"), 30));
                options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\UI:OptionsPage_FarmhandCreation"), 32));
            }
            if (Game1.multiplayerMode == 2 && Game1.server != null)
            {
                options.Add(new OptionsDropDown(Game1.content.LoadString("Strings\\UI:GameMenu_MoveBuildingPermissions"), 40));
            }
            if (Game1.multiplayerMode == 2 && Game1.server != null && !Game1.server.IsLocalMultiplayerInitiatedServer() && Program.sdk.Networking != null)
            {
                options.Add(new OptionsButton(Game1.content.LoadString("Strings\\UI:GameMenu_ServerInvite"), delegate
                {
                    offerInvite();
                }));
                if (Program.sdk.Networking.SupportsInviteCodes())
                {
                    options.Add(new OptionsButton(Game1.content.LoadString("Strings\\UI:OptionsPage_ShowInviteCode"), delegate
                    {
                        showInviteCode();
                    }));
                }
            }
            if (show_local_coop_options)
            {
                options.Add(new OptionsButton(Game1.content.LoadString("Strings\\UI:StartLocalMulti"), delegate
                {
                    exitThisMenu(playSound: false);
                    Game1.game1.ShowLocalCoopJoinMenu();
                }));
            }
            if (Game1.IsMultiplayer)
            {
                options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\UI:OptionsPage_ShowReadyStatus"), 35));
            }
            options.Add(new OptionsElement(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11241")));
            if (Game1.game1.IsMainInstance)
            {
                options.Add(new OptionsSlider(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11242"), 1));
                options.Add(new OptionsSlider(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11243"), 2));
                options.Add(new OptionsSlider(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11244"), 20));
                options.Add(new OptionsSlider(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11245"), 21));
            }
            options.Add(new OptionsDropDown(Game1.content.LoadString("Strings\\StringsFromCSFiles:BiteChime"), 42));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11246"), 3));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:Options_ToggleAnimalSounds"), 43));
            options.Add(new OptionsElement(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11247")));
            if (!Game1.conventionMode && Game1.game1.IsMainInstance)
            {
                options.Add(new OptionsDropDown(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11248"), 13));
                options.Add(new OptionsDropDown(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11251"), 6));
            }
            if (Game1.game1.IsMainInstance)
            {
                options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\UI:Options_Vsync"), 37));
            }
            List <string> zoom_options = new List <string>();

            for (int zoom2 = 75; zoom2 <= 150; zoom2 += 5)
            {
                zoom_options.Add(zoom2 + "%");
            }
            options.Add(new OptionsPlusMinus(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage_UIScale"), 39, zoom_options, zoom_options));
            zoom_options = new List <string>();
            for (int zoom = 75; zoom <= 200; zoom += 5)
            {
                zoom_options.Add(zoom + "%");
            }
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11252"), 9));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11253"), 15));
            options.Add(new OptionsPlusMinus(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11254"), 18, zoom_options, zoom_options));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11266"), 19));
            if (Game1.game1.IsMainInstance)
            {
                options.Add(new OptionsPlusMinus(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11267"), 25, new List <string>
                {
                    "Low",
                    "Med.",
                    "High"
                }, new List <string>
                {
                    Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11268"),
                    Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11269"),
                    Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11270")
                }));
            }
            options.Add(new OptionsSlider(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11271"), 23));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11272"), 24));
            if (!LocalMultiplayer.IsLocalMultiplayer())
            {
                options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11273"), 26));
            }
            options.Add(new OptionsElement(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11274")));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11275"), 16));
            options.Add(new OptionsCheckbox(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11276"), 22));
            if (Game1.game1.IsMainInstance)
            {
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11277"), -1, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11278"), 7, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11279"), 10, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11280"), 15, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11281"), 18, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11282"), 19, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11283"), 11, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11284"), 14, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11285"), 13, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11286"), 12, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11287"), 17, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\UI:Input_EmoteButton"), 33, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11288"), 16, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.toolbarSwap"), 32, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11289"), 20, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11290"), 21, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11291"), 22, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11292"), 23, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11293"), 24, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11294"), 25, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11295"), 26, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11296"), 27, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11297"), 28, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11298"), 29, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11299"), 30, optionSlots[0].bounds.Width));
                options.Add(new OptionsInputListener(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11300"), 31, optionSlots[0].bounds.Width));
            }
            if (!Game1.game1.CanTakeScreenshots())
            {
                return;
            }
            options.Add(new OptionsElement(Game1.content.LoadString("Strings\\UI:OptionsPage_ScreenshotHeader")));
            int index = options.Count;

            if (!Game1.game1.CanZoomScreenshots())
            {
                Action action = delegate
                {
                    OptionsElement e = options[index];
                    Game1.flashAlpha = 1f;
                    Console.WriteLine("{0}.greyedOut = {1}", e.label, true);
                    e.greyedOut = true;
                    Action onDone = delegate
                    {
                        Console.WriteLine("{0}.greyedOut = {1}", e.label, false);
                        e.greyedOut = false;
                    };
                    string text2 = Game1.game1.takeMapScreenshot(null, null, onDone);
                    if (text2 != null)
                    {
                        Game1.addHUDMessage(new HUDMessage(text2, 6));
                    }
                    Game1.playSound("cameraNoise");
                };
                OptionsButton btn = new OptionsButton(Game1.content.LoadString("Strings\\UI:OptionsPage_ScreenshotHeader").Replace(":", ""), action);
                if (Game1.game1.ScreenshotBusy)
                {
                    btn.greyedOut = true;
                }
                options.Add(btn);
            }
            else
            {
                options.Add(new OptionsPlusMinusButton(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11254"), 36, new List <string>
                {
                    "25%",
                    "50%",
                    "75%",
                    "100%"
                }, new List <string>
                {
                    "25%",
                    "50%",
                    "75%",
                    "100%"
                }, Game1.mouseCursors2, new Rectangle(72, 31, 18, 16), delegate(string selection)
                {
                    Game1.flashAlpha = 1f;
                    selection        = selection.Substring(0, selection.Length - 1);
                    int result       = 25;
                    if (!int.TryParse(selection, out result))
                    {
                        result = 25;
                    }
                    string text = Game1.game1.takeMapScreenshot((float)result / 100f, null, null);
                    if (text != null)
                    {
                        Game1.addHUDMessage(new HUDMessage(text, 6));
                    }
                    Game1.playSound("cameraNoise");
                }));
            }
            if (Game1.game1.CanBrowseScreenshots())
            {
                options.Add(new OptionsButton(Game1.content.LoadString("Strings\\UI:OptionsPage_OpenFolder"), delegate
                {
                    Game1.game1.BrowseScreenshots();
                }));
            }
        }