-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSupportInfo.cs
More file actions
193 lines (167 loc) · 8.33 KB
/
SupportInfo.cs
File metadata and controls
193 lines (167 loc) · 8.33 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
using ModAPI.Common.Update;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace ModAPI.Common
{
public static class SupportInfo
{
/// <summary>
/// The current version of the Launcher Kit.
/// </summary>
public static Version LauncherKitVersion => UpdateManager.CurrentVersion;
/// <summary>
/// The current version of the Launcher Kit, as a string containing a minimum of three version components (i.e. "1.2.3"). A fourth component (revision) will be included only if it is non-zero.
/// </summary>
public static string LauncherKitVersionString => LauncherKitVersion.Revision == 0 ? LauncherKitVersion.ToString(3) : LauncherKitVersion.ToString();
/// <summary>
/// The current version of the ModAPI DLLs that will be injected into the game.
/// </summary>
public static Version ModAPIDllsVersion => UpdateManager.CurrentDllsBuild;
/// <summary>
/// The current version of the ModAPI DLLs, as a string containing a minimum of three version components (i.e. "1.2.3"). A fourth component (revision) will be included only if it is non-zero.
/// </summary>
public static string ModAPIDllsVersionString => ModAPIDllsVersion.Revision == 0 ? ModAPIDllsVersion.ToString(3) : ModAPIDllsVersion.ToString();
/// <summary>
/// The folder path where the Launcher Kit is installed. This folder contains the executables for the Easy Installer, Easy Uninstaller, and Launcher.
/// By default, this is "%programdata%\Spore ModAPI Launcher Kit".
/// The path will NOT have a trailing slash.
/// </summary>
public static string LauncherKitPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
/// <summary>
/// The file version of SporeApp.exe.
/// If SporeApp.exe could not be found, this will return null.
/// </summary>
public static string GameVersionString
{
get
{
var sporebinEP1Path = SporePath.GetSporebinEP1Path();
if (sporebinEP1Path == null)
{
return null;
}
// If not null, SporebinEP1Path is guaranteed to exist and contain SporeApp.exe
var sporeAppPath = Path.Combine(sporebinEP1Path, "SporeApp.exe");
return FileVersionInfo.GetVersionInfo(sporeAppPath).FileVersion;
}
}
/// <summary>
/// The version type of the game. This will be one of the following values:
/// "Disc + Patch 5.1, July 2009",
/// "Origin, March 2017",
/// "EA App, October 2024",
/// "GOG/Steam, March 2017",
/// "GOG, October 2024",
/// "Steam, October 2024",
/// "Unknown".
/// If SporeApp.exe could not be found, this will return null.
/// </summary>
public static string GameVersionTypeString
{
get
{
var sporebinEP1Path = SporePath.GetSporebinEP1Path();
if (sporebinEP1Path == null)
{
return null;
}
var sporeAppPath = Path.Combine(sporebinEP1Path, "SporeApp.exe");
var versionType = GameVersion.DetectVersion(sporeAppPath);
return GameVersion.GetFriendlyVersionName(versionType);
}
}
/// <summary>
/// Gets a string with the game version and version type, i.e. "3.1.0.29 - GOG, October 2024, LAA".
/// If SporeApp.exe could not be found, this will return "Game not found".
/// </summary>
public static string GameFullVersionInfoString
{
get
{
if (GameVersionString == null || GameVersionTypeString == null)
{
return "Game not found";
}
// Check if LAA
var laaString = "";
var versionType = GameVersion.DetectVersion(Path.Combine(SporePath.GetSporebinEP1Path(), "SporeApp.exe"));
var exeName = GameVersion.GetExecutableFileName(versionType);
if (exeName != null)
{
var sporeAppPath = Path.Combine(SporePath.GetSporebinEP1Path(), exeName);
if (File.Exists(sporeAppPath))
{
laaString = LAAUtils.IsLAA(sporeAppPath) ? ", LAA" : "";
}
}
return $"{GameVersionString} - {GameVersionTypeString}{laaString}";
}
}
private static DialogResult ShowMessageBox(string message, string title, bool showGameInfo, bool showPaths, MessageBoxButtons buttons, MessageBoxIcon icon)
{
message += "\n";
// Append game info
if (showGameInfo)
{
message += $"\nSpore version: {GameFullVersionInfoString}";
if (showPaths)
{
message += $"\nSpore path: {SporePath.GetSporebinEP1Path()}";
}
}
// Append LK info
message += $"\nLauncher Kit version: {LauncherKitVersionString}\nModAPI DLLs version: {ModAPIDllsVersionString}";
if (showPaths)
{
message += $"\nLauncher Kit path: {LauncherKitPath}";
}
return MessageBox.Show(message, title, buttons, icon);
}
/// <summary>
/// Shows an info message box to the user. Information about the Launcher Kit will be included, and optionally information about the game.
/// Info message boxes should be used for information that the user should be aware of, but is not causing a problem.
/// </summary>
public static DialogResult ShowInfo(string message, string title, bool showGameInfo = true, bool showPaths = true, MessageBoxButtons buttons = MessageBoxButtons.OK)
{
return ShowMessageBox(message, title, showGameInfo, showPaths, buttons, MessageBoxIcon.Information);
}
/// <summary>
/// Shows a warning message box to the user. Information about the Launcher Kit will be included, and optionally information about the game.
/// Warning message boxes should be used for potential problems, where the program can continue, but further problems are likely to occur.
/// </summary>
public static DialogResult ShowWarning(string message, string title, bool showGameInfo = true, bool showPaths = true, MessageBoxButtons buttons = MessageBoxButtons.OK)
{
return ShowMessageBox(message, title, showGameInfo, showPaths, buttons, MessageBoxIcon.Warning);
}
/// <summary>
/// Shows an error message box to the user. Information about the Launcher Kit will be included, and optionally information about the game.
/// Error message boxes should be used for problems that prevent the program from continuing.
/// </summary>
public static DialogResult ShowError(string message, string title, bool showGameInfo = true, bool showPaths = true, MessageBoxButtons buttons = MessageBoxButtons.OK)
{
return ShowMessageBox(message, title, showGameInfo, showPaths, buttons, MessageBoxIcon.Error);
}
/// <summary>
/// Writes a text file containing support information.
/// This includes the game version, game paths, Launcher Kit version, ModAPI DLLs version, and Launcher Kit path.
/// </summary>
public static void WriteSupportInfoFile(string path)
{
string[] text =
{
$"Spore version: {GameFullVersionInfoString}",
$"Spore path: {SporePath.GetSporebinEP1Path()}",
$"Spore Core data path: {SporePath.GetDataPath(SporePath.Game.Spore)}",
$"Spore C&C data path: {SporePath.GetDataPath(SporePath.Game.CreepyAndCute)}",
$"Spore GA data path: {SporePath.GetDataPath(SporePath.Game.GalacticAdventures)}",
$"Launcher Kit version: {LauncherKitVersionString}",
$"ModAPI DLLs version: {ModAPIDllsVersionString}",
$"Launcher Kit path: {LauncherKitPath}",
};
File.WriteAllLines(path, text);
}
}
}