Add -console option on Windows

This adds the `-console` command-line option (for Win32 only) so the
game can spawn an attached console window which will contain all console
output.

This is to make it easier for people to debug on Windows systems.
Otherwise, the only way to get console output would be to either compile
the application as a console app (i.e. switch the subsystem to console)
- which is undesirable for regular users as this makes it so a console
is always spawned even when unwanted - or launch the game with shell
arguments that make it so output is redirected to a file.

As a result, color checking support is factored out of vlog_init() into
its own function, even though we don't support colors on Windows.
This commit is contained in:
Misa
2022-11-14 19:34:48 -08:00
parent 5bb3768782
commit 3fc23f2b2c
3 changed files with 61 additions and 2 deletions

View File

@@ -369,6 +369,9 @@ int main(int argc, char *argv[])
char* baseDir = NULL;
char* assetsPath = NULL;
bool seed_use_sdl_getticks = false;
#ifdef _WIN32
bool open_console = false;
#endif
vlog_init();
@@ -479,6 +482,12 @@ int main(int argc, char *argv[])
{
vlog_toggle_error(0);
}
#ifdef _WIN32
else if (ARG("-console"))
{
open_console = true;
}
#endif
else if (ARG("-seed-use-sdl-getticks"))
{
seed_use_sdl_getticks = true;
@@ -492,6 +501,13 @@ int main(int argc, char *argv[])
}
}
#ifdef _WIN32
if (open_console)
{
vlog_open_console();
}
#endif
if(!FILESYSTEM_init(argv[0], baseDir, assetsPath))
{
vlog_error("Unable to initialize filesystem!");