-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
75 lines (64 loc) · 1.75 KB
/
main.cpp
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
#include "RED2Launcher.h"
#define IMAGECLASS LauncherImages
#define IMAGEFILE <Launcher/images.iml>
#include <Draw/iml.h>
//-----------------------------------------------
RED2Launcher::RED2Launcher()
{
// Change working directory in case someone start the launcher from another directory.
#ifdef PLATFORM_LINUX
char path_buff[PATH_MAX];
ssize_t len = readlink("/proc/self/exe", path_buff, sizeof(path_buff) - 1);
if (len != -1 ) {
std::string path_with_exe = std::string(path_buff);
size_t last_slash = path_with_exe.find_last_of("/");
chdir(path_with_exe.substr(0, last_slash).c_str());
} else {
Exclamation("Cannot change working directory of the process");
Exit(-1);
}
#endif
CtrlLayout(*this, "Driver 2 PC");
logoImg.SetImage(LauncherImages::Logo());
launchBtn << [=] {
LaunchGame();
Exit(0);
};
configureBtn << [=] {
configWindow.Open(this);
};
setupBtn << [=] {
wizardWindow.Open(this);
};
}
void RED2Launcher::LaunchGame()
{
#ifdef PLATFORM_WIN32
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWDEFAULT;
if(!CreateProcess("REDRIVER2_dev.EXE", NULL, NULL, NULL, FALSE,
CREATE_NO_WINDOW|NORMAL_PRIORITY_CLASS, NULL, NULL,
&si, &pi))
{
if(!CreateProcess("REDRIVER2.EXE", NULL, NULL, NULL, FALSE,
CREATE_NO_WINDOW|NORMAL_PRIORITY_CLASS, NULL, NULL,
&si, &pi))
{
Exclamation("Unable to launch game!");
}
}
#endif
#ifdef PLATFORM_LINUX
execl("REDRIVER2", (char *) NULL);
#endif
}
GUI_APP_MAIN
{
// TODO: check if needed to run Setup Wizard
//SetupWizardWindow().Run();
RED2Launcher().Run();
}