diff options
author | Arisotura <thetotalworm@gmail.com> | 2020-04-25 18:48:33 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2020-04-25 18:48:33 +0200 |
commit | 3b3a09ed2b7a1f3d6f81ba6d1ddd7fbf17acd52d (patch) | |
tree | 83f92d55db61c0d6739d572c34a9f8d6cc3f940c /src/frontend/qt_sdl | |
parent | 231f0fc2e5e22b2d4907341cc191cfc9215556fb (diff) | |
parent | 5ef71181c891aceec9db7297d1642b0e70e98911 (diff) |
attempt something. maybe this worked, maybe not.
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 3f61ec6..0b9d15e 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -22,10 +22,11 @@ #include <string.h> // Qt includes and shit here, I guess +#include <QtCore/QBitArray> #include "main.h" -#include "../version.h" +#include "../../version.h" // @@ -43,3 +44,42 @@ int main(int argc, char** argv) return 0; } + +#ifdef __WIN32__ + +#include <windows.h> + +int CALLBACK WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int cmdshow) +{ + int argc = 0; + wchar_t** argv_w = CommandLineToArgvW(GetCommandLineW(), &argc); + char* nullarg = ""; + + char** argv = new char*[argc]; + for (int i = 0; i < argc; i++) + { + int len = WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, NULL, 0, NULL, NULL); + if (len < 1) return NULL; + argv[i] = new char[len]; + int res = WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, argv[i], len, NULL, NULL); + if (res != len) { delete[] argv[i]; argv[i] = nullarg; } + } + + if (AttachConsole(ATTACH_PARENT_PROCESS)) + { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + printf("\n"); + } + + int ret = main(argc, argv); + + printf("\n\n>"); + + for (int i = 0; i < argc; i++) if (argv[i] != nullarg) delete[] argv[i]; + delete[] argv; + + return ret; +} + +#endif |