Exemple #1
0
        public DataLoader(IModHelper modHelper)
        {
            Helper    = modHelper;
            I18N      = modHelper.Translation;
            ModConfig = Helper.ReadConfig <ModConfig>();

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.DeliveryQuestsInfo"
                    , I18N.Get("Shipment.Quest.DeliveryQuestsLetter")
                    , (l) => !DataLoader.ModConfig.DisableQuestService && !Game1.player.mailReceived.Contains(l.Id) && SDate.Now() >= new SDate(2, "spring", 1)
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
            {
                Title = I18N.Get("Shipment.Quest.DeliveryQuestsLetter.Title")
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.ToolUpgradeInfo"
                    , I18N.Get("Shipment.Clint.UpgradeLetter")
                    , (l) => !DataLoader.ModConfig.DisableToolShipmentService && !Game1.player.mailReceived.Contains(l.Id) && SDate.Now() >= new SDate(6, "spring", 1)
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
            {
                Title = I18N.Get("Shipment.Clint.UpgradeLetter.Title")
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.GiftShipmentInfo"
                    , I18N.Get("Shipment.Wizard.GiftShipmentLetter")
                    , (l) => !DataLoader.ModConfig.DisableGiftService && !Game1.player.mailReceived.Contains(l.Id) && Game1.player.eventsSeen.Contains(112)
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
            {
                Title   = I18N.Get("Shipment.Wizard.GiftShipmentLetter.Title"),
                WhichBG = 2
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServiceMod.MarlonRecoveryReward"
                    , I18N.Get("Delivery.Marlon.RecoveryRewardLetter")
                    , (l) => !Game1.player.mailReceived.Contains(l.Id) && Game1.player.hasCompletedAllMonsterSlayerQuests.Value && !GetRecoveryConfig(Game1.player).DisableRecoveryConfigInGameChanges
                    , (l) =>
            {
                Game1.player.mailReceived.Add(l.Id);
                SaveRecoveryConfig(Game1.player, true, true, true);
            }
                    )
            {
                Title   = I18N.Get("Delivery.Marlon.RecoveryRewardLetter.Title"),
                GroupId = "MailServicesMod.GuildRecovery"
            }
                );

            MailDao.SaveLetter(
                new Letter(
                    "MailServicesMod.MarlonRecoveryOffer"
                    , I18N.Get("Delivery.Marlon.RecoveryOfferLetter")
                    , (l) => !Game1.player.mailReceived.Contains(l.Id) && !Game1.player.mailReceived.Contains("MailServiceMod.MarlonRecoveryReward") && Game1.player.mailReceived.Contains("guildMember") && !DataLoader.GetRecoveryConfig(Game1.player).EnableRecoveryService&& !GetRecoveryConfig(Game1.player).DisableRecoveryConfigInGameChanges
                    , (l) =>
            {
                Game1.player.mailReceived.Add(l.Id);
                GuildRecoveryController.OpenOfferDialog();
            }
                    )
            {
                Title   = I18N.Get("Delivery.Marlon.RecoveryOfferLetter.Title"),
                GroupId = "MailServicesMod.GuildRecovery"
            }
                );

            Letter upgradeLetter = new Letter(
                ToolUpgradeMailId
                , I18N.Get("Delivery.Clint.UpgradeLetter")
                , (l) => !DataLoader.ModConfig.DisableToolDeliveryService && Game1.player.toolBeingUpgraded.Value != null && Game1.player.daysLeftForToolUpgrade.Value <= 0
                , (l) =>
            {
                if (!Game1.player.mailReceived.Contains(l.Id))
                {
                    Game1.player.mailReceived.Add(l.Id);
                }
                if (Game1.player.toolBeingUpgraded.Value != null)
                {
                    Tool tool = Game1.player.toolBeingUpgraded.Value;
                    Game1.player.toolBeingUpgraded.Value          = null;
                    Game1.player.hasReceivedToolUpgradeMessageYet = false;
                    Game1.player.holdUpItemThenMessage(tool);
                    if (tool is GenericTool)
                    {
                        tool.actionWhenClaimed();
                    }
                    if (Game1.player.team.useSeparateWallets.Value && tool.UpgradeLevel == 4)
                    {
                        Multiplayer multiplayer = Helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue();
                        multiplayer.globalChatInfoMessage("IridiumToolUpgrade", Game1.player.Name, tool.DisplayName);
                    }
                }
            }
                )
            {
                Title        = I18N.Get("Delivery.Clint.UpgradeLetter.Title"),
                DynamicItems = (l) => Game1.player.toolBeingUpgraded.Value != null ? new List <Item> {
                    Game1.player.toolBeingUpgraded.Value
                } : new List <Item>()
            };

            MailDao.SaveLetter(upgradeLetter);

            Letter recoveryLetter = new Letter(
                ItemRecoveryMailId
                , I18N.Get("Delivery.Marlon.RecoveryLetter")
                , (l) => GetRecoveryConfig(Game1.player).EnableRecoveryService&& GuildRecoveryController.GetItemsToRecover()?.Count > 0
                , (l) =>
            {
                if (!Game1.player.mailReceived.Contains(l.Id))
                {
                    Game1.player.mailReceived.Add(l.Id);
                }
                GuildRecoveryController.ItemsRecovered();
            }
                )
            {
                Title        = I18N.Get("Delivery.Marlon.RecoveryLetter.Title"),
                DynamicItems = (l) => GuildRecoveryController.GetItemsToRecover()
            };

            MailDao.SaveLetter(recoveryLetter);
        }
Exemple #2
0
        /*********
        ** Public methods
        *********/
        public PlannerMenu(MenuTab tabIndex, ModConfig config, Planner planner, 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.Planner           = planner;
            this.TranslationHelper = i18n;
            this.CheckList         = new CheckList();

            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.Daily.ToString(), i18n.Get("tabs.daily")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Checklist.ToString(), i18n.Get("tabs.checklist")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Weekly.ToString(), i18n.Get("tabs.weekly")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Monthly.ToString(), i18n.Get("tabs.monthly")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(labelX, labelY + labelHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Add.ToString(), i18n.Get("tabs.add")));
            }

            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 < PlannerMenu.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) / PlannerMenu.ItemsPerPage), this.width - Game1.tileSize / 2, (this.height - Game1.tileSize * 2) / PlannerMenu.ItemsPerPage + Game1.pixelZoom), string.Concat(i)));
            }

            int slotWidth = this.OptionSlots[0].bounds.Width;

            switch (this.CurrentTab)
            {
            case MenuTab.Daily:
                this.Options.Add(new OptionsElement(Game1.Date.ToString() + ":"));
                //this.Options.Add(new OptionsElement(this.Planner.ToString()));
                foreach (string task in this.Planner.GetDailyPlan())
                {
                    this.Options.Add(new DailyPlannerInputListener(task, slotWidth, this.Planner, this));
                }
                break;

            case MenuTab.Checklist:
                // TODO: Add checklist tab
                foreach (string task in this.CheckList.GetCheckListItems())
                {
                    this.Options.Add(new DailyPlannerInputListener(task, slotWidth, this.CheckList, this));
                }
                break;

            case MenuTab.Weekly:
                foreach (string line in this.Planner.CreateWeekList())
                {
                    this.Options.Add(new OptionsElement(line));
                }
                break;

            case MenuTab.Monthly:
                foreach (string line in this.Planner.CreateMonthList())
                {
                    this.Options.Add(new OptionsElement(line));
                }
                break;

            case MenuTab.Add:
                // TODO: Create "Add" Tab
                this.Options.Add(new OptionsElement("In-game task adding will"));
                this.Options.Add(new OptionsElement("come in a future update!"));
                break;
            }
            this.SetScrollBarToCurrentIndex();
        }
        private string GetFestivalName(ITranslationHelper Trans)
        {
            var season = Game1.currentSeason;
            var day    = Game1.dayOfMonth;

            switch (season)
            {
            case "spring":
                if (day == 13)
                {
                    return(Trans.Get("EggFestival"));
                }
                if (day == 24)
                {
                    return(Trans.Get("FlowerDance"));
                }
                break;

            case "summer":
                if (day == 11)
                {
                    return(Trans.Get("Luau"));
                }
                if (day == 28)
                {
                    return(Trans.Get("MoonlightJellies"));
                }
                break;

            case "fall":
                if (day == 16)
                {
                    return(Trans.Get("ValleyFair"));
                }
                if (day == 27)
                {
                    return(Trans.Get("SpiritsEve"));
                }
                break;

            case "winter":
                if (day == 8)
                {
                    return(Trans.Get("IceFestival"));
                }
                if (day == 14)
                {
                    return(Trans.Get("NightFestival"));
                }
                if (day == 15)
                {
                    return(Trans.Get("NightFestival"));
                }
                if (day == 16)
                {
                    return(Trans.Get("NightFestival"));
                }
                if (day == 25)
                {
                    return(Trans.Get("WinterStar"));
                }
                break;

            default:
                break;
            }
            return(Trans.Get("festival"));
        }
