From 5b9e365b5d252e2d1e957303c6b06fa1b3ae2f14 Mon Sep 17 00:00:00 2001 From: Dan Volchek Date: Sun, 10 Jun 2018 13:15:53 -0700 Subject: add version info to ModMetadata, change update checking to consider preview versions --- src/SMAPI/Framework/ModLoading/ModMetadata.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/SMAPI/Framework/ModLoading') diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index e4ec7e3b..8f544da3 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -43,6 +43,15 @@ namespace StardewModdingAPI.Framework.ModLoading /// The mod-provided API (if any). public object Api { get; private set; } + /// The latest version of the mod. + public ISemanticVersion LatestVersion { get; private set; } + + /// The latest preview version of the mod, if any. + public ISemanticVersion LatestPreviewVersion { get; private set; } + + /// The error checking for updates for this mod, if any. + public string UpdateCheckError { get; private set; } + /// Whether the mod is a content pack. public bool IsContentPack => this.Manifest?.ContentPackFor != null; @@ -115,6 +124,24 @@ namespace StardewModdingAPI.Framework.ModLoading return this; } + /// Set the update status. + /// The latest version. + /// The latest preview version. + public IModMetadata SetUpdateStatus(ISemanticVersion latestVersion, ISemanticVersion latestPreviewVersion) + { + this.LatestVersion = latestVersion; + this.LatestPreviewVersion = latestPreviewVersion; + return this; + } + + // Set the update status, indicating an error happened. + /// The error checking for updates, if any. + public IModMetadata SetUpdateStatus(string updateCheckError) + { + this.UpdateCheckError = updateCheckError; + return this; + } + /// Whether the mod manifest was loaded (regardless of whether the mod itself was loaded). public bool HasManifest() { -- cgit From 1fa2632289134c39f268c374bb290549f28751d5 Mon Sep 17 00:00:00 2001 From: Dan Volchek Date: Sun, 10 Jun 2018 14:19:05 -0700 Subject: seperate IModMetadata methods, call them correctly when updating --- src/SMAPI/Framework/ModLoading/ModMetadata.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/SMAPI/Framework/ModLoading') diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 8f544da3..1ead1387 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -124,19 +124,25 @@ namespace StardewModdingAPI.Framework.ModLoading return this; } - /// Set the update status. + /// Set the update version. /// The latest version. - /// The latest preview version. - public IModMetadata SetUpdateStatus(ISemanticVersion latestVersion, ISemanticVersion latestPreviewVersion) + public IModMetadata SetUpdateVersion(ISemanticVersion latestVersion) { this.LatestVersion = latestVersion; + return this; + } + + /// Set the preview update version. + /// The latest preview version. + public IModMetadata SetPreviewUpdateVersion(ISemanticVersion latestPreviewVersion) + { this.LatestPreviewVersion = latestPreviewVersion; return this; } - // Set the update status, indicating an error happened. - /// The error checking for updates, if any. - public IModMetadata SetUpdateStatus(string updateCheckError) + /// Set the error that occured while checking for updates. + /// The error checking for updates. + public IModMetadata SetUpdateError(string updateCheckError) { this.UpdateCheckError = updateCheckError; return this; -- cgit From 0b2e46d55cb09a169c7bb64ade37c82fc8233cb3 Mon Sep 17 00:00:00 2001 From: Dan Volchek Date: Sun, 10 Jun 2018 15:05:59 -0700 Subject: refactor IModMetadata update info --- src/SMAPI/Framework/ModLoading/ModMetadata.cs | 36 ++++++++++----------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'src/SMAPI/Framework/ModLoading') diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 1ead1387..88d2770c 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using StardewModdingAPI.Framework.ModData; +using StardewModdingAPI.Framework.ModUpdateChecking; namespace StardewModdingAPI.Framework.ModLoading { @@ -43,14 +44,11 @@ namespace StardewModdingAPI.Framework.ModLoading /// The mod-provided API (if any). public object Api { get; private set; } - /// The latest version of the mod. - public ISemanticVersion LatestVersion { get; private set; } + /// The update status of this mod (if any). + public ModUpdateStatus UpdateStatus { get; private set; } - /// The latest preview version of the mod, if any. - public ISemanticVersion LatestPreviewVersion { get; private set; } - - /// The error checking for updates for this mod, if any. - public string UpdateCheckError { get; private set; } + /// The preview update status of this mod (if any). + public ModUpdateStatus PreviewUpdateStatus { get; private set; } /// Whether the mod is a content pack. public bool IsContentPack => this.Manifest?.ContentPackFor != null; @@ -124,27 +122,19 @@ namespace StardewModdingAPI.Framework.ModLoading return this; } - /// Set the update version. - /// The latest version. - public IModMetadata SetUpdateVersion(ISemanticVersion latestVersion) - { - this.LatestVersion = latestVersion; - return this; - } - - /// Set the preview update version. - /// The latest preview version. - public IModMetadata SetPreviewUpdateVersion(ISemanticVersion latestPreviewVersion) + /// Set the update status. + /// The mod update status. + public IModMetadata SetUpdateStatus(ModUpdateStatus updateStatus) { - this.LatestPreviewVersion = latestPreviewVersion; + this.UpdateStatus = updateStatus; return this; } - /// Set the error that occured while checking for updates. - /// The error checking for updates. - public IModMetadata SetUpdateError(string updateCheckError) + /// Set the preview update status. + /// The mod preview update status. + public IModMetadata SetPreviewUpdateStatus(ModUpdateStatus previewUpdateStatus) { - this.UpdateCheckError = updateCheckError; + this.PreviewUpdateStatus = previewUpdateStatus; return this; } -- cgit