diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-27 13:52:32 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-27 13:52:32 -0500 |
commit | b9dd6eb742e4f0c42ed887abd0f17f113f250056 (patch) | |
tree | 352a208a25780285419b0bae73148a00a98356ff /src/StardewModdingAPI/Framework/Models | |
parent | c24294c3dd73db3754d10ff8fe5bd51338555638 (diff) | |
parent | b75d86e7cc19f9bc961abb475f22e8f2b059533c (diff) | |
download | SMAPI-b9dd6eb742e4f0c42ed887abd0f17f113f250056.tar.gz SMAPI-b9dd6eb742e4f0c42ed887abd0f17f113f250056.tar.bz2 SMAPI-b9dd6eb742e4f0c42ed887abd0f17f113f250056.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Framework/Models')
3 files changed, 81 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Framework/Models/GitRelease.cs b/src/StardewModdingAPI/Framework/Models/GitRelease.cs new file mode 100644 index 00000000..bc53468f --- /dev/null +++ b/src/StardewModdingAPI/Framework/Models/GitRelease.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace StardewModdingAPI.Framework.Models +{ + /// <summary>Metadata about a GitHub release tag.</summary> + internal class GitRelease + { + /********* + ** Accessors + *********/ + /// <summary>The display name.</summary> + [JsonProperty("name")] + public string Name { get; set; } + + /// <summary>The semantic version string.</summary> + [JsonProperty("tag_name")] + public string Tag { get; set; } + } +}
\ No newline at end of file diff --git a/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs b/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs new file mode 100644 index 00000000..9bf06552 --- /dev/null +++ b/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs @@ -0,0 +1,47 @@ +using System.Text.RegularExpressions; + +namespace StardewModdingAPI.Framework.Models +{ + /// <summary>Contains abstract metadata about an incompatible mod.</summary> + internal class IncompatibleMod + { + /********* + ** Accessors + *********/ + /// <summary>The unique mod ID.</summary> + public string ID { get; set; } + + /// <summary>The mod name.</summary> + public string Name { get; set; } + + /// <summary>The most recent incompatible mod version.</summary> + public string Version { get; set; } + + /// <summary>The URL the user can check for an official updated version.</summary> + public string UpdateUrl { get; set; } + + /// <summary>The URL the user can check for an unofficial updated version.</summary> + public string UnofficialUpdateUrl { get; set; } + + /// <summary>A regular expression matching version strings to consider compatible, even if they technically precede <see cref="Version"/>.</summary> + public string ForceCompatibleVersion { get; set; } + + + /********* + ** Public methods + *********/ + /// <summary>Get whether the specified version is compatible according to this metadata.</summary> + /// <param name="version">The current version of the matching mod.</param> + public bool IsCompatible(ISemanticVersion version) + { + ISemanticVersion incompatibleVersion = new SemanticVersion(this.Version); + + // allow newer versions + if (version.IsNewerThan(incompatibleVersion)) + return true; + + // allow versions matching override + return !string.IsNullOrWhiteSpace(this.ForceCompatibleVersion) && Regex.IsMatch(version.ToString(), this.ForceCompatibleVersion, RegexOptions.IgnoreCase); + } + } +}
\ No newline at end of file diff --git a/src/StardewModdingAPI/Framework/Models/UserSettings.cs b/src/StardewModdingAPI/Framework/Models/UserSettings.cs new file mode 100644 index 00000000..a0074f77 --- /dev/null +++ b/src/StardewModdingAPI/Framework/Models/UserSettings.cs @@ -0,0 +1,15 @@ +namespace StardewModdingAPI.Framework.Models +{ + /// <summary>Contains user settings from SMAPI's JSON configuration file.</summary> + internal class UserSettings + { + /********* + ** Accessors + *********/ + /// <summary>Whether to enable development features.</summary> + public bool DeveloperMode { get; set; } + + /// <summary>Whether to check if a newer version of SMAPI is available on startup.</summary> + public bool CheckForUpdates { get; set; } = true; + } +} |