diff --git a/.gitignore b/.gitignore index 7261c536..ed3052fd 100644 --- a/.gitignore +++ b/.gitignore @@ -30,9 +30,6 @@ _ReSharper*/ # sensitive files appsettings.Development.json -# generated build files -build/0Harmony.* - # Azure generated files src/SMAPI.Web/Properties/PublishProfiles/*.pubxml diff --git a/build/0Harmony.dll b/build/0Harmony.dll new file mode 100644 index 00000000..2e893d0e Binary files /dev/null and b/build/0Harmony.dll differ diff --git a/build/common.targets b/build/common.targets index 8ad5e88b..eebad019 100644 --- a/build/common.targets +++ b/build/common.targets @@ -4,7 +4,7 @@ - 3.5.0 + 3.6.1 SMAPI latest diff --git a/docs/release-notes.md b/docs/release-notes.md index c47ee835..1fa58807 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,45 +1,58 @@ ← [README](README.md) # Release notes -## Upcoming release + 1 + + +## 3.6.1 +Released 21 June 2020 for Stardew Valley 1.4.1 or later. + +* Fixed event priority sorting. + +## 3.6 +Released 20 June 2020 for Stardew Valley 1.4.1 or later. -## Upcoming release * For players: - * Mod warnings are now listed alphabetically. + * Added crossplatform compatibility for mods which use the `[HarmonyPatch(type)]` attribute. + * Added experimental option to reduce startup time when loading mod DLLs (thanks to ZaneYork!). Enable `RewriteInParallel` in the `smapi-internal/config.json` to try it. + * Reduced processing time when a mod loads many unpacked images (thanks to Entoarox!). + * Mod load warnings are now listed alphabetically. * MacOS files starting with `._` are now ignored and can no longer cause skipped mods. * Simplified paranoid warning logs and reduced their log level. - * Reduced startup time when loading mod DLLs (thanks to ZaneYork!). - * Reduced processing time when a mod loads many unpacked images (thanks to Entoarox!). - * Fixed `BadImageFormatException` error detection. * Fixed black maps on Android for mods which use `.tmx` files. + * Fixed `BadImageFormatException` error detection. + * Fixed `reload_i18n` command not reloading content pack translations. * For the web UI: * Added GitHub licenses to mod compatibility list. + * Improved JSON validator: + * added SMAPI `i18n` schema; + * editing an uploaded file now remembers the selected schema; + * changed default schema to plain JSON. * Updated ModDrop URLs. * Internal changes to improve performance and reliability. * For modders: * Added [event priorities](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Events#Custom_priority) (thanks to spacechase0!). * Added [update subkeys](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Update_checks#Update_subkeys). + * Added [a custom build of Harmony](https://github.com/Pathoschild/Harmony#readme) to provide more useful stack traces in error logs. + * Added `harmony_summary` console command to list or search current Harmony patches. * Added `Multiplayer.PeerConnected` event. - * Added ability to override update keys from the compatibility list. - * Harmony mods which use the `[HarmonyPatch(type)]` attribute now work crossplatform. Previously SMAPI couldn't rewrite types in custom attributes for compatibility. - * Improved mod rewriting for compatibility: - * Fixed rewriting types in custom attributes. - * Fixed rewriting generic types to method references. - * Fixed `helper.Reflection` blocking access to game methods/properties that were extended by SMAPI. + * Added support for overriding update keys from the wiki compatibility list. + * Improved mod rewriting for compatibility to support more cases (e.g. custom attributes and generic types). + * Fixed `helper.Reflection` blocking access to game methods/properties intercepted by SMAPI. * Fixed asset propagation for Gil's portraits. - * Fixed `.pdb` files ignored for error stack traces for mods rewritten by SMAPI. + * Fixed `.pdb` files ignored for error stack traces when mods are rewritten by SMAPI. * Fixed `ModMessageReceived` event handlers not tracked for performance monitoring. * For SMAPI developers: - * Added support for bundling a custom Harmony build for upcoming use. * Eliminated MongoDB storage in the web services, which complicated the code unnecessarily. The app still uses an abstract interface for storage, so we can wrap a distributed cache in the future if needed. - * Overhauled update checks to simplify individual clients, centralize common logic, and enable upcoming features. + * Overhauled update checks to simplify mod site integrations, centralize common logic, and enable upcoming features. * Merged the separate legacy redirects app on AWS into the main app on Azure. + * Changed SMAPI's Harmony ID from `io.smapi` to `SMAPI` for readability in Harmony summaries. ## 3.5 Released 27 April 2020 for Stardew Valley 1.4.1 or later. diff --git a/docs/technical/smapi.md b/docs/technical/smapi.md index 3b2d6e56..3cb450ae 100644 --- a/docs/technical/smapi.md +++ b/docs/technical/smapi.md @@ -58,7 +58,7 @@ SMAPI uses a small number of conditional compilation constants, which you can se flag | purpose ---- | ------- `SMAPI_FOR_WINDOWS` | Whether SMAPI is being compiled on Windows for players on Windows. Set automatically in `crossplatform.targets`. -`HARMONY_2` | Whether to enable experimental Harmony 2.0 support. Existing Harmony 1._x_ mods will be rewritten automatically for compatibility. +`HARMONY_2` | Whether to enable experimental Harmony 2.0 support and rewrite existing Harmony 1._x_ mods for compatibility. Note that you need to replace `build/0Harmony.dll` with a Harmony 2.0 build (or switch to a package reference) to use this flag. ## For SMAPI developers ### Compiling from source @@ -81,8 +81,8 @@ To prepare a crossplatform SMAPI release, you'll need to compile it on two platf [crossplatforming info](https://stardewvalleywiki.com/Modding:Modder_Guide/Test_and_Troubleshoot#Testing_on_all_platforms) on the wiki for the first-time setup. -1. Update the version number in `.root/build/common.targets` and `Constants::Version`. Make sure - you use a [semantic version](https://semver.org). Recommended format: +1. Update the version numbers in `build/common.targets`, `Constants`, and the `manifest.json` for + bundled mods. Make sure you use a [semantic version](https://semver.org). Recommended format: build type | format | example :--------- | :----------------------- | :------ @@ -102,14 +102,10 @@ on the wiki for the first-time setup. 3. Rename the folders to `SMAPI installer` and `SMAPI installer for developers`. 4. Zip the two folders. -### Using a custom Harmony build -The official SMAPI releases include [a custom build of Harmony](https://github.com/Pathoschild/Harmony), -but compiling from source will use the official build. To use a custom build, put `0Harmony.dll` in -the `build` folder and it'll be referenced automatically. - -Note that Harmony merges its dependencies into `0Harmony.dll` when compiled in release mode. To use -a debug build of Harmony, you'll need to manually copy those dependencies into your game's -`smapi-internal` folder. +### 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 +folder. ## Release notes See [release notes](../release-notes.md). diff --git a/docs/technical/web.md b/docs/technical/web.md index d21b87ac..50237bfe 100644 --- a/docs/technical/web.md +++ b/docs/technical/web.md @@ -110,8 +110,9 @@ Available schemas: format | schema URL ------ | ---------- -[SMAPI `manifest.json`](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Manifest) | https://smapi.io/schemas/manifest.json -[Content Patcher `content.json`](https://github.com/Pathoschild/StardewMods/tree/develop/ContentPatcher#readme) | https://smapi.io/schemas/content-patcher.json +[SMAPI: `manifest.json`](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Manifest) | https://smapi.io/schemas/manifest.json +[SMAPI: translations (`i18n` folder)](https://stardewvalleywiki.com/Modding:Modder_Guide/APIs/Translation) | https://smapi.io/schemas/i18n.json +[Content Patcher: `content.json`](https://github.com/Pathoschild/StardewMods/tree/develop/ContentPatcher#readme) | https://smapi.io/schemas/content-patcher.json ## Web API ### Overview diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index 908d4f65..7300cdf8 100644 --- a/src/SMAPI.Mods.ConsoleCommands/manifest.json +++ b/src/SMAPI.Mods.ConsoleCommands/manifest.json @@ -1,9 +1,9 @@ { "Name": "Console Commands", "Author": "SMAPI", - "Version": "3.5.0", + "Version": "3.6.1", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.5.0" + "MinimumApiVersion": "3.6.1" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index cd42459e..cffd780d 100644 --- a/src/SMAPI.Mods.SaveBackup/manifest.json +++ b/src/SMAPI.Mods.SaveBackup/manifest.json @@ -1,9 +1,9 @@ { "Name": "Save Backup", "Author": "SMAPI", - "Version": "3.5.0", + "Version": "3.6.1", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.5.0" + "MinimumApiVersion": "3.6.1" } diff --git a/src/SMAPI.Web/Controllers/JsonValidatorController.cs b/src/SMAPI.Web/Controllers/JsonValidatorController.cs index c43fb929..5f83eafd 100644 --- a/src/SMAPI.Web/Controllers/JsonValidatorController.cs +++ b/src/SMAPI.Web/Controllers/JsonValidatorController.cs @@ -27,12 +27,13 @@ namespace StardewModdingAPI.Web.Controllers private readonly IDictionary SchemaFormats = new Dictionary { ["none"] = "None", - ["manifest"] = "Manifest", + ["manifest"] = "SMAPI: manifest", + ["i18n"] = "SMAPI: translations (i18n)", ["content-patcher"] = "Content Patcher" }; /// The schema ID to use if none was specified. - private string DefaultSchemaID = "manifest"; + private string DefaultSchemaID = "none"; /// A token in an error message which indicates that the child errors should be displayed instead. private readonly string TransparentToken = "$transparent"; @@ -57,16 +58,22 @@ namespace StardewModdingAPI.Web.Controllers /// Render the schema validator UI. /// The schema name with which to validate the JSON, or 'edit' to return to the edit screen. /// The stored file ID. + /// The operation to perform for the selected log ID. This can be 'edit', or any other value to view. [HttpGet] [Route("json")] [Route("json/{schemaName}")] [Route("json/{schemaName}/{id}")] - public async Task Index(string schemaName = null, string id = null) + [Route("json/{schemaName}/{id}/{operation}")] + public async Task Index(string schemaName = null, string id = null, string operation = null) { + // parse arguments schemaName = this.NormalizeSchemaName(schemaName); + bool hasId = !string.IsNullOrWhiteSpace(id); + bool isEditView = !hasId || operation?.Trim().ToLower() == "edit"; - var result = new JsonValidatorModel(id, schemaName, this.SchemaFormats); - if (string.IsNullOrWhiteSpace(id)) + // build result model + var result = this.GetModel(id, schemaName, isEditView); + if (!hasId) return this.View("Index", result); // fetch raw JSON @@ -76,7 +83,7 @@ namespace StardewModdingAPI.Web.Controllers result.SetContent(file.Content, expiry: file.Expiry, uploadWarning: file.Warning); // skip parsing if we're going to the edit screen - if (schemaName?.ToLower() == "edit") + if (isEditView) return this.View("Index", result); // parse JSON @@ -130,7 +137,7 @@ namespace StardewModdingAPI.Web.Controllers public async Task PostAsync(JsonValidatorRequestModel request) { if (request == null) - return this.View("Index", this.GetModel(null, null).SetUploadError("The request seems to be invalid.")); + return this.View("Index", this.GetModel(null, null, isEditView: true).SetUploadError("The request seems to be invalid.")); // normalize schema name string schemaName = this.NormalizeSchemaName(request.SchemaName); @@ -138,12 +145,12 @@ namespace StardewModdingAPI.Web.Controllers // get raw text string input = request.Content; if (string.IsNullOrWhiteSpace(input)) - return this.View("Index", this.GetModel(null, schemaName).SetUploadError("The JSON file seems to be empty.")); + return this.View("Index", this.GetModel(null, schemaName, isEditView: true).SetUploadError("The JSON file seems to be empty.")); // upload file UploadResult result = await this.Storage.SaveAsync(input); if (!result.Succeeded) - return this.View("Index", this.GetModel(result.ID, schemaName).SetUploadError(result.UploadError)); + return this.View("Index", this.GetModel(result.ID, schemaName, isEditView: true).SetContent(input, null).SetUploadError(result.UploadError)); // redirect to view return this.Redirect(this.Url.PlainAction("Index", "JsonValidator", new { schemaName = schemaName, id = result.ID })); @@ -156,9 +163,10 @@ namespace StardewModdingAPI.Web.Controllers /// Build a JSON validator model. /// The stored file ID. /// The schema name with which the JSON was validated. - private JsonValidatorModel GetModel(string pasteID, string schemaName) + /// Whether to show the edit view. + private JsonValidatorModel GetModel(string pasteID, string schemaName, bool isEditView) { - return new JsonValidatorModel(pasteID, schemaName, this.SchemaFormats); + return new JsonValidatorModel(pasteID, schemaName, this.SchemaFormats, isEditView); } /// Get a normalized schema name, or the if blank. diff --git a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs index c0dd7184..0ea69911 100644 --- a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs +++ b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs @@ -10,6 +10,9 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator /********* ** Accessors *********/ + /// Whether to show the edit view. + public bool IsEditView { get; set; } + /// The paste ID. public string PasteID { get; set; } @@ -51,11 +54,13 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator /// The stored file ID. /// The schema name with which the JSON was validated. /// The supported JSON schemas (names indexed by ID). - public JsonValidatorModel(string pasteID, string schemaName, IDictionary schemaFormats) + /// Whether to show the edit view. + public JsonValidatorModel(string pasteID, string schemaName, IDictionary schemaFormats, bool isEditView) { this.PasteID = pasteID; this.SchemaName = schemaName; this.SchemaFormats = schemaFormats; + this.IsEditView = isEditView; } /// Set the validated content. diff --git a/src/SMAPI.Web/Views/JsonValidator/Index.cshtml b/src/SMAPI.Web/Views/JsonValidator/Index.cshtml index f23bd150..7b89a23d 100644 --- a/src/SMAPI.Web/Views/JsonValidator/Index.cshtml +++ b/src/SMAPI.Web/Views/JsonValidator/Index.cshtml @@ -9,7 +9,6 @@ string newUploadUrl = this.Url.PlainAction("Index", "JsonValidator", new { schemaName = Model.SchemaName }); string schemaDisplayName = null; bool isValidSchema = Model.SchemaName != null && Model.SchemaFormats.TryGetValue(Model.SchemaName, out schemaDisplayName) && schemaDisplayName?.ToLower() != "none"; - bool isEditView = Model.Content == null || Model.SchemaName?.ToLower() == "edit"; // build title ViewData["Title"] = "JSON validator"; @@ -63,7 +62,7 @@ else if (Model.ParseError != null) Error details: @Model.ParseError } -else if (!isEditView && Model.PasteID != null) +else if (!Model.IsEditView && Model.PasteID != null) {