Skip to content

Commit 1edd98a

Browse files
committed
Merge branch 'develop' into stable
2 parents 36930ff + 8743c41 commit 1edd98a

125 files changed

Lines changed: 5451 additions & 1765 deletions

File tree

Some content is hidden

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

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Do you want to...
2+
3+
* **Ask for help using SMAPI?**
4+
Please post a message in the [SMAPI support thread](http://community.playstarbound.com/threads/108375),
5+
don't create a GitHub issue.
6+
7+
* **Report a bug?**
8+
Please post a message in the [SMAPI support thread](http://community.playstarbound.com/threads/108375)
9+
instead, unless you're sure it's a bug in SMAPI itself.
10+
11+
* **Submit a pull request?**
12+
Pull requests are welcome! If you're submitting a new feature, it's best to discuss first to make
13+
sure it'll be accepted. Feel free to come chat in [#modding on Discord](https://discord.gg/kH55QXP)
14+
or post in the [SMAPI support thread](http://community.playstarbound.com/threads/108375).
15+
16+
Documenting your code and using the same formatting conventions is appreciated, but don't worry too
17+
much about it. We'll fix up the code after we accept the pull request if needed.

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ doesn't change any of your game files. It serves five main purposes:
4141
otherwise show a generic 'program has stopped working' type of message._
4242

4343
## For players
44-
* [How to install SMAPI & use mods](http://canimod.com/guides/using-mods#installing-smapi)
44+
* [Intro & FAQs](http://stardewvalleywiki.com/Modding:Player_FAQs)
45+
* [Installing SMAPI](http://stardewvalleywiki.com/Modding:Installing_SMAPI)
4546
* [Release notes](release-notes.md#release-notes)
4647
* Need help? Come [chat on Discord](https://discord.gg/KCJHWhX) or [post in the support forums](http://community.playstarbound.com/threads/smapi-stardew-modding-api.108375/).
4748
_Please don't submit issues on GitHub for support questions._
4849

4950
## For mod developers
50-
* [How to develop mods](http://canimod.com/guides/creating-a-smapi-mod)
51-
* [How to update mods](http://canimod.com/guides/updating-a-smapi-mod)
51+
* [Modding documentation](http://stardewvalleywiki.com/Modding:Index)
5252
* [Release notes](release-notes.md#release-notes)
5353
* [Chat on Discord](https://discord.gg/KCJHWhX) with SMAPI developers and other modders
5454

@@ -118,6 +118,7 @@ on the wiki for the first-time setup.
118118
steam_appid.txt
119119
System.Numerics.dll
120120
System.Runtime.Caching.dll
121+
System.ValueTuple.dll
121122
Windows/
122123
Mods/*
123124
Mono.Cecil.dll
@@ -127,6 +128,7 @@ on the wiki for the first-time setup.
127128
StardewModdingAPI.exe
128129
StardewModdingAPI.pdb
129130
StardewModdingAPI.xml
131+
System.ValueTuple.dll
130132
steam_appid.txt
131133
```
132134
4. Open a terminal in the `SMAPI <version>` folder and run `chmod 755 internal/Mono/StardewModdingAPI`.
@@ -144,7 +146,7 @@ game folder. It contains these fields:
144146
145147
field | purpose
146148
----- | -------
147-
`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.
149+
`DeveloperMode` | Default `false` (except in _SMAPI for developers_ releases). Whether to enable features intended for mod developers (mainly more detailed console logging).
148150
`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.
149151
`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.
150152
`VerboseLogging` | Whether SMAPI should log more information about the game context.
@@ -164,6 +166,5 @@ SMAPI uses a small number of conditional compilation constants, which you can se
164166
165167
flag | purpose
166168
---- | -------
167-
`EXPERIMENTAL` | Enables preview features that aren't officially released yet.
168169
`SMAPI_FOR_WINDOWS` | Indicates that SMAPI is being compiled on Windows for players on Windows. Set automatically in `crossplatform.targets`.
169-
170+
`SMAPI_2_0` | Sets SMAPI 2.0 mode, which enables features planned for SMAPI 2.0 and removes all deprecated code. This helps test how mods will work when SMAPI 2.0 is released.

release-notes.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,53 @@
11
# Release notes
2+
## 2.0 (upcoming)
3+
<!--See [log](https://github.com/Pathoschild/SMAPI/compare/1.10...2.0).-->
24

3-
<!--
4-
## 2.0
5-
See [log](https://github.com/Pathoschild/SMAPI/compare/1.10...2.0).
5+
For players:
6+
* The SMAPI console is now much simpler and easier-to-read.
67

78
For mod developers:
8-
* Added `ContentEvents.AssetLoading` event with a helper which lets you intercept the XNB content
9-
load, and dynamically adjust or replace the content being loaded (including support for patching
10-
images).
11-
-->
9+
* Added API to edit XNB images & data loaded by the game (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Content)).
10+
* Added API to inject new XNB images & data (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Content)).
11+
* 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)).
12+
* Added useful `InputEvents` metadata like the cursor position, grab tile, etc.
13+
* Added ability to prevent the game from handling a button press via `InputEvents`.
14+
* In `manifest.json`:
15+
* Dependencies can now be optional.
16+
* The version can now be a string like `"1.0-alpha"` instead of a structure.
17+
* Removed all deprecated code.
18+
19+
## 1.15
20+
See [log](https://github.com/Pathoschild/SMAPI/compare/1.14...1.15).
21+
22+
For players:
23+
* Cleaned up SMAPI console a bit.
24+
* Revamped TrainerMod's item commands:
25+
* `player_add` is a new command to add any item to your inventory (including tools, weapons, equipment, craftables, wallpaper, etc). This replaces the former `player_additem`, `player_addring`, and `player_addweapon`.
26+
* `list_items` now shows all items in the game. You can search by item type like `list_items weapon`, or search by item name like `list_items galaxy sword`.
27+
* `list_items` now also matches translated item names when playing in another language.
28+
* `list_item_types` is a new command to see a list of item types.
29+
* Fixed unhelpful error when a `config.json` is invalid.
30+
* Fixed rare crash when window loses focus for a few players (further to fix in 1.14).
31+
* Fixed invalid `ObjectInformation.xnb` causing a flood of warnings; SMAPI now shows one error instead.
32+
* Updated mod compatibility list.
33+
34+
For modders:
35+
* Added `SDate` utility for in-game date calculations (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Dates)).
36+
* Added support for minimum dependency versions in `manifest.json` (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Manifest)).
37+
* Added more useful logging when loading mods.
38+
* Added a `ModID` property to all mod helpers for extension methods.
39+
* Changed `manifest.MinimumApiVersion` from string to `ISemanticVersion`. This shouldn't affect mods unless they referenced that field in code.
40+
* Fixed `SemanticVersion` parsing some invalid versions into close approximations (like `1.apple` &rarr; `1.0-apple`).
41+
* Fixed `SemanticVersion` not treating hyphens as separators when comparing prerelease tags.
42+
<small>_(While that was technically correct, it leads to unintuitive behaviour like sorting `-alpha-2` _after_ `-alpha-10`, even though `-alpha.2` sorts before `-alpha.10`.)_</small>
43+
* Fixed corrupted state exceptions not being logged by SMAPI.
44+
* Increased all deprecations to _pending removal_.
45+
46+
For SMAPI developers:
47+
* Added SMAPI 2.0 compile mode, for testing how mods will work with SMAPI 2.0.
48+
* Added prototype SMAPI 2.0 feature to override XNB files (not enabled for mods yet).
49+
* Added prototype SMAPI 2.0 support for version strings in `manifest.json` (not recommended for mods yet).
50+
* Compiling SMAPI now uses your `~/stardewvalley.targets` file if present.
1251

1352
## 1.14
1453
See [log](https://github.com/Pathoschild/SMAPI/compare/1.13...1.14).

src/.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ indent_style = space
1010
indent_size = 4
1111
insert_final_newline = true
1212
trim_trailing_whitespace = true
13+
charset = utf-8
1314

1415
[*.json]
1516
indent_size = 2

src/GlobalAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
using System.Runtime.InteropServices;
33

44
[assembly: ComVisible(false)]
5-
[assembly: AssemblyVersion("1.14.1.0")]
6-
[assembly: AssemblyFileVersion("1.14.1.0")]
5+
[assembly: AssemblyVersion("1.15.0.0")]
6+
[assembly: AssemblyFileVersion("1.15.0.0")]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using Mono.Cecil;
2+
using Mono.Cecil.Cil;
3+
4+
namespace StardewModdingAPI.AssemblyRewriters.Finders
5+
{
6+
/// <summary>Finds incompatible CIL instructions that reference a given property and throws an <see cref="IncompatibleInstructionException"/>.</summary>
7+
public class PropertyFinder : IInstructionRewriter
8+
{
9+
/*********
10+
** Properties
11+
*********/
12+
/// <summary>The full type name for which to find references.</summary>
13+
private readonly string FullTypeName;
14+
15+
/// <summary>The property name for which to find references.</summary>
16+
private readonly string PropertyName;
17+
18+
19+
/*********
20+
** Accessors
21+
*********/
22+
/// <summary>A brief noun phrase indicating what the instruction finder matches.</summary>
23+
public string NounPhrase { get; }
24+
25+
26+
/*********
27+
** Public methods
28+
*********/
29+
/// <summary>Construct an instance.</summary>
30+
/// <param name="fullTypeName">The full type name for which to find references.</param>
31+
/// <param name="propertyName">The property name for which to find references.</param>
32+
/// <param name="nounPhrase">A brief noun phrase indicating what the instruction finder matches (or <c>null</c> to generate one).</param>
33+
public PropertyFinder(string fullTypeName, string propertyName, string nounPhrase = null)
34+
{
35+
this.FullTypeName = fullTypeName;
36+
this.PropertyName = propertyName;
37+
this.NounPhrase = nounPhrase ?? $"{fullTypeName}.{propertyName} property";
38+
}
39+
40+
/// <summary>Rewrite a method definition for compatibility.</summary>
41+
/// <param name="module">The module being rewritten.</param>
42+
/// <param name="method">The method definition to rewrite.</param>
43+
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
44+
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
45+
/// <returns>Returns whether the instruction was rewritten.</returns>
46+
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
47+
public virtual bool Rewrite(ModuleDefinition module, MethodDefinition method, PlatformAssemblyMap assemblyMap, bool platformChanged)
48+
{
49+
return false;
50+
}
51+
52+
/// <summary>Rewrite a CIL instruction for compatibility.</summary>
53+
/// <param name="module">The module being rewritten.</param>
54+
/// <param name="cil">The CIL rewriter.</param>
55+
/// <param name="instruction">The instruction to rewrite.</param>
56+
/// <param name="assemblyMap">Metadata for mapping assemblies to the current platform.</param>
57+
/// <param name="platformChanged">Whether the mod was compiled on a different platform.</param>
58+
/// <returns>Returns whether the instruction was rewritten.</returns>
59+
/// <exception cref="IncompatibleInstructionException">The CIL instruction is not compatible, and can't be rewritten.</exception>
60+
public virtual bool Rewrite(ModuleDefinition module, ILProcessor cil, Instruction instruction, PlatformAssemblyMap assemblyMap, bool platformChanged)
61+
{
62+
if (!this.IsMatch(instruction))
63+
return false;
64+
65+
throw new IncompatibleInstructionException(this.NounPhrase);
66+
}
67+
68+
69+
/*********
70+
** Protected methods
71+
*********/
72+
/// <summary>Get whether a CIL instruction matches.</summary>
73+
/// <param name="instruction">The IL instruction.</param>
74+
protected bool IsMatch(Instruction instruction)
75+
{
76+
MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
77+
return
78+
methodRef != null
79+
&& methodRef.DeclaringType.FullName == this.FullTypeName
80+
&& (methodRef.Name == "get_" + this.PropertyName || methodRef.Name == "set_" + this.PropertyName);
81+
}
82+
}
83+
}

src/StardewModdingAPI.AssemblyRewriters/StardewModdingAPI.AssemblyRewriters.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<Link>Properties\GlobalAssemblyInfo.cs</Link>
5050
</Compile>
5151
<Compile Include="Finders\EventFinder.cs" />
52+
<Compile Include="Finders\PropertyFinder.cs" />
5253
<Compile Include="Finders\FieldFinder.cs" />
5354
<Compile Include="Finders\MethodFinder.cs" />
5455
<Compile Include="Finders\TypeFinder.cs" />

src/StardewModdingAPI.Installer/InteractiveInstaller.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ private IEnumerable<string> GetUninstallPaths(DirectoryInfo installDir, Director
8282
yield return GetInstallPath("StardewModdingAPI.config.json");
8383
yield return GetInstallPath("StardewModdingAPI.data.json");
8484
yield return GetInstallPath("StardewModdingAPI.AssemblyRewriters.dll");
85+
yield return GetInstallPath("System.ValueTuple.dll");
8586
yield return GetInstallPath("steam_appid.txt");
8687

8788
// Linux/Mac only

src/StardewModdingAPI.Installer/readme.txt

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,32 @@
1313

1414
SMAPI lets you run Stardew Valley with mods. Don't forget to download mods separately.
1515

16-
Need help? See:
17-
- Install guide: http://canimod.com/for-players/install-smapi
18-
- Troubleshooting: http://canimod.com/for-players/faqs#troubleshooting
19-
- Ask for help: https://discord.gg/kH55QXP
16+
17+
Install guide
18+
--------------------------------
19+
See http://stardewvalleywiki.com/Modding:Installing_SMAPI.
20+
21+
22+
Need help?
23+
--------------------------------
24+
- FAQs: http://stardewvalleywiki.com/Modding:Player_FAQs
25+
- Ask for help: https://discord.gg/kH55QXP
26+
27+
28+
Manual install
29+
--------------------------------
30+
THIS IS NOT RECOMMENDED FOR MOST PLAYERS. See instructions above instead.
31+
If you really want to install SMAPI manually, here's how.
32+
33+
1. Download the latest version of SMAPI: https://github.com/Pathoschild/SMAPI/releases.
34+
2. Unzip the .zip file somewhere (not in your game folder).
35+
3. Copy the files from the "internal/Windows" folder (on Windows) or "internal/Mono" folder (on
36+
Linux/Mac) into your game folder. The `StardewModdingAPI.exe` file should be right next to the
37+
game's executable.
38+
4.
39+
- Windows only: if you use Steam, see the install guide above to enable achievements and
40+
overlay. Otherwise, just run StardewModdingAPI.exe in your game folder to play with mods.
41+
42+
- Linux/Mac only: rename the "StardewValley" file (no extension) to "StardewValley-original", and
43+
"StardewModdingAPI" (no extension) to "StardewValley". Now just launch the game as usual to
44+
play with mods.

0 commit comments

Comments
 (0)