summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/IModMetadata.cs
blob: 1a007297d6d96706c25cb5fc204c082499c6a5bd (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using StardewModdingAPI.Framework.ModLoading;
using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
using StardewModdingAPI.Toolkit.Framework.ModData;

namespace StardewModdingAPI.Framework
{
    /// <summary>Metadata for a mod.</summary>
    internal interface IModMetadata : IModInfo
    {
        /*********
        ** Accessors
        *********/
        /// <summary>The mod's display name.</summary>
        string DisplayName { get; }

        /// <summary>The mod's full directory path.</summary>
        string DirectoryPath { get; }

        /// <summary>Metadata about the mod from SMAPI's internal data (if any).</summary>
        ModDataRecordVersionedFields DataRecord { get; }

        /// <summary>The metadata resolution status.</summary>
        ModMetadataStatus Status { get; }

        /// <summary>Indicates non-error issues with the mod.</summary>
        ModWarning Warnings { get; }

        /// <summary>The reason the metadata is invalid, if any.</summary>
        string Error { get; }

        /// <summary>The mod instance (if loaded and <see cref="IModInfo.IsContentPack"/> is false).</summary>
        IMod Mod { get; }

        /// <summary>The content pack instance (if loaded and <see cref="IModInfo.IsContentPack"/> is true).</summary>
        IContentPack ContentPack { get; }

        /// <summary>Writes messages to the console and log file as this mod.</summary>
        IMonitor Monitor { get; }

        /// <summary>The mod-provided API (if any).</summary>
        object Api { get; }

        /// <summary>The update-check metadata for this mod (if any).</summary>
        ModEntryModel UpdateCheckData { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Set the mod status.</summary>
        /// <param name="status">The metadata resolution status.</param>
        /// <param name="error">The reason the metadata is invalid, if any.</param>
        /// <returns>Return the instance for chaining.</returns>
        IModMetadata SetStatus(ModMetadataStatus status, string error = null);

        /// <summary>Set a warning flag for the mod.</summary>
        /// <param name="warning">The warning to set.</param>
        IModMetadata SetWarning(ModWarning warning);

        /// <summary>Set the mod instance.</summary>
        /// <param name="mod">The mod instance to set.</param>
        IModMetadata SetMod(IMod mod);

        /// <summary>Set the mod instance.</summary>
        /// <param name="contentPack">The contentPack instance to set.</param>
        /// <param name="monitor">Writes messages to the console and log file.</param>
        IModMetadata SetMod(IContentPack contentPack, IMonitor monitor);

        /// <summary>Set the mod-provided API instance.</summary>
        /// <param name="api">The mod-provided API.</param>
        IModMetadata SetApi(object api);

        /// <summary>Set the update-check metadata for this mod.</summary>
        /// <param name="data">The update-check metadata.</param>
        IModMetadata SetUpdateData(ModEntryModel data);

        /// <summary>Whether the mod manifest was loaded (regardless of whether the mod itself was loaded).</summary>
        bool HasManifest();

        /// <summary>Whether the mod has an ID (regardless of whether the ID is valid or the mod itself was loaded).</summary>
        bool HasID();

        /// <summary>Whether the mod has at least one update key set.</summary>
        bool HasUpdateKeys();
    }
}