Beispiel #1
0
        public void ResetLoadButtons()
        {
            LoadGameMenu menu             = stardewMenu as LoadGameMenu;
            int          currentItemIndex = ModEntry.GetHelper().Reflection.GetField <int>(menu, "currentItemIndex").GetValue();

            ClearItems();

            string ShortDescr(int idx)
            {
                StardewValley.Farmer farmer = (menuSlots[idx] as LoadGameMenu.SaveFileSlot).Farmer;
                return($"slot {idx + 1}: {farmer.Name} on {farmer.farmName} farm");
            }

            string LongDescr(int idx)
            {
                StardewValley.Farmer farmer = (menuSlots[idx] as LoadGameMenu.SaveFileSlot).Farmer;
                string season = "";

                switch (farmer.seasonForSaveGame)
                {
                case 0: season = "spring"; break;

                case 1: season = "summer"; break;

                case 2: season = "fall"; break;

                case 3: season = "winter"; break;

                default: season = ""; break;
                }
                string timePlayed = StardewValley.Utility.getHoursMinutesStringFromMilliseconds(farmer.millisecondsPlayed);

                return($"Day {farmer.dayOfMonthForSaveGame} of {season} in year {farmer.yearForSaveGame}. Playtime {timePlayed}. Press delete button to delete.");
            }

            for (int j = 0; j < System.Math.Min(itemCount, LoadGameMenu.itemsPerPage); j++)
            {
                MenuItem menuItem = MenuItem.MenuItemFromComponent(menu.slotButtons[j], menu, ShortDescr(j));
                menuItem.Description  = LongDescr(j);
                menuItem.TextOnAction = "Loading " + ShortDescr(j);
                AddItem(menuItem);
            }

            for (int j = LoadGameMenu.itemsPerPage; j < itemCount; j++)
            {
                MenuItem menuItem = MenuItem.MenuItemFromComponent(menu.slotButtons[LoadGameMenu.itemsPerPage - 1], menu, ShortDescr(j));
                menuItem.Description  = LongDescr(j);
                menuItem.TextOnAction = "Loading " + ShortDescr(j);
                AddItem(menuItem);
            }

            backButton              = MenuItem.MenuItemFromComponent(menu.backButton, StardewValley.Game1.activeClickableMenu);
            backButton.Label        = "back to title";
            backButton.TextOnAction = AccessTitleMenu.Title();
            AddItem(backButton);
        }
        public AccessLanguageMenu(LanguageSelectionMenu menu, TitleMenu titleMenu) : base(menu)
        {
            foreach (ClickableComponent comp in menu.languages)
            {
                AddItem(MenuItem.MenuItemFromComponent(comp, menu));
            }
            MenuItem menuItem = MenuItem.MenuItemFromComponent(titleMenu.backButton, StardewValley.Game1.activeClickableMenu);

            menuItem.Label        = "back to title";
            menuItem.TextOnAction = AccessTitleMenu.Title();
            AddItem(menuItem);
        }
Beispiel #3
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);
        }