Ejemplo n.º 1
0
        public static void VerifyConfigValues(RingOverhaul mod, RingConfig config)
        {
            bool invalidConfig = false;

            if (config.CraftableGemRingsMetalBar < 0 || config.CraftableGemRingsMetalBar > 3)
            {
                invalidConfig = true;
                config.CraftableGemRingsMetalBar = 0;
            }

            if (!(config.CraftableGemRingsUnlockLevels is 0 or 1))
            {
                invalidConfig = true;
                config.CraftableGemRingsUnlockLevels = 0;
            }

            if (invalidConfig)
            {
                mod.DebugLog("At least one config value was out of range and was reset.");
                mod.Helper.WriteConfig(config);
            }

            try
            {
                mod.Helper.Content.InvalidateCache("Data/CraftingRecipes");
                mod.Helper.Content.InvalidateCache("Data/ObjectInformation");
                mod.Helper.Content.InvalidateCache("Maps/springobjects");
            }
            catch (Exception e)
            {
                mod.DebugLog($"Exception when trying to invalidate cache on config change {e}");
            }
        }
 public static void VerifyConfigValues(RingOverhaul mod)
 {
     try
     {
         mod.Helper.Content.InvalidateCache("Data/CraftingRecipes");
         mod.Helper.Content.InvalidateCache("Data/ObjectInformation");
     }
     catch (Exception e)
     {
         mod.DebugLog($"Exception when trying to invalidate cache on config change {e}");
     }
 }
Ejemplo n.º 3
0
        private static string TranslateProgressionChoice(string englishValue, RingOverhaul mod)
        {
            switch (englishValue)
            {
            case "Progressive":
                return(mod.Helper.Translation.Get("ConfigCraftableGemRingsProgressive"));

            case "Copper":
                return(new StardewValley.Object(334, 1).DisplayName);

            case "Iron":
                return(new StardewValley.Object(335, 1).DisplayName);

            case "Gold":
                return(new StardewValley.Object(336, 1).DisplayName);
            }

            return("Unknown Option");
        }
