summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-08-21 16:39:21 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-08-21 16:39:21 -0400
commit8ba54a682fd7de3756b6ddd262b232cf40d23ea0 (patch)
tree7e44d53b733d95b05b232da46306a0d3d57e9231
parent674ad0d90f8780130a5fcefb3869acfe2315df2a (diff)
parenteea5100acea0bceaf440f9d1bd50ee2b24cf8ebc (diff)
downloadSMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.tar.gz
SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.tar.bz2
SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.zip
Merge branch 'develop' into stable
-rw-r--r--README.md26
-rw-r--r--release-notes.md47
-rw-r--r--src/.editorconfig9
-rw-r--r--src/GlobalAssemblyInfo.cs6
-rw-r--r--src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj2
-rw-r--r--src/StardewModdingAPI.Installer/InteractiveInstaller.cs75
-rw-r--r--src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj2
-rw-r--r--src/StardewModdingAPI.Tests/Core/ModResolverTests.cs2
-rw-r--r--src/StardewModdingAPI.Tests/StardewModdingAPI.Tests.csproj14
-rw-r--r--src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs47
-rw-r--r--src/StardewModdingAPI.Tests/packages.config6
-rw-r--r--src/StardewModdingAPI.sln4
-rw-r--r--src/StardewModdingAPI/Constants.cs52
-rw-r--r--src/StardewModdingAPI/Context.cs7
-rw-r--r--src/StardewModdingAPI/Events/GraphicsEvents.cs6
-rw-r--r--src/StardewModdingAPI/Framework/Exceptions/SAssemblyLoadFailedException.cs16
-rw-r--r--src/StardewModdingAPI/Framework/GameVersion.cs68
-rw-r--r--src/StardewModdingAPI/Framework/ModHelpers/ContentHelper.cs38
-rw-r--r--src/StardewModdingAPI/Framework/ModHelpers/ReflectionHelper.cs46
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/AssemblyLoadStatus.cs15
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/AssemblyLoader.cs24
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/AssemblyParseResult.cs9
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs28
-rw-r--r--src/StardewModdingAPI/Framework/Models/Manifest.cs6
-rw-r--r--src/StardewModdingAPI/Framework/Models/ModCompatibility.cs50
-rw-r--r--src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs57
-rw-r--r--src/StardewModdingAPI/Framework/Monitor.cs61
-rw-r--r--src/StardewModdingAPI/Framework/SContentManager.cs228
-rw-r--r--src/StardewModdingAPI/Framework/SGame.cs34
-rw-r--r--src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs (renamed from src/StardewModdingAPI/Framework/Serialisation/ManifestFieldConverter.cs)21
-rw-r--r--src/StardewModdingAPI/Framework/Utilities/ContextHash.cs62
-rw-r--r--src/StardewModdingAPI/Framework/Utilities/Countdown.cs (renamed from src/StardewModdingAPI/Framework/Countdown.cs)2
-rw-r--r--src/StardewModdingAPI/IContentHelper.cs36
-rw-r--r--src/StardewModdingAPI/ISemanticVersion.cs3
-rw-r--r--src/StardewModdingAPI/Metadata/CoreAssets.cs166
-rw-r--r--src/StardewModdingAPI/Program.cs63
-rw-r--r--src/StardewModdingAPI/SemanticVersion.cs33
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.config.json384
-rw-r--r--src/StardewModdingAPI/StardewModdingAPI.csproj42
-rw-r--r--src/StardewModdingAPI/Utilities/SDate.cs32
-rw-r--r--src/StardewModdingAPI/unix-launcher.sh2
-rw-r--r--src/TrainerMod/Framework/Commands/Saves/LoadCommand.cs4
-rw-r--r--src/TrainerMod/Framework/Commands/Saves/SaveCommand.cs4
-rw-r--r--src/TrainerMod/TrainerMod.csproj11
-rw-r--r--src/common.targets (renamed from src/crossplatform.targets)43
45 files changed, 1430 insertions, 463 deletions
diff --git a/README.md b/README.md
index bc5da52e..cbf0ec36 100644
--- a/README.md
+++ b/README.md
@@ -142,18 +142,34 @@ on the wiki for the first-time setup.
## Advanced usage
### Configuration file
You can customise the SMAPI behaviour by editing the `StardewModdingAPI.config.json` file in your
-game folder. It contains these fields:
+game folder.
+
+Basic fields:
field | purpose
----- | -------
`DeveloperMode` | Default `false` (except in _SMAPI for developers_ releases). Whether to enable features intended for mod developers (mainly more detailed console logging).
`CheckForUpdates` | Default `true`. Whether SMAPI should check for a newer version when you load the game. If a new version is available, a small message will appear in the console. This doesn't affect the load time even if your connection is offline or slow, because it happens in the background.
-`ModCompatibility` | A list of mod versions SMAPI should consider compatible or broken regardless of whether it detects incompatible code. Each record can be set to `AssumeCompatible` or `AssumeBroken`. Changing this field is not recommended and may destabilise your game.
-`VerboseLogging` | Whether SMAPI should log more information about the game context.
+`VerboseLogging` | Default `false`. Whether SMAPI should log more information about the game context.
+
+Advanced fields (changing these isn't recommended and may destabilise your game):
+
+field | purpose
+----- | -------
+`DisabledMods` | A list of mods to consider obsolete and not load.
+`ModCompatibility` | A list of mod versions SMAPI should consider compatible or broken regardless of whether it detects incompatible code. This can be used to force SMAPI to load an incompatible mod, though that isn't recommended.
### Command-line arguments
-SMAPI recognises the following command-line arguments. These are intended for internal use or
-testing and may change without warning.
+The SMAPI installer recognises three command-line arguments:
+
+argument | purpose
+-------- | -------
+`--install` | Preselects the install action, skipping the prompt asking what the user wants to do.
+`--uninstall` | Preselects the uninstall action, skipping the prompt asking what the user wants to do.
+`--game-path "path"` | Specifies the full path to the folder containing the Stardew Valley executable, skipping automatic detection and any prompt to choose a path. If the path is not valid, the installer displays an error.
+
+SMAPI itself recognises two arguments, but these are intended for internal use or testing and may
+change without warning.
argument | purpose
-------- | -------
diff --git a/release-notes.md b/release-notes.md
index 924ecb90..c482986b 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -3,20 +3,45 @@
<!--See [log](https://github.com/Pathoschild/SMAPI/compare/1.10...2.0).-->
For players:
-* The SMAPI console is now much simpler and easier-to-read.
+* The SMAPI console is now much simpler and easier to read.
+* The SMAPI console now adjusts its colors when you have a light terminal background.
+* Updated compatibility list.
For mod developers:
-* Added API to edit XNB images & data loaded by the game (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Content)).
-* Added API to inject new XNB images & data (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Content)).
-* Added `InputEvents` which unify keyboard, mouse, and controller input for much simpler input handling (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Input_events)).
-* Added useful `InputEvents` metadata like the cursor position, grab tile, etc.
-* Added ability to prevent the game from handling a button press via `InputEvents`.
-* In `manifest.json`:
- * Dependencies can now be optional.
- * The version can now be a string like `"1.0-alpha"` instead of a structure.
- * The `Name`, `Version,` and `UniqueID` fields are no longer optional.
- * The `UniqueID` field must now be unique (case-insensitive). If two installed mods have the same ID, SMAPI will show an error and load neither.
+* Added new APIs to edit, inject, and reload XNB assets loaded by the game at any time.
+ <small>_This let mods do anything previously only possible with XNB mods, plus enables new mod scenarios (e.g. seasonal textures, NPC clothing that depend on the weather or location, etc)._</small>
+* Added new input events.
+ <small>_The new `InputEvents` combine keyboard + mouse + controller input into one event for easy handling, add metadata like the cursor position and grab tile to support click handling, and add an option to suppress input from the game to enable new scenarios like action highjacking and UI overlays._</small>
+* Added support for optional dependencies.
+* Added support for string versions (like `"1.0-alpha"`) in `manifest.json`.
+* Added `IEquatable<ISemanticVersion>` to `ISemanticVersion`.
+* Added day of week to `SDate` instances.
+* Removed the TrainerMod's `save` and `load` commands.
* Removed all deprecated code.
+* Removed support for mods with no `Name`, `Version`, or `UniqueID` in their manifest.
+* Removed support for mods with a non-unique `UniqueID` value in their manifest.
+* Removed access to SMAPI internals through the reflection helper, to discourage fragile mods.
+* Fixed `TimeEvents.AfterDayStarted` being raised during the new-game intro.
+
+For power users:
+* Added command-line arguments to the SMAPI installer so it can be scripted.
+
+## 1.15.2
+For players:
+* Improved errors when a mod DLL can't be loaded.
+* Improved errors when using very old versions of Stardew Valley.
+* Updated compatibility list.
+
+For mod developers:
+* Added `Context.CanPlayerMove` property for mod convenience.
+* Added content helper properties for the game's current language.
+* Fixed `Context.IsPlayerFree` being false if the player is performing an action.
+* Fixed `GraphicsEvents.Resize` being raised before the game updates its window data.
+* Fixed `SemanticVersion` not being deserialisable through Json.NET.
+* Fixed terminal not launching on Xfce Linux.
+
+For SMAPI developers:
+* Internal changes to support the upcoming SMAPI 2.0 release.
## 1.15.1
For players:
diff --git a/src/.editorconfig b/src/.editorconfig
index 4271803d..a5cdcf97 100644
--- a/src/.editorconfig
+++ b/src/.editorconfig
@@ -12,13 +12,16 @@ insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
+[*.csproj]
+indent_size = 2
+insert_final_newline = false
+
[*.json]
indent_size = 2
##########
## C# formatting
## documentation: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
-## some undocumented settings from: https://github.com/dotnet/roslyn/blob/master/.editorconfig
##########
[*.cs]
@@ -47,6 +50,7 @@ dotnet_style_explicit_tuple_names = true:suggestion
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
+csharp_prefer_simple_default_expression = true:suggestion
# prefer method block bodies
csharp_style_expression_bodied_methods = false:suggestion
@@ -59,3 +63,6 @@ csharp_style_expression_bodied_accessors = true:suggestion
# prefer inline out variables
csharp_style_inlined_variable_declaration = true:warning
+
+# avoid superfluous braces
+csharp_prefer_braces = false:suggestion
diff --git a/src/GlobalAssemblyInfo.cs b/src/GlobalAssemblyInfo.cs
index d9a01635..d496fbd1 100644
--- a/src/GlobalAssemblyInfo.cs
+++ b/src/GlobalAssemblyInfo.cs
@@ -1,6 +1,6 @@
-using System.Reflection;
+using System.Reflection;
using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("1.15.1.0")]
-[assembly: AssemblyFileVersion("1.15.1.0")]
+[assembly: AssemblyVersion("1.15.2.0")]
+[assembly: AssemblyFileVersion("1.15.2.0")]
diff --git a/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj b/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj
index 7a12a8e9..8416bd51 100644
--- a/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj
+++ b/src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj
@@ -68,6 +68,6 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
- <Import Project="$(SolutionDir)\crossplatform.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\common.targets" />
</Project> \ No newline at end of file
diff --git a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
index 78d3d10e..01288f33 100644
--- a/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
+++ b/src/StardewModdingAPI.Installer/InteractiveInstaller.cs
@@ -135,6 +135,33 @@ namespace StardewModdingApi.Installer
/// </remarks>
public void Run(string[] args)
{
+#if SMAPI_1_x
+ bool installArg = false;
+ bool uninstallArg = false;
+ string gamePathArg = null;
+#else
+ /****
+ ** read command-line arguments
+ ****/
+ // get action from CLI
+ bool installArg = args.Contains("--install");
+ bool uninstallArg = args.Contains("--uninstall");
+ if (installArg && uninstallArg)
+ {
+ this.PrintError("You can't specify both --install and --uninstall command-line flags.");
+ Console.ReadLine();
+ return;
+ }
+
+ // get game path from CLI
+ string gamePathArg = null;
+ {
+ int pathIndex = Array.LastIndexOf(args, "--game-path") + 1;
+ if (pathIndex >= 1 && args.Length >= pathIndex)
+ gamePathArg = args[pathIndex];
+ }
+#endif
+
/****
** collect details
****/
@@ -142,9 +169,17 @@ namespace StardewModdingApi.Installer
Platform platform = this.DetectPlatform();
this.PrintDebug($"Platform: {(platform == Platform.Windows ? "Windows" : "Linux or Mac")}.");
+ // get game path
+ DirectoryInfo installDir = this.InteractivelyGetInstallPath(platform, gamePathArg);
+ if (installDir == null)
+ {
+ this.PrintError("Failed finding your game path.");
+ Console.ReadLine();
+ return;
+ }
+
// get folders
DirectoryInfo packageDir = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "internal", platform.ToString()));
- DirectoryInfo installDir = this.InteractivelyGetInstallPath(platform);
DirectoryInfo modsDir = new DirectoryInfo(Path.Combine(installDir.FullName, "Mods"));
var paths = new
{
@@ -203,13 +238,19 @@ namespace StardewModdingApi.Installer
/****
** ask user what to do
****/
- Console.WriteLine("You can....");
- Console.WriteLine("[1] Install SMAPI.");
- Console.WriteLine("[2] Uninstall SMAPI.");
- Console.WriteLine();
-
ScriptAction action;
+
+ if (installArg)
+ action = ScriptAction.Install;
+ else if (uninstallArg)
+ action = ScriptAction.Uninstall;
+ else
{
+ Console.WriteLine("You can....");
+ Console.WriteLine("[1] Install SMAPI.");
+ Console.WriteLine("[2] Uninstall SMAPI.");
+ Console.WriteLine();
+
string choice = this.InteractivelyChoose("What do you want to do? Type 1 or 2, then press enter.", "1", "2");
switch (choice)
{
@@ -222,8 +263,8 @@ namespace StardewModdingApi.Installer
default:
throw new InvalidOperationException($"Unexpected action key '{choice}'.");
}
+ Console.WriteLine();
}
- Console.WriteLine();
/****
** Always uninstall old files
@@ -513,13 +554,31 @@ namespace StardewModdingApi.Installer
/// <summary>Interactively locate the game install path to update.</summary>
/// <param name="platform">The current platform.</param>
- private DirectoryInfo InteractivelyGetInstallPath(Platform platform)
+ /// <param name="specifiedPath">The path specified as a command-line argument (if any), which should override automatic path detection.</param>
+ private DirectoryInfo InteractivelyGetInstallPath(Platform platform, string specifiedPath)
{
// get executable name
string executableFilename = platform == Platform.Windows
? "Stardew Valley.exe"
: "StardewValley.exe";
+ // validate specified path
+ if (specifiedPath != null)
+ {
+ var dir = new DirectoryInfo(specifiedPath);
+ if (!dir.Exists)
+ {
+ this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't exist.");
+ return null;
+ }
+ if (!dir.EnumerateFiles(executableFilename).Any())
+ {
+ this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't contain the Stardew Valley executable.");
+ return null;
+ }
+ return dir;
+ }
+
// get installed paths
DirectoryInfo[] defaultPaths =
(
diff --git a/src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj b/src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj
index 765364dc..58ce519c 100644
--- a/src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj
+++ b/src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj
@@ -51,6 +51,6 @@
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <Import Project="$(SolutionDir)\crossplatform.targets" />
+ <Import Project="$(SolutionDir)\common.targets" />
<Import Project="$(SolutionDir)\prepare-install-package.targets" />
</Project> \ No newline at end of file
diff --git a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
index eda3a425..fc84ca29 100644
--- a/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
+++ b/src/StardewModdingAPI.Tests/Core/ModResolverTests.cs
@@ -141,7 +141,7 @@ namespace StardewModdingAPI.Tests.Core
{
// arrange
Mock<IModMetadata> mock = this.GetMetadata("Mod A", new string[0], allowStatusChange: true);
- this.SetupMetadataForValidation(mock, new ModCompatibility { Compatibility = ModCompatibilityType.AssumeBroken });
+ this.SetupMetadataForValidation(mock, new ModCompatibility { Compatibility = ModCompatibilityType.AssumeBroken, UpperVersion = new SemanticVersion("1.0"), UpdateUrls = new[] { "http://example.org" }});
// act
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"));
diff --git a/src/StardewModdingAPI.Tests/StardewModdingAPI.Tests.csproj b/src/StardewModdingAPI.Tests/StardewModdingAPI.Tests.csproj
index 9bfd7567..f3dbcdd4 100644
--- a/src/StardewModdingAPI.Tests/StardewModdingAPI.Tests.csproj
+++ b/src/StardewModdingAPI.Tests/StardewModdingAPI.Tests.csproj
@@ -30,17 +30,17 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
- <HintPath>..\packages\Castle.Core.4.0.0\lib\net45\Castle.Core.dll</HintPath>
+ <Reference Include="Castle.Core, Version=4.1.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <HintPath>..\packages\Castle.Core.4.1.1\lib\net45\Castle.Core.dll</HintPath>
</Reference>
- <Reference Include="Moq, Version=4.7.10.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
- <HintPath>..\packages\Moq.4.7.10\lib\net45\Moq.dll</HintPath>
+ <Reference Include="Moq, Version=4.7.99.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
+ <HintPath>..\packages\Moq.4.7.99\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
- <Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
- <HintPath>..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
+ <Reference Include="nunit.framework, Version=3.7.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
@@ -64,6 +64,6 @@
<Name>StardewModdingAPI</Name>
</ProjectReference>
</ItemGroup>
- <Import Project="$(SolutionDir)\crossplatform.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\common.targets" />
</Project> \ No newline at end of file
diff --git a/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs b/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs
index 95d0d74f..03cd26c9 100644
--- a/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs
+++ b/src/StardewModdingAPI.Tests/Utilities/SemanticVersionTests.cs
@@ -1,6 +1,8 @@
using System;
using System.Diagnostics.CodeAnalysis;
+using Newtonsoft.Json;
using NUnit.Framework;
+using StardewModdingAPI.Framework;
namespace StardewModdingAPI.Tests.Utilities
{
@@ -206,6 +208,51 @@ namespace StardewModdingAPI.Tests.Utilities
return version.IsBetween(lower, upper);
}
+ /****
+ ** Serialisable
+ ****/
+ [Test(Description = "Assert that SemanticVersion can be round-tripped through JSON with no special configuration.")]
+ [TestCase("1.0")]
+ public void Serialisable(string versionStr)
+ {
+ // act
+ string json = JsonConvert.SerializeObject(new SemanticVersion(versionStr));
+ SemanticVersion after = JsonConvert.DeserializeObject<SemanticVersion>(json);
+
+ // assert
+ Assert.IsNotNull(after, "The semantic version after deserialisation is unexpectedly null.");
+ Assert.AreEqual(versionStr, after.ToString(), "The semantic version after deserialisation doesn't match the input version.");
+ }
+
+ /****
+ ** GameVersion
+ ****/
+ [Test(Description = "Assert that the GameVersion subclass correctly parses legacy game versions.")]
+ [TestCase("1.0")]
+ [TestCase("1.01")]
+ [TestCase("1.02")]
+ [TestCase("1.03")]
+ [TestCase("1.04")]
+ [TestCase("1.05")]
+ [TestCase("1.051")]
+ [TestCase("1.051b")]
+ [TestCase("1.06")]
+ [TestCase("1.07")]
+ [TestCase("1.07a")]
+ [TestCase("1.1")]
+ [TestCase("1.11")]
+ [TestCase("1.2")]
+ [TestCase("1.2.15")]
+ public void GameVersion(string versionStr)
+ {
+ // act
+ GameVersion version = new GameVersion(versionStr);
+
+ // assert
+ Assert.AreEqual(versionStr, version.ToString(), "The game version did not round-trip to the same value.");
+ Assert.IsTrue(version.IsOlderThan(new SemanticVersion("1.2.30")), "The game version should be considered older than the later semantic versions.");
+ }
+
/*********
** Private methods
diff --git a/src/StardewModdingAPI.Tests/packages.config b/src/StardewModdingAPI.Tests/packages.config
index ba954308..6f04e625 100644
--- a/src/StardewModdingAPI.Tests/packages.config
+++ b/src/StardewModdingAPI.Tests/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Castle.Core" version="4.0.0" targetFramework="net45" />
- <package id="Moq" version="4.7.10" targetFramework="net45" />
+ <package id="Castle.Core" version="4.1.1" targetFramework="net45" />
+ <package id="Moq" version="4.7.99" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
- <package id="NUnit" version="3.6.1" targetFramework="net452" />
+ <package id="NUnit" version="3.7.1" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/src/StardewModdingAPI.sln b/src/StardewModdingAPI.sln
index 4d27e51b..9c3f18f8 100644
--- a/src/StardewModdingAPI.sln
+++ b/src/StardewModdingAPI.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.26430.14
+VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrainerMod", "TrainerMod\TrainerMod.csproj", "{28480467-1A48-46A7-99F8-236D95225359}"
EndProject
@@ -12,8 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "metadata", "metadata", "{86
.editorconfig = .editorconfig
..\.gitattributes = ..\.gitattributes
..\.gitignore = ..\.gitignore
+ common.targets = common.targets
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
- crossplatform.targets = crossplatform.targets
GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs
..\LICENSE = ..\LICENSE
prepare-install-package.targets = prepare-install-package.targets
diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs
index 3bd31c2d..7a790f1a 100644
--- a/src/StardewModdingAPI/Constants.cs
+++ b/src/StardewModdingAPI/Constants.cs
@@ -9,6 +9,7 @@ using StardewModdingAPI.AssemblyRewriters.Finders;
using StardewModdingAPI.AssemblyRewriters.Rewriters;
using StardewModdingAPI.AssemblyRewriters.Rewriters.Wrappers;
using StardewModdingAPI.Events;
+using StardewModdingAPI.Framework;
using StardewValley;
namespace StardewModdingAPI
@@ -35,7 +36,7 @@ namespace StardewModdingAPI
/// <summary>SMAPI's current semantic version.</summary>
public static ISemanticVersion ApiVersion { get; } =
#if SMAPI_1_x
- new SemanticVersion(1, 15, 1); // alpha-{DateTime.UtcNow:yyyyMMddHHmm}
+ new SemanticVersion(1, 15, 2);
#else
new SemanticVersion(2, 0, 0, $"alpha-{DateTime.UtcNow:yyyyMMddHHmm}");
#endif
@@ -86,7 +87,7 @@ namespace StardewModdingAPI
internal static string ModPath { get; } = Path.Combine(Constants.ExecutionPath, "Mods");
/// <summary>The game's current semantic version.</summary>
- internal static ISemanticVersion GameVersion { get; } = Constants.GetGameVersion();
+ internal static ISemanticVersion GameVersion { get; } = new GameVersion(Constants.GetGameVersion());
/// <summary>The target game platform.</summary>
internal static Platform TargetPlatform { get; } =
@@ -98,7 +99,7 @@ namespace StardewModdingAPI
/*********
- ** Protected methods
+ ** Internal methods
*********/
/// <summary>Get metadata for mapping assemblies to the current platform.</summary>
/// <param name="targetPlatform">The target game platform.</param>
@@ -179,15 +180,6 @@ namespace StardewModdingAPI
new TypeFinder("StardewModdingAPI.Command"),
new TypeFinder("StardewModdingAPI.Config"),
new TypeFinder("StardewModdingAPI.Log"),
- new TypeFinder("StardewModdingAPI.Event