From 3a832b99bf3f82cfe39de776b5e15db6c8ddff1a Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Nov 2017 14:54:32 -0500 Subject: add date.DaysSinceStart property, add unit tests, update release notes (#390) --- docs/release-notes.md | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 1a9e4681..a74b1927 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,4 +1,11 @@ # Release notes +## 2.2 +* For players: + * Fixed mods crashing when loading a custom asset on Linux/Mac. + +* For modders: + * Added `DaysSinceStart` property to `SDate` dates. + ## 2.1 * For players: * Added a log parser at [log.smapi.io](https://log.smapi.io). -- cgit From ca13b2834c3d34be94c4d46a59cba945e62cce33 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Nov 2017 15:39:41 -0500 Subject: fix e.SuppressButton() not working with some mouse buttons, update release notes (#389) --- docs/release-notes.md | 2 ++ src/SMAPI/Events/EventArgsInput.cs | 31 +++++++++---------------------- 2 files changed, 11 insertions(+), 22 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index a74b1927..433050fb 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -5,6 +5,8 @@ * For modders: * Added `DaysSinceStart` property to `SDate` dates. + * Fixed input `e.SuppressButton(button)` method ignoring input. + * Fixed input `e.SuppressButton()` method not working with mouse buttons. ## 2.1 * For players: diff --git a/src/SMAPI/Events/EventArgsInput.cs b/src/SMAPI/Events/EventArgsInput.cs index 276bfef6..54ce9b53 100644 --- a/src/SMAPI/Events/EventArgsInput.cs +++ b/src/SMAPI/Events/EventArgsInput.cs @@ -129,30 +129,17 @@ namespace StardewModdingAPI.Events } // mouse - else if (button == SButton.MouseLeft) + else if (button == SButton.MouseLeft || button == SButton.MouseMiddle || button == SButton.MouseRight || button == SButton.MouseX1 || button == SButton.MouseX2) { Game1.oldMouseState = new MouseState( - Game1.oldMouseState.X, - Game1.oldMouseState.Y, - Game1.oldMouseState.ScrollWheelValue, - ButtonState.Pressed, - Game1.oldMouseState.MiddleButton, - Game1.oldMouseState.RightButton, - Game1.oldMouseState.XButton1, - Game1.oldMouseState.XButton2 - ); - } - else if (button == SButton.MouseRight) - { - Game1.oldMouseState = new MouseState( - Game1.oldMouseState.X, - Game1.oldMouseState.Y, - Game1.oldMouseState.ScrollWheelValue, - Game1.oldMouseState.LeftButton, - Game1.oldMouseState.MiddleButton, - ButtonState.Pressed, - Game1.oldMouseState.XButton1, - Game1.oldMouseState.XButton2 + x: Game1.oldMouseState.X, + y: Game1.oldMouseState.Y, + scrollWheel: Game1.oldMouseState.ScrollWheelValue, + leftButton: button == SButton.MouseLeft ? ButtonState.Pressed : Game1.oldMouseState.LeftButton, + middleButton: button == SButton.MouseMiddle ? ButtonState.Pressed : Game1.oldMouseState.MiddleButton, + rightButton: button == SButton.MouseRight ? ButtonState.Pressed : Game1.oldMouseState.RightButton, + xButton1: button == SButton.MouseX1 ? ButtonState.Pressed : Game1.oldMouseState.XButton1, + xButton2: button == SButton.MouseX2 ? ButtonState.Pressed : Game1.oldMouseState.XButton2 ); } } -- cgit From 05415497930da5fc156a0936a646ebf522124bd5 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Nov 2017 15:51:35 -0500 Subject: update release notes (#386) --- docs/release-notes.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 433050fb..4c5f49d6 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,6 +8,9 @@ * Fixed input `e.SuppressButton(button)` method ignoring input. * Fixed input `e.SuppressButton()` method not working with mouse buttons. +* For log.smapi.io: + * The upload-log modal can now be closed by pressing `ESC` or clicking outside it. + ## 2.1 * For players: * Added a log parser at [log.smapi.io](https://log.smapi.io). -- cgit From 1aa4098a510ce0f82e7ea7abc24e31e4f5f27225 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Nov 2017 16:27:36 -0500 Subject: fix CFAutomate compatibility errors showing no URL (#393) --- docs/release-notes.md | 1 + src/SMAPI/StardewModdingAPI.config.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 4c5f49d6..da6c046d 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ## 2.2 * For players: * Fixed mods crashing when loading a custom asset on Linux/Mac. + * Updated compatibility list. * For modders: * Added `DaysSinceStart` property to `SDate` dates. diff --git a/src/SMAPI/StardewModdingAPI.config.json b/src/SMAPI/StardewModdingAPI.config.json index fa3bdcc9..6718806e 100644 --- a/src/SMAPI/StardewModdingAPI.config.json +++ b/src/SMAPI/StardewModdingAPI.config.json @@ -509,7 +509,8 @@ This file contains advanced configuration for SMAPI. You generally shouldn't cha "ID": "Platonymous.CFAutomate", "Compatibility": { "~1.0.1": { "Status": "AssumeBroken" } // no longer compatible with Automate - } + }, + "AlternativeUrl": "https://www.nexusmods.com/stardewvalley/mods/991" }, { // Custom Farm Types -- cgit From fc9043c1ba80bc7d593ca9f00659b866d99e2251 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Nov 2017 16:58:41 -0500 Subject: fix rare installer error on Mac due to generated mcs file (#394) --- docs/release-notes.md | 1 + src/SMAPI.Installer/InteractiveInstaller.cs | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index da6c046d..d2014b51 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ## 2.2 * For players: * Fixed mods crashing when loading a custom asset on Linux/Mac. + * Fixed rare installer errors on Mac due to generated `mcs` file. * Updated compatibility list. * For modders: diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index b5c2735b..83f353ae 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -296,7 +296,7 @@ namespace StardewModdingApi.Installer { // copy SMAPI files to game dir this.PrintDebug("Adding SMAPI files..."); - foreach (FileInfo sourceFile in packageDir.EnumerateFiles()) + foreach (FileInfo sourceFile in packageDir.EnumerateFiles().Where(this.ShouldCopyFile)) { string targetPath = Path.Combine(installDir.FullName, sourceFile.Name); this.InteractivelyDelete(targetPath); @@ -338,7 +338,7 @@ namespace StardewModdingApi.Installer targetDir.Create(); // copy files - foreach (FileInfo sourceFile in sourceDir.EnumerateFiles()) + foreach (FileInfo sourceFile in sourceDir.EnumerateFiles().Where(this.ShouldCopyFile)) sourceFile.CopyTo(Path.Combine(targetDir.FullName, sourceFile.Name)); } } @@ -684,7 +684,7 @@ namespace StardewModdingApi.Installer this.PrintDebug(" Support for mods here was dropped in SMAPI 1.0 (it was never officially supported)."); // move mods if no conflicts (else warn) - foreach (FileSystemInfo entry in modDir.EnumerateFileSystemInfos()) + foreach (FileSystemInfo entry in modDir.EnumerateFileSystemInfos().Where(this.ShouldCopyFile)) { // get type bool isDir = entry is DirectoryInfo; @@ -718,7 +718,7 @@ namespace StardewModdingApi.Installer else { this.PrintDebug(" Deleted empty directory."); - modDir.Delete(); + modDir.Delete(recursive: true); } } @@ -741,11 +741,22 @@ namespace StardewModdingApi.Installer Directory.CreateDirectory(newPath); DirectoryInfo directory = (DirectoryInfo)entry; - foreach (FileSystemInfo child in directory.EnumerateFileSystemInfos()) + foreach (FileSystemInfo child in directory.EnumerateFileSystemInfos().Where(this.ShouldCopyFile)) this.Move(child, Path.Combine(newPath, child.Name)); - directory.Delete(); + directory.Delete(recursive: true); } } + + /// Get whether a file should be copied when moving a folder. + /// The file info. + private bool ShouldCopyFile(FileSystemInfo file) + { + // ignore Mac symlink + if (file is FileInfo && file.Name == "mcs") + return false; + + return true; + } } } -- cgit From f44df025cab4c2b70bf07c6d8407c8cc465b57cb Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Nov 2017 17:02:54 -0500 Subject: no longer expire saved logs after a week (#400) --- docs/release-notes.md | 1 + src/SMAPI.Web/Framework/LogParser/PastebinClient.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index d2014b51..b60dad9d 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -11,6 +11,7 @@ * Fixed input `e.SuppressButton()` method not working with mouse buttons. * For log.smapi.io: + * Saved logs no longer expire after a week. * The upload-log modal can now be closed by pressing `ESC` or clicking outside it. ## 2.1 diff --git a/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs b/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs index 738330d3..60441234 100644 --- a/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs +++ b/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs @@ -85,7 +85,7 @@ namespace StardewModdingAPI.Web.Framework.LogParser ["api_dev_key"] = this.DevKey, ["api_paste_private"] = "1", // unlisted ["api_paste_name"] = $"SMAPI log {DateTime.UtcNow:s}", - ["api_paste_expire_date"] = "1W", // one week + ["api_paste_expire_date"] = "N", // never expire ["api_paste_code"] = content })) .AsString(); -- cgit From 49bc98fa4c2432277647c968f57e81b63c474860 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 26 Nov 2017 21:13:38 -0500 Subject: fix player_add command not handling upgrade level (#397) --- docs/release-notes.md | 1 + .../Framework/Commands/Player/AddCommand.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index b60dad9d..1b06f86f 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -3,6 +3,7 @@ * For players: * Fixed mods crashing when loading a custom asset on Linux/Mac. * Fixed rare installer errors on Mac due to generated `mcs` file. + * Fixed `player_add` command not handling tool upgrade levels. * Updated compatibility list. * For modders: diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs index 81167747..14a519fb 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/AddCommand.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData; using StardewValley; @@ -49,10 +49,14 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player return; } - // apply count & quality + // apply count match.Item.Stack = count; + + // apply quality if (match.Item is Object obj) obj.quality = quality; + else if (match.Item is Tool tool) + tool.UpgradeLevel = quality; // add to inventory Game1.player.addItemByMenuIfNecessary(match.Item); -- cgit From 5ae28b2a8caf764e0df0e3bfeca8941db5f4be87 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 27 Nov 2017 22:19:23 -0500 Subject: fix error when a mod has an invalid filename in the EntryDLL manifest field (#402) --- docs/release-notes.md | 11 +++++------ src/SMAPI/Framework/ModLoading/ModResolver.cs | 12 ++++++++++++ src/SMAPI/Program.cs | 10 +++++----- 3 files changed, 22 insertions(+), 11 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 1b06f86f..f371e5d4 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,20 +1,19 @@ # Release notes ## 2.2 * For players: - * Fixed mods crashing when loading a custom asset on Linux/Mac. - * Fixed rare installer errors on Mac due to generated `mcs` file. + * Fixed error when a mod loads custom assets on Linux/Mac. + * Fixed error when a mod has an invalid `EntryDLL` manifest value format. + * Fixed rare error when Mac adds an `mcs` file to the installer package. * Fixed `player_add` command not handling tool upgrade levels. * Updated compatibility list. + * (log.smapi.io) Saved logs no longer expire after a week. + * (log.smapi.io) The upload-log modal can now be closed by pressing `ESC` or clicking outside it. * For modders: * Added `DaysSinceStart` property to `SDate` dates. * Fixed input `e.SuppressButton(button)` method ignoring input. * Fixed input `e.SuppressButton()` method not working with mouse buttons. -* For log.smapi.io: - * Saved logs no longer expire after a week. - * The upload-log modal can now be closed by pressing `ESC` or clicking outside it. - ## 2.1 * For players: * Added a log parser at [log.smapi.io](https://log.smapi.io). diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs index d0ef1b08..9802d9e9 100644 --- a/src/SMAPI/Framework/ModLoading/ModResolver.cs +++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs @@ -142,6 +142,18 @@ namespace StardewModdingAPI.Framework.ModLoading continue; } + // validate DLL value + if (string.IsNullOrWhiteSpace(mod.Manifest.EntryDll)) + { + mod.SetStatus(ModMetadataStatus.Failed, "its manifest has no EntryDLL field."); + continue; + } + if (mod.Manifest.EntryDll.Intersect(Path.GetInvalidFileNameChars()).Any()) + { + mod.SetStatus(ModMetadataStatus.Failed, $"its manifest has invalid filename '{mod.Manifest.EntryDll}' for the EntryDLL field."); + continue; + } + // validate DLL path string assemblyPath = Path.Combine(mod.DirectoryPath, mod.Manifest.EntryDll); if (!File.Exists(assemblyPath)) diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index b742467b..3ba35e43 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -653,11 +653,8 @@ namespace StardewModdingAPI { // get basic info IManifest manifest = metadata.Manifest; - string assemblyPath = metadata.Manifest?.EntryDll != null - ? Path.Combine(metadata.DirectoryPath, metadata.Manifest.EntryDll) - : null; - this.Monitor.Log(assemblyPath != null - ? $"Loading {metadata.DisplayName} from {assemblyPath.Replace(Constants.ModPath, "").TrimStart(Path.DirectorySeparatorChar)}..." + this.Monitor.Log(metadata.Manifest?.EntryDll != null + ? $"Loading {metadata.DisplayName} from {metadata.DirectoryPath.Replace(Constants.ModPath, "").TrimStart(Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{metadata.Manifest.EntryDll}..." // don't use Path.Combine here, since EntryDLL might not be valid : $"Loading {metadata.DisplayName}...", LogLevel.Trace); // validate status @@ -669,6 +666,9 @@ namespace StardewModdingAPI } // preprocess & load mod assembly + string assemblyPath = metadata.Manifest?.EntryDll != null + ? Path.Combine(metadata.DirectoryPath, metadata.Manifest.EntryDll) + : null; Assembly modAssembly; try { -- cgit From c81520e0bc3433ca7165fbea9b8eaa31eb53a694 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 28 Nov 2017 18:34:27 -0500 Subject: update for 2.2 release --- build/GlobalAssemblyInfo.cs | 4 ++-- docs/release-notes.md | 10 ++++++---- src/SMAPI/Constants.cs | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/build/GlobalAssemblyInfo.cs b/build/GlobalAssemblyInfo.cs index 9af704e0..65211aad 100644 --- a/build/GlobalAssemblyInfo.cs +++ b/build/GlobalAssemblyInfo.cs @@ -2,5 +2,5 @@ using System.Reflection; using System.Runtime.InteropServices; [assembly: ComVisible(false)] -[assembly: AssemblyVersion("2.1.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyVersion("2.2.0.0")] +[assembly: AssemblyFileVersion("2.2.0.0")] diff --git a/docs/release-notes.md b/docs/release-notes.md index f371e5d4..338a0f9e 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,12 +2,12 @@ ## 2.2 * For players: * Fixed error when a mod loads custom assets on Linux/Mac. - * Fixed error when a mod has an invalid `EntryDLL` manifest value format. + * Fixed error when a mod has an invalid `EntryDLL` filename. * Fixed rare error when Mac adds an `mcs` file to the installer package. * Fixed `player_add` command not handling tool upgrade levels. * Updated compatibility list. - * (log.smapi.io) Saved logs no longer expire after a week. - * (log.smapi.io) The upload-log modal can now be closed by pressing `ESC` or clicking outside it. + * The [log parser][] no longer expires logs after a week. + * The [log parser][] now lets you close modals with `ESC` or a click outside it. * For modders: * Added `DaysSinceStart` property to `SDate` dates. @@ -16,7 +16,7 @@ ## 2.1 * For players: - * Added a log parser at [log.smapi.io](https://log.smapi.io). + * Added a [log parser][] site. * Added better Steam instructions to the SMAPI installer. * Renamed the bundled _TrainerMod_ to _ConsoleCommands_ to make its purpose clearer. * Removed the game's test messages from the console log. @@ -558,3 +558,5 @@ For SMAPI developers: * 0.3 (2016-03-01, [log](https://github.com/Pathoschild/SMAPI/compare/Alpha0.2...0.3)) * 0.2 (2016-02-29, [log](https://github.com/Pathoschild/SMAPI/compare/Alpha0.1...Alpha0.2) * 0.1 (2016-02-28) + +[log parser]: https://log.smapi.io diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index a2dbdd98..c9f9be41 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -29,7 +29,7 @@ namespace StardewModdingAPI ** Public ****/ /// SMAPI's current semantic version. - public static ISemanticVersion ApiVersion { get; } = new SemanticVersion(2, 1, 0); + public static ISemanticVersion ApiVersion { get; } = new SemanticVersion(2, 2, 0); /// The minimum supported version of Stardew Valley. public static ISemanticVersion MinimumGameVersion { get; } = new SemanticVersion("1.2.30"); -- cgit From 051b0c9bdacd86c18fe4b2a3419fe469e732c9ed Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 28 Nov 2017 18:53:08 -0500 Subject: fix API always redirecting to HTTPS when accessed via subdomain --- docs/release-notes.md | 7 ++++--- src/SMAPI.Web/Startup.cs | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 338a0f9e..833f96b4 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -3,7 +3,8 @@ * For players: * Fixed error when a mod loads custom assets on Linux/Mac. * Fixed error when a mod has an invalid `EntryDLL` filename. - * Fixed rare error when Mac adds an `mcs` file to the installer package. + * Fixed error when checking for updates on Linux/Mac due to API HTTPS redirect. + * Fixed error when Mac adds an `mcs` symlink to the installer package. * Fixed `player_add` command not handling tool upgrade levels. * Updated compatibility list. * The [log parser][] no longer expires logs after a week. @@ -11,8 +12,8 @@ * For modders: * Added `DaysSinceStart` property to `SDate` dates. - * Fixed input `e.SuppressButton(button)` method ignoring input. - * Fixed input `e.SuppressButton()` method not working with mouse buttons. + * Fixed input events' `e.SuppressButton(button)` method ignoring specified button. + * Fixed input events' `e.SuppressButton()` method not working with mouse buttons. ## 2.1 * For players: diff --git a/src/SMAPI.Web/Startup.cs b/src/SMAPI.Web/Startup.cs index 799fb0f8..16952124 100644 --- a/src/SMAPI.Web/Startup.cs +++ b/src/SMAPI.Web/Startup.cs @@ -80,6 +80,7 @@ namespace StardewModdingAPI.Web shouldRewrite: req => req.Host.Host != "localhost" && !req.Path.StartsWithSegments("/api") + && !req.Host.Host.StartsWith("api.") )) // convert subdomain.smapi.io => smapi.io/subdomain for routing -- cgit From 08f4a6fa0b9166f5c70715ffe9dab6ac4daf1a02 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 30 Nov 2017 16:54:50 -0500 Subject: fix log parser error when uploading very large logs --- docs/release-notes.md | 1 + .../Framework/LogParser/PastebinClient.cs | 41 +++++++++++++++------- 2 files changed, 30 insertions(+), 12 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 833f96b4..683e97b8 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -9,6 +9,7 @@ * Updated compatibility list. * The [log parser][] no longer expires logs after a week. * The [log parser][] now lets you close modals with `ESC` or a click outside it. + * Fixed [log parser][] error when uploading very large logs. * For modders: * Added `DaysSinceStart` property to `SDate` dates. diff --git a/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs b/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs index 60441234..1cfaed17 100644 --- a/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs +++ b/src/SMAPI.Web/Framework/LogParser/PastebinClient.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; +using System.Text; using System.Threading.Tasks; +using System.Web; using Pathoschild.Http.Client; namespace StardewModdingAPI.Web.Framework.LogParser @@ -67,6 +69,8 @@ namespace StardewModdingAPI.Web.Framework.LogParser } } + /// Save a paste to Pastebin. + /// The paste content. public async Task PostAsync(string content) { try @@ -77,18 +81,18 @@ namespace StardewModdingAPI.Web.Framework.LogParser // post to API string response = await this.Client - .PostAsync("api/api_post.php") - .WithBodyContent(new FormUrlEncodedContent(new Dictionary - { - ["api_option"] = "paste", - ["api_user_key"] = this.UserKey, - ["api_dev_key"] = this.DevKey, - ["api_paste_private"] = "1", // unlisted - ["api_paste_name"] = $"SMAPI log {DateTime.UtcNow:s}", - ["api_paste_expire_date"] = "N", // never expire - ["api_paste_code"] = content - })) - .AsString(); + .PostAsync("api/api_post.php") + .WithBodyContent(this.GetFormUrlEncodedContent(new Dictionary + { + ["api_option"] = "paste", + ["api_user_key"] = this.UserKey, + ["api_dev_key"] = this.DevKey, + ["api_paste_private"] = "1", // unlisted + ["api_paste_name"] = $"SMAPI log {DateTime.UtcNow:s}", + ["api_paste_expire_date"] = "N", // never expire + ["api_paste_code"] = content + })) + .AsString(); // handle Pastebin errors if (string.IsNullOrWhiteSpace(response)) @@ -113,5 +117,18 @@ namespace StardewModdingAPI.Web.Framework.LogParser { this.Client.Dispose(); } + + + /********* + ** Private methods + *********/ + /// Build an HTTP content body with form-url-encoded content. + /// The content to encode. + /// This bypasses an issue where restricts the body length to the maximum size of a URL, which isn't applicable here. + private HttpContent GetFormUrlEncodedContent(IDictionary data) + { + string body = string.Join("&", from arg in data select $"{HttpUtility.UrlEncode(arg.Key)}={HttpUtility.UrlEncode(arg.Value)}"); + return new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded"); + } } } -- cgit From 424578539408aea2685c86d0f46b87573c37363a Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 1 Dec 2017 22:41:16 -0500 Subject: tweak log parser instructions to avoid confusion --- docs/release-notes.md | 2 +- src/SMAPI.Web/Views/LogParser/Index.cshtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 683e97b8..53ec07c6 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,8 +8,8 @@ * Fixed `player_add` command not handling tool upgrade levels. * Updated compatibility list. * The [log parser][] no longer expires logs after a week. - * The [log parser][] now lets you close modals with `ESC` or a click outside it. * Fixed [log parser][] error when uploading very large logs. + * Slightly improved the [log parser][] UI. * For modders: * Added `DaysSinceStart` property to `SDate` dates. diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index 49688d78..d90f1e35 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -95,7 +95,7 @@

Upload log file

    -
  1. Find your SMAPI log.
  2. +
  3. Find your SMAPI log file (not the console text).
  4. Drag the file onto the textbox below (or paste the text in).
  5. Click Parse.
  6. Share the URL of the new page.
  7. -- cgit From 72a02c56d51f5e5b0e8e2fc7db59e1f0e6d93d5c Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 2 Dec 2017 14:27:03 -0500 Subject: add NormaliseAssetName content helper method (#404) --- docs/release-notes.md | 3 ++- src/SMAPI/Framework/ModHelpers/ContentHelper.cs | 9 +++++++++ src/SMAPI/IContentHelper.cs | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 53ec07c6..1e89667a 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -12,7 +12,8 @@ * Slightly improved the [log parser][] UI. * For modders: - * Added `DaysSinceStart` property to `SDate` dates. + * Added `helper.Content.NormaliseAssetName` method. + * Added `SDate.DaysSinceStart` property. * Fixed input events' `e.SuppressButton(button)` method ignoring specified button. * Fixed input events' `e.SuppressButton()` method not working with mouse buttons. diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs index 7665eb78..4a1d3853 100644 --- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.Contracts; using System.IO; using System.Linq; using Microsoft.Xna.Framework.Content; @@ -134,6 +135,14 @@ namespace StardewModdingAPI.Framework.ModHelpers } } + /// Normalise an asset name so it's consistent with those generated by the game. This is mainly useful for string comparisons like on generated asset names, and isn't necessary when passing asset names into other content helper methods. + /// The asset key. + [Pure] + public string NormaliseAssetName(string assetName) + { + return this.ContentManager.NormaliseAssetName(assetName); + } + /// Get the underlying key in the game's content cache for an asset. This can be used to load custom map tilesheets, but should be avoided when you can use the content API instead. This does not validate whether the asset exists. /// The asset key to fetch (if the is ), or the local path to a content file relative to the mod folder. /// Where to search for a matching content asset. diff --git a/src/SMAPI/IContentHelper.cs b/src/SMAPI/IContentHelper.cs index e3362502..1b87183d 100644 --- a/src/SMAPI/IContentHelper.cs +++ b/src/SMAPI/IContentHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.Contracts; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using StardewValley; @@ -37,6 +38,11 @@ namespace StardewModdingAPI /// The content asset couldn't be loaded (e.g. because it doesn't exist). T Load(string key, ContentSource source = ContentSource.ModFolder); + /// Normalise an asset name so it's consistent with those generated by the game. This is mainly useful for string comparisons like on generated asset names, and isn't necessary when passing asset names into other content helper methods. + /// The asset key. + [Pure] + string NormaliseAssetName(string assetName); + /// Get the underlying key in the game's content cache for an asset. This can be used to load custom map tilesheets, but should be avoided when you can use the content API instead. This does not validate whether the asset exists. /// The asset key to fetch (if the is ), or the local path to a content file relative to the mod folder. /// Where to search for a matching content asset. -- cgit From e7395dfb4d1a71b14d10d39e6add68c0a8a343de Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 2 Dec 2017 14:27:20 -0500 Subject: tweak release notes --- docs/release-notes.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/release-notes.md b/docs/release-notes.md index 1e89667a..4cf8efa2 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,14 +2,16 @@ ## 2.2 * For players: * Fixed error when a mod loads custom assets on Linux/Mac. - * Fixed error when a mod has an invalid `EntryDLL` filename. * Fixed error when checking for updates on Linux/Mac due to API HTTPS redirect. * Fixed error when Mac adds an `mcs` symlink to the installer package. * Fixed `player_add` command not handling tool upgrade levels. + * Improved error when a mod has an invalid `EntryDLL` filename format. * Updated compatibility list. - * The [log parser][] no longer expires logs after a week. - * Fixed [log parser][] error when uploading very large logs. - * Slightly improved the [log parser][] UI. + +* For the [log parser][]: + * Logs no longer expire after a week. + * Fixed error when uploading very large logs. + * Slightly improved the UI. * For modders: * Added `helper.Content.NormaliseAssetName` method. -- cgit