summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-11-06 11:15:46 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-11-06 11:15:46 -0500
commit956e477edb515953e71d1cce1a728284f6ce3cc0 (patch)
treec24db349e8d9d9c42c0258b83a07aad217904984 /src/StardewModdingAPI
parente4d6cc138129153d654f43aabed16d2ba482beee (diff)
downloadSMAPI-956e477edb515953e71d1cce1a728284f6ce3cc0.tar.gz
SMAPI-956e477edb515953e71d1cce1a728284f6ce3cc0.tar.bz2
SMAPI-956e477edb515953e71d1cce1a728284f6ce3cc0.zip
add developer mode which shows all deprecation warnings, update release process (#165)
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r--src/StardewModdingAPI/Framework/DeprecationManager.cs12
-rw-r--r--src/StardewModdingAPI/Framework/UserSettings.cs9
-rw-r--r--src/StardewModdingAPI/Program.cs15
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI-settings.json4
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.csproj8
5 files changed, 44 insertions, 4 deletions
diff --git a/src/StardewModdingAPI/Framework/DeprecationManager.cs b/src/StardewModdingAPI/Framework/DeprecationManager.cs
index a3d1ea41..0c5a49f9 100644
--- a/src/StardewModdingAPI/Framework/DeprecationManager.cs
+++ b/src/StardewModdingAPI/Framework/DeprecationManager.cs
@@ -19,6 +19,13 @@ namespace StardewModdingAPI.Framework
/*********
+ ** Accessors
+ *********/
+ /// <summary>Whether <see cref="DeprecationLevel.Notice"/>-level deprecation messages should be shown in the console.</summary>
+ public bool SendNoticesToConsole { get; set; }
+
+
+ /*********
** Public methods
*********/
/// <summary>Register a mod as a possible source of deprecation warnings.</summary>
@@ -63,7 +70,10 @@ namespace StardewModdingAPI.Framework
switch (severity)
{
case DeprecationLevel.Notice:
- Log.LogToFile(message);
+ if (this.SendNoticesToConsole)
+ Log.Debug($"[DEV] {message}");
+ else
+ Log.LogToFile(message);
break;
case DeprecationLevel.Info:
diff --git a/src/StardewModdingAPI/Framework/UserSettings.cs b/src/StardewModdingAPI/Framework/UserSettings.cs
new file mode 100644
index 00000000..199d19b3
--- /dev/null
+++ b/src/StardewModdingAPI/Framework/UserSettings.cs
@@ -0,0 +1,9 @@
+namespace StardewModdingAPI.Framework
+{
+ /// <summary>Contains user settings from SMAPI's JSON configuration file.</summary>
+ internal class UserSettings
+ {
+ /// <summary>Whether to enable development features.</summary>
+ public bool DeveloperMode { get; set; }
+ }
+}
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index e9e357d5..047d74c7 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -8,6 +8,7 @@ using System.Threading;
using System.Windows.Forms;
#endif
using Microsoft.Xna.Framework.Graphics;
+using Newtonsoft.Json;
using StardewModdingAPI.Events;
using StardewModdingAPI.Framework;
using StardewModdingAPI.Inheritance;
@@ -67,6 +68,18 @@ namespace StardewModdingAPI
// set thread culture for consistent log formatting
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
+ // load user settings
+ {
+ string settingsPath = $@"{Constants.ExecutionPath}\{typeof(Program).Assembly.GetName().Name}-settings.json";
+ if (File.Exists(settingsPath))
+ {
+ string json = File.ReadAllText(settingsPath);
+ UserSettings settings = JsonConvert.DeserializeObject<UserSettings>(json);
+ Program.DeprecationManager.SendNoticesToConsole = settings?.DeveloperMode == true;
+ }
+
+ }
+
// hook into & launch the game
try
{
@@ -271,7 +284,7 @@ namespace StardewModdingAPI
}
// log deprecated fields
- if(manifest.UsedAuthourField)
+ if (manifest.UsedAuthourField)
Program.DeprecationManager.Warn(manifest.Name, $"{nameof(Manifest)}.{nameof(Manifest.Authour)}", "1.0", DeprecationLevel.Notice);
}
catch (Exception ex)
diff --git a/src/StardewModdingAPI/StardewModdingAPI-settings.json b/src/StardewModdingAPI/StardewModdingAPI-settings.json
new file mode 100644
index 00000000..d27d0141
--- /dev/null
+++ b/src/StardewModdingAPI/StardewModdingAPI-settings.json
@@ -0,0 +1,4 @@
+{
+ /* show all deprecation notices in the console? */
+ "DeveloperMode": true
+}
diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj
index 5540267a..bbb41ee3 100644
--- a/src/StardewModdingAPI/StardewModdingAPI.csproj
+++ b/src/StardewModdingAPI/StardewModdingAPI.csproj
@@ -59,7 +59,7 @@
<UseVSHostingProcess>true</UseVSHostingProcess>
<Optimize>false</Optimize>
<OutputPath>$(SolutionDir)\..\bin\Debug\SMAPI</OutputPath>
- <DocumentationFile>bin\Debug\StardewModdingAPI.xml</DocumentationFile>
+ <DocumentationFile>$(SolutionDir)\..\bin\Debug\SMAPI\StardewModdingAPI.xml</DocumentationFile>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<LangVersion>6</LangVersion>
</PropertyGroup>
@@ -68,7 +68,7 @@
<OutputPath>bin\Release\</OutputPath>
<Prefer32Bit>false</Prefer32Bit>
<OutputPath>$(SolutionDir)\..\bin\Release\SMAPI</OutputPath>
- <DocumentationFile>bin\Release\StardewModdingAPI.xml</DocumentationFile>
+ <DocumentationFile>$(SolutionDir)\..\bin\Debug\SMAPI\StardewModdingAPI.xml</DocumentationFile>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
@@ -200,6 +200,7 @@
<Compile Include="Framework\DeprecationManager.cs" />
<Compile Include="Framework\UpdateHelper.cs" />
<Compile Include="Framework\GitRelease.cs" />
+ <Compile Include="Framework\UserSettings.cs" />
<Compile Include="Inheritance\ChangeType.cs" />
<Compile Include="Inheritance\ItemStackChange.cs" />
<Compile Include="Log.cs" />
@@ -220,6 +221,9 @@
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
+ <Content Include="StardewModdingAPI-settings.json">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
<None Include="unix-launcher.sh">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>