5LPWSTR* extractAndCheck(
int& argc, std::filesystem::path& currentExecutableDirPath, std::filesystem::path& pythonExecutablePath)
7 LPWSTR* argvW =
nullptr;
9 LPWSTR lpCmdLineW = GetCommandLineW();
11 argvW = CommandLineToArgvW(lpCmdLineW, &argc);
18 wchar_t currentExecutablePathBuf[MAX_PATH];
19 GetModuleFileNameW(NULL, currentExecutablePathBuf, MAX_PATH);
21 currentExecutableDirPath = std::filesystem::path(currentExecutablePathBuf).parent_path();
22 pythonExecutablePath = currentExecutableDirPath / L
".." / L
"Python" / PYTHON_BIN_NAME;
24 if (!std::filesystem::exists(pythonExecutablePath))
26 MessageBoxW(NULL, (L
"Error: python.exe not found at " + pythonExecutablePath.wstring() + L
"\nPlease ensure python.exe is in the same directory as this executable.").c_str(), L
"Launcher Error", MB_OK | MB_ICONERROR);
33 MessageBoxW(NULL, L
"Error: No command line arguments provided.", L
"Launcher Error", MB_OK | MB_ICONERROR);
42std::wstring commandLineConverter(std::wstring scriptFileName, std::filesystem::path pythonExecutablePath, LPWSTR* argvW,
int argc,
bool& console)
45 std::wstringstream commandLineStream;
47 commandLineStream << L
"\"" << pythonExecutablePath.wstring() << L
"\"";
48 commandLineStream << L
" \"" << scriptFileName << L
"\"";
50 bool bOtherArgs =
false;
51 bool bImportModel =
false;
55 for (
int i = 1; i < argc; ++i)
57 std::wstring arglo = argvW[i];
58 std::transform(arglo.begin(), arglo.end(), arglo.begin(), [](
auto c) { return towlower(c); });
59 if (arglo == std::wstring(L
"--console"))
64 else if (arglo == std::wstring(L
"--verbose"))
68 else if (arglo == std::wstring(L
"--gui"))
72 else if (arglo == std::wstring(L
"--import-model"))
80 commandLineStream << L
" \"" << argvW[i] << L
"\"";
83 console = console || (bOtherArgs && !gui) || bImportModel;
87 return commandLineStream.str();