-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMMI.cs
91 lines (68 loc) · 2.12 KB
/
MMI.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
using System;
using GTA;
/*
Update assembly version before release!
*/
namespace MMI_SP
{
internal class MMI : Script
{
public static bool IsDebug = false;
private static bool _initialized = false;
public static bool IsInitialized { get => _initialized; }
public MMI()
{
#if DEBUG
IsDebug = true;
#endif
// Trick to be able to wait for the game
Tick += Initialize;
if (IsDebug) Tick += DebugOnTick;
}
private void Initialize(object sender, EventArgs e)
{
// Reset log file
Logger.ResetLogFile();
Logger.Debug($"Waiting for game to be loaded...");
while (Game.IsLoading)
{
Yield();
}
Logger.Debug("Game is loaded");
Logger.Debug("Waiting for screen to fade...");
while (Game.IsScreenFadingIn)
{
Yield();
}
Logger.Debug("Screen has faded");
Logger.Debug("Loading configuration values...");
Config.Initialize();
Logger.Debug("Configuration values loaded");
Logger.Debug("Checking prerequisites...");
if (SelfCheck.Check())
{
Logger.Debug("Prerequisites are installed");
Logger.Debug("Checking for updates...");
if (Config.CheckForUpdate)
{
// Async check for updates
Updater.CheckForUpdate();
}
}
else
{
Logger.Debug("Prerequisites are not installed");
}
_initialized = true;
Tick -= Initialize;
}
void DebugOnTick(object sender, EventArgs e)
{
Ped character = Game.Player.Character;
if (character.CurrentVehicle != null)
{
SE.UI.DrawText(character.CurrentVehicle.IsPersistent.ToString());
}
}
}
}