support a command line switch "--debug" (or "-d") to enable debug mode

This commit is contained in:
Sebastian Krzyszkowiak 2019-03-28 15:33:21 +01:00
parent 6d7007b39e
commit a309b8cb2b
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF

View file

@ -22,6 +22,7 @@
#include "internal.h"
#include <dlfcn.h>
#include <getopt.h>
#include <libgen.h>
#include <locale.h>
#include <unistd.h>
@ -52,6 +53,9 @@ static char* GetDefaultWindowHeight(struct Game* game) {
SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char* name, struct Params params) {
struct Game* game = calloc(1, sizeof(struct Game));
game->_priv.argc = argc;
game->_priv.argv = argv;
game->_priv.name = strdup(name);
game->_priv.params = params;
@ -126,6 +130,21 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
game->config.fullscreen = false; // we can't start fullscreen on emscripten
#endif
static struct option long_options[] =
{
{"debug", no_argument, NULL, 'd'},
{NULL, 0, NULL, 0},
};
char opt;
while ((opt = getopt_long(argc, argv, "d", long_options, NULL)) != -1) {
switch (opt) {
case 'd':
game->config.debug.enabled = true;
break;
}
}
game->_priv.showconsole = game->config.debug.enabled;
game->_priv.showtimeline = false;
@ -320,9 +339,6 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
setlocale(LC_NUMERIC, "C");
game->_priv.argc = argc;
game->_priv.argv = argv;
game->data = NULL;
game->_priv.shutting_down = false;