-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
79 lines (62 loc) · 1.6 KB
/
Copy pathmain.cpp
File metadata and controls
79 lines (62 loc) · 1.6 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
#include "config.h"
#include "gameDetection.h"
#include "setup.h"
#include "sourceGameLounge.h"
#include "pluginManager.h"
#include <vector>
#define LOAD false
#define SAVE true
sgl::SourceGameLounge* g_pWindow = NULL;
void config(bool save)
{
try
{
if (save)
sgl::Config::instance().save(".\\configs\\config.xml");
else
sgl::Config::instance().load(".\\configs\\config.xml");
}
catch (std::exception &e)
{
displayErrorA(e.what());
}
}
int main(int argc, char *argv[])
{
HRESULT hres = CoInitializeEx(0, COINIT_MULTITHREADED);
QApplication application(argc, argv);
config(LOAD);
config(SAVE);
std::vector<commondll::Plugin*> plugins;
WIN32_FIND_DATA fileData;
HANDLE fileHandle = FindFirstFile(TEXT(".\\plugins\\*.dll"), &fileData);
if (fileHandle == (void*)ERROR_INVALID_HANDLE || fileHandle == (void*)ERROR_FILE_NOT_FOUND)
displayError(L"No plugins were found.");
else
{
do
{
commondll::Plugin* plugin = commondll::PluginManager::instance().loadPlugin(fileData.cFileName);
if (plugin != NULL)
plugins.push_back(plugin);
} while (FindNextFile(fileHandle, &fileData));
}
int ret = 1;
if (sgl::GameDetection::instance().wmiInitialize(true))
{
g_pWindow = new sgl::SourceGameLounge(&application);
g_pWindow->show();
sgl::SetupPre* setupPre = new sgl::SetupPre();
if (!setupPre->initialSetup())
setupPre->pSetup->exec();
delete setupPre;
setupPre = NULL;
ret = application.exec();
delete g_pWindow;
g_pWindow = NULL;
}
config(SAVE);
for (commondll::Plugin* plugin : plugins)
commondll::PluginManager::instance().unloadPlugin(plugin);
return ret;
}