-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·220 lines (186 loc) · 10.6 KB
/
main.cpp
File metadata and controls
executable file
·220 lines (186 loc) · 10.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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#define SDL_MAIN_HANDLED
#include <fstream>
#include <iostream>
#include <string>
#include <thread>
// UI instances
#include "./main/include/modules/load.h"
#include "./main/include/plugins/load.h"
#include "./main/include/templates/load.h"
#include "./main/include/vortex.h"
#include "./ui/launcher/launcher.hpp"
static std::string session_id = "unknow";
// TODO vortex -i --module --path
// TODO vortex -d --module --url
void PrintInfinite() {
std::cout << R"(
███ ███ ███ ███████▓▒███ ███░ ░███ ███▓█████████ ████████
███ ███▒ ███ ███████▓▒███ █████ ░███ ███▓█████████ ████████
███ ████ ███ ███▓▓▓▓ ▒███ ██████▒███ ███▓ ███░ ███
███ █████ ███ ███████ ▒███ ███▒██████ ███▓ ███░ ███
███ █████████ ███ ▒███ ███▒ █████ ███▓ ███░ ███
███ ███▓█████ ███ ▒███ ███▒ ████ ███▓ ███░ ███
███ ███ █████ ███ ███▓ ███░ ███████
███ ███ ▒████ ██░ ░ ███░ ███████
███ ███ ████ ███░ ███
███ ███ ░█▓ █░ ███
███ ███ ███
███ ███ ███▒
███ ██ ░████
███ ████▒
███ ███░
██▒ ███
█░ ██
█ █
)"
<< std::endl;
}
void PrintHeader() {
// Print this every time
std::cout << std::endl;
std::cout << "\033[38;2;177;255;49m";
PrintInfinite();
std::cout << "\033[0m";
std::cout << "\033[38;2;177;255;49m"
<< " Vortex Launcher " << VORTEXLAUNCHER_VERSION << "\033[0m" << std::endl;
std::cout << "┌────────────────────────────────────────────────────────────────────────────────────────────────┐"
<< std::endl;
std::cout << "│"
<< "\033[38;2;177;255;49m"
<< " Description : "
<< "\033[0m"
<< " │ " << std::endl;
std::cout << "│ ❓ Vortex is a complete open creation platform that contain a bunch of tools for creators and │ "
<< std::endl;
std::cout << "│ makers. │ "
<< std::endl;
std::cout << "├────────────────────────────────────────────────────────────────────────────────────────────────┤"
<< std::endl;
std::cout << "│"
<< "\033[38;2;177;255;49m"
<< " Usage : "
<< "\033[0m"
<< "vortex <paramater(s)...> <information(s)...> │ " << std::endl;
std::cout << "├────────────────────────────────────────────────────────────────────────────────────────────────┤"
<< std::endl;
std::cout << "│"
<< "\033[38;2;177;255;49m"
<< " Helpfull commands : "
<< "\033[0m"
<< " │ " << std::endl;
std::cout << "│ -h --help : See all parameters │ "
<< std::endl;
std::cout << "│ -i --install : Install contents/components on the system │ "
<< std::endl;
std::cout << "│ -d --download : Download contents/components to install on the system │ "
<< std::endl;
std::cout << "├────────────────────────────────────────────────────────────────────────────────────────────────┤"
<< std::endl;
std::cout << "│"
<< "\033[38;2;177;255;49m"
<< " Links : "
<< "\033[0m"
<< " │ " << std::endl;
std::cout << "│ 🌍 Vortex website : https://infinite.si/ │ "
<< std::endl;
std::cout << "│ 📝 News : https://infinite.si/blog │ "
<< std::endl;
std::cout << "│ 💬 Discord : https://discord.gg/H2wptkecUg │ "
<< std::endl;
std::cout
<< "│ 🧑💻 GitHub : https://github.com/infiniteHQ/Vortex │ "
<< std::endl;
std::cout << "└────────────────────────────────────────────────────────────────────────────────────────────────┘ "
<< std::endl;
std::cout << std::endl;
}
VxContext *InitBlankRuntime(bool logger) {
VxContext *ctx = VortexMaker::CreateContext();
ctx->disconnected = true;
ctx->web_fetched = false;
std::thread([=]() {
if (VortexMaker::GetCurrentContext()->net.CheckNet()) {
VortexMaker::GetCurrentContext()->disconnected = false;
}
}).detach();
std::thread([=]() {
while (!VortexMaker::GetCurrentContext()->web_fetched) {
if (!VortexMaker::GetCurrentContext()->disconnected) {
VortexMaker::UpdateVortexWebData();
VortexMaker::UpdateVortexLauncherWebData();
VortexMaker::UpdateVortexNews({ "vortex1", "vortex2" });
VortexMaker::GetCurrentContext()->web_fetched = true;
std::string version = VORTEXLAUNCHER_VERSION;
if (VortexMaker::IsVersionGreater(version, ctx->latest_launcher_version.version)) {
ctx->launcher_update_available = true;
}
}
std::this_thread::sleep_for(std::chrono::seconds(2));
}
}).detach();
#ifdef _WIN32
ctx->m_VortexLauncherPath = VortexMaker::GetPath(".\\");
#else
ctx->m_VortexLauncherPath = VortexMaker::GetPath("./");
#endif
ctx->state.session_id = session_id;
ctx->version = VORTEXLAUNCHER_VERSION;
VortexMaker::InitializePlatformVendor();
VortexMaker::CreateGlobalLogger();
VortexMaker::CreateConsoleLogger();
VortexMaker::LogInfo("Bootstrapp", "Initializing runtime...");
VortexMaker::CreateSessionTopic(ctx->state.session_id);
// Initialize environment
VortexMaker::InitEnvironment();
VortexMaker::DetectPlatform();
VortexMaker::DetectArch();
VortexMaker::RefreshActiveSessions();
// Refresh environment pools
VortexMaker::RefreshEnvironmentProjectsPools();
VortexMaker::RefreshEnvironmentModulesPools();
VortexMaker::RefreshEnvironmentContentsPools();
VortexMaker::RefreshEnvironmentTemplatesPools();
VortexMaker::RefreshEnvironmentPluginsPools();
VortexMaker::RefreshEnvironmentVortexVersionsPools();
VortexMaker::RefreshVortexLauncherDists();
VortexMaker::RefreshVortexDists();
VortexMaker::RefreshEnvironmentProjects();
VortexMaker::RefreshEnvironmentVortexVersion();
VortexMaker::LoadSystemTemplates(ctx->IO.sys_templates);
VortexMaker::LoadSystemContents(ctx->IO.sys_contents);
VortexMaker::LoadSystemModules(ctx->IO.sys_em);
VortexMaker::LoadSystemPlugins(ctx->IO.sys_ep);
ctx->logger = logger;
return ctx;
}
/**
* @brief : Entry point of main Vortex runtime command.
*/
int main(int argc, char *argv[]) {
// Check command-line arguments for --install, -i, --download, -d
bool installFlag = false;
bool downloadFlag = false;
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if (arg == "-i" || arg == "--install") {
installFlag = true;
} else if (arg == "-d" || arg == "--download") {
downloadFlag = true;
} else if (arg == "--test" || arg == "--download") {
std::cout << "OK" << std::endl;
return 0;
}
}
PrintHeader();
VxContext *ctx = InitBlankRuntime(true);
VortexMaker::LogInfo("Bootstrapp", "Opening the graphical interface...");
CherryRun(argc, argv);
return 0;
}
#ifdef _WIN32
#include <windows.h>
extern int main(int argc, char *argv[]);
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
return main(__argc, __argv);
}
#endif