summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-07-03 14:26:45 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-07-03 14:26:45 -0400
commit18e5e42529e13f21553651014a93c0f48cd93a59 (patch)
tree642eea265b07ad61909e50c60b2f0740ba3a8302
parent0f05e7bd54823750d6ccd153ec929e831b51f426 (diff)
downloadSMAPI-18e5e42529e13f21553651014a93c0f48cd93a59.tar.gz
SMAPI-18e5e42529e13f21553651014a93c0f48cd93a59.tar.bz2
SMAPI-18e5e42529e13f21553651014a93c0f48cd93a59.zip
defer some console changes until SMAPI 2.0
-rw-r--r--release-notes.md7
-rw-r--r--src/StardewModdingAPI/Framework/Monitor.cs8
-rw-r--r--src/StardewModdingAPI/Program.cs34
3 files changed, 46 insertions, 3 deletions
diff --git a/release-notes.md b/release-notes.md
index e34990aa..0d34e8e0 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -4,21 +4,24 @@
## 2.0
See [log](https://github.com/Pathoschild/SMAPI/compare/1.10...2.0).
+For players:
+* The SMAPI console is now cleaner and simpler.
+
For mod developers:
-* The manifest.json version can now be specified as a string.
* SMAPI mods can now edit XNB images and data loaded by the game (see [API reference](http://stardewvalleywiki.com/Modding:SMAPI_APIs#Content)).
+* The manifest.json version can now be specified as a string.
-->
## 1.15
See [log](https://github.com/Pathoschild/SMAPI/compare/1.14...1.15).
For players:
-* Several changes to the SMAPI console to make it simpler for players.
* Revamped TrainerMod's item commands:
* `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`.
* `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`.
* `list_items` now also matches translated item names when playing in another language.
* `list_item_types` is a new command to see a list of item types.
+* Cleaned up SMAPI console a bit.
* Fixed unhelpful error when a `config.json` is invalid.
* Fixed rare crash when window loses focus for a few players (further to fix in 1.14).
* Fixed invalid `ObjectInformation.xnb` causing a flood of warnings; SMAPI now shows one error instead.
diff --git a/src/StardewModdingAPI/Framework/Monitor.cs b/src/StardewModdingAPI/Framework/Monitor.cs
index 64cc0bdc..6359b454 100644
--- a/src/StardewModdingAPI/Framework/Monitor.cs
+++ b/src/StardewModdingAPI/Framework/Monitor.cs
@@ -45,8 +45,10 @@ namespace StardewModdingAPI.Framework
/// <summary>Whether SMAPI is aborting. Mods don't need to worry about this unless they have background tasks.</summary>
public bool IsExiting => this.ExitTokenSource.IsCancellationRequested;
+#if SMAPI_2_0
/// <summary>Whether to show the full log stamps (with time/level/logger) in the console. If false, shows a simplified stamp with only the logger.</summary>
internal bool ShowFullStampInConsole { get; set; }
+#endif
/// <summary>Whether to show trace messages in the console.</summary>
internal bool ShowTraceInConsole { get; set; }
@@ -95,6 +97,7 @@ namespace StardewModdingAPI.Framework
this.ExitTokenSource.Cancel();
}
+#if SMAPI_2_0
/// <summary>Write a newline to the console and log file.</summary>
internal void Newline()
{
@@ -103,6 +106,7 @@ namespace StardewModdingAPI.Framework
if (this.WriteToFile)
this.LogFile.WriteLine("");
}
+#endif
#if !SMAPI_2_0
/// <summary>Log a message for the player or developer, using the specified console color.</summary>
@@ -140,7 +144,11 @@ namespace StardewModdingAPI.Framework
string levelStr = level.ToString().ToUpper().PadRight(Monitor.MaxLevelLength);
string fullMessage = $"[{DateTime.Now:HH:mm:ss} {levelStr} {source}] {message}";
+#if SMAPI_2_0
string consoleMessage = this.ShowFullStampInConsole ? fullMessage : $"[{source}] {message}";
+#else
+ string consoleMessage = fullMessage;
+#endif
// write to console
if (this.WriteToConsole && (this.ShowTraceInConsole || level != LogLevel.Trace))
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index ed1fe2e7..c7adcb94 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -126,6 +126,9 @@ namespace StardewModdingAPI
// init logging
this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GetGameDisplayVersion(Constants.GameVersion)} on {this.GetFriendlyPlatformName()}", LogLevel.Info);
this.Monitor.Log($"Mods go here: {Constants.ModPath}");
+#if !SMAPI_2_0
+ this.Monitor.Log("Preparing SMAPI...");
+#endif
// validate paths
this.VerifyPath(Constants.ModPath);
@@ -209,7 +212,11 @@ namespace StardewModdingAPI
}
// start game
+#if SMAPI_2_0
this.Monitor.Log("Starting game...", LogLevel.Trace);
+#else
+ this.Monitor.Log("Starting game...");
+#endif
try
{
this.IsGameRunning = true;
@@ -349,7 +356,9 @@ namespace StardewModdingAPI
if (this.Settings.DeveloperMode)
{
this.Monitor.ShowTraceInConsole = true;
+#if SMAPI_2_0
this.Monitor.ShowFullStampInConsole = true;
+#endif
this.Monitor.Log($"You configured SMAPI to run in developer mode. The console may be much more verbose. You can disable developer mode by installing the non-developer version of SMAPI, or by editing {Constants.ApiConfigPath}.", LogLevel.Info);
}
if (!this.Settings.CheckForUpdates)
@@ -365,7 +374,11 @@ namespace StardewModdingAPI
// load mods
{
+#if SMAPI_2_0
this.Monitor.Log("Loading mod metadata...", LogLevel.Trace);
+#else
+ this.Monitor.Log("Loading mod metadata...");
+#endif
ModResolver resolver = new ModResolver();
// load manifests
@@ -455,6 +468,9 @@ namespace StardewModdingAPI
private void RunConsoleLoop()
{
// prepare console
+#if !SMAPI_2_0
+ this.Monitor.Log("Starting console...");
+#endif
this.Monitor.Log("Type 'help' for help, or 'help <cmd>' for a command's usage", LogLevel.Info);
this.CommandManager.Add("SMAPI", "help", "Lists command documentation.\n\nUsage: help\nLists all available commands.\n\nUsage: help <cmd>\n- cmd: The name of a command whose documentation to display.", this.HandleCommand);
this.CommandManager.Add("SMAPI", "reload_i18n", "Reloads translation files for all mods.\n\nUsage: reload_i18n", this.HandleCommand);
@@ -593,8 +609,11 @@ namespace StardewModdingAPI
private void LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, SContentManager contentManager)
#endif
{
+#if SMAPI_2_0
this.Monitor.Log("Loading mods...", LogLevel.Trace);
-
+#else
+ this.Monitor.Log("Loading mods...");
+#endif
// load mod assemblies
IDictionary<IModMetadata, string> skippedMods = new Dictionary<IModMetadata, string>();
{
@@ -702,7 +721,9 @@ namespace StardewModdingAPI
IModMetadata[] loadedMods = this.ModRegistry.GetMods().ToArray();
// log skipped mods
+#if SMAPI_2_0
this.Monitor.Newline();
+#endif
if (skippedMods.Any())
{
this.Monitor.Log($"Skipped {skippedMods.Count} mods:", LogLevel.Error);
@@ -716,7 +737,9 @@ namespace StardewModdingAPI
else
this.Monitor.Log($" {mod.DisplayName} because {reason}", LogLevel.Error);
}
+#if SMAPI_2_0
this.Monitor.Newline();
+#endif
}
// log loaded mods
@@ -731,7 +754,9 @@ namespace StardewModdingAPI
LogLevel.Info
);
}
+#if SMAPI_2_0
this.Monitor.Newline();
+#endif
// initialise translations
this.ReloadTranslations();
@@ -835,6 +860,7 @@ namespace StardewModdingAPI
}
else
{
+#if SMAPI_2_0
string message = "The following commands are registered:\n";
IGrouping<string, string>[] groups = (from command in this.CommandManager.GetAll() orderby command.ModName, command.Name group command.Name by command.ModName).ToArray();
foreach (var group in groups)
@@ -846,6 +872,10 @@ namespace StardewModdingAPI
message += "For more information about a command, type 'help command_name'.";
this.Monitor.Log(message, LogLevel.Info);
+#else
+ this.Monitor.Log("The following commands are registered: " + string.Join(", ", this.CommandManager.GetAll().Select(p => p.Name)) + ".", LogLevel.Info);
+ this.Monitor.Log("For more information about a command, type 'help command_name'.", LogLevel.Info);
+#endif
}
break;
@@ -894,7 +924,9 @@ namespace StardewModdingAPI
{
WriteToConsole = this.Monitor.WriteToConsole,
ShowTraceInConsole = this.Settings.DeveloperMode,
+#if SMAPI_2_0
ShowFullStampInConsole = this.Settings.DeveloperMode
+#endif
};
}