From fc0b98be4584eec2b06a3af09cc4b85f9e9a9efc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 25 Jan 2020 18:22:50 -0500 Subject: add user settings that override defaults (#693) --- src/SMAPI/Constants.cs | 3 +++ src/SMAPI/Framework/SCore.cs | 3 +++ src/SMAPI/SMAPI.config.json | 6 ++++++ 3 files changed, 12 insertions(+) (limited to 'src/SMAPI') diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index da2ee375..d2af5de2 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -61,6 +61,9 @@ namespace StardewModdingAPI /// The file path for the SMAPI configuration file. internal static string ApiConfigPath => Path.Combine(Constants.InternalFilesPath, "config.json"); + /// The file path for the overrides file for , which is applied over it. + internal static string ApiUserConfigPath => Path.Combine(Constants.InternalFilesPath, "config.user.json"); + /// The file path for the SMAPI metadata file. internal static string ApiMetadataPath => Path.Combine(Constants.InternalFilesPath, "metadata.json"); diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index d71b5e5a..81b7c2e8 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -153,6 +153,9 @@ namespace StardewModdingAPI.Framework // init basics this.Settings = JsonConvert.DeserializeObject(File.ReadAllText(Constants.ApiConfigPath)); + if (File.Exists(Constants.ApiUserConfigPath)) + JsonConvert.PopulateObject(File.ReadAllText(Constants.ApiUserConfigPath), this.Settings); + this.LogFile = new LogFileManager(logPath); this.Monitor = new Monitor("SMAPI", this.ConsoleManager, this.LogFile, this.Settings.ConsoleColors, this.Settings.VerboseLogging) { diff --git a/src/SMAPI/SMAPI.config.json b/src/SMAPI/SMAPI.config.json index 824bb783..57b4f885 100644 --- a/src/SMAPI/SMAPI.config.json +++ b/src/SMAPI/SMAPI.config.json @@ -6,6 +6,12 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha The default values are mirrored in StardewModdingAPI.Framework.Models.SConfig to log custom changes. +This file is overwritten each time you update or reinstall SMAPI. To avoid losing custom settings, +create a 'config.user.json' file in the same folder with *only* the settings you want to change. +That file won't be overwritten, and any settings in it will override the default options. Don't +copy all the settings, or you may cause bugs due to overridden changes in future SMAPI versions. + + */ { -- cgit