Skip to content

Commit 16281fb

Browse files
committed
Merge branch 'develop' into stable
2 parents c84310d + cbb1777 commit 16281fb

48 files changed

Lines changed: 2767 additions & 1408 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,38 @@ section isn't relevant to you; see the previous sections to use or create mods._
5959
### Compiling from source
6060
Using an official SMAPI release is recommended for most users.
6161

62-
If you'd like to compile SMAPI from source, you can do that on any platform using
63-
[Visual Studio](https://www.visualstudio.com/vs/community/) or [MonoDevelop](http://www.monodevelop.com/).
64-
SMAPI uses build configuration derived from the [crosswiki mod config](https://github.com/Pathoschild/Stardew.ModBuildConfig#readme)
65-
to detect your current OS automatically and load the correct references. Compile output will be
66-
placed in a `bin` folder at the root of the git repository.
62+
SMAPI uses some C# 7 code, so you'll need at least
63+
[Visual Studio 2017](https://www.visualstudio.com/vs/community/) on Windows,
64+
[MonoDevelop 7.0](http://www.monodevelop.com/) on Linux,
65+
[Visual Studio 2017 for Mac](https://www.visualstudio.com/vs/visual-studio-mac/), or an equivalent
66+
IDE to compile it. It uses build configuration derived from the
67+
[crossplatform mod config](https://github.com/Pathoschild/Stardew.ModBuildConfig#readme) to detect
68+
your current OS automatically and load the correct references. Compile output will be placed in a
69+
`bin` folder at the root of the git repository.
6770

6871
### Debugging a local build
6972
Rebuilding the solution in debug mode will copy the SMAPI files into your game folder. Starting
70-
the `StardewModdingAPI` project with debugging will launch SMAPI with the debugger attached, so you
71-
can intercept errors and step through the code being executed.
73+
the `StardewModdingAPI` project with debugging from Visual Studio (on Mac or Windows) will launch
74+
SMAPI with the debugger attached, so you can intercept errors and step through the code being
75+
executed. This doesn't work in MonoDevelop on Linux, unfortunately.
7276

7377
### Preparing a release
7478
To prepare a crossplatform SMAPI release, you'll need to compile it on two platforms. See
75-
_[crossplatforming a SMAPI mod](http://canimod.com/guides/crossplatforming-a-smapi-mod#preparing-a-mod-release)_
76-
for the first-time setup. For simplicity, all paths are relative to the root of the repository (the
77-
folder containing `src`).
79+
[crossplatforming info](http://stardewvalleywiki.com/Modding:Creating_a_SMAPI_mod#Test_on_all_platforms)
80+
on the wiki for the first-time setup.
7881

7982
1. Update the version number in `GlobalAssemblyInfo.cs` and `Constants::Version`. Make sure you use a
8083
[semantic version](http://semver.org). Recommended format:
8184

8285
build type | format | example
8386
:--------- | :-------------------------------- | :------
84-
dev build | `<version>-alpha.<timestamp>` | `1.0.0-alpha.20171230`
85-
beta | `<version>-beta.<incrementing ID>`| `1.0.0-beta`, `1.0.0-beta.2`, …
86-
release | `<version>` | `1.0.0`
87+
dev build | `<version>-alpha.<timestamp>` | `1.0-alpha.20171230`
88+
prerelease | `<version>-prerelease.<ID>` | `1.0-prerelease.2`
89+
release | `<version>` | `1.0`
8790

8891
2. In Windows:
8992
1. Rebuild the solution in _Release_ mode.
90-
2. Rename `bin/Packaged` to `SMAPI <version>` (e.g. `SMAPI 1.6`).
93+
2. Rename `bin/Packaged` to `SMAPI <version>` (e.g. `SMAPI 1.0`).
9194
2. Transfer the `SMAPI <version>` folder to Linux or Mac.
9295
_This adds the installer executable and Windows files. We'll do the rest in Linux or Mac,
9396
since we need to set Unix file permissions that Windows won't save._
@@ -110,7 +113,8 @@ folder containing `src`).
110113
StardewModdingAPI.AssemblyRewriters.dll
111114
StardewModdingAPI.config.json
112115
StardewModdingAPI.exe
113-
StardewModdingAPI.exe.mdb
116+
StardewModdingAPI.pdb
117+
StardewModdingAPI.xml
114118
steam_appid.txt
115119
System.Numerics.dll
116120
System.Runtime.Caching.dll
@@ -129,7 +133,7 @@ folder containing `src`).
129133
5. Copy & paste the `SMAPI <version>` folder as `SMAPI <version> for developers`.
130134
6. In the `SMAPI <version>` folder...
131135
* edit `internal/Mono/StardewModdingAPI.config.json` and
132-
`internal/Windows/StardewModdingAPI.config.json` to disable developer mode;
136+
`internal/Windows/StardewModdingAPI.config.json` to disable developer mode;
133137
* delete `internal/Windows/StardewModdingAPI.xml`.
134138
7. Compress the two folders into `SMAPI <version>.zip` and `SMAPI <version> for developers.zip`.
135139
@@ -143,6 +147,7 @@ field | purpose
143147
`DeveloperMode` | Default `false` (except in _SMAPI for developers_ releases). Whether to enable features intended for mod developers. Currently this only makes `TRACE`-level messages appear in the console.
144148
`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.
145149
`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.
150+
`VerboseLogging` | Whether SMAPI should log more information about the game context.
146151
147152
### Command-line arguments
148153
SMAPI recognises the following command-line arguments. These are intended for internal use or
@@ -152,3 +157,13 @@ argument | purpose
152157
-------- | -------
153158
`--log-path "path"` | The relative or absolute path of the log file SMAPI should write.
154159
`--no-terminal` | SMAPI won't write anything to the console window. (Messages will still be written to the log file.)
160+
161+
### Compile flags
162+
SMAPI uses a small number of conditional compilation constants, which you can set by editing the
163+
`<DefineConstants>` element in `StardewModdingAPI.csproj`. Supported constants:
164+
165+
flag | purpose
166+
---- | -------
167+
`EXPERIMENTAL` | Enables preview features that aren't officially released yet.
168+
`SMAPI_FOR_WINDOWS` | Indicates that SMAPI is being compiled on Windows for players on Windows. Set automatically in `crossplatform.targets`.
169+

release-notes.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@ For mod developers:
1010
images).
1111
-->
1212

13+
## 1.13
14+
See [log](https://github.com/Pathoschild/SMAPI/compare/1.12...1.13).
15+
16+
For players:
17+
* SMAPI now recovers better from mod draw errors and detects when the error is irrecoverable.
18+
* SMAPI now recovers automatically from errors in the game loop when possible.
19+
* SMAPI now remembers if your game crashed and offers help next time you launch it.
20+
* Fixed installer sometimes finding redundant game paths.
21+
* Fixed save events not being raised after the first day on Linux/Mac.
22+
* Fixed error on Linux/Mac when a mod loads a PNG immediately after the save is loaded.
23+
* Updated mod compatibility list for Stardew Valley 1.2.
24+
25+
For mod developers:
26+
* Added a `Context.IsWorldReady` flag for mods to use.
27+
_<small>This indicates whether a save is loaded and the world is finished initialising, which starts at the same point that `SaveEvents.AfterLoad` and `TimeEvents.AfterDayStarted` are raised. This is mainly useful for events which can be raised before the world is loaded (like update tick).</small>_
28+
* Added a `debug` console command which lets you run the game's debug commands (e.g. `debug warp FarmHouse 1 1` warps you to the farmhouse).
29+
* Added basic context info to logs to simplify troubleshooting.
30+
* Added a `Mod.Dispose` method which can be overriden to clean up before exit. This method isn't guaranteed to be called on every exit.
31+
* Deprecated mods that don't have a `Name`, `Version`, or `UniqueID` in their manifest. These will be required in SMAPI 2.0.
32+
* Deprecated `GameEvents.GameLoaded` and `GameEvents.FirstUpdateTick`. You can move any affected code into your mod's `Entry` method.
33+
* Fixed maps not recognising custom tilesheets added through the SMAPI content API.
34+
* Internal refactoring for upcoming features.
35+
1336
## 1.12
1437
See [log](https://github.com/Pathoschild/SMAPI/compare/1.11...1.12).
1538

@@ -40,6 +63,7 @@ For mod developers:
4063
* Added a content API which loads custom textures/maps/data from the mod's folder (`.xnb` or `.png` format) or game content.
4164
* `Console.Out` messages are now written to the log file.
4265
* `Monitor.ExitGameImmediately` now aborts SMAPI initialisation and events more quickly.
66+
* Fixed value-changed events being raised when the player loads a save due to values being initialised.
4367

4468
## 1.10
4569
See [log](https://github.com/Pathoschild/SMAPI/compare/1.9...1.10).

src/.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ indent_size = 4
1111
insert_final_newline = true
1212
trim_trailing_whitespace = true
1313

14+
[*.json]
15+
indent_size = 2
1416

1517
##########
1618
## C# formatting

src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
77
<ProjectGuid>{10DB0676-9FC1-4771-A2C8-E2519F091E49}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -12,7 +12,7 @@
1212
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
</PropertyGroup>
15-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
15+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
1616
<DebugSymbols>true</DebugSymbols>
1717
<DebugType>full</DebugType>
1818
<Optimize>false</Optimize>
@@ -21,32 +21,14 @@
2121
<ErrorReport>prompt</ErrorReport>
2222
<WarningLevel>4</WarningLevel>
2323
</PropertyGroup>
24-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
24+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
2525
<DebugType>pdbonly</DebugType>
2626
<Optimize>true</Optimize>
2727
<OutputPath>bin\Release\</OutputPath>
2828
<DefineConstants>TRACE</DefineConstants>
2929
<ErrorReport>prompt</ErrorReport>
3030
<WarningLevel>4</WarningLevel>
3131
</PropertyGroup>
32-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
33-
<DebugSymbols>true</DebugSymbols>
34-
<OutputPath>bin\x86\Debug\</OutputPath>
35-
<DefineConstants>DEBUG;TRACE;SMAPI_FOR_WINDOWS</DefineConstants>
36-
<DebugType>full</DebugType>
37-
<PlatformTarget>x86</PlatformTarget>
38-
<ErrorReport>prompt</ErrorReport>
39-
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
40-
</PropertyGroup>
41-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
42-
<OutputPath>bin\x86\Release\</OutputPath>
43-
<DefineConstants>TRACE;SMAPI_FOR_WINDOWS</DefineConstants>
44-
<Optimize>true</Optimize>
45-
<DebugType>pdbonly</DebugType>
46-
<PlatformTarget>x86</PlatformTarget>
47-
<ErrorReport>prompt</ErrorReport>
48-
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
49-
</PropertyGroup>
5032
<ItemGroup>
5133
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
5234
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll</HintPath>

src/StardewModdingAPI.Installer/InteractiveInstaller.cs

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,39 @@ private IEnumerable<string> GetDefaultInstallPaths(Platform platform)
2727
switch (platform)
2828
{
2929
case Platform.Mono:
30-
// Linux
31-
yield return $"{Environment.GetEnvironmentVariable("HOME")}/GOG Games/Stardew Valley/game";
32-
yield return $"{Environment.GetEnvironmentVariable("HOME")}/.local/share/Steam/steamapps/common/Stardew Valley";
33-
yield return $"{Environment.GetEnvironmentVariable("HOME")}/.steam/steam/steamapps/common/Stardew Valley";
34-
35-
// Mac
36-
yield return "/Applications/Stardew Valley.app/Contents/MacOS";
37-
yield return $"{Environment.GetEnvironmentVariable("HOME")}/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS";
30+
{
31+
string home = Environment.GetEnvironmentVariable("HOME");
32+
33+
// Linux
34+
yield return $"{home}/GOG Games/Stardew Valley/game";
35+
yield return Directory.Exists($"{home}/.steam/steam/steamapps/common/Stardew Valley")
36+
? $"{home}/.steam/steam/steamapps/common/Stardew Valley"
37+
: $"{home}/.local/share/Steam/steamapps/common/Stardew Valley";
38+
39+
// Mac
40+
yield return "/Applications/Stardew Valley.app/Contents/MacOS";
41+
yield return $"{home}/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS";
42+
}
3843
break;
3944

4045
case Platform.Windows:
41-
// Windows
42-
yield return @"C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley";
43-
yield return @"C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley";
44-
45-
// Windows registry
46-
IDictionary<string, string> registryKeys = new Dictionary<string, string>
47-
{
48-
[@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150"] = "InstallLocation", // Steam
49-
[@"SOFTWARE\WOW6432Node\GOG.com\Games\1453375253"] = "PATH", // GOG on 64-bit Windows
50-
};
51-
foreach (var pair in registryKeys)
5246
{
53-
string path = this.GetLocalMachineRegistryValue(pair.Key, pair.Value);
54-
if (!string.IsNullOrWhiteSpace(path))
55-
yield return path;
47+
// Windows
48+
yield return @"C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley";
49+
yield return @"C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley";
50+
51+
// Windows registry
52+
IDictionary<string, string> registryKeys = new Dictionary<string, string>
53+
{
54+
[@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150"] = "InstallLocation", // Steam
55+
[@"SOFTWARE\WOW6432Node\GOG.com\Games\1453375253"] = "PATH", // GOG on 64-bit Windows
56+
};
57+
foreach (var pair in registryKeys)
58+
{
59+
string path = this.GetLocalMachineRegistryValue(pair.Key, pair.Value);
60+
if (!string.IsNullOrWhiteSpace(path))
61+
yield return path;
62+
}
5663
}
5764
break;
5865

@@ -511,7 +518,7 @@ private DirectoryInfo InteractivelyGetInstallPath(Platform platform)
511518
// get installed paths
512519
DirectoryInfo[] defaultPaths =
513520
(
514-
from path in this.GetDefaultInstallPaths(platform).Distinct()
521+
from path in this.GetDefaultInstallPaths(platform).Distinct(StringComparer.InvariantCultureIgnoreCase)
515522
let dir = new DirectoryInfo(path)
516523
where dir.Exists && dir.EnumerateFiles(executableFilename).Any()
517524
select dir

src/StardewModdingAPI.Installer/StardewModdingAPI.Installer.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
77
<ProjectGuid>{443DDF81-6AAF-420A-A610-3459F37E5575}</ProjectGuid>
88
<OutputType>Exe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
@@ -13,8 +13,8 @@
1313
<FileAlignment>512</FileAlignment>
1414
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1515
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<PlatformTarget>AnyCPU</PlatformTarget>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
17+
<PlatformTarget>x86</PlatformTarget>
1818
<DebugSymbols>true</DebugSymbols>
1919
<DebugType>full</DebugType>
2020
<Optimize>false</Optimize>
@@ -23,8 +23,8 @@
2323
<ErrorReport>prompt</ErrorReport>
2424
<WarningLevel>4</WarningLevel>
2525
</PropertyGroup>
26-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27-
<PlatformTarget>AnyCPU</PlatformTarget>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
27+
<PlatformTarget>x86</PlatformTarget>
2828
<DebugType>pdbonly</DebugType>
2929
<Optimize>true</Optimize>
3030
<OutputPath>$(SolutionDir)\..\bin\Release\Installer</OutputPath>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
3+
namespace StardewModdingAPI.Tests.Framework
4+
{
5+
/// <summary>Provides sample values for unit testing.</summary>
6+
internal static class Sample
7+
{
8+
/*********
9+
** Properties
10+
*********/
11+
/// <summary>A random number generator.</summary>
12+
private static readonly Random Random = new Random();
13+
14+
15+
/*********
16+
** Properties
17+
*********/
18+
/// <summary>Get a sample string.</summary>
19+
public static string String()
20+
{
21+
return Guid.NewGuid().ToString("N");
22+
}
23+
24+
/// <summary>Get a sample integer.</summary>
25+
public static int Int()
26+
{
27+
return Sample.Random.Next();
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)