forked from MintLily/GamePriority
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUniversalGamePriorityMod.cs
More file actions
53 lines (46 loc) · 1.79 KB
/
UniversalGamePriorityMod.cs
File metadata and controls
53 lines (46 loc) · 1.79 KB
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
using MelonLoader;
using System.Diagnostics;
namespace GamePriority
{
public class GamePriorityChanger : MelonMod
{
public static class BuildInfo
{
public const string Name = "GamePriority";
public const string Author = "Lily";
public const string Company = null;
public const string Version = "1.1.2";
public const string DownloadLink = "https://github.com/MintLily/GamePriority/";
}
public static MelonMod Instance;
public static MelonPreferences_Category category;
public static MelonPreferences_Entry<bool> setGamePriority;
public override void OnApplicationStart()
{
Instance = this;
category = MelonPreferences.CreateCategory("GamePriority", "Game Priority");
setGamePriority = category.CreateEntry("SetGamePriorityToHigh", false, "Set game priority to High");
ApplyChanges();
}
public override void OnPreferencesSaved()
{
ApplyChanges();
}
private static void ApplyChanges()
{
bool highPriority = setGamePriority.Value;
if (!highPriority)
{
using (Process p = Process.GetCurrentProcess())
p.PriorityClass = ProcessPriorityClass.Normal;
Instance.LoggerInstance.Msg($"Set game's process priority to: Normal");
}
else if (highPriority)
{
using (Process p = Process.GetCurrentProcess())
p.PriorityClass = ProcessPriorityClass.High;
Instance.LoggerInstance.Msg($"Set game's process priority to: High");
}
}
}
}