Exemple #4
0
        public static CustomEvent CreateEvent(SDate contestDate)
        {
            int    eventId = GetEventId(contestDate);
            string key     = GenerateKey(eventId, contestDate);

            Random random = new Random((int)((long)Game1.uniqueIDForThisGame * 100000 + contestDate.Year * 1000 + Utility.getSeasonNumber(contestDate.Season) * 100 + contestDate.Day));

            //Player and Participant init
            long?        contestParticipantId    = AnimalContestController.ContestParticipantId(contestDate);
            AnimalStatus participantAnimalStatus = contestParticipantId != null?AnimalStatusController.GetAnimalStatus((long)contestParticipantId) : null;

            bool       isPlayerJustWatching = participantAnimalStatus == null;
            bool       isParticipantPet     = !isPlayerJustWatching && participantAnimalStatus.Id == AnimalData.PetId;
            FarmAnimal farmAnimal           = null;

            if (isParticipantPet)
            {
                AnimalContestController.TemporalyRemovePet();
            }
            else if (!isPlayerJustWatching)
            {
                farmAnimal = AnimalContestController.GetAnimal(participantAnimalStatus.Id);
                if (farmAnimal == null)
                {
                    isPlayerJustWatching = true;
                }
                else
                {
                    AnimalContestController.TemporalyRemoveFarmAnimal(farmAnimal);
                }
            }

            List <AnimalContestItem> history = FarmerLoader.FarmerData.AnimalContestData;

            string[] contenders = new string[3];
            contenders[0] = "Marnie";
            contenders[1] = GetContenderFromPool(new List <IAnimalContestAct>(PossibleSecondContenders).Where(c => !isPlayerJustWatching || !c.NpcName.Equals("Jas")).ToList(), history) ?? "Maru";
            contenders[2] = GetContenderFromPool(new List <IAnimalContestAct>(PossibleThirdContenders), history) ?? "Jodi";

            string        marnieAnimal  = MarnieAct.ChooseMarnieAnimal(random, history);
            VincentAnimal vincentAnimal = VincentAct.ChooseVincentAnimal(random, history);

            AnimalContestItem animalContestInfo = new AnimalContestItem(eventId, contestDate, contenders.ToList(), vincentAnimal.ToString(), marnieAnimal)
            {
                ParticipantId = isParticipantPet ? AnimalData.PetId : farmAnimal?.myID.Value,
                PlayerAnimal  = isParticipantPet ? Game1.player.catPerson ? "Cat" : "Dog" : farmAnimal?.type.Value
            };

            animalContestInfo = PickTheWinner(animalContestInfo, history, participantAnimalStatus, farmAnimal, contenders[2]);

            // Deciding who will be present
            bool isHaleyWatching     = Game1.player.eventsSeen.Contains(14) || Game1.player.spouse == "Haley";
            bool isKentWatching      = Game1.year > 1 && contenders.Contains("Jodi");
            bool isSebastianWatching = Game1.player.spouse != "Sebastian" && (vincentAnimal == VincentAnimal.Frog || contenders.Contains("Abigail"));
            bool isPennyWatching     = Game1.player.spouse != "Penny" && !isSebastianWatching && (contenders.Contains("Maru") || contenders.Contains("Jas") || isPlayerJustWatching || Game1.player.getFriendshipHeartLevelForNPC("Penny") >= 4);
            bool isDemetriusWatching = contenders.Contains("Maru");
            bool isClintWatching     = contenders.Contains("Emily");
            bool isLeahWatching      = Game1.player.spouse != "Leah" && Game1.player.eventsSeen.Contains(53);
            bool isLinusWatching     = !contenders.Contains("Linus") && (Game1.player.eventsSeen.Contains(26) || vincentAnimal == VincentAnimal.Rabbit);
            bool isShaneWatching     = !contenders.Contains("Shane") && (contenders.Contains("Jas") || isPlayerJustWatching || Game1.player.eventsSeen.Contains(3900074) || Game1.player.spouse == "Shane");

            StringBuilder initialPosition = new StringBuilder();

            initialPosition.Append("none/-100 -100");
            if (!isPlayerJustWatching)
            {
                initialPosition.Append("/farmer 27 62 2");
            }
            else
            {
                if (IsWatchingPositionNorthEast(animalContestInfo))
                {
                    initialPosition.Append("/farmer 37 62 2");
                }
                else
                {
                    initialPosition.Append($"/farmer 28 70 {(IsWatchingPositionSouthEest(animalContestInfo)?"1":"3")}");
                }
            }

            initialPosition.Append(" Lewis 28 63 2");
            initialPosition.Append($" {contenders[0]} 24 66 3");
            initialPosition.Append($" {contenders[1]} 30 66 1");
            initialPosition.Append($" {contenders[2]} 33 66 1");
            if (isKentWatching)
            {
                initialPosition.Append($" Kent 36 66 3");
            }

            if (!contenders.Contains("Jodi"))
            {
                initialPosition.Append($" Jodi 36 65 3");
            }
            initialPosition.Append($" Sam 37 66 3");
            initialPosition.Append($" Gus 36 68 3");
            initialPosition.Append($" Evelyn 30 69 1");
            initialPosition.Append($" George 31 69 0");
            if (!contenders.Contains("Alex"))
            {
                initialPosition.Append($" Alex 31 70 0");
            }
            initialPosition.Append($" Pierre 26 69 1");
            initialPosition.Append($" Caroline 27 69 3");
            if (Game1.player.spouse != "Elliott")
            {
                initialPosition.Append($" Elliott 33 69 0");
            }
            if (!contenders.Contains("Willy"))
            {
                initialPosition.Append($" Willy 35 69 0");
            }
            if (isHaleyWatching)
            {
                initialPosition.Append($" Haley 22 68 1");
            }
            if (isLeahWatching)
            {
                initialPosition.Append($" Leah 22 70 0");
            }
            if (isSebastianWatching)
            {
                initialPosition.Append($" Sebastian 37 67 3");
            }
            else if (isPennyWatching)
            {
                initialPosition.Append($" Penny 37 67 3");
            }
            if (isDemetriusWatching)
            {
                initialPosition.Append($" Demetrius 32 70 0");
            }
            if (isClintWatching)
            {
                initialPosition.Append($" Clint 34 70 0");
            }
            if (isPlayerJustWatching)
            {
                initialPosition.Append($" Jas 27 66 0");
            }
            else if (!contenders.Contains("Jas"))
            {
                initialPosition.Append($" Jas 23 70 0");
            }
            if (isShaneWatching)
            {
                initialPosition.Append($" Shane 24 70 0");
            }

            bool linusAlternateAnimal = false;

            if (isLinusWatching)
            {
                initialPosition.Append($" Linus 37 70 3");
            }
            else
            {
                linusAlternateAnimal = history.Count(h => h.Contenders.Contains("Linus")) % 2 == new Random((int)Game1.uniqueIDForThisGame).Next(2);
            }

            if (Game1.player.spouse != null && !new string[] { "Shane", "Alex", "Sam", "Haley" }.Contains(Game1.player.spouse) &&
                !animalContestInfo.Contenders.Contains(Game1.player.spouse))
            {
                initialPosition.Append($" {Game1.player.spouse} 25 69 0");
            }

            initialPosition.Append($" Vincent 28 80 0");

            if (isParticipantPet)
            {
                if (!Game1.player.catPerson)
                {
                    initialPosition.Append(" dog 26 66 2/showFrame Dog 23");
                }
                else
                {
                    initialPosition.Append(" cat 26 66 2/positionOffset Cat -8 0/showFrame Cat 18");
                }
            }
            else
            {
                if (!isPlayerJustWatching)
                {
                    string spriteTextureName = farmAnimal.Sprite.textureName.Value;
                    string playerAnimalTextureName;
                    if (spriteTextureName.StartsWith("Animals\\"))
                    {
                        playerAnimalTextureName = farmAnimal.Sprite.textureName.Value
                                                  .Substring(farmAnimal.Sprite.textureName.Value.IndexOf('\\') + 1)
                                                  .Replace(' ', '_');
                    }
                    else
                    {
                        DataLoader.AssetsToLoad["Animals\\" + spriteTextureName.Replace('_', ' ')] = farmAnimal.Sprite.Texture;
                        playerAnimalTextureName = spriteTextureName.Replace(' ', '_');;
                    }
                    bool isPlayerAnimalSmall = IsAnimalSmall(farmAnimal);
                    initialPosition.Append($"/addTemporaryActor {playerAnimalTextureName} {(isPlayerAnimalSmall? SmallSize : BigSize)} {(isPlayerAnimalSmall?26:25)} 66 0 false Animal participant/showFrame participant 0");
                    if (!isPlayerAnimalSmall)
                    {
                        initialPosition.Append("/positionOffset participant 5 0");
                    }
                }
            }
            initialPosition.Append("/specificTemporarySprite animalContest/skippable");
            initialPosition.Append(GetContendersAnimalPosition(contenders, marnieAnimal, isPlayerJustWatching, linusAlternateAnimal));

            initialPosition.Append("/viewport 28 65 true");

            StringBuilder eventAction = new StringBuilder();

            if (isHaleyWatching)
            {
                eventAction.Append("/showFrame Haley 25");
            }
            if (contenders.Contains("Maru"))
            {
                eventAction.Append("/animate Maru false false 130 16 16 16 16 16 17 18 19 20 21 22 23 23 23 23");
            }
            string faceDirectionPlayerPosition;

            if (!isPlayerJustWatching)
            {
                faceDirectionPlayerPosition = "farmer";
                eventAction.Append("/move farmer 0 4 2/faceDirection farmer 3");
                if (isParticipantPet)
                {
                    eventAction.Append($"/playSound {(Game1.player.catPerson ? "cat" : "dog_bark")}");
                }
                eventAction.Append("/emote farmer 32");
                //eventAction.Append($"/emote {(isParticipantPet?!Game1.player.catPerson? "Dog":"Cat": "participant")} 20");
            }
            else
            {
                faceDirectionPlayerPosition = "Jas";
                if (IsWatchingPositionNorthEast(animalContestInfo))
                {
                    eventAction.Append("/move farmer 0 3 2/faceDirection farmer 3");
                }
                else if (IsWatchingPositionSouthEest(animalContestInfo))
                {
                    eventAction.Append("/move farmer 2 0 1/faceDirection farmer 0");
                }
                else
                {
                    eventAction.Append("/move farmer -3 0 3/faceDirection farmer 0");
                }
                if (Game1.player.spouse != null)
                {
                    eventAction.Append($"/emote {Game1.player.spouse} 20 true/emote farmer 20");
                }
            }

            if (isHaleyWatching)
            {
                eventAction.Append("/pause 200/playSound cameraNoise/shake Haley 50/screenFlash .5/pause 1000/showFrame Haley 5/pause 1000");
            }
            if (!isPlayerJustWatching)
            {
                eventAction.Append("/faceDirection farmer 0");
                eventAction.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.PlayerParticipant")}\"");
            }
            else
            {
                eventAction.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.PlayerWatching")}\"");
            }
            eventAction.Append($"/faceDirection {contenders[0]} 0");
            eventAction.Append($"/pause 1000/emote Lewis 40/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.Attention")}\"");

            eventAction.Append($"/pause 100/faceDirection {contenders[1]} 0 true");
            eventAction.Append($"/faceDirection Pierre 0");
            eventAction.Append($"/faceDirection {contenders[2]} 0 true");
            eventAction.Append($"/faceDirection Evelyn 0 true");
            if (!contenders.Contains("Willy"))
            {
                initialPosition.Append($"/faceDirection Willy 3");
            }
            eventAction.Append($"/faceDirection Caroline 0");

            if (history.Count == 0)
            {
                eventAction.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.IntroductionFirstTime")}\"");
            }
            else
            {
                eventAction.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.IntroductionOtherTimes")}\"");
            }

            eventAction.Append(new VincentAct().GetAct(animalContestInfo, history));

            eventAction.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.ContestExplanation")}\"");
            eventAction.Append($"/faceDirection {contenders[2]} 3 true");
            eventAction.Append("/move Lewis 0 1 2");
            eventAction.Append($"/faceDirection {contenders[0]} 3 true");
            eventAction.Append("/move Lewis 0 1 2");
            eventAction.Append($"/faceDirection {faceDirectionPlayerPosition} 3 true");
            eventAction.Append($"/faceDirection {contenders[1]} 3 true");
            eventAction.Append("/move Lewis 0 2 2");
            eventAction.Append("/move Lewis -5 0 3/faceDirection Lewis 0");
            eventAction.Append(new MarnieAct().GetAct(animalContestInfo, history));
            eventAction.Append($"/faceDirection Lewis 1/move Lewis 1 0 1/faceDirection {contenders[0]} 2 true/move Lewis 2 0 1/faceDirection {contenders[0]} 1 true/faceDirection Lewis 0");
            if (!isPlayerJustWatching)
            {
                eventAction.Append(GetPlayerAct(animalContestInfo, farmAnimal, history));
            }
            else
            {
                eventAction.Append(JasAct.GetAct(animalContestInfo, history));
            }
            eventAction.Append($"/faceDirection Lewis 1/move Lewis 1 0 1/faceDirection {faceDirectionPlayerPosition} 2 true/move Lewis 1 0 1/faceDirection {faceDirectionPlayerPosition} 1 true/move Lewis 1 0 1/faceDirection {contenders[1]} 2 true/move Lewis 2 0 1/faceDirection {contenders[1]} 1 true/faceDirection Lewis 0");
            eventAction.Append(PossibleSecondContenders.First(c => c.NpcName.Equals(contenders[1])).GetAct(animalContestInfo, history));
            eventAction.Append($"/faceDirection Lewis 1/move Lewis 1 0 1/faceDirection {contenders[2]} 2 true/move Lewis 2 0 1/faceDirection {contenders[2]} 1 true/faceDirection Lewis 0");
            eventAction.Append(PossibleThirdContenders.First(c => c.NpcName.Equals(contenders[2])).GetAct(animalContestInfo, history));
            eventAction.Append($"/playMusic event1/faceDirection Lewis 3/faceDirection Lewis 2/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.Closure")}\"");
            eventAction.Append($"/faceDirection Lewis 3/move Lewis -6 0 3/faceDirection Lewis 0/move Lewis 0 -4 0/faceDirection {contenders[1]} 0 true/faceDirection {contenders[0]} 0 true/faceDirection Lewis 3/faceDirection {contenders[2]} 0 true/faceDirection {faceDirectionPlayerPosition} 0 true/faceDirection Lewis 2");

            eventAction.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.ClosureThanks")}#$b#");
            if (history.Count == 0)
            {
                eventAction.Append($"{i18n.Get("AnimalContest.Dialog.Lewis.ClosureSuccessFirstTime")}\"");
            }
            else
            {
                eventAction.Append($"{i18n.Get("AnimalContest.Dialog.Lewis.ClosureSuccessOtherTimes")}\"");
            }
            String winnerAnimalName = animalContestInfo.Winner == "Farmer"
                ? farmAnimal.displayName
                : animalContestInfo.Winner == "Emily"
                    ? i18n.Get("AnimalContest.Dialog.Lewis.EmilyUnnamedParrot")
                    : "%name";
            String winnerName = animalContestInfo.Winner == "Farmer"?"@":animalContestInfo.Winner;

            eventAction.Append($"/stopMusic/pause 200/speak Lewis \"{ i18n.Get("AnimalContest.Dialog.Lewis.WinnerAnnouncement", new {winnerName, winnerAnimalName})}\"");
            eventAction.Append("/playMusic event1/emote Alex 56 true/pause 60");
            if (animalContestInfo.Winner == "Farmer")
            {
                eventAction.Append("/emote farmer 32 true/pause 500");
                if (Game1.player.spouse != null)
                {
                    eventAction.Append($"/textAboveHead {Game1.player.spouse} \"{i18n.Get("AnimalContest.Dialog.Spouse.PlayerCongrats")}\"/pause 1500");
                }
                if (Game1.player.getFriendshipHeartLevelForNPC("Gus") >= 4)
                {
                    eventAction.Append($"/textAboveHead Gus \"{i18n.Get("AnimalContest.Dialog.Gus.PlayerCongrats", new { playerName = Game1.player.Name })}\"/pause 1500");
                }
                else if (Game1.player.spouse != null)
                {
                    eventAction.Append($"/pause 1500");
                }
                if (Game1.player.getFriendshipHeartLevelForNPC("Pierre") >= 4)
                {
                    eventAction.Append($"/textAboveHead Pierre \"{i18n.Get("AnimalContest.Dialog.Pierre.PlayerCongrats", new { playerName = Game1.player.Name })}\"/pause 1500");
                }
                if (isLinusWatching && Game1.player.getFriendshipHeartLevelForNPC("Linus") >= 4)
                {
                    eventAction.Append($"/textAboveHead Linus \"{i18n.Get("AnimalContest.Dialog.Linus.PlayerCongrats", new { playerName = Game1.player.Name })}\"/pause 1500");
                }
                else if (Game1.player.getFriendshipHeartLevelForNPC("Pierre") >= 4)
                {
                    eventAction.Append($"/pause 1500");
                }
            }
            else if (animalContestInfo.Winner == "Marnie")
            {
                eventAction.Append("/specificTemporarySprite animalContestMarnieWinning/warp Marnie -2000 -2000/pause 500");
                eventAction.Append($"/emote Jas 32 true/pause 1500");
                if (isShaneWatching || animalContestInfo.Contenders.Contains("Shane"))
                {
                    eventAction.Append($"/textAboveHead Shane \"{i18n.Get("AnimalContest.Dialog.Shane.MarnieCongrats")}\"/pause 1000");
                }
            }
            else if (animalContestInfo.Winner == "Shane")
            {
                eventAction.Append("/emote Shane 16 true/emote shaneAnimal 20 true");
                eventAction.Append($"/pause 500/emote Jas 32 true/pause 500/textAboveHead Marnie \"{i18n.Get("AnimalContest.Dialog.Marnie.ShaneContrats")}\"/pause 1000");
            }
            else if (animalContestInfo.Winner == "Emily")
            {
                eventAction.Append("/specificTemporarySprite animalContestEmilyParrotAction/emote Emily 20 true");
                eventAction.Append($"/textAboveHead Clint \"{i18n.Get("AnimalContest.Dialog.Clint.EmilyContrats")}\"/pause 500");
                if (isHaleyWatching)
                {
                    eventAction.Append($"/textAboveHead Haley \"{i18n.Get("AnimalContest.Dialog.Haley.EmilyContrats")}\"/pause 500");
                }
                eventAction.Append($"/pause 1000/textAboveHead Gus \"{i18n.Get("AnimalContest.Dialog.Gus.EmilyContrats")}\"/pause 1000");
            }
            else if (animalContestInfo.Winner == "Jodi")
            {
                eventAction.Append("/emote jodiAnimal 20 true/emote Jodi 32 true/pause 1000");
                if (isKentWatching)
                {
                    eventAction.Append($"/textAboveHead Kent \"{i18n.Get("AnimalContest.Dialog.Kent.JodiContrats")}\"/pause 1500");
                }
                eventAction.Append($"/textAboveHead Caroline \"{i18n.Get("AnimalContest.Dialog.Caroline.JodiContrats")}\"/pause 1500");
                eventAction.Append($"/textAboveHead Sam \"{i18n.Get("AnimalContest.Dialog.Sam.JodiContrats")}\"/pause 1500");
            }
            eventAction.Append($"/textAboveHead Evelyn \"{i18n.Get("AnimalContest.Dialog.Evelyn.Contrats")}\"");
            if (isHaleyWatching)
            {
                eventAction.Append("/showFrame Haley 25/pause 1000/playSound cameraNoise/shake Haley 50/screenFlash .5/pause 1000/showFrame Haley 5/pause 1500");
            }
            else
            {
                eventAction.Append($"/pause 3000");
            }

            eventAction.Append($"/speak Lewis \"{i18n.Get("AnimalContest.Dialog.Lewis.Ending")}\"/faceDirection Lewis 3/move Lewis -2 0 3 true");
            if (animalContestInfo.Winner != "Marnie")
            {
                eventAction.Append($"/faceDirection Marnie 0/move Marnie 0 -2 0 true");
            }
            eventAction.Append($"/pause 1500/showFrame Lewis 16/globalFade/viewport -1000 -1000");
            if (animalContestInfo.Winner == "Farmer" && !DataLoader.ModConfig.DisableContestBonus)
            {
                string bonusType = contestDate.Season == "spring" || contestDate.Season == "summer" ? i18n.Get("AnimalContest.Message.Reward.Fertility") : i18n.Get("AnimalContest.Message.Reward.Production");
                eventAction.Append($"/playSound reward/message \"{i18n.Get("AnimalContest.Message.Reward", new { animalName = farmAnimal.displayName, bonusType })}\"");
            }
            eventAction.Append("/specificTemporarySprite animalContestEnding/end");

            string script = initialPosition.ToString() + eventAction.ToString();

            FarmerLoader.FarmerData.AnimalContestData.Add(animalContestInfo);

            return(new CustomEvent(key, script));
        }
