forked from Gameslinx/Tessellation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_ParallaxInstallationChecker.cs
More file actions
138 lines (135 loc) · 5.36 KB
/
Copy path_ParallaxInstallationChecker.cs
File metadata and controls
138 lines (135 loc) · 5.36 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
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
using System;
using System.IO;
using UnityEngine;
namespace ParallaxInstallChecker
{
[KSPAddon(KSPAddon.Startup.Instantly, false)]
public class Checker : MonoBehaviour
{
string path = "";
bool meetsKopernicus = false;
bool meetsStockTextures = false;
bool meetsParallax = false;
bool dependencyAdvancedSubdivision = false;
bool dependencySubdivMod = false;
bool dependencyCore = false;
bool dependencyQualityLibrary = false;
public void Start()
{
path = Path.Combine(KSPUtil.ApplicationRootPath + "GameData/");
GetVersion();
PreValidate();
}
public void GetVersion()
{
bool hasVersion = false;
int maj = Versioning.version_major;
int min = Versioning.version_minor;
string versionString = maj.ToString() + "." + min.ToString();
string[] supportedVersions = { "1.11", "1.10" }; //If you're decompiling to change the version, don't bother. There's no lock, this is simply advice
foreach (string s in supportedVersions)
{
if (s == versionString)
{
hasVersion = true;
}
}
if (hasVersion == false)
{
VisualLog("WARNING: Parallax is not running on a supported version of KSP - Bug reports from this version will be invalid. You have been warned!");
Debug.Log("[Parallax] DidntReadInstallationInstructionsException: Parallax is not supported on this version of KSP.");
}
}
public void PreValidate()
{
Validate(path + "Kopernicus/Config/System.cfg", "Kopernicus", out meetsKopernicus);
Validate(path + "Parallax/License.md", "Parallax Core", out meetsParallax);
Validate(path + "Parallax_StockTextures/ParallaxTerrain.cfg", "Parallax (Stock Textures)", out meetsStockTextures);
Validate(path + "Parallax/AdvancedSubdivision.dll", "Advanced Subdivision", out dependencyAdvancedSubdivision);
Validate(path + "Parallax/PQSModExpansion.dll", "Subdivision PQSMod", out dependencySubdivMod);
Validate(path + "Parallax/ParallaxQualityLibrary.dll", "Parallax Quality Library", out dependencyQualityLibrary);
Log("Finished validating your Parallax install.");
Finish();
}
public void Validate(string path, string reason, out bool meets)
{
meets = false;
Log("Attempting to validate " + reason + " at: ");
Log("\t" + path);
if (File.Exists(path))
{
meets = true;
Log("\tParallax has met dependency: " + reason);
}
else
{
meets = false;
Log("\tException: Parallax has failed to meet dependency: " + reason);
if (reason == "Parallax (Stock Textures)")
{
Log("\tIf you are not playing with a planet mod, you need to install these.");
}
}
}
public void Finish()
{
if (meetsKopernicus == true)
{
VisualLog("Parallax has met dependency: Kopernicus");
}
else
{
VisualLog("<color=#f0871f>Parallax has not met dependency: Kopernicus</color>");
}
if (meetsParallax == true)
{
VisualLog("Parallax has met dependency: Parallax (Core)");
}
else
{
VisualLog("<color=#f0871f>Parallax has not met dependency: Parallax (CORE)</color>");
}
if (meetsStockTextures == true)
{
VisualLog("Parallax has met dependency: Parallax (Stock Textures)");
}
else
{
VisualLog("<color=#f0871f>Parallax has not met dependency: Parallax (Stock Textures)</color>");
VisualLog("<color=#f0871f>If you are running Parallax with a planet mod, you can ignore this.</color>");
}
if (dependencyQualityLibrary == true)
{
VisualLog("Parallax has met dependency: Parallax Quality Library");
}
else
{
VisualLog("<color=#f0871f>Parallax has not met dependency: Parallax Quality Library</color>");
}
if (dependencySubdivMod == true)
{
VisualLog("Parallax has met dependency: Subdivision PQSMod");
}
else
{
VisualLog("<color=#f0871f>Parallax has not met dependency: Subdivision PQSMod</color>");
}
if (dependencyAdvancedSubdivision == true)
{
VisualLog("Parallax has met dependency: Advanced Subdivision");
}
else
{
VisualLog("<color=#f0871f>Parallax has not met dependency: Advanced Subdivision</color>");
}
}
public void VisualLog(string message)
{
ScreenMessages.PostScreenMessage(message, 20f, ScreenMessageStyle.UPPER_LEFT);
}
public void Log(string message)
{
Debug.Log("[Parallax Checker] " + message);
}
}
}