Add --show-console option

This commit is contained in:
Mr-Wiseguy
2025-09-07 22:59:41 -04:00
parent 79321e7f86
commit dd61fa8953
3 changed files with 29 additions and 2 deletions
+1 -1
View File
@@ -290,7 +290,7 @@ if (WIN32)
)
# target_sources(BanjoRecompiled PRIVATE ${CMAKE_SOURCE_DIR}/icons/app.rc)
target_link_libraries(BanjoRecompiled PRIVATE SDL2)
target_link_libraries(BanjoRecompiled PRIVATE SDL2 Winmm.lib)
endif()
if (APPLE)
+2 -1
View File
@@ -7,7 +7,8 @@
"project": "CMakeLists.txt",
"projectTarget": "BanjoRecompiled.exe",
"name": "BanjoRecompiled.exe",
"currentDir": "${workspaceRoot}"
"currentDir": "${workspaceRoot}",
"args": ["--show-console"]
}
]
}
+26
View File
@@ -42,6 +42,7 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <timeapi.h>
#include "SDL_syswm.h"
#endif
@@ -543,6 +544,26 @@ int main(int argc, char** argv) {
}
#ifdef _WIN32
// Set up high resolution timing period.
timeBeginPeriod(1);
// Process arguments.
for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "--show-console") == 0)
{
if (GetConsoleWindow() == nullptr)
{
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stderr);
freopen("CONOUT$", "w", stdout);
}
break;
}
}
// Set up console output to accept UTF-8 on windows
SetConsoleOutputCP(CP_UTF8);
@@ -683,5 +704,10 @@ int main(int argc, char** argv) {
release_preload(preload_context);
}
#ifdef _WIN32
// End high resolution timing period.
timeEndPeriod(1);
#endif
return EXIT_SUCCESS;
}