Skip to content

Commit 17fccd7

Browse files
committed
refactor startGameExecutable() in DEV7Launcher
1 parent 9e23bc3 commit 17fccd7

1 file changed

Lines changed: 32 additions & 23 deletions

File tree

tools/DEV7Launcher/DEV7Launcher.cpp

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <iostream>
22
#include <fstream>
33
#include <filesystem>
4+
#include <string>
5+
#include <vector>
46

57
#include "common-code/ConsoleUtils.h"
68
#include "common-code/TaskExecution.h"
@@ -220,31 +222,38 @@ void Ed4Intro() {
220222
#endif
221223
}
222224

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;
246254
}
247255

256+
248257
int main(int argc, char* argv[]) {
249258
auto start = std::chrono::steady_clock::now(); // Record the start time
250259

0 commit comments

Comments
 (0)