/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="initialTab">The tab to display by default.</param> /// <param name="cheats">The cheats helper.</param> /// <param name="monitor">Encapsulates monitoring and logging.</param> public CheatsMenu(MenuTab initialTab, CheatManager cheats, IMonitor monitor) { this.Cheats = cheats; this.Monitor = monitor; this.CurrentTab = initialTab; this.ResetComponents(); this.SetOptions(); }
/// <summary>Set the options to display.</summary> private void SetOptions() { CheatManager cheats = this.Cheats; CheatContext context = cheats.Context; ModConfig config = context.Config; cheats.Context.SlotWidth = this.OptionSlots[0].bounds.Width; this.Options.Clear(); switch (this.CurrentTab) { case MenuTab.PlayerAndTools: // player this.AddOptions( $"{I18n.Player_Title()}:", cheats.InfiniteHealth, cheats.InfiniteStamina, cheats.InstantCooldowns, cheats.OneHitKill, cheats.MaxDailyLuck, cheats.MoveSpeed, cheats.InventorySize ); // tools this.AddOptions( $"{I18n.Tools_Title()}:", cheats.InfiniteWater, cheats.OneHitBreak, cheats.HarvestWithScythe ); // money this.AddOptions( $"{I18n.Add_Money()}:", cheats.AddMoney ); // casino coins this.AddOptions( $"{I18n.Add_CasinoCoins()}:", cheats.AddCasinoCoins ); // golden walnuts this.AddOptions( $"{I18n.Add_GoldenWalnuts()}:", cheats.AddGoldenWalnuts ); // Qi gems this.AddOptions( $"{I18n.Add_QiGems()}:", cheats.AddQiGems ); break; case MenuTab.FarmAndFishing: // farming this.AddOptions( $"{I18n.Farm_Title()}:", cheats.AutoWater, cheats.DurableFences, cheats.InstantBuild, cheats.AlwaysAutoFeed, cheats.InfiniteHay, cheats.NoAnimalFriendshipDecay ); // fishing this.AddOptions( $"{I18n.Fishing_Title()}:", cheats.InstantFishCatch, cheats.InstantFishBite, cheats.AlwaysCastMaxDistance, cheats.AlwaysFishTreasure, cheats.DurableFishTackles ); // fast machines this.AddOptions( $"{I18n.FastMachines_Title()}:", cheats.FastMachines ); break; case MenuTab.Skills: // skills this.AddOptions( $"{I18n.Skills_Title()}:", cheats.Skills ); // professions this.AddOptions( $"{I18n.Professions_Title()}:", cheats.Professions ); break; case MenuTab.Weather: this.AddOptions( $"{I18n.Weather_Title()}:", cheats.SetWeatherForTomorrow ); break; case MenuTab.Relationships: // relationship options this.AddOptions( $"{I18n.Relationships_Title()}:", cheats.AlwaysGiveGifts, cheats.NoFriendshipDecay ); // heart levels this.AddOptions( $"{I18n.Relationships_Friends()}:", cheats.Hearts ); break; case MenuTab.WarpLocations: this.AddOptions( cheats.Warps // grouped into sections, no need for a tab title ); break; case MenuTab.Time: this.AddOptions( $"{I18n.Time_Title()}:", cheats.FreezeTime, cheats.SetTime ); break; case MenuTab.Advanced: { this.AddDescription(I18n.Flags_Warning()); // quests this.AddOptions( $"{I18n.Flags_Quests()}:", cheats.Quests ); // wallet items this.AddOptions( $"{I18n.Flags_Wallet()}:", cheats.WalletItems ); // locked doors this.AddOptions( $"{I18n.Flags_Unlocked()}:", cheats.UnlockDoor ); // locked content this.AddOptions( $"{I18n.Flags_UnlockedContent()}:", cheats.UnlockContent ); // community center this.AddOptions( $"{I18n.Flags_CommunityCenter()}:", cheats.Bundles ); } break; case MenuTab.Controls: this.AddTitle($"{I18n.Controls_Title()}:"); if (this.IsAndroid) { this.AddDescription(I18n.Controls_AndroidConfigNote()); } this.AddOptions( new CheatsOptionsKeyListener( label: I18n.Controls_OpenMenu(), value: this.GetSingleButton(config.OpenMenuKey), setValue: key => config.OpenMenuKey = new(key), slotWidth: context.SlotWidth, clearToButton: this.GetSingleButton(ModConfig.Defaults.OpenMenuKey) ), new CheatsOptionsKeyListener( label: I18n.Controls_FreezeTime(), value: this.GetSingleButton(config.FreezeTimeKey), setValue: key => config.FreezeTimeKey = new(key), slotWidth: context.SlotWidth ), new CheatsOptionsKeyListener( label: I18n.Controls_GrowTree(), value: this.GetSingleButton(config.GrowTreeKey), setValue: key => config.GrowTreeKey = new(key), slotWidth: context.SlotWidth ), new CheatsOptionsKeyListener( label: I18n.Controls_GrowCrops(), value: this.GetSingleButton(config.GrowCropsKey), setValue: key => config.GrowCropsKey = new(key), slotWidth: context.SlotWidth ), new CheatsOptionsSlider( label: I18n.Controls_GrowRadius(), value: config.GrowRadius, minValue: 1, maxValue: 10, setValue: value => config.GrowRadius = value, disabled: () => !config.GrowTreeKey.IsBound && !config.GrowCropsKey.IsBound ), new OptionsElement(string.Empty), // blank line new CheatsOptionsButton( label: I18n.Controls_ResetControls(), toggle: this.ResetControls, slotWidth: context.SlotWidth ) ); break; } this.SetScrollBarToCurrentIndex(); }
/// <summary>Set the options to display.</summary> private void SetOptions() { CheatManager cheats = this.Cheats; CheatContext context = cheats.Context; ITranslationHelper text = context.Text; ModConfig config = context.Config; cheats.Context.SlotWidth = this.OptionSlots[0].bounds.Width; this.Options.Clear(); switch (this.CurrentTab) { case MenuTab.PlayerAndTools: // player this.AddOptions( $"{text.Get("player.title")}:", cheats.InfiniteHealth, cheats.InfiniteStamina, cheats.InstantCooldowns, cheats.OneHitKill, cheats.MaxDailyLuck, cheats.MoveSpeed, cheats.InventorySize ); // tools this.AddOptions( $"{text.Get("tools.title")}:", cheats.InfiniteWater, cheats.OneHitBreak, cheats.HarvestWithScythe ); // money this.AddOptions( $"{text.Get("money.title")}:", cheats.AddMoney ); // casino coins this.AddOptions( $"{text.Get("casino-coins.title")}:", cheats.AddCasinoCoins ); break; case MenuTab.FarmAndFishing: // farming this.AddOptions( $"{text.Get("farm.title")}:", cheats.AutoWater, cheats.DurableFences, cheats.InstantBuild, cheats.AlwaysAutoFeed, cheats.InfiniteHay ); // fishing this.AddOptions( $"{text.Get("fishing.title")}:", cheats.InstantFishCatch, cheats.InstantFishBite, cheats.AlwaysCastMaxDistance, cheats.AlwaysFishTreasure, cheats.DurableFishTackles ); // fast machines this.AddOptions( $"{text.Get("fast-machines.title")}:", cheats.FastMachines ); break; case MenuTab.Skills: // skills this.AddOptions( $"{text.Get("skills.title")}:", cheats.Skills ); // professions this.AddOptions( $"{text.Get("professions.title")}:", cheats.Professions ); break; case MenuTab.Weather: this.AddOptions( $"{text.Get("weather.title")}:", cheats.SetWeatherForTomorrow ); break; case MenuTab.Relationships: // relationship options this.AddOptions( $"{text.Get("relationships.title")}:", cheats.AlwaysGiveGifts, cheats.NoFriendshipDecay ); // heart levels this.AddOptions( $"{text.Get("relationships.friends")}:", cheats.Hearts ); break; case MenuTab.WarpLocations: this.AddOptions( cheats.Warps // grouped into sections, no need for a tab title ); break; case MenuTab.Time: this.AddOptions( $"{text.Get("time.title")}:", cheats.FreezeTime, cheats.SetTime ); break; case MenuTab.Advanced: { this.AddDescription(text.Get("flags.warning")); // quests this.AddOptions( $"{text.Get("flags.quests")}:", cheats.Quests ); // wallet items this.AddOptions( $"{text.Get("flags.wallet")}:", cheats.WalletItems ); // locked doors this.AddOptions( $"{text.Get("flags.unlocked")}:", cheats.UnlockDoor ); // locked content this.AddOptions( $"{text.Get("flags.unlocked-content")}:", cheats.UnlockContent ); // community center this.AddOptions( $"{text.Get("flags.community-center")}:", cheats.Bundles ); } break; case MenuTab.Controls: this.AddTitle($"{text.Get("controls.title")}:"); if (this.IsAndroid) { this.AddDescription(text.Get("controls.android-config-note")); } this.AddOptions( new CheatsOptionsKeyListener( label: text.Get("controls.open-menu"), value: config.OpenMenuKey, setValue: key => config.OpenMenuKey = key, slotWidth: context.SlotWidth, i18n: text, clearToButton: ModConfig.Defaults.OpenMenuKey ), new CheatsOptionsKeyListener( label: text.Get("controls.freeze-time"), value: config.FreezeTimeKey, setValue: key => config.FreezeTimeKey = key, slotWidth: context.SlotWidth, i18n: text ), new CheatsOptionsKeyListener( label: text.Get("controls.grow-tree"), value: config.GrowTreeKey, setValue: key => config.GrowTreeKey = key, slotWidth: context.SlotWidth, i18n: text ), new CheatsOptionsKeyListener( label: text.Get("controls.grow-crops"), value: config.GrowCropsKey, setValue: key => config.GrowCropsKey = key, slotWidth: context.SlotWidth, i18n: text ), new CheatsOptionsSlider( label: text.Get("controls.grow-radius"), value: config.GrowRadius, minValue: 1, maxValue: 10, setValue: value => config.GrowRadius = value, disabled: () => config.GrowTreeKey == SButton.None && config.GrowCropsKey == SButton.None ), new OptionsElement(string.Empty), // blank line new CheatsOptionsButton( label: text.Get("controls.reset-controls"), toggle: this.ResetControls, slotWidth: context.SlotWidth ) ); break; } this.SetScrollBarToCurrentIndex(); }