Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed Oct 10, 2022
2 parents e7d29a2 + ee77efc commit 93a7489
Show file tree
Hide file tree
Showing 47 changed files with 612 additions and 247 deletions.
Binary file modified build/0Harmony.dll
Binary file not shown.
27 changes: 25 additions & 2 deletions build/0Harmony.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repo. It imports the other MSBuild files as needed.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--set general build properties -->
<Version>3.16.2</Version>
<Version>3.17.0</Version>
<Product>SMAPI</Product>
<LangVersion>latest</LangVersion>
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
Expand Down
4 changes: 4 additions & 0 deletions build/windows/prepare-install-package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ foreach ($folder in $folders) {
cp "$smapiBin/$name" "$bundlePath/smapi-internal"
}

if ($folder -eq "windows") {
cp "$smapiBin/VdfConverter.dll" "$bundlePath/smapi-internal"
}

cp "$smapiBin/SMAPI.config.json" "$bundlePath/smapi-internal/config.json"
cp "$smapiBin/SMAPI.metadata.json" "$bundlePath/smapi-internal/metadata.json"
if ($folder -eq "linux" -or $folder -eq "macOS") {
Expand Down
22 changes: 22 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@
_If needed, you can update to SMAPI 3.16.0 first and then install the latest version._
-->

## 3.17.0
Released 09 October 2022 for Stardew Valley 1.5.6 or later. See [release highlights](https://www.patreon.com/posts/73090322).

* For players:
* You can now download SMAPI 'strict mode' from [Nexus files](https://www.nexusmods.com/stardewvalley/mods/2400/?tab=files), which removes all deprecated APIs. This may significantly improve performance, but mods which still show deprecation warnings won't work.
* The SMAPI installer now also detects game folders in Steam's `.vdf` library data on Windows (thanks to pizzaoverhead!).
* SMAPI now prevents mods from enabling Harmony debug mode, which impacts performance and creates a file on your desktop.
_You can allow debug mode by editing `smapi-internal/config.json` in your game folder._
* Optimized performance and memory usage (thanks to atravita!).
* Other internal optimizations.
* Added more file extensions to ignore when searching for mod folders: `.7z`, `.tar`, `.tar.gz`, and `.xcf` (thanks to atravita!).
* Removed transitional `UseRawImageLoading` option added in 3.15.0. This is now always enabled, except when PyTK is installed.
* Fixed update alerts incorrectly shown for prerelease versions on GitHub that aren't marked as prerelease.

* For mod authors:
* When [providing a mod API in a C# mod](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Integrations), you can now get the mod requesting it as an optional parameter (thanks to KhloeLeclair!).
* SMAPI now treats square brackets in the manifest `Name` field as round ones to avoid breaking tools which parse log files.
* Made deprecation message wording stronger for the upcoming SMAPI 4.0.0 release.
* The `Texture2D.Name` field is now set earlier to support mods like SpriteMaster.
* Updated dependencies: [Harmony](https://harmony.pardeike.net) 2.2.2 (see [changes](https://github.com/pardeike/Harmony/releases/tag/v2.2.2.0)) and [FluentHttpClient](https://github.com/Pathoschild/FluentHttpClient#readme) 4.2.0 (see [changes](https://github.com/Pathoschild/FluentHttpClient/blob/develop/RELEASE-NOTES.md#420)).
* Fixed `LocationListChanged` event not raised & memory leak occurring when a generated mine/volcano is removed (thanks to tylergibbs2!).

## 3.16.2
Released 31 August 2022 for Stardew Valley 1.5.6 or later.

Expand Down
6 changes: 5 additions & 1 deletion docs/technical/mod-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,12 @@ The NuGet package is generated automatically in `StardewModdingAPI.ModBuildConfi
when you compile it.

## Release notes
### Upcoming release
### 4.0.2
Released 09 October 2022.

* Switched to the newer crossplatform `portable` debug symbols (thanks to lanturnalis!).
* Fixed `BundleExtraAssemblies` option being partly case-sensitive.
* Fixed `BundleExtraAssemblies` not applying `All` value to game assemblies.

### 4.0.1
Released 14 April 2022.
Expand Down
4 changes: 2 additions & 2 deletions docs/technical/smapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ the `SMAPI` project with debugging from Visual Studio or Rider should launch SMA
debugger attached, so you can intercept errors and step through the code being executed.

### Custom Harmony build
SMAPI uses [a custom build of Harmony](https://github.com/Pathoschild/Harmony#readme), which is
included in the `build` folder. To use a different build, just replace `0Harmony.dll` in that
SMAPI uses [a custom build of Harmony 2.2.2](https://github.com/Pathoschild/Harmony#readme), which
is included in the `build` folder. To use a different build, just replace `0Harmony.dll` in that
folder before compiling.

## Prepare a release
Expand Down
2 changes: 1 addition & 1 deletion src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!--NuGet package-->
<PackageId>Pathoschild.Stardew.ModBuildConfig</PackageId>
<Title>Build package for SMAPI mods</Title>
<Version>4.0.1</Version>
<Version>4.0.2</Version>
<Authors>Pathoschild</Authors>
<Description>Automates the build configuration for crossplatform Stardew Valley SMAPI mods. For SMAPI 3.13.0 or later.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
20 changes: 12 additions & 8 deletions src/SMAPI.ModBuildConfig/build/smapi.targets
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@
<EnableGameDebugging Condition="'$(EnableGameDebugging)' == ''">true</EnableGameDebugging>
<BundleExtraAssemblies Condition="'$(BundleExtraAssemblies)' == ''"></BundleExtraAssemblies>

<!-- simplify conditions -->
<_BundleExtraAssembliesForGame>$([System.Text.RegularExpressions.Regex]::IsMatch('$(BundleExtraAssemblies)', '\bGame|All\b', RegexOptions.IgnoreCase))</_BundleExtraAssembliesForGame>
<_BundleExtraAssembliesForAny>$([System.Text.RegularExpressions.Regex]::IsMatch('$(BundleExtraAssemblies)', '\bGame|System|ThirdParty|All\b', RegexOptions.IgnoreCase))</_BundleExtraAssembliesForAny>

<!-- coppy referenced DLLs into build output -->
<CopyLocalLockFileAssemblies Condition="$(BundleExtraAssemblies.Contains('ThirdParty')) OR $(BundleExtraAssemblies.Contains('Game')) OR $(BundleExtraAssemblies.Contains('System')) OR $(BundleExtraAssemblies.Contains('All'))">true</CopyLocalLockFileAssemblies>
<CopyLocalLockFileAssemblies Condition="$(_BundleExtraAssembliesForAny)">true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup Condition="'$(OS)' == 'Windows_NT' AND '$(EnableGameDebugging)' == 'true'">
Expand All @@ -44,17 +48,17 @@
**********************************************-->
<ItemGroup>
<!-- game -->
<Reference Include="Stardew Valley" HintPath="$(GamePath)\Stardew Valley.dll" Private="$(BundleExtraAssemblies.Contains('Game'))" />
<Reference Include="StardewValley.GameData" HintPath="$(GamePath)\StardewValley.GameData.dll" Private="$(BundleExtraAssemblies.Contains('Game'))" />
<Reference Include="MonoGame.Framework" HintPath="$(GamePath)\MonoGame.Framework.dll" Private="$(BundleExtraAssemblies.Contains('Game'))" />
<Reference Include="xTile" HintPath="$(GamePath)\xTile.dll" Private="$(BundleExtraAssemblies.Contains('Game'))" />
<Reference Include="Stardew Valley" HintPath="$(GamePath)\Stardew Valley.dll" Private="$(_BundleExtraAssembliesForGame)" />
<Reference Include="StardewValley.GameData" HintPath="$(GamePath)\StardewValley.GameData.dll" Private="$(_BundleExtraAssembliesForGame)" />
<Reference Include="MonoGame.Framework" HintPath="$(GamePath)\MonoGame.Framework.dll" Private="$(_BundleExtraAssembliesForGame)" />
<Reference Include="xTile" HintPath="$(GamePath)\xTile.dll" Private="$(_BundleExtraAssembliesForGame)" />

<!-- SMAPI -->
<Reference Include="StardewModdingAPI" HintPath="$(GamePath)\StardewModdingAPI.dll" Private="$(BundleExtraAssemblies.Contains('Game'))" />
<Reference Include="SMAPI.Toolkit.CoreInterfaces" HintPath="$(GamePath)\smapi-internal\SMAPI.Toolkit.CoreInterfaces.dll" Private="$(BundleExtraAssemblies.Contains('Game'))" />
<Reference Include="StardewModdingAPI" HintPath="$(GamePath)\StardewModdingAPI.dll" Private="$(_BundleExtraAssembliesForGame)" />
<Reference Include="SMAPI.Toolkit.CoreInterfaces" HintPath="$(GamePath)\smapi-internal\SMAPI.Toolkit.CoreInterfaces.dll" Private="$(_BundleExtraAssembliesForGame)" />

<!-- Harmony -->
<Reference Include="0Harmony" Condition="'$(EnableHarmony)' == 'true'" HintPath="$(GamePath)\smapi-internal\0Harmony.dll" Private="$(BundleExtraAssemblies.Contains('Game'))" />
<Reference Include="0Harmony" Condition="'$(EnableHarmony)' == 'true'" HintPath="$(GamePath)\smapi-internal\0Harmony.dll" Private="$(_BundleExtraAssembliesForGame)" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public override void Handle(IMonitor monitor, string command, ArgumentParser arg
/// <param name="color">The color to set.</param>
private bool TryParseColor(string input, out Color color)
{
string[] colorHexes = input.Split(new[] { ',' }, 3);
string[] colorHexes = input.Split(',', 3);
if (int.TryParse(colorHexes[0], out int r) && int.TryParse(colorHexes[1], out int g) && int.TryParse(colorHexes[2], out int b))
{
color = new Color(r, g, b);
Expand Down
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ConsoleCommands/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Console Commands",
"Author": "SMAPI",
"Version": "3.16.2",
"Version": "3.17.0",
"Description": "Adds SMAPI console commands that let you manipulate the game.",
"UniqueID": "SMAPI.ConsoleCommands",
"EntryDll": "ConsoleCommands.dll",
"MinimumApiVersion": "3.16.2"
"MinimumApiVersion": "3.17.0"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.ErrorHandler/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Error Handler",
"Author": "SMAPI",
"Version": "3.16.2",
"Version": "3.17.0",
"Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.",
"UniqueID": "SMAPI.ErrorHandler",
"EntryDll": "ErrorHandler.dll",
"MinimumApiVersion": "3.16.2"
"MinimumApiVersion": "3.17.0"
}
4 changes: 2 additions & 2 deletions src/SMAPI.Mods.SaveBackup/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Save Backup",
"Author": "SMAPI",
"Version": "3.16.2",
"Version": "3.17.0",
"Description": "Automatically backs up all your saves once per day into its folder.",
"UniqueID": "SMAPI.SaveBackup",
"EntryDll": "SaveBackup.dll",
"MinimumApiVersion": "3.16.2"
"MinimumApiVersion": "3.17.0"
}
6 changes: 3 additions & 3 deletions src/SMAPI.Tests/Utilities/KeybindListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ private SButtonState GetStateFromMap(SButton button, string stateMap)
foreach (string rawPair in stateMap.Split(','))
{
// parse values
string[] parts = rawPair.Split(new[] { ':' }, 2);
string[] parts = rawPair.Split(':', 2, StringSplitOptions.TrimEntries);
if (!Enum.TryParse(parts[0], ignoreCase: true, out SButton curButton))
Assert.Fail($"The state map is invalid: unknown button value '{parts[0].Trim()}'");
Assert.Fail($"The state map is invalid: unknown button value '{parts[0]}'");
if (!Enum.TryParse(parts[1], ignoreCase: true, out SButtonState state))
Assert.Fail($"The state map is invalid: unknown state value '{parts[1].Trim()}'");
Assert.Fail($"The state map is invalid: unknown state value '{parts[1]}'");

// get state
if (curButton == button)
Expand Down
4 changes: 2 additions & 2 deletions src/SMAPI.Tests/Utilities/SemanticVersionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,11 @@ public void Serializable(string versionStr)
{
// act
string json = JsonConvert.SerializeObject(new SemanticVersion(versionStr));
SemanticVersion after = JsonConvert.DeserializeObject<SemanticVersion>(json);
SemanticVersion? after = JsonConvert.DeserializeObject<SemanticVersion>(json);

// assert
Assert.IsNotNull(after, "The semantic version after deserialization is unexpectedly null.");
Assert.AreEqual(versionStr, after.ToString(), "The semantic version after deserialization doesn't match the input version.");
Assert.AreEqual(versionStr, after!.ToString(), "The semantic version after deserialization doesn't match the input version.");
}


Expand Down
50 changes: 49 additions & 1 deletion src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Reflection;
#if SMAPI_FOR_WINDOWS
using Microsoft.Win32;
using VdfParser;
#endif

namespace StardewModdingAPI.Toolkit.Framework.GameScanning
Expand All @@ -23,6 +24,9 @@ public class GameScanner
/// <summary>The current OS.</summary>
private readonly Platform Platform;

/// <summary>The Steam app ID for Stardew Valley.</summary>
private const string SteamAppId = "413150";


/*********
** Public methods
Expand Down Expand Up @@ -145,7 +149,7 @@ private IEnumerable<string> GetDefaultInstallPaths()
#if SMAPI_FOR_WINDOWS
IDictionary<string, string> registryKeys = new Dictionary<string, string>
{
[@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150"] = "InstallLocation", // Steam
[@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App " + GameScanner.SteamAppId] = "InstallLocation", // Steam
[@"SOFTWARE\WOW6432Node\GOG.com\Games\1453375253"] = "PATH", // GOG on 64-bit Windows
};
foreach (var pair in registryKeys)
Expand All @@ -158,7 +162,15 @@ private IEnumerable<string> GetDefaultInstallPaths()
// via Steam library path
string? steamPath = this.GetCurrentUserRegistryValue(@"Software\Valve\Steam", "SteamPath");
if (steamPath != null)
{
// conventional path
yield return Path.Combine(steamPath.Replace('/', '\\'), @"steamapps\common\Stardew Valley");

// from Steam's .vdf file
string? path = this.GetPathFromSteamLibrary(steamPath);
if (!string.IsNullOrWhiteSpace(path))
yield return path;
}
#endif

// default GOG/Steam paths
Expand Down Expand Up @@ -243,6 +255,42 @@ private IEnumerable<string> GetCustomInstallPaths()
using (openKey)
return (string?)openKey.GetValue(name);
}

/// <summary>Get the game directory path from alternative Steam library locations.</summary>
/// <param name="steamPath">The full path to the directory containing steam.exe.</param>
/// <returns>The game directory, if found.</returns>
private string? GetPathFromSteamLibrary(string? steamPath)
{
if (steamPath == null)
return null;

// get raw .vdf data
string libraryFoldersPath = Path.Combine(steamPath.Replace('/', '\\'), "steamapps\\libraryfolders.vdf");
using FileStream fileStream = File.OpenRead(libraryFoldersPath);
VdfDeserializer deserializer = new();
dynamic libraries = deserializer.Deserialize(fileStream);
if (libraries?.libraryfolders is null)
return null;

// get path from Stardew Valley app (if any)
foreach (dynamic pair in libraries.libraryfolders)
{
dynamic library = pair.Value;

foreach (dynamic app in library.apps)
{
string key = app.Key;
if (key == GameScanner.SteamAppId)
{
string path = library.path;

return Path.Combine(path.Replace("\\\\", "\\"), "steamapps", "common", "Stardew Valley");
}
}
}

return null;
}
#endif
}
}
4 changes: 4 additions & 0 deletions src/SMAPI.Toolkit/Framework/ModScanning/ModScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ public class ModScanner
".png",
".psd",
".tif",
".xcf", // gimp files

// archives
".rar",
".zip",
".7z",
".tar",
".tar.gz",

// backup files
".backup",
Expand Down
3 changes: 2 additions & 1 deletion src/SMAPI.Toolkit/SMAPI.Toolkit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.43" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Pathoschild.Http.FluentClient" Version="4.1.1" />
<PackageReference Include="Pathoschild.Http.FluentClient" Version="4.2.0" />
<PackageReference Include="System.Management" Version="5.0.0" Condition="'$(OS)' == 'Windows_NT'" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" Condition="'$(OS)' == 'Windows_NT'" />
<PackageReference Include="VdfConverter" Version="1.0.3" Condition="'$(OS)' == 'Windows_NT'" Private="False" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 93a7489

Please sign in to comment.