-
Notifications
You must be signed in to change notification settings - Fork 6
/
Utils.cs
55 lines (44 loc) · 1.82 KB
/
Utils.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
using System.Linq;
using IPALogger = IPA.Logging.Logger;
using System.Reflection;
using HarmonyLib;
using System.Collections.Generic;
using HRCounter.Configuration;
namespace HRCounter.Utils
{
public static class Utils
{
// private static IPALogger _logger = Logger.logger;
internal static readonly List<object> DataSources = new object[] {"HypeRate", "WebRequest", "FitbitHRtoWS", "Pulsoid", "YUR APP"}.ToList();
private static readonly MethodBase ScoreSaber_playbackEnabled =
AccessTools.Method("ScoreSaber.Core.ReplaySystem.HarmonyPatches.PatchHandleHMDUnmounted:Prefix");
// code copied from Camera2
internal static bool IsInReplay()
{
// detect whether we are in a replay
return ScoreSaber_playbackEnabled != null && (bool) ScoreSaber_playbackEnabled.Invoke(null, null) == false;
}
internal static bool IsModInstalled(string modName)
{
return IPA.Loader.PluginManager.EnabledPlugins.Any(x => x.Id == modName);
}
internal static string GetCurrentSourceLinkText()
{
switch (PluginConfig.Instance.DataSource)
{
case "WebRequest":
return PluginConfig.Instance.FeedLink;
case "HypeRate":
return PluginConfig.Instance.HypeRateSessionID;
case "FitbitHRtoWS":
return PluginConfig.Instance.FitbitWebSocket;
case "Pulsoid":
return PluginConfig.Instance.PulsoidWidgetID;
case "YUR APP":
return "Make sure to have your desktop YUR app running";
default:
return "Unknown Data Source";
}
}
}
}