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}");
            }
        }
Ejemplo n.º 2
0
        public override void Entry(IModHelper helper)
        {
            Config = Helper.ReadConfig <RingConfig>();

            Helper.Events.GameLoop.GameLaunched += delegate { RingConfig.SetUpModConfigMenu(Config, this); };

            ExplorerRingTexture  = Helper.Content.Load <Texture2D>($"assets/explorer_ring.png");
            BerserkerRingTexture = Helper.Content.Load <Texture2D>($"assets/berserker_ring.png");
            PaladinRingTexture   = Helper.Content.Load <Texture2D>($"assets/paladin_ring.png");

            Patcher.PatchAll(this);
        }
Ejemplo n.º 3
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            RingConfig.SetUpModConfigMenu(Config, this);

            try
            {
                Helper.Content.InvalidateCache("Data/CraftingRecipes");
                Helper.Content.InvalidateCache("Data/ObjectInformation");
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 4
0
        // TODO add API
        // TODO make fake assets to make this CP changeable
        // TODO make rings of the same category type not equippable at the same time (care for compatibility with equip more rings)

        public override void Entry(IModHelper helper)
        {
            Config = Helper.ReadConfig <RingConfig>();

            Helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;
            Helper.Events.GameLoop.DayStarted   += GameLoop_DayStarted;

            string path = Helper.ModRegistry.IsLoaded("BBR.BetterRings") ? "assets/betterRings" : "assets";

            ExplorerRingTexture  = Helper.Content.Load <Texture2D>($"{path}/explorer_ring.png");
            BerserkerRingTexture = Helper.Content.Load <Texture2D>($"{path}/berserker_ring.png");
            PaladinRingTexture   = Helper.Content.Load <Texture2D>($"{path}/paladin_ring.png");

            Patcher.PatchAll(this);
        }
Ejemplo n.º 5
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"));
        }