summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs
blob: 29e18ddb0fe76f5b7b50b62f5c6b91d4a43db09d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace StardewModdingAPI.Framework.Models
{
    /// <summary>Contains abstract metadata about an incompatible mod.</summary>
    internal class IncompatibleMod
    {
        /*********
        ** Accessors
        *********/
        /****
        ** From config
        ****/
        /// <summary>The unique mod ID.</summary>
        public string ID { get; set; }

        /// <summary>The mod name.</summary>
        public string Name { get; set; }

        /// <summary>The oldest incompatible mod version, or <c>null</c> for all past versions.</summary>
        public string LowerVersion { get; set; }

        /// <summary>The most recent incompatible mod version.</summary>
        public string UpperVersion { 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="UpperVersion"/>.</summary>
        public string ForceCompatibleVersion { get; set; }

        /// <summary>The reason phrase to show in the warning, or <c>null</c> to use the default value.</summary>
        /// <example>"this version is incompatible with the latest version of the game"</example>
        public string ReasonPhrase { get; set; }


        /****
        ** Injected
        ****/
        /// <summary>The semantic version corresponding to <see cref="LowerVersion"/>.</summary>
        [JsonIgnore]
        public ISemanticVersion LowerSemanticVersion { get; set; }

        /// <summary>The semantic version corresponding to <see cref="UpperVersion"/>.</summary>
        [JsonIgnore]
        public ISemanticVersion UpperSemanticVersion { get; set; }


        /*********
        ** Private methods
        *********/
        /// <summary>The method called when the model finishes deserialising.</summary>
        /// <param name="context">The deserialisation context.</param>
        [OnDeserialized]
        private void OnDeserialized(StreamingContext context)
        {
            this.LowerSemanticVersion = this.LowerVersion != null ? new SemanticVersion(this.LowerVersion) : null;
            this.UpperSemanticVersion = this.UpperVersion != null ? new SemanticVersion(this.UpperVersion) : null;
        }
    }
}