add friendly error when Steam isn't loaded
This commit is contained in:
parent
aba15074b3
commit
0a009d6fda
|
@ -2,6 +2,7 @@
|
|||
## Upcoming
|
||||
* For players:
|
||||
* Added support for ModDrop in update checks and the mod compatibility list.
|
||||
* Added friendly error when Steam isn't loaded (for Steam players).
|
||||
* Fixed cryptic error when running the installer from inside a zip file on Windows.
|
||||
* Fixed error when leaving and rejoining a multiplayer server in the same session.
|
||||
* Fixed Console Commands' handling of tool upgrade levels for item commands.
|
||||
|
|
|
@ -99,6 +99,20 @@ namespace StardewModdingAPI.Framework
|
|||
new Regex(@"^static SerializableDictionary<.+>\(\) called\.$", RegexOptions.Compiled | RegexOptions.CultureInvariant),
|
||||
};
|
||||
|
||||
/// <summary>Regex patterns which match console messages to show a more friendly error for.</summary>
|
||||
private readonly Tuple<Regex, string, LogLevel>[] ReplaceConsolePatterns =
|
||||
{
|
||||
Tuple.Create(
|
||||
new Regex(@"^System\.InvalidOperationException: Steamworks is not initialized\.", RegexOptions.Compiled | RegexOptions.CultureInvariant),
|
||||
#if SMAPI_FOR_WINDOWS
|
||||
"Oops! Steam achievements won't work because Steam isn't loaded. You can launch the game through Steam to fix that (see 'Part 2: Configure Steam' in the install guide for more info: https://smapi.io/install).",
|
||||
#else
|
||||
"Oops! Steam achievements won't work because Steam isn't loaded. You can launch the game through Steam to fix that.",
|
||||
#endif
|
||||
LogLevel.Error
|
||||
)
|
||||
};
|
||||
|
||||
/// <summary>The mod toolkit used for generic mod interactions.</summary>
|
||||
private readonly ModToolkit Toolkit = new ModToolkit();
|
||||
|
||||
|
@ -1275,9 +1289,9 @@ namespace StardewModdingAPI.Framework
|
|||
}
|
||||
|
||||
/// <summary>Redirect messages logged directly to the console to the given monitor.</summary>
|
||||
/// <param name="monitor">The monitor with which to log messages.</param>
|
||||
/// <param name="gameMonitor">The monitor with which to log messages as the game.</param>
|
||||
/// <param name="message">The message to log.</param>
|
||||
private void HandleConsoleMessage(IMonitor monitor, string message)
|
||||
private void HandleConsoleMessage(IMonitor gameMonitor, string message)
|
||||
{
|
||||
// detect exception
|
||||
LogLevel level = message.Contains("Exception") ? LogLevel.Error : LogLevel.Trace;
|
||||
|
@ -1286,8 +1300,19 @@ namespace StardewModdingAPI.Framework
|
|||
if (level != LogLevel.Error && this.SuppressConsolePatterns.Any(p => p.IsMatch(message)))
|
||||
return;
|
||||
|
||||
// show friendly error if applicable
|
||||
foreach (var entry in this.ReplaceConsolePatterns)
|
||||
{
|
||||
if (entry.Item1.IsMatch(message))
|
||||
{
|
||||
this.Monitor.Log(entry.Item2, entry.Item3);
|
||||
gameMonitor.Log(message, LogLevel.Trace);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// forward to monitor
|
||||
monitor.Log(message, level);
|
||||
gameMonitor.Log(message, level);
|
||||
}
|
||||
|
||||
/// <summary>Show a 'press any key to exit' message, and exit when they press a key.</summary>
|
||||
|
|
|
@ -31,7 +31,7 @@ using StardewValley.TerrainFeatures;
|
|||
using StardewValley.Tools;
|
||||
using xTile.Dimensions;
|
||||
using xTile.Layers;
|
||||
using Object = StardewValley.Object;
|
||||
using SObject = StardewValley.Object;
|
||||
|
||||
namespace StardewModdingAPI.Framework
|
||||
{
|
||||
|
@ -718,8 +718,8 @@ namespace StardewModdingAPI.Framework
|
|||
if (watcher.ObjectsWatcher.IsChanged)
|
||||
{
|
||||
GameLocation location = watcher.Location;
|
||||
KeyValuePair<Vector2, Object>[] added = watcher.ObjectsWatcher.Added.ToArray();
|
||||
KeyValuePair<Vector2, Object>[] removed = watcher.ObjectsWatcher.Removed.ToArray();
|
||||
KeyValuePair<Vector2, SObject>[] added = watcher.ObjectsWatcher.Added.ToArray();
|
||||
KeyValuePair<Vector2, SObject>[] removed = watcher.ObjectsWatcher.Removed.ToArray();
|
||||
watcher.ObjectsWatcher.Reset();
|
||||
|
||||
this.Events.ObjectListChanged.Raise(new ObjectListChangedEventArgs(location, added, removed));
|
||||
|
|
Loading…
Reference in New Issue