This repository was archived by the owner on Apr 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathModManager.cs
52 lines (50 loc) · 1.59 KB
/
ModManager.cs
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
using Splotch.Loader.ModLoader;
using System.Collections.Generic;
namespace Splotch
{
/// <summary>
/// A class that contains every loaded mod.
/// </summary>
public static class ModManager
{
public static List<ModInfo> loadedMods = new List<ModInfo>();
public static int modDisplayLimit = 20;
/// <summary>
/// Generates an info text describing the loaded mods. <c>modDisplayLimit</c> defines the maximum number of mods that will be displayed.
///
/// <example>
/// For example:
/// <code>
/// ModManager.modDisplayLimit = 2;
/// string info = ModManager.GetLoadedModsInfoText()
/// </code>
/// Could result in info equaling:
/// <code>
/// Splotch Mod Template by Codemob version 1.0
/// BasicMod by WackyModer, Shad0w version 0.1.2
/// ...and 3 others
/// </code>
/// </example>
/// </summary>
/// <returns>The info text</returns>
public static string GetLoadedModsInfoText()
{
string modInfoString = "";
int i = 0;
foreach (var loadedMod in loadedMods)
{
if (i < modDisplayLimit)
{
modInfoString += $"\n{loadedMod}";
} else
{
modInfoString += $"\n...and {loadedMods.Count - modDisplayLimit} others";
break;
}
i++;
}
Logger.Log(modInfoString);
return modInfoString;
}
}
}