Exemple #5
0
        /// <summary>
        /// Adds or replace a list of custom producer rules to the game.
        /// You should probably call this method everytime a save game loads, to ensure all custom objects are properly loaded.
        /// Producer rules should be unique per name of producer and input identifier.
        /// </summary>
        /// <param name="producerRules">A list of producer rules to be added or replaced.</param>
        /// <param name="i18n">Optional i18n object, to look for the output name in case a translation key was used.</param>
        /// <param name="modUniqueId">The mod unique id.</param>
        public static void AddProducerItems(List <ProducerRule> producerRules, ITranslationHelper i18n = null, string modUniqueId = null)
        {
            Dictionary <int, string> objects = DataLoader.Helper.Content.Load <Dictionary <int, string> >("Data\\ObjectInformation", ContentSource.GameContent);

            foreach (var producerRule in producerRules)
            {
                try {
                    producerRule.ModUniqueID = modUniqueId;
                    if (String.IsNullOrEmpty(producerRule.ProducerName))
                    {
                        ProducerFrameworkModEntry.ModMonitor.Log($"The ProducerName property can't be null or empty. This rule will be ignored.", LogLevel.Warn);
                    }
                    else if (UnsupportedMachines.Contains(producerRule.ProducerName) || producerRule.ProducerName.Contains("arecrow"))
                    {
                        if (producerRule.ProducerName == "Crystalarium")
                        {
                            ProducerFrameworkModEntry.ModMonitor.Log($"Producer Framework Mod doesn't support Crystalariums. Use Custom Cristalarium Mod instead.", LogLevel.Warn);
                        }
                        else if (producerRule.ProducerName == "Cask")
                        {
                            ProducerFrameworkModEntry.ModMonitor.Log($"Producer Framework Mod doesn't support Casks. Use Custom Cask Mod instead.", LogLevel.Warn);
                        }
                        else
                        {
                            ProducerFrameworkModEntry.ModMonitor.Log($"Producer Framework Mod doesn't support {producerRule.ProducerName}. This rule will be ignored.", LogLevel.Warn);
                        }
                    }
                    else if (string.IsNullOrEmpty(producerRule.InputIdentifier) && (GetProducerConfig(producerRule.ProducerName)?.NoInputStartMode == null))
                    {
                        ProducerFrameworkModEntry.ModMonitor.Log($"The InputIdentifier property can't be null or empty if there is no config for 'NoInputStartMode' for producer '{producerRule.ProducerName}'. This rule will be ignored.", LogLevel.Warn);
                    }
                    else if ((!string.IsNullOrEmpty(producerRule.InputIdentifier) && GetProducerConfig(producerRule.ProducerName)?.NoInputStartMode != null))
                    {
                        ProducerFrameworkModEntry.ModMonitor.Log($"The InputIdentifier property can't have a value if there is a config for 'NoInputStartMode' for producer '{producerRule.ProducerName}'. This rule will be ignored.", LogLevel.Warn);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(producerRule.InputIdentifier))
                        {
                            if (producerRule.InputIdentifier == "Stone")
                            {
                                producerRule.InputKey = 390;
                            }
                            else if (!Int32.TryParse(producerRule.InputIdentifier, out var intInputIdentifier))
                            {
                                KeyValuePair <int, string> pair = objects.FirstOrDefault(o => ObjectUtils.IsObjectStringFromObjectName(o.Value, producerRule.InputIdentifier));
                                if (pair.Value != null)
                                {
                                    producerRule.InputKey = pair.Key;
                                }
                                else
                                {
                                    producerRule.InputKey = producerRule.InputIdentifier;
                                }
                            }
                            else
                            {
                                producerRule.InputKey = intInputIdentifier;
                            }
                        }

                        if (producerRule.OutputIdentifier != null)
                        {
                            producerRule.OutputConfigs.Add(new OutputConfig()
                            {
                                OutputIdentifier        = producerRule.OutputIdentifier,
                                OutputName              = producerRule.OutputName,
                                OutputTranslationKey    = producerRule.OutputTranslationKey,
                                OutputGenericParentName = producerRule.OutputGenericParentName,
                                OutputGenericParentNameTranslationKey = producerRule.OutputGenericParentNameTranslationKey,
                                PreserveType          = producerRule.PreserveType,
                                KeepInputParentIndex  = producerRule.KeepInputParentIndex,
                                InputPriceBased       = producerRule.InputPriceBased,
                                OutputPriceIncrement  = producerRule.OutputPriceIncrement,
                                OutputPriceMultiplier = producerRule.OutputPriceMultiplier,
                                KeepInputQuality      = producerRule.KeepInputQuality,
                                OutputQuality         = producerRule.OutputQuality,
                                OutputStack           = producerRule.OutputStack,
                                OutputMaxStack        = producerRule.OutputMaxStack,
                                SilverQualityInput    = producerRule.SilverQualityInput,
                                GoldQualityInput      = producerRule.GoldQualityInput,
                                IridiumQualityInput   = producerRule.IridiumQualityInput,
                                OutputColorConfig     = producerRule.OutputColorConfig
                            });
                        }
                        producerRule.OutputConfigs.AddRange(producerRule.AdditionalOutputs);

                        foreach (OutputConfig outputConfig in producerRule.OutputConfigs)
                        {
                            if (!Int32.TryParse(outputConfig.OutputIdentifier, out int outputIndex))
                            {
                                KeyValuePair <int, string> pair = objects.FirstOrDefault(o => ObjectUtils.IsObjectStringFromObjectName(o.Value, outputConfig.OutputIdentifier));
                                if (pair.Value != null)
                                {
                                    outputIndex = pair.Key;
                                }
                                else
                                {
                                    ProducerFrameworkModEntry.ModMonitor.Log($"No Output found for '{outputConfig.OutputIdentifier}', producer '{producerRule.ProducerName}' and input '{producerRule.InputIdentifier}'. This rule will be ignored.", LogLevel.Warn);
                                    break;
                                }
                            }
                            outputConfig.OutputIndex = outputIndex;

                            if (outputConfig.OutputName != null)
                            {
                                string customName        = outputConfig.OutputName;
                                string genericParentName = outputConfig.OutputGenericParentName ?? "";
                                if (i18n != null)
                                {
                                    if (outputConfig.OutputTranslationKey != null)
                                    {
                                        string translation = i18n.Get(outputConfig.OutputTranslationKey);
                                        if (!translation.Contains("(no translation:"))
                                        {
                                            customName = translation;
                                        }
                                    }
                                    if (outputConfig.OutputGenericParentNameTranslationKey != null)
                                    {
                                        string translation = i18n.Get(outputConfig.OutputGenericParentNameTranslationKey);
                                        if (!translation.Contains("(no translation:"))
                                        {
                                            genericParentName = translation;
                                        }
                                    }
                                }
                                NameUtils.AddCustomName(outputConfig.OutputIndex, customName);
                                NameUtils.AddGenericParentName(outputConfig.OutputIndex, genericParentName);
                            }

                            foreach (var fuel in outputConfig.RequiredFuel)
                            {
                                if (!Int32.TryParse(fuel.Key, out int fuelIndex))
                                {
                                    KeyValuePair <int, string> pair = objects.FirstOrDefault(o =>
                                                                                             ObjectUtils.IsObjectStringFromObjectName(o.Value, fuel.Key));
                                    if (pair.Value != null)
                                    {
                                        fuelIndex = pair.Key;
                                    }
                                    else
                                    {
                                        ProducerFrameworkModEntry.ModMonitor.Log(
                                            $"No required fuel found for '{fuel.Key}', producer '{producerRule.ProducerName}' and input '{fuel.Key}'. This rule will be ignored.",
                                            LogLevel.Warn);
                                        //This is done to abort the rule.
                                        outputConfig.OutputIndex = -1;
                                        break;
                                    }
                                }
                                outputConfig.FuelList.Add(new Tuple <int, int>(fuelIndex, fuel.Value));
                            }
                        }
                        if (producerRule.OutputConfigs.Any(p => p.OutputIndex < 0))
                        {
                            continue;
                        }

                        if (producerRule.FuelIdentifier != null)
                        {
                            producerRule.AdditionalFuel[producerRule.FuelIdentifier] = producerRule.FuelStack;
                        }
                        foreach (var fuel in producerRule.AdditionalFuel)
                        {
                            if (!Int32.TryParse(fuel.Key, out int fuelIndex))
                            {
                                KeyValuePair <int, string> pair = objects.FirstOrDefault(o => ObjectUtils.IsObjectStringFromObjectName(o.Value, fuel.Key));
                                if (pair.Value != null)
                                {
                                    fuelIndex = pair.Key;
                                }
                                else
                                {
                                    ProducerFrameworkModEntry.ModMonitor.Log($"No fuel found for '{fuel.Key}', producer '{producerRule.ProducerName}' and input '{producerRule.InputIdentifier}'. This rule will be ignored.", LogLevel.Warn);
                                    break;
                                }
                            }
                            producerRule.FuelList.Add(new Tuple <int, int>(fuelIndex, fuel.Value));
                        }
                        if (producerRule.AdditionalFuel.Count != producerRule.FuelList.Count)
                        {
                            continue;
                        }

                        if (producerRule.PlacingAnimationColorName != null)
                        {
                            try
                            {
                                producerRule.PlacingAnimationColor = DataLoader.Helper.Reflection.GetProperty <Color>(typeof(Color), producerRule.PlacingAnimationColorName).GetValue();
                            }
                            catch (Exception)
                            {
                                ProducerFrameworkModEntry.ModMonitor.Log($"Color '{producerRule.PlacingAnimationColorName}' isn't valid. Check XNA Color Chart for valid names. It'll use the default color '{producerRule.PlacingAnimationColor}'.");
                            }
                        }

                        Tuple <string, object> ruleKey = new Tuple <string, object>(producerRule.ProducerName, producerRule.InputKey);
                        if (RulesRepository.ContainsKey(ruleKey))
                        {
                            ProducerRule oldRule = RulesRepository[ruleKey];
                            if (oldRule.ModUniqueID != producerRule.ModUniqueID)
                            {
                                if (oldRule.OverrideMod.Contains(producerRule.ModUniqueID) && producerRule.OverrideMod.Contains(oldRule.ModUniqueID))
                                {
                                    ProducerFrameworkModEntry.ModMonitor.Log($"Both mod '{oldRule.ModUniqueID}' and '{producerRule.ModUniqueID}' are saying they should override the rule for producer '{producerRule.ProducerName}' and input '{producerRule.InputIdentifier}'. You should report the problem to these mod's authors. Rule from mod '{oldRule.ModUniqueID}' will be used.", LogLevel.Warn);
                                    continue;
                                }
                                else if (producerRule.OverrideMod.Contains(oldRule.ModUniqueID))
                                {
                                    ProducerFrameworkModEntry.ModMonitor.Log($"Mod '{producerRule.ModUniqueID}' if overriding mod '{oldRule.ModUniqueID}' rule for producer '{producerRule.ProducerName}' and input '{producerRule.InputIdentifier}'.", LogLevel.Debug);
                                }
                                else
                                {
                                    ProducerFrameworkModEntry.ModMonitor.Log($"Mod '{producerRule.ModUniqueID}' can't override mod '{oldRule.ModUniqueID}' rule for producer '{producerRule.ProducerName}' and input '{producerRule.InputIdentifier}'. This rule will be ignored.", LogLevel.Debug);
                                    continue;
                                }
                            }
                        }
                        RulesRepository[ruleKey] = producerRule;
                    }
                }
                catch (Exception e)
                {
                    ProducerFrameworkModEntry.ModMonitor.Log($"Unexpected error for rule from '{producerRule?.ModUniqueID}', producer '{producerRule?.ProducerName}' and input '{producerRule?.InputIdentifier}'. This rule will be ignored.", LogLevel.Error);
                    ProducerFrameworkModEntry.ModMonitor.Log(e.Message + "\n" + e.StackTrace);
                }
            }
        }
 public void AddSectionTitle(string keyPrefix)
 {
     Api.AddSectionTitle(
         mod: Mod,
         text: () => Translations.Get($"{keyPrefix}.name"),
         tooltip: GetOptionalTranslatedStringDelegate($"{keyPrefix}.tooltip")
         );
 }
Exemple #7
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="currentTab">The selected tab.</param>
        /// <param name="sortBy">How to sort items.</param>
        /// <param name="quality">The item quality to display.</param>
        /// <param name="search">The search term to prepopulate.</param>
        /// <param name="i18n">Provides translations for the mod.</param>
        /// <param name="itemRepository">Provides methods for searching and constructing items.</param>
        public ItemMenu(MenuTab currentTab, ItemSort sortBy, ItemQuality quality, string search, ITranslationHelper i18n, ItemRepository itemRepository)
            : base(null, true, true, 0, -50)
        {
            // initialise
            this.TranslationHelper = i18n;
            this.ItemRepository    = itemRepository;
            this.MovePosition(110, Game1.viewport.Height / 2 - (650 + IClickableMenu.borderWidth * 2) / 2);
            this.CurrentTab      = currentTab;
            this.SortBy          = sortBy;
            this.Quality         = quality;
            this.SpawnableItems  = this.ItemRepository.GetFiltered().Select(p => p.Item).ToArray();
            this.AllowRightClick = true;

            // create search box
            int textWidth = Game1.tileSize * 8;

            this.Textbox = new TextBox(null, null, Game1.dialogueFont, Game1.textColor)
            {
                X        = this.xPositionOnScreen + (this.width / 2) - (textWidth / 2) - Game1.tileSize + 32,
                Y        = this.yPositionOnScreen + (this.height / 2) + Game1.tileSize * 2 + 40,
                Width    = textWidth,
                Height   = Game1.tileSize * 3,
                Selected = false,
                Text     = search
            };
            Game1.keyboardDispatcher.Subscriber = this.Textbox;
            this.TextboxBounds = new Rectangle(this.Textbox.X, this.Textbox.Y, this.Textbox.Width, this.Textbox.Height / 3);

            // create buttons
            this.Title         = new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize, this.yPositionOnScreen - Game1.tileSize * 2, Game1.tileSize * 4, Game1.tileSize), i18n.Get("title"));
            this.QualityButton = new ClickableComponent(new Rectangle(this.xPositionOnScreen, this.yPositionOnScreen - Game1.tileSize * 2 + 10, (int)Game1.smallFont.MeasureString(i18n.Get("labels.quality")).X, Game1.tileSize), i18n.Get("labels.quality"));
            this.SortButton    = new ClickableComponent(new Rectangle(this.xPositionOnScreen + this.QualityButton.bounds.Width + 40, this.yPositionOnScreen - Game1.tileSize * 2 + 10, Game1.tileSize * 4, Game1.tileSize), this.GetSortLabel(sortBy));
            this.UpArrow       = new ClickableTextureComponent("up-arrow", new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2, 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 / 2, this.yPositionOnScreen + this.height / 2 - Game1.tileSize * 2, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom);

            // create tabs
            {
                int i = -1;

                int x         = (int)(this.xPositionOnScreen - Game1.tileSize * 5.3f);
                int y         = this.yPositionOnScreen + 10;
                int lblHeight = (int)(Game1.tileSize * 0.9F);

                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.All.ToString(), i18n.Get("tabs.all")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ToolsAndEquipment.ToString(), i18n.Get("tabs.equipment")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.SeedsAndCrops.ToString(), i18n.Get("tabs.crops")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.FishAndBaitAndTrash.ToString(), i18n.Get("tabs.fishing")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ForageAndFruits.ToString(), i18n.Get("tabs.forage")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ArtifactsAndMinerals.ToString(), i18n.Get("tabs.artifacts-and-minerals")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ResourcesAndCrafting.ToString(), i18n.Get("tabs.resources-and-crafting")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.ArtisanAndCooking.ToString(), i18n.Get("tabs.artisan-and-cooking")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.AnimalAndMonster.ToString(), i18n.Get("tabs.animal-and-monster")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i++, Game1.tileSize * 5, Game1.tileSize), MenuTab.Decorating.ToString(), i18n.Get("tabs.decorating")));
                this.Tabs.Add(new ClickableComponent(new Rectangle(x, y + lblHeight * i, Game1.tileSize * 5, Game1.tileSize), MenuTab.Misc.ToString(), i18n.Get("tabs.miscellaneous")));
            }

            // load items
            this.LoadInventory(this.SpawnableItems);
        }
