-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·251 lines (217 loc) · 11.3 KB
/
main.cpp
File metadata and controls
executable file
·251 lines (217 loc) · 11.3 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
//
// main.cpp
// Entry point for Vortex editor and crash handler
//
// Copyright (c) 2026 Infinite
//
// This work is licensed under the terms of the Apache-2.0 license.
// For a copy, see <https://github.com/infiniteHQ/Vortex/blob/main/LICENSE>.
//
#define SDL_MAIN_HANDLED
#include <fstream>
#include <iostream>
#include <string>
// UI instances
#include "./lib/cherry/cherry.hpp"
#include "./vxcore/include/crash/crash_writer.hpp"
#include "./vxcore/include/templates/load.hpp"
#include "./vxcore/include/vortex.h"
#include "./vxgui/crash_handler/crash_handler.hpp"
#include "./vxgui/editor/main/editor.hpp"
static std::string session_id = "unknow";
void PrintInfinite() {
std::cout << R"(
███ ███ ███ ███████▓▒███ ███░ ░███ ███▓█████████ ████████
███ ███▒ ███ ███████▓▒███ █████ ░███ ███▓█████████ ████████
███ ████ ███ ███▓▓▓▓ ▒███ ██████▒███ ███▓ ███░ ███
███ █████ ███ ███████ ▒███ ███▒██████ ███▓ ███░ ███
███ █████████ ███ ▒███ ███▒ █████ ███▓ ███░ ███
███ ███▓█████ ███ ▒███ ███▒ ████ ███▓ ███░ ███
███ ███ █████ ███ ███▓ ███░ ███████
███ ███ ▒████ ██░ ░ ███░ ███████
███ ███ ████ ███░ ███
███ ███ ░█▓ █░ ███
███ ███ ███
███ ███ ███▒
███ ██ ░████
███ ████▒
███ ███░
██▒ ███
█░ ██
█ █
)"
<< std::endl;
}
void print_header(const std::string &additions = "") {
// 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 " << VORTEX_VERSION << " " << additions << "\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 << "│ -l --launcher : Open the Vortex "
"launcher (for projects, components...) │ "
<< std::endl;
std::cout << "│ -e --editor : Open the Vortex "
"graphical interface │ "
<< std::endl;
std::cout << "│ -cp --create-project <...> : Create a new project "
" │ "
<< std::endl;
std::cout << "│ -i --install <...> : Install a ressource "
"into the user environment │ "
<< std::endl;
std::cout << "│ -bi --build-install <...> : Build & Install a "
"ressource into the user environment │ "
<< 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;
}
bool check_directory() {
std::ifstream mainconfig("vortex.config");
if (!mainconfig.good()) {
std::cout << "This directory does not contain a Vortex project. Please "
"initialize a new project with \"vortex --create-project "
"<project_name>\" or repair it."
<< std::endl;
return false;
}
return true;
}
std::shared_ptr<VxContext> init_runtime() {
auto ctx = vxe::create_context();
vxe::initialize_platform_vendor();
vxe::add_credits("vx", Cherry::GetPath("CREDITS"));
ctx->state.session_id = session_id;
vxe::create_global_logger();
vxe::create_console_logger();
ctx->logger = true;
vxe::create_session_topic(ctx->state.session_id);
// initialize environment
vxe::init_environment();
vxe::detect_platform();
vxe::detect_arch();
// Refresh environment registered projects
vxe::refresh_environment_projects();
vxe::load_system_templates(ctx->IO.sys_templates);
std::ifstream file("vortex.config");
if (file) {
nlohmann::json jsonContent;
file >> jsonContent;
vxe::init_project(jsonContent);
}
return ctx;
}
std::shared_ptr<VxContext> init_blank_runtime() {
auto ctx = vxe::create_context();
ctx->state.session_id = session_id;
// Link credits file
vxe::add_credits("vx", Cherry::GetPath("CREDITS"));
vxe::initialize_platform_vendor();
vxe::create_session_topic(ctx->state.session_id);
return ctx;
}
int main(int argc, char *argv[]) {
if (argc < 2) {
print_header();
} else {
if (std::string(argv[1]) == "-test") {
return 0;
} else if (std::string(argv[1]) == "--crash" || std::string(argv[1]) == "--get-last-crash") {
print_header("(Crash handler)");
if (argc > 2) {
std::string arg2 = argv[2];
if (arg2.rfind("--session_id=", 0) == 0) {
session_id = arg2.substr(13);
if (!session_id.empty() && session_id.front() == '"' && session_id.back() == '"') {
session_id = session_id.substr(1, session_id.size() - 2);
}
global_session_id = session_id;
}
}
auto ctx = init_blank_runtime();
vxe::VortexCrash(argc, argv);
} else if (std::string(argv[1]) == "-e" || std::string(argv[1]) == "--editor") {
print_header("(Editor)");
if (argc > 2) {
std::string arg2 = argv[2];
if (arg2.rfind("--session_id=", 0) == 0) {
session_id = arg2.substr(13);
if (!session_id.empty() && session_id.front() == '"' && session_id.back() == '"') {
session_id = session_id.substr(1, session_id.size() - 2);
global_session_id = session_id;
}
}
}
vxe::crash::install(session_id);
auto ctx = init_runtime();
vxe::log_info("Bootstrapp", "Opening the graphical interface...");
vxe::VortexEditor(argc, argv);
}
}
return 0;
}