|
1 | 1 | #include <iostream> |
2 | 2 | #include <fstream> |
3 | 3 | #include <filesystem> |
| 4 | +#include <string> |
| 5 | +#include <vector> |
4 | 6 |
|
5 | 7 | #include "common-code/ConsoleUtils.h" |
6 | 8 | #include "common-code/TaskExecution.h" |
@@ -220,31 +222,38 @@ void Ed4Intro() { |
220 | 222 | #endif |
221 | 223 | } |
222 | 224 |
|
223 | | -void startGameExecutable() { // TODO: Function refactor/rework has to be done from scratch |
224 | | - if (fileExists("LoaderMDO.exe")) |
225 | | - std::cout << "LoaderMDO.exe found. Starting LoaderMDO.exe..." << std::endl, launchCommand("LoaderMDO.exe"); |
226 | | - else if (fileExists("LoaderMDO.exe")) |
227 | | - std::cout << "LoaderMDO.exe found. Starting LoaderMDO.exe over wine..." << std::endl, launchCommand("wine LoaderMDO.exe"); |
228 | | - else if (fileExists("Adibou3.EXE")) |
229 | | - std::cout << "Adibou3.EXE found. Starting Adibou3.EXE..." << std::endl, launchCommand("Adibou3.EXE"); |
230 | | - else if (fileExists("Adibou3.exe")) |
231 | | - std::cout << "Adibou3.exe found. Starting Adibou3.exe over wine..." << std::endl, launchCommand("wine adibou3.exe"); |
232 | | - else if (fileExists("adiboo3.exe")) |
233 | | - std::cout << "adiboo3.exe found. Starting adiboo3.exe..." << std::endl, launchCommand("adiboo3.exe"); |
234 | | - else if (fileExists("adiboo3.exe")) |
235 | | - std::cout << "adiboo3.exe found. Starting adiboo3.exe over wine..." << std::endl, launchCommand("wine adiboo3.exe"); |
236 | | - else if (fileExists("ADI5.EXE")) |
237 | | - std::cout << "ADI5.EXE found. Starting ADI5.EXE..." << std::endl, launchCommand("ADI5.EXE"); |
238 | | - else if (fileExists("ADI5.exe")) |
239 | | - std::cout << "ADI5.exe found. Starting ADI5.exe over wine..." << std::endl, launchCommand("wine ADI5.exe"); |
240 | | - else if (fileExists("Loader7.exe")) |
241 | | - std::cout << "Loader7.exe found. Starting ADI5.EXE..." << std::endl, launchCommand("Loader7.exe"); |
242 | | - else if (fileExists("Loader7.exe")) |
243 | | - std::cout << "Loader7.exe found. Starting Loader7.exe over wine..." << std::endl, launchCommand("wine Loader7.exe"); |
244 | | - else |
245 | | - printf("None of the executables found. \nPlease make sure you have the exe in the same Directory as the Launcher."); |
| 225 | +void startGameExecutable() { |
| 226 | + struct ExecutableOption { |
| 227 | + std::string fileName; |
| 228 | + std::string command; |
| 229 | + bool useWine; |
| 230 | + }; |
| 231 | + |
| 232 | + std::vector<ExecutableOption> executables = { |
| 233 | + {"LoaderMDO.exe", "LoaderMDO.exe", false}, |
| 234 | + {"LoaderMDO.exe", "wine LoaderMDO.exe", true}, |
| 235 | + {"Adibou3.EXE", "Adibou3.EXE", false}, |
| 236 | + {"Adibou3.exe", "wine Adibou3.exe", true}, |
| 237 | + {"adiboo3.exe", "adiboo3.exe", false}, |
| 238 | + {"adiboo3.exe", "wine adiboo3.exe", true}, |
| 239 | + {"ADI5.EXE", "ADI5.EXE", false}, |
| 240 | + {"ADI5.exe", "wine ADI5.exe", true}, |
| 241 | + {"Loader7.exe", "Loader7.exe", false}, |
| 242 | + {"Loader7.exe", "wine Loader7.exe", true} |
| 243 | + }; |
| 244 | + |
| 245 | + for (const auto& exe : executables) { |
| 246 | + if (fileExists(exe.fileName)) { |
| 247 | + std::cout << exe.fileName << " found. Starting " << exe.command << "..." << std::endl; |
| 248 | + launchCommand(exe.command); |
| 249 | + return; |
| 250 | + } |
| 251 | + } |
| 252 | + |
| 253 | + std::cout << "None of the executables found.\nPlease make sure you have the exe in the same directory as the launcher." << std::endl; |
246 | 254 | } |
247 | 255 |
|
| 256 | + |
248 | 257 | int main(int argc, char* argv[]) { |
249 | 258 | auto start = std::chrono::steady_clock::now(); // Record the start time |
250 | 259 |
|
|
0 commit comments