Exemple #8
0
 /// <summary>Construct an instance.</summary>
 /// <param name="translations">The translation helper from which to get the display text based on the <paramref name="id"/>.</param>
 /// <param name="id">A unique identifier for the legend entry.</param>
 /// <param name="color">The tile color.</param>
 public LegendEntry(ITranslationHelper translations, string id, Color color)
     : this(id, translations.Get(id), color)
 {
 }
Exemple #9
0
        /// <summary>
        /// Adds or replace a list of custom producer rules to the game.
        /// You should probably call this method everytime a save game loads, to ensure all custom objects are properly loaded.
        /// Producer rules should be unique per name of producer and input identifier.
        /// </summary>
        /// <param name="producerRules">A list of producer rules to be added or replaced.</param>
        /// <param name="i18n">Optional i18n object, to look for the output name in case a translation key was used.</param>
        public static void AddProducerItems(List <ProducerRule> producerRules, ITranslationHelper i18n = null)
        {
            Dictionary <int, string> objects = DataLoader.Helper.Content.Load <Dictionary <int, string> >("Data\\ObjectInformation", ContentSource.GameContent);

            foreach (var producerRule in producerRules)
            {
                if (string.IsNullOrEmpty(producerRule.ProducerName))
                {
                    ProducerFrameworkModEntry.ModMonitor.Log($"The ProducerName property can't be null or empty. This rule will be ignored.", LogLevel.Warn);
                    continue;
                }
                else if (UnsupportedMachines.Contains(producerRule.ProducerName) || producerRule.ProducerName.Contains("arecrow"))
                {
                    if (producerRule.ProducerName == "Crystalarium")
                    {
                        ProducerFrameworkModEntry.ModMonitor.Log($"Producer Framework Mod doesn't support Crystalariums. Use Custom Cristalarium Mod instead.", LogLevel.Warn);
                    }
                    else if (producerRule.ProducerName == "Cask")
                    {
                        ProducerFrameworkModEntry.ModMonitor.Log($"Producer Framework Mod doesn't support Casks. Use Custom Cask Mod instead.", LogLevel.Warn);
                    }
                    else
                    {
                        ProducerFrameworkModEntry.ModMonitor.Log($"Producer Framework Mod doesn't support {producerRule.ProducerName}. This rule will be ignored.", LogLevel.Warn);
                    }
                }
                else if (string.IsNullOrEmpty(producerRule.InputIdentifier))
                {
                    ProducerFrameworkModEntry.ModMonitor.Log($"The InputIdentifier property can't be null or empty. This rule for '{producerRule.ProducerName}' will be ignored.", LogLevel.Warn);
                    continue;
                }
                else
                {
                    object inputIdentifier;
                    if (!int.TryParse(producerRule.InputIdentifier, out var intInputIdentifier))
                    {
                        KeyValuePair <int, string> pair = objects.FirstOrDefault(o => ObjectUtils.IsObjectStringFromObjectName(o.Value, producerRule.InputIdentifier));
                        if (pair.Value != null)
                        {
                            inputIdentifier = pair.Key;
                        }
                        else
                        {
                            inputIdentifier = producerRule.InputIdentifier;
                        }
                    }
                    else
                    {
                        inputIdentifier = intInputIdentifier;
                    }

                    if (producerRule.OutputIdentifier != null)
                    {
                        producerRule.OutputConfigs.Add(new OutputConfig()
                        {
                            OutputIdentifier      = producerRule.OutputIdentifier,
                            OutputName            = producerRule.OutputName,
                            OutputTranslationKey  = producerRule.OutputTranslationKey,
                            PreserveType          = producerRule.PreserveType,
                            InputPriceBased       = producerRule.InputPriceBased,
                            OutputPriceIncrement  = producerRule.OutputPriceIncrement,
                            OutputPriceMultiplier = producerRule.OutputPriceMultiplier,
                            KeepInputQuality      = producerRule.KeepInputQuality,
                            OutputQuality         = producerRule.OutputQuality,
                            OutputStack           = producerRule.OutputStack,
                            OutputMaxStack        = producerRule.OutputMaxStack,
                            SilverQualityInput    = producerRule.SilverQualityInput,
                            GoldQualityInput      = producerRule.GoldQualityInput,
                            IridiumQualityInput   = producerRule.IridiumQualityInput
                        });
                    }
                    producerRule.OutputConfigs.AddRange(producerRule.AdditionalOutputs);

                    foreach (OutputConfig outputConfig in producerRule.OutputConfigs)
                    {
                        if (!Int32.TryParse(outputConfig.OutputIdentifier, out int outputIndex))
                        {
                            KeyValuePair <int, string> pair = objects.FirstOrDefault(o => ObjectUtils.IsObjectStringFromObjectName(o.Value, outputConfig.OutputIdentifier));
                            if (pair.Value != null)
                            {
                                outputIndex = pair.Key;
                            }
                            else
                            {
                                ProducerFrameworkModEntry.ModMonitor.Log($"No Output found for '{outputConfig.OutputIdentifier}', producer '{producerRule.ProducerName}' and input '{producerRule.InputIdentifier}'. This rule will be ignored.", LogLevel.Warn);
                                break;
                            }
                        }
                        outputConfig.OutputIndex = outputIndex;
                        if (outputConfig.OutputTranslationKey != null && i18n != null)
                        {
                            string translation = i18n.Get(outputConfig.OutputTranslationKey);
                            if (!translation.Contains("(no translation:"))
                            {
                                NameUtils.AddCustomName(outputConfig.OutputIndex, translation);
                            }
                            else
                            {
                                NameUtils.AddCustomName(outputConfig.OutputIndex, outputConfig.OutputName);
                            }
                        }
                        else if (outputConfig.OutputName != null)
                        {
                            NameUtils.AddCustomName(outputConfig.OutputIndex, outputConfig.OutputName);
                        }
                    }
                    if (producerRule.OutputConfigs.Any(p => p.OutputIndex < 0))
                    {
                        continue;
                    }

                    if (producerRule.FuelIdentifier != null)
                    {
                        producerRule.AdditionalFuel[producerRule.FuelIdentifier] = producerRule.FuelStack;
                    }
                    foreach (var fuel in producerRule.AdditionalFuel)
                    {
                        if (!Int32.TryParse(fuel.Key, out int fuelIndex))
                        {
                            KeyValuePair <int, string> pair = objects.FirstOrDefault(o => ObjectUtils.IsObjectStringFromObjectName(o.Value, fuel.Key));
                            if (pair.Value != null)
                            {
                                fuelIndex = pair.Key;
                            }
                            else
                            {
                                ProducerFrameworkModEntry.ModMonitor.Log($"No fuel found for '{fuel.Key}', producer '{producerRule.ProducerName}' and input '{fuel.Key}'. This rule will be ignored.", LogLevel.Warn);
                                break;
                            }
                        }
                        producerRule.FuelList.Add(new Tuple <int, int>(fuelIndex, fuel.Value));
                    }
                    if (producerRule.AdditionalFuel.Count != producerRule.FuelList.Count)
                    {
                        continue;
                    }

                    if (producerRule.PlacingAnimationColorName != null)
                    {
                        try
                        {
                            producerRule.PlacingAnimationColor = DataLoader.Helper.Reflection.GetProperty <Color>(typeof(Color), producerRule.PlacingAnimationColorName).GetValue();
                        }
                        catch (Exception)
                        {
                            ProducerFrameworkModEntry.ModMonitor.Log($"Color '{producerRule.PlacingAnimationColorName}' isn't valid. Check XNA Color Chart for valid names. It'll use the default color '{producerRule.PlacingAnimationColor}'.");
                        }
                    }

                    RulesRepository[new Tuple <string, object>(producerRule.ProducerName, inputIdentifier)] = producerRule;
                }
            }
        }
 /*********
 ** Public methods
 *********/
 /// <summary>Select the correct translation based on the plural form.</summary>
 /// <param name="translations">The translation helper.</param>
 /// <param name="count">The number.</param>
 /// <param name="singleKey">The singular form.</param>
 /// <param name="pluralKey">The plural form.</param>
 public static Translation GetPlural(this ITranslationHelper translations, int count, string singleKey, string pluralKey)
 {
     return(translations.Get(count == 1 ? singleKey : pluralKey));
 }
        /// <summary>Get a human-readable representation of a value.</summary>
        /// <param name="translations">The translation helper.</param>
        /// <param name="value">The underlying value.</param>
        public static string Stringify(this ITranslationHelper translations, object value)
        {
            switch (value)
            {
            case null:
                return(null);

            // boolean
            case bool boolean:
                return(translations.Get(boolean ? L10n.Generic.Yes : L10n.Generic.No));

            // game date
            case GameDate date:
                return(translations.Stringify(date, withYear: false));

            // time span
            case TimeSpan span:
            {
                List <string> parts = new List <string>();
                if (span.Days > 0)
                {
                    parts.Add(translations.Get(L10n.Generic.Days, new { count = span.Days }));
                }
                if (span.Hours > 0)
                {
                    parts.Add(translations.Get(L10n.Generic.Hours, new { count = span.Hours }));
                }
                if (span.Minutes > 0)
                {
                    parts.Add(translations.Get(L10n.Generic.Minutes, new { count = span.Minutes }));
                }
                return(string.Join(", ", parts));
            }

            // vector
            case Vector2 vector:
                return($"({vector.X}, {vector.Y})");

            // rectangle
            case Rectangle rect:
                return($"(x:{rect.X}, y:{rect.Y}, width:{rect.Width}, height:{rect.Height})");

            // array
            case IEnumerable array when !(value is string):
            {
                string[] values = (from val in array.Cast <object>() select translations.Stringify(val)).ToArray();
                return("(" + string.Join(", ", values) + ")");
            }

            // color
            case Color color:
                return($"(r:{color.R} g:{color.G} b:{color.B} a:{color.A})");

            default:
                // key/value pair
            {
                Type type = value.GetType();
                if (type.IsGenericType)
                {
                    Type genericType = type.GetGenericTypeDefinition();
                    if (genericType == typeof(KeyValuePair <,>))
                    {
                        string k = translations.Stringify(type.GetProperty(nameof(KeyValuePair <byte, byte> .Key)).GetValue(value));
                        string v = translations.Stringify(type.GetProperty(nameof(KeyValuePair <byte, byte> .Value)).GetValue(value));
                        return($"({k}: {v})");
                    }
                }
            }

                // anything else
                return(value.ToString());
            }
        }
        // Method that is used to postfix for most furniture types
        private static void Furniture_canBeRemoved_Postfix(Farmer who, Furniture __instance, ref bool __result)
        {
            try
            {
                Vector2 position = ((!Game1.wasMouseVisibleThisFrame) ? Game1.player.GetToolLocation() : new Vector2(Game1.getOldMouseX() + Game1.viewport.X, Game1.getOldMouseY() + Game1.viewport.Y));

                switch ((int)__instance.furniture_type)
                {
                case 0:
                    // For type chair, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpChair)
                    {
                        Monitor.Log($"Preventing player from picking up chair", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpChair.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 1:
                    // For type bench, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpChair)
                    {
                        Monitor.Log($"Preventing player from picking up bench", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpChair.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 2:
                    // For type couch, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpChair)
                    {
                        Monitor.Log($"Preventing player from picking up couch", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpChair.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 3:
                    // For type armchair, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpChair)
                    {
                        Monitor.Log($"Preventing player from picking up armchair", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpChair.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 4:
                    // For type dresser, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpDresser)
                    {
                        Monitor.Log($"Preventing player from picking up dresser", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpDresser.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 5:
                    // For type longTable, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpTable)
                    {
                        Monitor.Log($"Preventing player from picking up long table", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpTable.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 6:
                    // For type painting, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpDecoration)
                    {
                        // Need to check that we're actually trying to pick up this painting
                        if (__instance.boundingBox.Value.Contains(position.X, position.Y))
                        {
                            Monitor.Log($"Preventing player from picking up painting", LogLevel.Debug);
                            Game1.showRedMessage(I18n.Get("CanPickUpDecoration.error"));
                            __result = false;
                            return;
                        }
                    }
                    break;

                case 7:
                    // For type lamp, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpLamp)
                    {
                        Monitor.Log($"Preventing player from picking up lamp", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpLamp.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 8:
                    // For type decor, change the result if it would be picked up but the config says not to
                    // Check if is TV and use TV config values
                    if (__result && __instance is TV && !Config.CanPickUpTV)
                    {
                        Monitor.Log($"Preventing player from picking up TV", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpTV.error"));
                        __result = false;
                        return;
                    }
                    // Othewise use decoration config values
                    else if (__result && !(__instance is TV) && !Config.CanPickUpDecoration)
                    {
                        Monitor.Log($"Preventing player from picking up decor", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpDecoration.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 9:
                    // For type other, change the result if it would be picked up but the config says not to
                    // Check if is fish tank and use fish tank config values
                    if (__result && __instance is FishTankFurniture && !Config.CanPickUpFishTank)
                    {
                        Monitor.Log($"Preventing player from picking up fish tank", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpFishTank.error"));
                        __result = false;
                        return;
                    }
                    // Othewise use decoration config values
                    else if (__result && !(__instance is FishTankFurniture) && !Config.CanPickUpDecoration)
                    {
                        Monitor.Log($"Preventing player from picking up other furniture", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpDecoration.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 10:
                    // For type bookcase, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpDecoration)
                    {
                        Monitor.Log($"Preventing player from picking up bookcase", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpDecoration.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 11:
                    // For type table, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpTable)
                    {
                        Monitor.Log($"Preventing player from picking up table", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpTable.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 12:
                    // For type rug, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpRug)
                    {
                        Monitor.Log($"Preventing player from picking up rug", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpRug.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 13:
                    // For type window, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpWindow)
                    {
                        // Need to check that we're actually trying to pick up this window
                        if (__instance.boundingBox.Value.Contains(position.X, position.Y))
                        {
                            Monitor.Log($"Preventing player from picking up window", LogLevel.Debug);
                            Game1.showRedMessage(I18n.Get("CanPickUpWindow.error"));
                            __result = false;
                            return;
                        }
                    }
                    break;

                case 14:
                    // For type fireplace, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpFireplace)
                    {
                        Monitor.Log($"Preventing player from picking up fireplace", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpFireplace.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 15:
                    // For type bed, need to postfix BedFurniture canBeRemoved() specifically
                    break;

                case 16:
                    // For type torch, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpTorch)
                    {
                        Monitor.Log($"Preventing player from picking up torch", LogLevel.Debug);
                        Game1.showRedMessage(I18n.Get("CanPickUpTorch.error"));
                        __result = false;
                        return;
                    }
                    break;

                case 17:
                    // For type sconce, change the result if it would be picked up but the config says not to
                    if (__result && !Config.CanPickUpSconce)
                    {
                        // Need to check that we're actually trying to pick up this sconce
                        if (__instance.boundingBox.Value.Contains(position.X, position.Y))
                        {
                            Monitor.Log($"Preventing player from picking up sconce", LogLevel.Debug);
                            Game1.showRedMessage(I18n.Get("CanPickUpSconce.error"));
                            __result = false;
                            return;
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to change furniture removal behavior with exception: {ex}", LogLevel.Error);
            }

            return;
        }
Exemple #13
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="tree">The lookup target.</param>
 /// <param name="tile">The tree's tile position.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public TreeSubject(Tree tree, Vector2 tile, ITranslationHelper translations)
     : base(TreeSubject.GetName(translations, tree), null, translations.Get(L10n.Types.Tree), translations)
 {
     this.Target = tree;
     this.Tile   = tile;
 }
        /// <summary>Register API stuff for Generic Mod Config Menu.</summary>
        internal static void SetUpMenu()
        {
            var api = Helper.ModRegistry.GetApi <GenericModConfigMenu.IApi>
                          ("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = ModEntry.Instance.ModManifest;

            api.RegisterModConfig(manifest, Reset, Save);

            api.RegisterLabel(manifest, i18n.Get("DialogueOptions.title"), "");

            api.RegisterChoiceOption(manifest,
                                     i18n.Get("GrandpaDialogue.name"),
                                     i18n.Get("GrandpaDialogue.description", new { NL }),
                                     () => Instance.GrandpaDialogue,
                                     (string val) => Instance.GrandpaDialogue = val,
                                     ModConfig.GrandpaDialogueChoices);

            api.RegisterSimpleOption(manifest,
                                     i18n.Get("GenderNeutrality.name"),
                                     i18n.Get("GenderNeutrality.description"),
                                     () => Instance.GenderNeutrality,
                                     (bool val) => Instance.GenderNeutrality = val);

            api.RegisterSimpleOption(manifest,
                                     i18n.Get("ExpressivePortraits.name"),
                                     i18n.Get("ExpressivePortraits.description"),
                                     () => Instance.ExpressivePortraits,
                                     (bool val) => Instance.ExpressivePortraits = val);

            api.RegisterChoiceOption(manifest,
                                     i18n.Get("PortraitStyle.name"),
                                     i18n.Get("PortraitStyle.description", new { NL }),
                                     () => Instance.PortraitStyle,
                                     (string val) => Instance.PortraitStyle = val,
                                     ModConfig.PortraitStyleChoices);

            api.RegisterLabel(manifest, "", "");
            api.RegisterLabel(manifest, i18n.Get("ScoringOptions.title"), "");

            api.RegisterChoiceOption(manifest,
                                     i18n.Get("ScoringSystem.name"),
                                     i18n.Get("ScoringSystem.description", new { NL }),
                                     () => Instance.ScoringSystem,
                                     (string val) => Instance.ScoringSystem = val,
                                     ModConfig.ScoringSystemChoices);

            api.RegisterSimpleOption(manifest,
                                     i18n.Get("YearsBeforeEvaluation.name"),
                                     i18n.Get("YearsBeforeEvaluation.description", new { NL }),
                                     () => Instance.YearsBeforeEvaluation,
                                     (int val) => Instance.YearsBeforeEvaluation = val);

            api.RegisterSimpleOption(manifest,
                                     i18n.Get("ShowPointsTotal.name"),
                                     i18n.Get("ShowPointsTotal.description"),
                                     () => Instance.ShowPointsTotal,
                                     (bool val) => Instance.ShowPointsTotal = val);

            api.RegisterLabel(manifest, "", "");
            api.RegisterLabel(manifest, i18n.Get("Rewards.title"), "");

            api.RegisterSimpleOption(manifest,
                                     i18n.Get("BonusRewards.name"),
                                     i18n.Get("BonusRewards.description"),
                                     () => Instance.BonusRewards,
                                     (bool val) => Instance.BonusRewards = val);

            api.RegisterSimpleOption(manifest,
                                     i18n.Get("StatuesForFarmhands.name"),
                                     i18n.Get("StatuesForFarmhands.description"),
                                     () => Instance.StatuesForFarmhands,
                                     (bool val) => Instance.StatuesForFarmhands = val);

            Monitor.Log("Added Angry Grandpa Config to GMCM", LogLevel.Info);
        }
Exemple #15
0
        internal static int GetNewRainAmount(int prevRain, ITranslationHelper Translation, bool showRain = true)
        {
            int    currRain           = prevRain;
            double ChanceOfRainChange = ClimatesOfFerngill.WeatherOpt.VRChangeChance;
            bool   massiveChange      = false;

            //do some rain chance pre pumping
            if (currRain == 0)
            {
                ChanceOfRainChange += .20;
            }
            if (currRain > WeatherUtilities.GetRainCategoryMidPoint(RainLevels.Torrential))
            {
                ChanceOfRainChange += .10;
            }
            if (WeatherUtilities.GetRainCategory(currRain) == RainLevels.NoahsFlood)
            {
                ChanceOfRainChange += .15;
            }

            double FlipChance = .5;

            //so, lower: decrease, higher: increase
            if (WeatherUtilities.IsSevereRainFall(currRain))
            {
                FlipChance += .2;
            }
            if (WeatherUtilities.GetRainCategory(currRain) == RainLevels.Torrential || WeatherUtilities.GetRainCategory(currRain) == RainLevels.Typhoon || WeatherUtilities.GetRainCategory(currRain) == RainLevels.NoahsFlood)
            {
                FlipChance += .15; //15% chance remaining of increasing.
            }
            if (WeatherUtilities.GetRainCategory(currRain) == RainLevels.Typhoon || WeatherUtilities.GetRainCategory(currRain) == RainLevels.NoahsFlood)
            {
                FlipChance += .1456; //.44% chance remaning of increasing.
            }
            if (WeatherUtilities.GetRainCategory(currRain) == RainLevels.NoahsFlood)
            {
                FlipChance += .0018; //.26% chance remaning of increasing.
            }
            if (currRain == ClimatesOfFerngill.WeatherOpt.MaxRainFall)
            {
                FlipChance = 1;         //you must go ddown.
            }
            if (currRain <= WeatherUtilities.GetRainCategoryMidPoint(RainLevels.Light))
            {
                FlipChance -= .2; //70% chance of increasing
            }
            if (currRain <= WeatherUtilities.GetRainCategoryMidPoint(RainLevels.Sunshower))
            {
                FlipChance -= .1; //80% chance of increasing
            }
            if (currRain == 0)
            {
                FlipChance -= .15;         //95% chance of increasing
            }
            if (ClimatesOfFerngill.WeatherOpt.Verbose)
            {
                ClimatesOfFerngill.Logger.Log($"Rain is {prevRain}, current chance for rain change is {ChanceOfRainChange}.");
                ClimatesOfFerngill.Logger.Log($"Calculated chance for rain decreasing: {WeatherUtilities.GetStepChance(currRain, increase: false).ToString("N3")}, rain increasing: {WeatherUtilities.GetStepChance(currRain, increase: true).ToString("N3")}. Flip chance is {FlipChance.ToString("N3")} ");
            }

            // I just spent nine minutes typing out an invalid explanation for this. :|
            // So, i'm renaming the variables.

            // And redoing this entirely. It's a lot of duplicated effort.
            //Greater than flip chance is increase, lesser is decrease

            if (ClimatesOfFerngill.Dice.NextDouble() < ChanceOfRainChange)
            {
                // Handle rain changes.
                // first check for a massive change 145% to 245%
                double stepRoll = ClimatesOfFerngill.Dice.NextDouble();
                if (ClimatesOfFerngill.Dice.NextDouble() > FlipChance)
                {
                    if (ClimatesOfFerngill.WeatherOpt.Verbose)
                    {
                        ClimatesOfFerngill.Logger.Log("Increasing rain!");
                    }

                    if (stepRoll <= WeatherUtilities.GetStepChance(currRain, increase: true))
                    {
                        //get the multiplier.  This should be between 145% and 245%

                        int mult = Math.Max(1, (int)(Math.Floor(ClimatesOfFerngill.Dice.NextDouble() + .68)));

                        if (currRain == 0)
                        {
                            currRain = 15 * mult;
                        }
                        else
                        {
                            currRain = (int)(Math.Floor(currRain * mult * 1.0));
                        }

                        massiveChange = true;
                    }
                }
                else
                {
                    if (stepRoll <= WeatherUtilities.GetStepChance(currRain, increase: false))
                    {
                        ClimatesOfFerngill.Logger.Log("Increasing rain!");
                        currRain      = (int)(Math.Floor(currRain / (ClimatesOfFerngill.Dice.NextDouble() + 1.45)));
                        massiveChange = true;
                    }
                }

                if (!massiveChange)
                {
                    double mult = (1 + (ClimatesOfFerngill.Dice.NextDouble() * 1.3) - .55);
                    if (currRain == 0)
                    {
                        currRain = 4;
                    }

                    if (currRain < WeatherUtilities.GetRainCategoryMidPoint(RainLevels.Light))
                    {
                        mult += 4.5;
                    }

                    currRain = (int)(Math.Floor(currRain * mult));
                }
            }

            if (!ClimatesOfFerngill.WeatherOpt.HazardousWeather)
            {
                if (ClimatesOfFerngill.WeatherOpt.Verbose)
                {
                    ClimatesOfFerngill.Logger.Log("Triggering Hazardous Weather Failsafe");
                }

                currRain = WeatherUtilities.GetRainCategoryMidPoint(RainLevels.Severe);
            }

            if (WeatherConditions.PreventGoingOutside(currRain))
            {
                if (Game1.timeOfDay >= 2300)
                {
                    //drop the rain to at least allow the person to return home if they aren't.
                    currRain = WeatherUtilities.GetRainCategoryMidPoint(RainLevels.Severe);
                }
            }

            if (currRain > ClimatesOfFerngill.WeatherOpt.MaxRainFall)
            {
                currRain = ClimatesOfFerngill.WeatherOpt.MaxRainFall;
            }

            if (currRain < 0)
            {
                currRain = 0;
            }

            //notifications time
            if (currRain != prevRain && Game1.timeOfDay != 600 && showRain && !(Game1.currentLocation is Desert))
            {
                if (WeatherUtilities.GetRainCategory(currRain) == RainLevels.None)
                {
                    Game1.addHUDMessage(new HUDMessage(Translation.Get("hud-text.NearlyNoRain")));
                    return(currRain);
                }

                else if (currRain > prevRain)
                {
                    if (WeatherUtilities.GetRainCategory(currRain) != WeatherUtilities.GetRainCategory(prevRain))
                    {
                        Game1.addHUDMessage(new HUDMessage(Translation.Get("hud-text.CateIncrease", new { rain = WeatherUtilities.GetUnitAmt(currRain), category = WeatherUtilities.DescRainCategory(currRain) })));
                        return(currRain);
                    }
                }
                else
                {
                    if (WeatherUtilities.GetRainCategory(currRain) != WeatherUtilities.GetRainCategory(prevRain))
                    {
                        Game1.addHUDMessage(new HUDMessage(Translation.Get("hud-text.CateDecrease", new { rain = WeatherUtilities.GetUnitAmt(currRain), category = WeatherUtilities.DescRainCategory(currRain) })));
                        return(currRain);
                    }
                }
            }

            return(currRain);
        }
Exemple #16
0
        private void ButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            // Custom \\
            // Tile \\
            // Actions \\
            if (e.Button.IsActionButton())
            {
                // grabs player's cursor xy coords
                Vector2 tile = e.Cursor.GrabTile;

                string tileAction = Game1.player.currentLocation.doesTileHaveProperty((int)tile.X, (int)tile.Y, "Action", "Buildings");

                if (tileAction != null)
                {
                    // --- General Tile Actions ---
                    // ----------------------------

                    /// <summary>
                    /// Action | BVEMessage (strMessage)
                    /// If interacted, prints out a message from the i18n key
                    /// </summary>
                    if (tileAction.StartsWith("BVEMessage "))
                    {
                        string[] input = tileAction.Split(' ').Skip(1).ToArray();

                        // get's strMessage
                        string strMessage = i18n.Get(input[0]);

                        //print's message out
                        Game1.drawObjectDialogue(strMessage);
                    }

                    // --- Delete Tiles Actions ---
                    // ----------------------------

                    /// <summary>
                    /// Action | BVECopperAxe (coordX) (coordY) (strLayer)
                    /// If interacted with your Copper axe(+) equipped, it will remove the following tiles on that layer, separate with '/' delimiter
                    /// </summary>
                    if (tileAction.StartsWith("BVECopperAxe "))
                    {
                        // process to get the first word in the current tile action
                        string[] fullString    = tileAction.Split(' ').ToArray();
                        string   currentAction = fullString[0];

                        if (Game1.player.CurrentTool is Axe)
                        {
                            /* --- copper axe or better required --- */
                            if (Game1.player.CurrentTool.UpgradeLevel >= 1)
                            {
                                // skips first word (CopperAxe)
                                string arguments = string.Join(" ", tileAction.Split(' ').Skip(1));

                                // perform deleting tiles
                                DeletedTilesAction(arguments, currentAction);
                            }

                            // does not have copper axe or better
                            else
                            {
                                axeUnderLeveled = true;
                                FailedTileActionState();
                            }
                        }

                        // does not have axe equipped
                        else
                        {
                            axeNotEquipped = true;
                            FailedTileActionState();
                        }
                    }
                }

                /// <summary>
                /// Action | BVESteel Axe (coordX) (coordY) (strLayer
                /// If interacted with your Steel axe(+) equipped, it will remove the following tiles on that layer, separate with '/' delimiter
                /// </summary>
                if (tileAction.StartsWith("BVESteelAxe "))
                {
                    // process to get the first word in the current tile action
                    string[] fullString    = tileAction.Split(' ').ToArray();
                    string   currentAction = fullString[0];

                    if (Game1.player.CurrentTool is Axe)
                    {
                        /* --- steel axe or better required --- */
                        if (Game1.player.CurrentTool.UpgradeLevel >= 2)
                        {
                            // skips first word (SteelAxe)
                            string arguments = string.Join(" ", tileAction.Split(' ').Skip(1));

                            // perform deleting tiles
                            DeletedTilesAction(arguments, currentAction);
                        }

                        // does not have steel axe
                        else
                        {
                            axeUnderLeveled = true;
                            FailedTileActionState();
                        }
                    }

                    // does not have axe equipped
                    else
                    {
                        axeNotEquipped = true;
                        FailedTileActionState();
                    }
                }

                /// <summary>
                /// Action | BVEGold Axe (coordX) (coordY) (strLayer)
                /// If interacted with your Gold axe(+) equipped, it will remove the following tiles on that layer, separate with '/' delimiter
                /// </summary>
                if (tileAction.StartsWith("BVEGoldAxe "))
                {
                    // process to get the first word in the current tile action
                    string[] fullString    = tileAction.Split(' ').ToArray();
                    string   currentAction = fullString[0];

                    if (Game1.player.CurrentTool is Axe)
                    {
                        /* --- steel axe or better required --- */
                        if (Game1.player.CurrentTool.UpgradeLevel >= 2)
                        {
                            // skips first word (SteelAxe)
                            string arguments = string.Join(" ", tileAction.Split(' ').Skip(1));

                            // perform deleting tiles
                            DeletedTilesAction(arguments, currentAction);
                        }

                        // does not have steel axe
                        else
                        {
                            axeUnderLeveled = true;
                            FailedTileActionState();
                        }
                    }

                    // does not have axe equipped
                    else
                    {
                        axeNotEquipped = true;
                        FailedTileActionState();
                    }
                }

                /// <summary>
                /// Action | BVEIridiumAxe (coordX) (coordY) (strLayer)
                /// If interacted with your Iridium axe(+) equipped, it will remove the following tiles on that layer, separate with '/' delimiter
                /// </summary>
                if (tileAction.StartsWith("BVEIridiumAxe "))
                {
                    // process to get the first word in the current tile action
                    string[] fullString    = tileAction.Split(' ').ToArray();
                    string   currentAction = fullString[0];

                    if (Game1.player.CurrentTool is Axe)
                    {
                        /* --- iridium axe or better required --- */
                        if (Game1.player.CurrentTool.UpgradeLevel >= 4)
                        {
                            // skips first word (IridiumAxe)
                            string arguments = String.Join(" ", tileAction.Split(' ').Skip(1));

                            // perform deleting tiles
                            DeletedTilesAction(arguments, currentAction);
                        }

                        // does not have iridium axe
                        else
                        {
                            axeUnderLeveled = true;
                            FailedTileActionState();
                        }
                    }

                    // does not have axe equipped
                    else
                    {
                        axeNotEquipped = true;
                        FailedTileActionState();
                    }
                }
            }
        }
Exemple #17
0
        public static void DoWeatherReminder(ITranslationHelper trans)
        {
            switch (Game1.weatherForTomorrow)
            {
            case 1:
                Util.ShowMessage(trans.Get("weather", new { weather = trans.Get("weather-rain") }));
                break;

            case 2:
                Util.ShowMessage(trans.Get("weather", new { weather = trans.Get("weather-wind") }));
                break;

            case 3:
                Util.ShowMessage(trans.Get("weather", new { weather = trans.Get("weather-tstorm") }));
                break;

            case 5:
                Util.ShowMessage(trans.Get("weather", new { weather = trans.Get("weather-snow") }));
                break;

            case 6:
                Util.ShowMessage(trans.Get("weather", new { weather = trans.Get("weather-wedding") }));
                break;

            case 4:
                Util.ShowMessage(trans.Get("weather", new { weather = trans.Get("weather-festival") }));
                break;

            case 0:
            default:
                Util.ShowMessage(trans.Get("weather", new { weather = trans.Get("weather-sunny") }));
                break;
            }
        }
Exemple #18
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="farmer">The lookup target.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 /// <param name="reflectionHelper">Simplifies access to private game code.</param>
 public FarmerSubject(SFarmer farmer, ITranslationHelper translations, IReflectionHelper reflectionHelper)
     : base(farmer.Name, null, translations.Get(L10n.Types.Player), translations)
 {
     this.Target     = farmer;
     this.Reflection = reflectionHelper;
 }
Exemple #19
0
 internal string GetDescOfDay(SDate date)
 {
     return(Translator.Get("date" + GeneralFunctions.FirstLetterToUpper(date.Season) + date.Day));
 }
Exemple #20
0
 internal static string GetString(string key)
 {
     return(i18n.Get(key));
 }
        /// <summary>Edit the evaluation entries in Strings\StringsFromCSFiles with new dialogues and tokens.</summary>
        /// <typeparam name="_T">The asset Type</typeparam>
        /// <param name="asset">A helper which encapsulates metadata about an asset and enables changes to it</param>
        public void Edit <_T> (IAssetData asset)
        {
            // Can't edit these assets without an active game for spouse, NPC, and year info

            if (!Context.IsWorldReady)
            {
                return;
            }

            // Prepare tokens

            string pastYears;
            int    yearsPassed = Max(Game1.year - 1, Config.YearsBeforeEvaluation);          // Accurate dialogue even for delayed event

            if (yearsPassed >= 10)
            {
                if (Config.GrandpaDialogue == "Nuclear")
                {
                    pastYears = i18n.Get("GrandpaDuringManyYears.Nuclear");
                }
                else
                {
                    pastYears = i18n.Get("GrandpaDuringManyYears");
                }
            }
            else             // yearsPassed < 10
            {
                pastYears = i18n.Get("GrandpaDuringPastYears").ToString().Split('|')[yearsPassed];
            }

            string spouseOrLewis;

            if (Game1.player.isMarried())
            {
                spouseOrLewis = "%spouse";
            }
            else
            {
                spouseOrLewis = Game1.getCharacterFromName <NPC>("Lewis").displayName;
            }

            string fifthCandle = "";
            bool   inOneYear   = Game1.year == 1 || (Game1.year == 2 && Game1.currentSeason == "spring" && Game1.dayOfMonth == 1);

            if (Utility.getGrandpaScore() >= 21 && inOneYear)
            {
                fifthCandle = i18n.Get("FifthCandle." + Config.GrandpaDialogue);
            }

            // Collect all portrait tokens & others

            var allEvaluationTokens = new Dictionary <string, string>(Config.PortraitTokens)
            {
                ["pastYears"]     = pastYears,
                ["spouseOrLewis"] = spouseOrLewis,
                ["fifthCandle"]   = fifthCandle
            };

            // Prepare data

            var data = asset.AsDictionary <string, string>().Data;

            // Main patching loop

            if (asset.AssetNameEquals($"Strings\\StringsFromCSFiles"))
            {
                foreach (string entry in EvaluationStrings)
                {
                    string gameKey = i18n.Get(entry + ".gameKey");
                    string modKey  = entry + "." + Config.GrandpaDialogue;
                    if (Config.GenderNeutrality)
                    {
                        modKey += "-gn";
                    }
                    string value = i18n.Get(modKey, allEvaluationTokens);

                    data[gameKey] = value;
                }
            }
        }
Exemple #22
0
        public DataLoader(IModHelper helper)
        {
            Helper    = helper;
            I18N      = helper.Translation;
            ModConfig = helper.ReadConfig <ModConfig>();

            CraftingData = DataLoader.Helper.ReadJsonFile <CraftingData>("data\\CraftingRecipes.json") ?? new CraftingData();
            DataLoader.Helper.WriteJsonFile("data\\CraftingRecipes.json", CraftingData);

            var editors = Helper.Content.AssetEditors;

            editors.Add(this);

            if (!ModConfig.DisableIridiumQualityFish)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "IridiumQualityFishWithWildBait"
                        , I18N.Get("IridiumQualityFishWithWildBait.Letter")
                        , (l) => !Game1.player.mailReceived.Contains(l.Id) && Game1.player.craftingRecipes.ContainsKey("Wild Bait") && Game1.player.FishingLevel >= 4
                        , (l) => Game1.player.mailReceived.Add(l.Id)
                    )
                );
            }

            AddLetter(BaitTackle.EverlastingBait, (l) => Game1.player.FishingLevel >= 10 && GetNpcFriendship("Willy") >= 10 * 250 && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.EverlastingBait.GetDescription()));
            AddLetter(BaitTackle.EverlastingWildBait, (l) => Game1.player.craftingRecipes.ContainsKey("Wild Bait") && Game1.player.craftingRecipes.ContainsKey(BaitTackle.EverlastingBait.GetDescription()) && Game1.player.craftingRecipes[BaitTackle.EverlastingBait.GetDescription()] > 0 && GetNpcFriendship("Linus") >= 10 * 250 && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.EverlastingWildBait.GetDescription()));
            AddLetter(BaitTackle.EverlastingMagnet, (l) => Game1.player.FishingLevel >= 10 && GetNpcFriendship("Wizard") >= 10 * 250 && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.EverlastingMagnet.GetDescription()), null, 2);
            MailDao.SaveLetter
            (
                new Letter
                (
                    "UnbreakableTackleIntroduction"
                    , I18N.Get("UnbreakableTackleIntroduction.Letter")
                    , (l) => !Game1.player.mailReceived.Contains(l.Id) && Game1.player.achievements.Contains(21) && Game1.player.FishingLevel >= 8 && GetNpcFriendship("Willy") >= 6 * 250 && GetNpcFriendship("Clint") >= 6 * 250
                    , (l) => Game1.player.mailReceived.Add(l.Id)
                )
            );
            AddLetter
            (
                BaitTackle.UnbreakableSpinner
                , (l) => Game1.player.achievements.Contains(21) && Game1.player.FishingLevel >= 8 && GetNpcFriendship("Willy") >= 6 * 250 && GetNpcFriendship("Clint") >= 6 * 250 && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableSpinner.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableSpinner)
            );
            AddLetter
            (
                BaitTackle.UnbreakableLeadBobber
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableSpinner.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableLeadBobber.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableLeadBobber)
            );
            AddLetter
            (
                BaitTackle.UnbreakableTrapBobber
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableLeadBobber.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableTrapBobber.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableTrapBobber)
            );
            AddLetter
            (
                BaitTackle.UnbreakableCorkBobber
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableTrapBobber.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableCorkBobber.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableCorkBobber)
            );
            AddLetter
            (
                BaitTackle.UnbreakableTreasureHunter
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableCorkBobber.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableTreasureHunter.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableTreasureHunter)
            );
            AddLetter
            (
                BaitTackle.UnbreakableBarbedHook
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableTreasureHunter.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableBarbedHook.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableBarbedHook)
            );
            AddLetter
            (
                BaitTackle.UnbreakableDressedSpinner
                , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableBarbedHook.GetQuestName()) && !Game1.player.craftingRecipes.ContainsKey(BaitTackle.UnbreakableDressedSpinner.GetDescription())
                , (l) => LoadTackleQuest(BaitTackle.UnbreakableDressedSpinner)
            );
            MailDao.SaveLetter
            (
                new Letter
                (
                    "UnbreakableTackleReward"
                    , I18N.Get("UnbreakableTackleReward.Letter")
                    , new List <Item> {
                new StardewValley.Object(74, 1)
            }
                    , (l) => Game1.player.mailReceived.Contains(BaitTackle.UnbreakableDressedSpinner.GetQuestName()) && !Game1.player.mailReceived.Contains(l.Id)
                    , (l) =>
            {
                Game1.player.mailReceived.Add(l.Id);
            }
                )
            );
        }
Exemple #23
0
 /********************************
  ** Config Menu Initialization **
  ********************************/
 
 /// <summary>Initializes menu for Generic Mod Config Menu on game launch.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event data.</param>
 private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
 {
     try
     {
         // Get Generic Mod Config Menu's API (if it's installed).
         var configMenu = Helper.ModRegistry.GetApi<IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");
         if (configMenu is null)
             return;
         
         // Register mod.
         configMenu.Register(mod: ModManifest, reset: () => Config = new ModConfig(), save: () => Helper.WriteConfig(Config));
         
         // Add options.
         configMenu.AddSectionTitle(mod: ModManifest, text: () => str.Get("headerRanges"));
         
         List<string> rangeList = new List<string>();
         rangeList.Add("1");
         rangeList.Add("-1");
         for (int i = 2; i <= 20; i++)
             rangeList.Add(i.ToString());
         
         foreach (string subject in new string[] { "axe", "pickaxe", "hoe", "wateringCan", "seeds", "objects" })
         {
             configMenu.AddTextOption(
                 mod: ModManifest,
                 name: () => str.Get("optionRangeName", new { subject = str.Get(subject + "ForRangeName") }),
                 tooltip: () => str.Get("optionRangeTooltip", new { subject = str.Get(subject + "ForRangeTooltip") }),
                 getValue: () =>
                 {
                     int value = 1;
                     switch (subject)
                     {
                         case "axe": value = Config.AxeRange; break;
                         case "pickaxe": value = Config.PickaxeRange; break;
                         case "hoe": value = Config.HoeRange; break;
                         case "wateringCan": value = Config.WateringCanRange; break;
                         case "seeds": value = Config.SeedRange; break;
                         case "objects": value = Config.ObjectPlaceRange; break;
                     }
                     return rangeList[value == 1? 0 // Default
                                    : value < 0? 1 // Unlimited
                                    : value]; // Extended
                 },
                 setValue: strValue =>
                 {
                     int value = 1;
                     if (strValue.Equals(rangeList[0]))
                         value = 1;
                     else if (strValue.Equals(rangeList[1]))
                         value = -1;
                     else
                     {
                         for (int i = 2; i <= 20; i++)
                         {
                             if (strValue.Equals(rangeList[i]))
                             {
                                 value = i;
                                 break;
                             }
                         }
                     }
                     
                     switch (subject)
                     {
                         case "axe": Config.AxeRange = value; break;
                         case "pickaxe": Config.PickaxeRange = value; break;
                         case "hoe": Config.HoeRange = value; break;
                         case "wateringCan": Config.WateringCanRange = value; break;
                         case "seeds": Config.SeedRange = value; break;
                         case "objects": Config.ObjectPlaceRange = value; break;
                     }
                 },
                 allowedValues: rangeList.ToArray(),
                 formatAllowedValue: value =>
                 {
                     if (value.Equals("1"))
                         return str.Get("rangeDefault");
                     else if (value.Equals("-1"))
                         return str.Get("rangeUnlimited");
                     else
                         return str.Get("rangeExtended", new { tiles = value });
                 }
             );
         }
         
         configMenu.AddSectionTitle(mod: ModManifest, text: () => str.Get("headerUseOnTile"));
         
         foreach (string tool in new string[] { "axe", "pickaxe", "hoe" })
         {
             configMenu.AddBoolOption(
                 mod: ModManifest,
                 name: () => str.Get("optionSelfUsabilityName", new { tool = str.Get(tool + "ForUsabilityName") }),
                 tooltip: () => str.Get("optionSelfUsabilityTooltip", new { tool = str.Get(tool + "ForUsabilityTooltip") }),
                 getValue: () =>
                 {
                     switch (tool)
                     {
                         case "axe": return Config.AxeUsableOnPlayerTile;
                         case "pickaxe": return Config.PickaxeUsableOnPlayerTile;
                         case "hoe": return Config.HoeUsableOnPlayerTile;
                     }
                     return true;
                 },
                 setValue: value =>
                 {
                     switch (tool)
                     {
                         case "axe": Config.AxeUsableOnPlayerTile = value; break;
                         case "pickaxe": Config.PickaxeUsableOnPlayerTile = value; break;
                         case "hoe": Config.HoeUsableOnPlayerTile = value; break;
                     }
                 }
             );
         }
         
         configMenu.AddSectionTitle(mod: ModManifest, text: () => str.Get("headerFaceClick"));
         
         configMenu.AddBoolOption(
             mod: ModManifest,
             name: () => str.Get("optionToolFaceClickName"),
             tooltip: () => str.Get("optionToolFaceClickTooltip"),
             getValue: () => Config.ToolAlwaysFaceClick,
             setValue: value => Config.ToolAlwaysFaceClick = value
         );
         
         configMenu.AddBoolOption(
             mod: ModManifest,
             name: () => str.Get("optionWeaponFaceClickName"),
             tooltip: () => str.Get("optionWeaponFaceClickTooltip"),
             getValue: () => Config.WeaponAlwaysFaceClick,
             setValue: value => Config.WeaponAlwaysFaceClick = value
         );
         
         configMenu.AddSectionTitle(mod: ModManifest, text: () => str.Get("headerMisc"));
         
         configMenu.AddTextOption(
             mod: ModManifest,
             name: () => str.Get("optionToolHitLocationName"),
             tooltip: () => str.Get("optionToolHitLocationTooltip"),
             getValue: () => Config.ToolHitLocationDisplay.ToString(),
             setValue: value => Config.ToolHitLocationDisplay = int.Parse(value),
             allowedValues: new string[] { "0", "1", "2" },
             formatAllowedValue: value =>
             {
                 switch (value)
                 {
                     case "0": return str.Get("locationLogicOriginal");
                     case "1": default: return str.Get("locationLogicNew");
                     case "2": return str.Get("locationLogicCombined");
                 }
             }
         );
         
         configMenu.AddBoolOption(
             mod: ModManifest,
             name: () => str.Get("optionAllowRangedChargeName"),
             tooltip: () => str.Get("optionAllowRangedChargeTooltip"),
             getValue: () => Config.AllowRangedChargeEffects,
             setValue: value => Config.AllowRangedChargeEffects = value
         );
         
         configMenu.AddBoolOption(
             mod: ModManifest,
             name: () => str.Get("optionOnClickOnlyName"),
             tooltip: () => str.Get("optionOnClickOnlyTooltip"),
             getValue: () => Config.CustomRangeOnClickOnly,
             setValue: value => Config.CustomRangeOnClickOnly = value
         );
     }
     catch (Exception exception)
     {
         Log("Error setting up mod config menu (menu may not appear): " + exception.InnerException
           + Environment.NewLine + exception.StackTrace);
     }
 }
Exemple #24
0
        private bool OpenMenuHandler(bool isActionKey)
        {
            // returns true if menu is opened, otherwise false

            String  locationString = Game1.player.currentLocation.Name;
            Vector2 playerPosition = Game1.player.getTileLocation();
            int     faceDirection  = Game1.player.getFacingDirection();

            bool result = false; // default

            if (ShouldOpen(isActionKey, Game1.player.getFacingDirection(), locationString, playerPosition))
            {
                result = true;
                switch (locationString)
                {
                case "SeedShop":
                    Game1.player.currentLocation.createQuestionDialogue(
                        i18n.Get("SeedShop_Menu"),
                        new Response[2]
                    {
                        new Response("Shop", i18n.Get("SeedShopMenu_Shop")),
                        new Response("Leave", i18n.Get("SeedShopMenu_Leave"))
                    },
                        delegate(Farmer who, string whichAnswer)
                    {
                        switch (whichAnswer)
                        {
                        case "Shop":
                            Game1.activeClickableMenu = (IClickableMenu) new ShopMenu(Utility.getShopStock(true), 0, "Pierre");
                            break;

                        case "Leave":
                            // do nothing
                            break;

                        default:
                            Monitor.Log($"invalid dialogue answer: {whichAnswer}", LogLevel.Info);
                            break;
                        }
                    }
                        );
                    break;

                case "AnimalShop":
                    Game1.player.currentLocation.createQuestionDialogue(
                        i18n.Get("AnimalShop_Menu"),
                        new Response[3]
                    {
                        new Response("Supplies", Game1.content.LoadString("Strings\\Locations:AnimalShop_Marnie_Supplies")),
                        new Response("Purchase", Game1.content.LoadString("Strings\\Locations:AnimalShop_Marnie_Animals")),
                        new Response("Leave", Game1.content.LoadString("Strings\\Locations:AnimalShop_Marnie_Leave"))
                    },
                        "Marnie"
                        );
                    break;

                case "ScienceHouse":
                    if (Game1.player.daysUntilHouseUpgrade < 0 && !Game1.getFarm().isThereABuildingUnderConstruction())
                    {
                        Response[] answerChoices;
                        if (Game1.player.HouseUpgradeLevel < 3)
                        {
                            answerChoices = new Response[4]
                            {
                                new Response("Shop", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_Shop")),
                                new Response("Upgrade", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_UpgradeHouse")),
                                new Response("Construct", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_Construct")),
                                new Response("Leave", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_Leave"))
                            }
                        }
                        ;
                        else
                        {
                            answerChoices = new Response[3]
                            {
                                new Response("Shop", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_Shop")),
                                new Response("Construct", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_Construct")),
                                new Response("Leave", Game1.content.LoadString("Strings\\Locations:ScienceHouse_CarpenterMenu_Leave"))
                            }
                        };

                        Game1.player.currentLocation.createQuestionDialogue(i18n.Get("ScienceHouse_CarpenterMenu"), answerChoices, "carpenter");
                    }
                    else
                    {
                        Game1.activeClickableMenu = (IClickableMenu) new ShopMenu(Utility.getCarpenterStock(), 0, "Robin");
                    }
                    break;

                case "FishShop":
                    Game1.player.currentLocation.createQuestionDialogue(
                        (SDate.Now() != new SDate(9, "spring")) ? i18n.Get("FishShop_Menu") : i18n.Get("FishShop_Menu_DocVisit"),
                        new Response[2]
                    {
                        new Response("Shop", i18n.Get("FishShopMenu_Shop")),
                        new Response("Leave", i18n.Get("FishShopMenu_Leave"))
                    },
                        delegate(Farmer who, string whichAnswer)
                    {
                        switch (whichAnswer)
                        {
                        case "Shop":
                            Game1.activeClickableMenu = (IClickableMenu) new ShopMenu(Utility.getFishShopStock(Game1.player), 0, "Willy");
                            break;

                        case "Leave":
                            // do nothing
                            break;

                        default:
                            Monitor.Log($"invalid dialogue answer: {whichAnswer}", LogLevel.Info);
                            break;
                        }
                    }
                        );
                    break;

                default:
                    Monitor.Log($"invalid location: {locationString}", LogLevel.Info);
                    break;
                }
            }

            return(result);
        }
Exemple #25
0
        /// <summary>Convert the blueprint data to a string stardew valley understands, and replace the name and description with the current language variants, if present.</summary>
        /// <param name="i18n"></param>
        /// <returns>The blueprint in the format Stardew Valley understands</returns>
        public string ToBlueprintString(ITranslationHelper i18n)
        {
            string s;

            string items = string.Join(" ", ItemsRequired);

#pragma warning disable CS8601 // Possible null reference assignment.
            s = string.Join("/", new string[] { items, Width, Height, HumanDoorX, HumanDoorY, AnimalDoorX, AnimalDoorY, MapToWarpTo, i18n.Get("industrial-furnace.name"), i18n.Get("industrial-furnace.description"),
                                                BlueprintType, NameOfBuildingToUpgrade, SourceRectForMenuViewX, SourceRectForMenuViewY, MaxOccupants, ActionBehaviour, NamesOfBuildingLocations, MoneyRequired, Magical, DaysToBuild });
#pragma warning restore CS8601 // Possible null reference assignment.

            return(s);
        }
Exemple #26
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.Quests.ToString(), i18n.Get("tabs.quests")));
                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)));
            }

            int slotWidth = this.OptionSlots[0].bounds.Width;

            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, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("money.add-amount", new { amount = 1000 }), 3, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("money.add-amount", new { amount = 10000 }), 4, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("money.add-amount", new { amount = 100000 }), 5, slotWidth, 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, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("casino-coins.add-amount", new { amount = 1000 }), 7, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("casino-coins.add-amount", new { amount = 10000 }), 8, slotWidth, 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, slotWidth, 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, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-mining"), 201, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-foraging"), 202, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-fishing"), 203, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.increase-combat"), 204, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("skills.reset"), 205, slotWidth, 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.mariner), value => this.SetProfession(SFarmer.mariner, value)));     // mariner = luremaster (???)
                this.Options.Add(new CheatsOptionsCheckbox(i18n.Get("professions.fishing.mariner"), this.GetProfession(SFarmer.baitmaster), value => this.SetProfession(SFarmer.baitmaster, value)));  // baitmaster = mariner (???)
                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, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("weather.raining"), 11, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("weather.lightning"), 12, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("weather.snowing"), 13, slotWidth, 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 this.GetSocialCharacters().Distinct().OrderBy(p => p.displayName))
                {
                    this.Options.Add(new CheatsOptionsNpcSlider(npc, onValueChanged: points => this.Cheats.UpdateFriendship(npc, points)));
                }
            }
            break;

            case MenuTab.WarpLocations:
                this.Options.Add(new OptionsElement($"{i18n.Get("warp.title")}:"));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.farm"), slotWidth, this.WarpToFarm));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.pierre-shop"), slotWidth, () => this.Warp("Town", 43, 57)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.blacksmith"), slotWidth, () => this.Warp("Town", 94, 82)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.museum"), slotWidth, () => this.Warp("Town", 101, 90)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.saloon"), slotWidth, () => this.Warp("Town", 45, 71)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.community-center"), slotWidth, () => this.Warp("Town", 52, 20)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.carpenter"), slotWidth, () => this.Warp("Mountain", 12, 26)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.adventurers-guild"), slotWidth, () => this.Warp("Mountain", 76, 9)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.ranch"), slotWidth, () => this.Warp("Forest", 90, 16)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.mines"), slotWidth, () => this.Warp("Mine", 13, 10)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.willy-shop"), slotWidth, () => this.Warp("Beach", 30, 34)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.wizard-tower"), slotWidth, () => this.Warp("Forest", 5, 27)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.hats"), slotWidth, () => this.Warp("Forest", 34, 96)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.desert"), slotWidth, () => this.Warp("Desert", 18, 28)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.sandy-shop"), slotWidth, () => this.Warp("SandyHouse", 4, 8)));
                if (Game1.player.hasClubCard)
                {
                    this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.casino"), slotWidth, () => this.Warp("Club", 8, 11)));
                }
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.quarry"), slotWidth, () => this.Warp("Mountain", 127, 12)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.new-beach"), slotWidth, () => this.Warp("Beach", 87, 26)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.secret-woods"), slotWidth, () => this.Warp("Woods", 58, 15)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.sewer"), slotWidth, () => this.Warp("Sewer", 3, 48)));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("warp.bathhouse"), slotWidth, () => this.Warp("Railroad", 10, 57)));
                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.Quests:
            {
                this.Options.Add(new OptionsElement($"{i18n.Get("activequests.title")}:"));
                {
                    int i = 0;
                    foreach (Quest quest in Game1.player.questLog)
                    {
                        if (!quest.completed.Value)
                        {
                            this.Options.Add(new CheatsOptionsInputListener(quest.questTitle, 300 + i++, slotWidth, config, cheats, i18n));
                        }
                    }
                }
                this.Options.Add(new OptionsElement($"{i18n.Get("completedquests.title")}:"));

                foreach (Quest quest in Game1.player.questLog)
                {
                    if (quest.completed.Value)
                    {
                        this.Options.Add(new OptionsElement(quest.questTitle)
                            {
                                whichOption = -999
                            });
                    }
                }
            }
            break;

            case MenuTab.Controls:
                this.Options.Add(new OptionsElement($"{i18n.Get("controls.title")}:"));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("controls.open-menu"), 1000, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("controls.freeze-time"), 1001, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("controls.grow-tree"), 1002, slotWidth, config, cheats, i18n));
                this.Options.Add(new CheatsOptionsInputListener(i18n.Get("controls.grow-crops"), 1003, slotWidth, config, cheats, i18n));
                break;
            }
            this.SetScrollBarToCurrentIndex();
        }
