add config switches for various debug options

This commit is contained in:
Sebastian Krzyszkowiak 2018-08-09 00:05:25 +02:00
parent e5dd715eb2
commit 7d4575308d
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
4 changed files with 12 additions and 6 deletions

View file

@ -558,7 +558,7 @@ SYMBOL_INTERNAL void ResumeExecution(struct Game* game) {
PrintConsole(game, "DEBUG: reloading the gamestates...");
struct Gamestate* tmp = game->_priv.gamestates;
while (tmp) {
if (tmp->fromlib) {
if (game->_priv.debug.livereload && tmp->fromlib) {
char* name = strdup(tmp->name);
CloseGamestate(game, tmp);
tmp->name = name;

View file

@ -95,12 +95,15 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
game->config.fx = strtol(GetConfigOptionDefault(game, "SuperDerpy", "fx", "10"), NULL, 10);
game->config.mute = strtol(GetConfigOptionDefault(game, "SuperDerpy", "mute", "0"), NULL, 10);
game->config.debug = strtol(GetConfigOptionDefault(game, "SuperDerpy", "debug", "0"), NULL, 10);
game->config.verbose = strtol(GetConfigOptionDefault(game, "SuperDerpy", "verbose", "0"), NULL, 10);
game->config.width = strtol(GetConfigOptionDefault(game, "SuperDerpy", "width", "1280"), NULL, 10);
if (game->config.width < 320) { game->config.width = 320; }
game->config.height = strtol(GetConfigOptionDefault(game, "SuperDerpy", "height", "720"), NULL, 10);
if (game->config.height < 180) { game->config.height = 180; }
game->_priv.debug.verbose = strtol(GetConfigOptionDefault(game, "debug", "verbose", "0"), NULL, 10);
game->_priv.debug.livereload = strtol(GetConfigOptionDefault(game, "debug", "livereload", "1"), NULL, 10);
game->_priv.debug.autopause = strtol(GetConfigOptionDefault(game, "debug", "autopause", "1"), NULL, 10);
game->_priv.showconsole = game->config.debug;
game->_priv.showtimeline = false;
@ -567,9 +570,9 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) {
} else if (ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE) {
al_acknowledge_resize(game->display);
SetupViewport(game, game->viewport_config);
} else if ((game->config.debug) && (ev.type == ALLEGRO_EVENT_DISPLAY_SWITCH_OUT)) {
} else if ((game->config.debug) && (game->_priv.debug.autopause) && (ev.type == ALLEGRO_EVENT_DISPLAY_SWITCH_OUT)) {
PauseExecution(game);
} else if ((game->config.debug) && (ev.type == ALLEGRO_EVENT_DISPLAY_SWITCH_IN)) {
} else if ((game->config.debug) && (game->_priv.debug.autopause) && (ev.type == ALLEGRO_EVENT_DISPLAY_SWITCH_IN)) {
ResumeExecution(game);
}
#ifdef ALLEGRO_ANDROID

View file

@ -86,7 +86,6 @@ struct Game {
bool mute; /*!< Whether audio should be muted globally. */
bool fullscreen; /*!< Fullscreen toggle. */
bool debug; /*!< Toggles debug mode. */
bool verbose; /*!< Toggles verbose debug. */
int width; /*!< Width of window as being set in configuration. */
int height; /*!< Height of window as being set in configuration. */
} config;
@ -151,6 +150,10 @@ struct Game {
ALLEGRO_MUTEX* texture_sync_mutex;
ALLEGRO_COND* texture_sync_cond;
struct {
bool verbose, livereload, autopause;
} debug;
#ifdef ALLEGRO_MACOSX
char cwd[MAXPATHLEN];
#endif

View file

@ -401,7 +401,7 @@ __attribute__((__format__(__printf__, 5, 0))) SYMBOL_EXPORT void PrintConsoleWit
if (game->config.debug)
#endif
{
if (game->config.verbose) {
if (game->_priv.debug.verbose) {
printf("%s:%d ", file, line);
}
printf("[%s] %s\n", func, text);