From 7af9a92842790dd374734307c79a51deb45c1d99 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 1 Nov 2016 18:08:05 -0400 Subject: fix mod versions not being displayed correctly (#160) --- src/StardewModdingAPI/Constants.cs | 2 +- src/StardewModdingAPI/Program.cs | 4 ++-- src/StardewModdingAPI/Version.cs | 13 ++++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs index 6bdd10ef..86689f96 100644 --- a/src/StardewModdingAPI/Constants.cs +++ b/src/StardewModdingAPI/Constants.cs @@ -43,7 +43,7 @@ namespace StardewModdingAPI /// /// Title for the API console /// - public static string ConsoleTitle => $"Stardew Modding API Console - Version {Version.VersionString} - Mods Loaded: {ModsLoaded}"; + public static string ConsoleTitle => $"Stardew Modding API Console - Version {Constants.Version} - Mods Loaded: {Constants.ModsLoaded}"; /// /// Path for log files to be output to. diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 2ee8c8f5..14b4a5f0 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -53,7 +53,7 @@ namespace StardewModdingAPI try { Log.AsyncY("SDV Version: " + Game1.version); - Log.AsyncY("SMAPI Version: " + Constants.Version.VersionString); + Log.AsyncY("SMAPI Version: " + Constants.Version); ConfigureUI(); CreateDirectories(); StartGame(); @@ -104,7 +104,7 @@ namespace StardewModdingAPI // Change the game's version Log.AsyncY("Injecting New SDV Version..."); - Game1.version += $"-Z_MODDED | SMAPI {Constants.Version.VersionString}"; + Game1.version += $"-Z_MODDED | SMAPI {Constants.Version}"; // add error interceptors #if SMAPI_FOR_WINDOWS diff --git a/src/StardewModdingAPI/Version.cs b/src/StardewModdingAPI/Version.cs index 73bb9ef0..cce68ad8 100644 --- a/src/StardewModdingAPI/Version.cs +++ b/src/StardewModdingAPI/Version.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System; +using Newtonsoft.Json; namespace StardewModdingAPI { @@ -20,9 +21,10 @@ namespace StardewModdingAPI /// An optional build tag. public string Build { get; set; } - /// A string representation of the version. + /// Obsolete. [JsonIgnore] - public string VersionString => $"{MajorVersion}.{MinorVersion}.{PatchVersion} {Build}"; + [Obsolete("Use `Version.ToString()` instead.")] + public string VersionString => this.ToString(); /********* @@ -40,6 +42,11 @@ namespace StardewModdingAPI this.PatchVersion = patch; this.Build = build; } + + /// Get a string representation of the version. + public override string ToString() + { + return $"{this.MajorVersion}.{this.MinorVersion}.{this.PatchVersion} {this.Build}".Trim(); } } } -- cgit