Exemple #27
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="tree">The lookup target.</param>
 /// <param name="tile">The tree's tile position.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public FruitTreeSubject(GameHelper gameHelper, FruitTree tree, Vector2 tile, ITranslationHelper translations)
     : base(gameHelper, translations.Get(L10n.FruitTree.Name, new { fruitName = gameHelper.GetObjectBySpriteIndex(tree.indexOfFruit.Value).DisplayName }), null, translations.Get(L10n.Types.FruitTree), translations)
 {
     this.Target = tree;
     this.Tile   = tile;
 }
Exemple #28
0
        internal JoeMenu(int width, int height)
            : base(Game1.viewport.Width / 2 - width / 2, Game1.viewport.Height / 2 - height / 2, width, height, true)
        {
            ITranslationHelper translation = InstanceHolder.Translation;

            _upCursor   = new ClickableTextureComponent("up-arrow", new Rectangle(xPositionOnScreen + this.width + Game1.tileSize / 4, yPositionOnScreen + Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 459, 11, 12), Game1.pixelZoom);
            _downCursor = new ClickableTextureComponent("down-arrow", new Rectangle(xPositionOnScreen + this.width + Game1.tileSize / 4, yPositionOnScreen + this.height - Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), "", "", Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom);

            _scrollBar       = new ClickableTextureComponent(new Rectangle(_upCursor.bounds.X + 12, _upCursor.bounds.Y + _upCursor.bounds.Height + 4, 24, 40), Game1.mouseCursors, new Rectangle(435, 463, 6, 10), 4f);
            _scrollBarRunner = new Rectangle(_scrollBar.bounds.X, _upCursor.bounds.Y + _upCursor.bounds.Height + 4, _scrollBar.bounds.Width, height - 128 - _upCursor.bounds.Height - 8);

            _tabAutomationString = translation.Get("tab.automation");
            Vector2 size = _font.MeasureString(_tabAutomationString);

            _tabAutomation = new Rectangle(xPositionOnScreen - (int)size.X - 20, yPositionOnScreen, (int)size.X + 32, 64);

            _tabUIsString = translation.Get("tab.UIs");
            size          = _font.MeasureString(_tabUIsString);
            _tabUIs       = new Rectangle(xPositionOnScreen - (int)size.X - 20, yPositionOnScreen + 68, (int)size.X + 32, 64);

            _tabMiscString = translation.Get("tab.misc");
            size           = _font.MeasureString(_tabMiscString);
            _tabMisc       = new Rectangle(xPositionOnScreen - (int)size.X - 20, yPositionOnScreen + 68 * 2, (int)size.X + 32, 64);

            _tabControlsString = translation.Get("tab.controls");
            size         = _font.MeasureString(_tabControlsString);
            _tabControls = new Rectangle(xPositionOnScreen - (int)size.X - 20, yPositionOnScreen + 68 * 3, (int)size.X + 32, 64);

            {
                //Automation Tab
                MenuTab tab = new MenuTab();
                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Balanced Mode"));
                tab.AddOptionsElement(new ModifiedCheckBox("BalancedMode", 20, Config.BalancedMode, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Water Nearby Crops"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoWaterNearbyCrops", 2, Config.AutoWaterNearbyCrops, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("AutoWaterRadius", 3, Config.AutoWaterRadius, 1, 3, OnSliderValueChanged, () => !Config.AutoWaterNearbyCrops || Config.BalancedMode));
                tab.AddOptionsElement(new ModifiedCheckBox("FindCanFromInventory", 16, Config.FindCanFromInventory, OnCheckboxValueChanged, i => !(Config.AutoWaterNearbyCrops || Config.AutoRefillWateringCan)));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Pet Nearby Animals/Pets"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoPetNearbyAnimals", 3, Config.AutoPetNearbyAnimals, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoPetNearbyPets", 24, Config.AutoPetNearbyPets, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("AutoPetRadius", 4, Config.AutoPetRadius, 1, 3, OnSliderValueChanged, () => !Config.AutoPetNearbyAnimals || Config.BalancedMode));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Animal Door"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoAnimalDoor", 4, Config.AutoAnimalDoor, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Fishing"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoFishing", 5, Config.AutoFishing, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("CPUThresholdFishing", 0, (int)(Config.CpuThresholdFishing * 10), 0, 5, OnSliderValueChanged, () => !Config.AutoFishing, Format));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Fishing Tweaks")); tab.AddOptionsElement(new ModifiedCheckBox("AutoReelRod", 6, Config.AutoReelRod, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Gate"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoGate", 9, Config.AutoGate, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Eat"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoEat", 10, Config.AutoEat, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("StaminaToEatRatio", 1, (int)(Config.StaminaToEatRatio * 10), 1, 8, OnSliderValueChanged, () => !Config.AutoEat, Format));
                tab.AddOptionsElement(new ModifiedSlider("HealthToEatRatio", 2, (int)(Config.HealthToEatRatio * 10), 1, 8, OnSliderValueChanged, () => !Config.AutoEat, Format));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Harvest"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoHarvest", 11, Config.AutoHarvest, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("AutoHarvestRadius", 5, Config.AutoHarvestRadius, 1, 3, OnSliderValueChanged, () => !Config.AutoHarvest || Config.BalancedMode));
                tab.AddOptionsElement(new ModifiedCheckBox("ProtectNectarProducingFlower", 25, Config.ProtectNectarProducingFlower, OnCheckboxValueChanged, i => !Config.AutoHarvest));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Destroy Dead Crops"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoDestroyDeadCrops", 12, Config.AutoDestroyDeadCrops, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Refill Watering Can"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoRefillWateringCan", 13, Config.AutoRefillWateringCan, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Collect Collectibles"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoCollectCollectibles", 14, Config.AutoCollectCollectibles, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("AutoCollectRadius", 6, Config.AutoCollectRadius, 1, 3, OnSliderValueChanged, () => !Config.AutoCollectCollectibles || Config.BalancedMode));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Shake Fruited Plants"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoShakeFruitedPlants", 15, Config.AutoShakeFruitedPlants, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("AutoShakeRadius", 7, Config.AutoShakeRadius, 1, 3, OnSliderValueChanged, () => !Config.AutoShakeFruitedPlants || Config.BalancedMode));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Dig Artifact Spot"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoDigArtifactSpot", 17, Config.AutoDigArtifactSpot, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("AutoDigRadius", 8, Config.AutoDigRadius, 1, 3, OnSliderValueChanged, () => !Config.AutoDigArtifactSpot || Config.BalancedMode));
                tab.AddOptionsElement(new ModifiedCheckBox("FindHoeFromInventory", 18, Config.FindHoeFromInventory, OnCheckboxValueChanged, i => !Config.AutoDigArtifactSpot));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Deposit/Pull Machines"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoDepositIngredient", 22, Config.AutoDepositIngredient, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoPullMachineResult", 23, Config.AutoPullMachineResult, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("MachineRadius", 10, Config.MachineRadius, 1, 3, OnSliderValueChanged, () => !(Config.AutoPullMachineResult || Config.AutoDepositIngredient) || Config.BalancedMode));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Loot Treasures"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoLootTreasures", 30, Config.AutoLootTreasures, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedCheckBox("CloseTreasureWhenAllLooted", 31, Config.CloseTreasureWhenAllLooted, OnCheckboxValueChanged));


                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Pick Up Trash"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoPickUpTrash", 34, Config.AutoPickUpTrash, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("ScavengingRadius", 13, Config.ScavengingRadius, 1, 3, OnSliderValueChanged, () => !Config.AutoPickUpTrash || Config.BalancedMode));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Shearing and Milking"));
                tab.AddOptionsElement(new ModifiedCheckBox("AutoShearingAndMilking", 35, Config.AutoShearingAndMilking, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("AnimalHarvestRadius", 14, Config.AnimalHarvestRadius, 1, 3, OnSliderValueChanged, () => !Config.AutoShearingAndMilking || Config.BalancedMode));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Collect Letter Attachments And Quests"));
                tab.AddOptionsElement(new ModifiedCheckBox("CollectLetterAttachmentsAndQuests", 36, Config.CollectLetterAttachmentsAndQuests, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Farm Cleaner"));
                tab.AddOptionsElement(new ModifiedSlider("ScavengingRadius", 16, Config.RadiusFarmCleanup, 1, 3, OnSliderValueChanged, () => !(Config.CutWeeds || Config.ChopTwigs || Config.BreakRocks)));
                tab.AddOptionsElement(new ModifiedCheckBox("CutWeeds", 39, Config.CutWeeds, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedCheckBox("BreakRocks", 40, Config.BreakRocks, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedCheckBox("ChopTwigs", 41, Config.ChopTwigs, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                _tabs.Add(tab);
            }
            {
                //UIs Tab
                MenuTab tab = new MenuTab();

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Config Menu"));
                tab.AddOptionsElement(new ModifiedCheckBox("FilterBackgroundInMenu", 32, Config.FilterBackgroundInMenu, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedCheckBox("ShowMousePositionWhenAssigningLocation", 38, Config.ShowMousePositionWhenAssigningLocation, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Mine Info GUI"));
                tab.AddOptionsElement(new ModifiedCheckBox("MineInfoGUI", 0, Config.MineInfoGui, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Gift Information Tooltip"));
                tab.AddOptionsElement(new ModifiedCheckBox("GiftInformation", 1, Config.GiftInformation, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Fishing Info"));
                tab.AddOptionsElement(new ModifiedCheckBox("FishingInfo", 8, Config.FishingInfo, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Fishing Probabilities Information"));
                tab.AddOptionsElement(new ModifiedCheckBox("FishingProbabilitiesInfo", 26, Config.FishingProbabilitiesInfo, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedClickListener(this, "ProbBoxLocation", 0, Config.ProbBoxCoordinates.X, Config.ProbBoxCoordinates.Y, translation, OnSomewhereClicked, OnStartListeningClick));
                tab.AddOptionsElement(new ModifiedCheckBox("MorePreciseProbabilities", 37, Config.MorePreciseProbabilities, OnCheckboxValueChanged, i => !Config.FishingProbabilitiesInfo));
                tab.AddOptionsElement(new ModifiedSlider("TrialOfExamine", 15, Config.TrialOfExamine, 1, 10, OnSliderValueChanged, () => !(Config.FishingProbabilitiesInfo && Config.MorePreciseProbabilities)));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Show Shipping Price"));
                tab.AddOptionsElement(new ModifiedCheckBox("EstimateShippingPrice", 28, Config.EstimateShippingPrice, OnCheckboxValueChanged));
                tab.AddOptionsElement(
                    new ModifiedClickListener(this, "PriceBoxCoordinates", 1,
                                              Config.PriceBoxCoordinates.X, Config.PriceBoxCoordinates.Y, translation, OnSomewhereClicked,
                                              OnStartListeningClick));

                tab.AddOptionsElement(new EmptyLabel());
                _tabs.Add(tab);
            }
            {
                //Misc Tab
                MenuTab tab = new MenuTab();

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Unify Flower Colors"));
                tab.AddOptionsElement(new ModifiedCheckBox("UnifyFlowerColors", 29, Config.UnifyFlowerColors, OnCheckboxValueChanged));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Pause When Idle"));
                tab.AddOptionsElement(new ModifiedCheckBox("PauseWhenIdle", 33, Config.PauseWhenIdle, OnCheckboxValueChanged));
                tab.AddOptionsElement(new ModifiedSlider("IdleTimeout", 12, Config.IdleTimeout, 1, 300, OnSliderValueChanged, () => !Config.PauseWhenIdle, (which, value) => value + "s"));

                tab.AddOptionsElement(new EmptyLabel());
                _tabs.Add(tab);
            }
            {
                //Controls Tab
                MenuTab tab = new MenuTab();

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Config Menu"));
                tab.AddOptionsElement(new ModifiedInputListener(this, "KeyShowMenu", 0, Config.ButtonShowMenu, translation, OnInputListenerChanged, OnStartListening));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Auto Harvest"));
                tab.AddOptionsElement(new ModifiedInputListener(this, "KeyToggleBlackList", 1, Config.ButtonToggleBlackList, translation, OnInputListenerChanged, OnStartListening));

                tab.AddOptionsElement(new EmptyLabel());
                tab.AddOptionsElement(new LabelComponent("Unify Flower Colors"));
                tab.AddOptionsElement(new ModifiedInputListener(this, "ButtonToggleFlowerColorUnification", 2, Config.ButtonToggleFlowerColorUnification, translation, OnInputListenerChanged, OnStartListening));

                tab.AddOptionsElement(new EmptyLabel());
                _tabs.Add(tab);
            }
        }
Exemple #29
0
        public static void AddTrait(CropTrait trait, List <CropTrait> traits, int id)
        {
            ITranslationHelper trans = ModEntry.GetHelper().Translation;

            void add()
            {
                ModEntry.GetMonitor().Log($"Added {trait} to {CropSeedsDisplayName(id)}", LogLevel.Trace);
                Game1.showGlobalMessage(trans.Get("cult.msg_traitinc", new { traitdesc = GetTraitDescr(trait), seed = CropSeedsDisplayName(id), trait = GetTraitName(trait) }));
                traits.Add(trait);
                CropTraits[id] = traits;
            }

            bool alreadyContains() => traits.Contains(trait);

            CropTrait newTrait = GetNewRandomTrait(traits);

            if (traits.Contains(newTrait))
            {
                ModEntry.GetMonitor().Log("Bug: tried to find new trait with full list or returned wrong trait", LogLevel.Error);
                return;
            }

            if (alreadyContains())
            {
                switch (trait)
                {
                case CropTrait.PestResistanceI:
                    AddTrait(CropTrait.PestResistanceII, traits, id);
                    break;

                case CropTrait.WaterI:
                    AddTrait(CropTrait.WaterII, traits, id);
                    break;

                case CropTrait.QualityI:
                    AddTrait(CropTrait.QualityII, traits, id);
                    break;

                case CropTrait.SpeedI:
                    AddTrait(CropTrait.SpeedII, traits, id);
                    break;

                default:
                    AddTrait(newTrait, traits, id);
                    break;
                }
            }
            else
            {
                switch (trait)
                {
                case CropTrait.PestResistanceII:
                    if (traits.Contains(CropTrait.PestResistanceI))
                    {
                        add();
                    }
                    else
                    {
                        trait = CropTrait.PestResistanceI;
                        add();
                    }
                    break;

                case CropTrait.WaterII:
                    if (traits.Contains(CropTrait.WaterI))
                    {
                        add();
                    }
                    else
                    {
                        trait = CropTrait.WaterI;
                        add();
                    }

                    break;

                case CropTrait.QualityII:
                    if (traits.Contains(CropTrait.QualityI))
                    {
                        add();
                    }
                    else
                    {
                        trait = CropTrait.QualityI;
                        add();
                    }

                    break;

                case CropTrait.SpeedII:
                    if (traits.Contains(CropTrait.SpeedI))
                    {
                        add();
                    }
                    else
                    {
                        trait = CropTrait.SpeedI;
                        add();
                    }
                    break;

                default:
                    add();
                    break;
                }
            }
        }
Exemple #30
0
        /// <summary>Constructs a Buff instance to match the ongoing effects of sunburn.</summary>
        /// <param name="level">Level of sunburn damage</param>
        private Buff NewSunburnDebuff(int level)
        {
            level = Math.Max(1, Math.Min(MAX_LEVEL, level));
            //int staminaDebuff = Config.EnergyLossPerLevel * level * -1;
            //int defenseDebuff = Config.DefenseLossPerLevel * level * -1;
            int speedDebuff   = Config.SunburnSpeedDebuff ? -1 : 0;
            int inGameMinutes = 60 * 40; //40 hours, more than plenty to last the day

            /*return new Buff(0, 0, 0, 0, 0, 0, 0,
             *  staminaDebuff, 0, speedDebuff, defenseDebuff, 0,
             *  inGameMinutes, $"{FlagBase}Sunburn", $"Sunburn ({severity})"); //Broken buff */

            string severity = i18n.Get("Severity.Mild");

            if (level > 1)
            {
                severity = i18n.Get("Severity.Moderate");
            }
            if (level > 2)
            {
                severity = i18n.Get("Severity.Severe");
            }

            return(new Buff(0, 0, 0, 0, 0, 0, 0, 0, 0, speedDebuff, 0, 0,
                            inGameMinutes, $"{FLAG_BASE}Sunburn", i18n.Get("Sunburn.DebuffSource", new { severity }))); //Working buff
        }