Ejemplo n.º 4
0
        public static void SetUpModConfigMenu(RingConfig config, RingOverhaul mod)
        {
            IGenericModConfigMenuApi api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(manifest, () => config = new RingConfig(), delegate { mod.Helper.WriteConfig(config); VerifyConfigValues(mod, config); });

            api.AddSectionTitle(manifest, () => mod.Helper.Translation.Get("ConfigCraftableGemRings"));

            api.AddBoolOption(manifest, () => config.CraftableGemRings, (bool val) => config.CraftableGemRings = val, () => mod.Helper.Translation.Get("ConfigCraftableGemRings"));

            api.AddTextOption(manifest, () => GetElementFromConfig(ProgressionChoices, config.CraftableGemRingsMetalBar), (string val) => config.CraftableGemRingsMetalBar         = GetIndexFromArrayElement(ProgressionChoices, val), () => mod.Helper.Translation.Get("ConfigCraftableGemRingsMetalBar"), null, ProgressionChoices, (s) => TranslateProgressionChoice(s, mod));
            api.AddTextOption(manifest, () => GetElementFromConfig(UnlockLevelChoices, config.CraftableGemRingsUnlockLevels), (string val) => config.CraftableGemRingsUnlockLevels = GetIndexFromArrayElement(UnlockLevelChoices, val), () => mod.Helper.Translation.Get("ConfigCraftableGemRingsUnlockLevel"), null, UnlockLevelChoices);

            if (mod.Helper.ModRegistry.IsLoaded("BBR.BetterRings"))
            {
                api.AddParagraph(manifest, () => mod.Helper.Translation.Get("ConfigCraftableGemRingsCustomSpritesBetterRings"));
            }
            else
            {
                api.AddBoolOption(manifest, () => config.CraftableGemRingsCustomSprites, (bool val) => config.CraftableGemRingsCustomSprites = val, () => mod.Helper.Translation.Get("ConfigCraftableGemRingsCustomSprites"));
            }

            api.AddSectionTitle(manifest, () => mod.Helper.Translation.Get("ConfigOtherCategory"));

            api.AddBoolOption(manifest, () => config.JukeboxRingEnabled, (bool val) => config.JukeboxRingEnabled         = val, () => mod.Helper.Translation.Get("ConfigJukeboxRing"));
            api.AddBoolOption(manifest, () => config.JukeboxRingWorksInRain, (bool val) => config.JukeboxRingWorksInRain = val, () => mod.Helper.Translation.Get("ConfigJukeboxRingWorksInRain"));

            api.AddBoolOption(manifest, () => config.MinorRingCraftingChanges, (bool val) => config.MinorRingCraftingChanges = val, () => mod.Helper.Translation.Get("ConfigMinorRingCraftingChanges"));
            api.AddBoolOption(manifest, () => config.RemoveCrabshellRingAndImmunityBandTooltipFromCombinedRing, (bool val) => config.RemoveCrabshellRingAndImmunityBandTooltipFromCombinedRing = val, () => mod.Helper.Translation.Get("ConfigRemoveCITooltip"));
            api.AddBoolOption(manifest, () => config.RemoveLuckyTooltipFromCombinedRing, (bool val) => config.RemoveLuckyTooltipFromCombinedRing = val, () => mod.Helper.Translation.Get("ConfigRemoveLTooltip"));
            api.AddBoolOption(manifest, () => config.OldGlowStoneRingRecipe, (bool val) => config.OldGlowStoneRingRecipe = val, () => mod.Helper.Translation.Get("ConfigOldGlowStoneRingRecipe"));
            api.AddBoolOption(manifest, () => config.OldIridiumBandRecipe, (bool val) => config.OldIridiumBandRecipe     = val, () => mod.Helper.Translation.Get("ConfigOldIridiumBandRecipe"));

            api.AddParagraph(manifest, () => mod.Helper.Translation.Get("ConfigFeedback"));
        }
        public static void SetUpModConfigMenu(RingConfig config, RingOverhaul mod)
        {
            IGenericModConfigMenuApi api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(manifest, () => config = new RingConfig(), delegate { mod.Helper.WriteConfig(config); VerifyConfigValues(mod); });

            api.AddBoolOption(manifest, () => config.CraftableGemRings, (bool val) => config.CraftableGemRings = val, () => mod.Helper.Translation.Get("ConfigCraftableGemRings"));
            api.AddBoolOption(manifest, () => config.MinorRingCraftingChanges, (bool val) => config.MinorRingCraftingChanges = val, () => mod.Helper.Translation.Get("ConfigMinorRingCraftingChanges"));
            api.AddBoolOption(manifest, () => config.RemoveCrabshellRingAndImmunityBandTooltipFromCombinedRing, (bool val) => config.RemoveCrabshellRingAndImmunityBandTooltipFromCombinedRing = val, () => mod.Helper.Translation.Get("ConfigRemoveCITooltip"));
            api.AddBoolOption(manifest, () => config.RemoveLuckyTooltipFromCombinedRing, (bool val) => config.RemoveLuckyTooltipFromCombinedRing = val, () => mod.Helper.Translation.Get("ConfigRemoveLTooltip"));
            api.AddBoolOption(manifest, () => config.OldGlowStoneRingRecipe, (bool val) => config.OldGlowStoneRingRecipe = val, () => mod.Helper.Translation.Get("ConfigOldGlowStoneRingRecipe"));
            api.AddBoolOption(manifest, () => config.OldIridiumBandRecipe, (bool val) => config.OldIridiumBandRecipe     = val, () => mod.Helper.Translation.Get("ConfigOldIridiumBandRecipe"));

            api.AddParagraph(manifest, () => mod.Helper.Translation.Get("ConfigFeedback"));
        }