forked from LavaGang/MelonLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeprecated.cs
139 lines (136 loc) · 6.37 KB
/
Deprecated.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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.Collections.Generic;
using System.Linq;
#pragma warning disable 0108
namespace MelonLoader
{
[Obsolete("Main is obsolete. Please use MelonLoaderBase or MelonHandler instead.")]
public static class Main
{
public static List<MelonMod> Mods = null;
public static List<MelonPlugin> Plugins = null;
public static bool IsVRChat = false;
public static bool IsBoneworks = false;
public static string GetUnityVersion() => MelonLoaderBase.UnityVersion;
public static string GetUserDataPath() => MelonLoaderBase.UserDataPath;
internal static void LegacySupport(List<MelonMod> mods, List<MelonPlugin> plugins, bool isVRChat, bool isBoneworks)
{
Mods = mods;
Plugins = plugins;
IsVRChat = isVRChat;
IsBoneworks = isBoneworks;
}
}
[Obsolete("MelonModGame is obsolete. Please use MelonGame instead.")]
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public class MelonModGameAttribute : Attribute
{
public string Developer { get; }
public string GameName { get; }
public MelonModGameAttribute(string developer = null, string gameName = null)
{
Developer = developer;
GameName = gameName;
}
internal MelonGameAttribute Convert() => new MelonGameAttribute(Developer, GameName);
}
[Obsolete("MelonModInfo is obsolete. Please use MelonInfo instead.")]
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class MelonModInfoAttribute : Attribute
{
public Type SystemType { get; }
public string Name { get; }
public string Version { get; }
public string Author { get; }
public string DownloadLink { get; }
public MelonModInfoAttribute(Type type, string name, string version, string author, string downloadLink = null)
{
SystemType = type;
Name = name;
Version = version;
Author = author;
DownloadLink = downloadLink;
}
internal MelonInfoAttribute Convert() => new MelonInfoAttribute(SystemType, Name, Version, Author, DownloadLink);
}
[Obsolete("MelonPluginGame is obsolete. Please use MelonGame instead.")]
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public class MelonPluginGameAttribute : Attribute
{
public string Developer { get; }
public string GameName { get; }
public MelonPluginGameAttribute(string developer = null, string gameName = null)
{
Developer = developer;
GameName = gameName;
}
public MelonGameAttribute Convert() => new MelonGameAttribute(Developer, GameName);
}
[Obsolete("MelonPluginInfo is obsolete. Please use MelonInfo instead.")]
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class MelonPluginInfoAttribute : Attribute
{
public Type SystemType { get; }
public string Name { get; }
public string Version { get; }
public string Author { get; }
public string DownloadLink { get; }
public MelonPluginInfoAttribute(Type type, string name, string version, string author, string downloadLink = null)
{
SystemType = type;
Name = name;
Version = version;
Author = author;
DownloadLink = downloadLink;
}
public MelonInfoAttribute Convert() => new MelonInfoAttribute(SystemType, Name, Version, Author, DownloadLink);
}
[Obsolete("MelonModLogger is obsolete. Please use MelonLogger instead.")]
public class MelonModLogger : MelonLogger {}
[Obsolete("ModPrefs is obsolete. Please use MelonPrefs instead.")]
public class ModPrefs : MelonPrefs
{
public static Dictionary<string, Dictionary<string, PrefDesc>> GetPrefs()
{
Dictionary<string, Dictionary<string, PrefDesc>> output = new Dictionary<string, Dictionary<string, PrefDesc>>();
Dictionary<string, Dictionary<string, MelonPreference>> prefs = GetPreferences();
for (int i = 0; i < prefs.Values.Count; i++)
{
Dictionary<string, MelonPreference> prefsdict = prefs.Values.ElementAt(i);
Dictionary<string, PrefDesc> newprefsdict = new Dictionary<string, PrefDesc>();
for (int j = 0; j < prefsdict.Values.Count; j++)
{
MelonPreference pref = prefsdict.Values.ElementAt(j);
PrefDesc newpref = new PrefDesc(pref.Value, (PrefType)pref.Type, pref.Hidden, pref.DisplayText);
newpref.ValueEdited = pref.ValueEdited;
newprefsdict.Add(prefsdict.Keys.ElementAt(j), newpref);
}
output.Add(prefs.Keys.ElementAt(i), newprefsdict);
}
return output;
}
public static void RegisterPrefString(string section, string name, string defaultValue, string displayText = null, bool hideFromList = false) => RegisterString(section, name, defaultValue, displayText, hideFromList);
public static void RegisterPrefBool(string section, string name, bool defaultValue, string displayText = null, bool hideFromList = false) => RegisterBool(section, name, defaultValue, displayText, hideFromList);
public static void RegisterPrefInt(string section, string name, int defaultValue, string displayText = null, bool hideFromList = false) => RegisterInt(section, name, defaultValue, displayText, hideFromList);
public static void RegisterPrefFloat(string section, string name, float defaultValue, string displayText = null, bool hideFromList = false) => RegisterFloat(section, name, defaultValue, displayText, hideFromList);
public enum PrefType
{
STRING,
BOOL,
INT,
FLOAT
}
public class PrefDesc : MelonPreference
{
public PrefType Type { get => (PrefType)base.Type; }
public PrefDesc(string value, PrefType type, bool hidden, string displayText) : base(value, type, hidden, displayText)
{
Value = value;
ValueEdited = value;
base.Type = (MelonPreferenceType)type;
Hidden = hidden;
DisplayText = displayText;
}
}
}
}