mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
put debug config into public config struct
This commit is contained in:
parent
ce66ba8060
commit
b9b231a438
6 changed files with 21 additions and 20 deletions
|
@ -111,7 +111,7 @@ SYMBOL_EXPORT void LoadSpritesheets(struct Game* game, struct Character* charact
|
|||
}
|
||||
for (int i = 0; i < tmp->frameCount; i++) {
|
||||
if ((!tmp->frames[i].source) && (tmp->frames[i].file)) {
|
||||
if (game->config.debug) {
|
||||
if (game->config.debug.enabled) {
|
||||
PrintConsole(game, " - %s", tmp->frames[i].file);
|
||||
}
|
||||
char filename[255] = {0};
|
||||
|
|
|
@ -249,7 +249,7 @@ SYMBOL_INTERNAL void* GamestateLoadingThread(void* arg) {
|
|||
data->gamestate->data = data->gamestate->api->Gamestate_Load(data->game, &GamestateProgress);
|
||||
if (data->game->_priv.loading.progress != data->gamestate->progressCount) {
|
||||
PrintConsole(data->game, "[%s] WARNING: Gamestate_ProgressCount does not match the number of progress invokations (%d)!", data->gamestate->name, data->game->_priv.loading.progress);
|
||||
if (data->game->config.debug) {
|
||||
if (data->game->config.debug.enabled) {
|
||||
PrintConsole(data->game, "(sleeping for 3 seconds...)");
|
||||
data->game->_priv.showconsole = true;
|
||||
al_rest(3.0);
|
||||
|
@ -277,7 +277,7 @@ SYMBOL_INTERNAL void* ScreenshotThread(void* arg) {
|
|||
SYMBOL_INTERNAL void CalculateProgress(struct Game* game) {
|
||||
struct Gamestate* tmp = game->_priv.loading.current;
|
||||
float progress = ((game->_priv.loading.progress / (float)(tmp->progressCount + 1)) / (float)game->_priv.loading.toLoad) + (game->_priv.loading.loaded / (float)game->_priv.loading.toLoad);
|
||||
if (game->config.debug) {
|
||||
if (game->config.debug.enabled) {
|
||||
PrintConsole(game, "[%s] Progress: %d%% (%d/%d)", tmp->name, (int)(progress * 100), game->_priv.loading.progress, tmp->progressCount + 1);
|
||||
}
|
||||
game->loading.progress = progress;
|
||||
|
|
|
@ -108,17 +108,17 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
|||
game->config.voice = strtol(GetConfigOptionDefault(game, "SuperDerpy", "voice", "10"), NULL, 10);
|
||||
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.debug.enabled = strtol(GetConfigOptionDefault(game, "SuperDerpy", "debug", "0"), NULL, 10);
|
||||
game->config.width = strtol(GetConfigOptionDefault(game, "SuperDerpy", "width", GetDefaultWindowWidth(game)), NULL, 10);
|
||||
if (game->config.width < 100) { game->config.width = 100; }
|
||||
game->config.height = strtol(GetConfigOptionDefault(game, "SuperDerpy", "height", GetDefaultWindowHeight(game)), NULL, 10);
|
||||
if (game->config.height < 100) { game->config.height = 100; }
|
||||
|
||||
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->config.debug.verbose = strtol(GetConfigOptionDefault(game, "debug", "verbose", "0"), NULL, 10);
|
||||
game->config.debug.livereload = strtol(GetConfigOptionDefault(game, "debug", "livereload", "1"), NULL, 10);
|
||||
game->config.debug.autopause = strtol(GetConfigOptionDefault(game, "debug", "autopause", "1"), NULL, 10);
|
||||
|
||||
game->_priv.showconsole = game->config.debug;
|
||||
game->_priv.showconsole = game->config.debug.enabled;
|
||||
game->_priv.showtimeline = false;
|
||||
|
||||
if (!al_init_image_addon()) {
|
||||
|
|
|
@ -157,9 +157,14 @@ struct Game {
|
|||
int voice; /*!< Voice volume. */
|
||||
bool mute; /*!< Whether audio should be muted globally. */
|
||||
bool fullscreen; /*!< Fullscreen toggle. */
|
||||
bool debug; /*!< Toggles debug mode. */
|
||||
int width; /*!< Width of window as being set in configuration. */
|
||||
int height; /*!< Height of window as being set in configuration. */
|
||||
struct {
|
||||
bool enabled; /*!< Toggles debug mode. */
|
||||
bool verbose; /*!< Prints file names and line numbers with every message. */
|
||||
bool livereload; /*!< Automatically reloads gamestates on window focus. */
|
||||
bool autopause; /*!< Pauses/resumes the game when the window loses/gains focus. */
|
||||
} debug; /*!< Debug mode settings. */
|
||||
} config; /*!< Configuration values from the config file. */
|
||||
|
||||
struct {
|
||||
|
@ -237,10 +242,6 @@ struct Game {
|
|||
bool shutting_down; /*!< If true then shut down of the game is pending. */
|
||||
bool restart; /*!< If true then restart of the game is pending. */
|
||||
|
||||
struct {
|
||||
bool verbose, livereload, autopause;
|
||||
} debug;
|
||||
|
||||
ALLEGRO_TRANSFORM projection; /*!< Projection of the game canvas into the actual game window. */
|
||||
|
||||
#ifdef ALLEGRO_MACOSX
|
||||
|
|
|
@ -59,7 +59,7 @@ static inline void HandleEvent(struct Game* game, ALLEGRO_EVENT* ev) {
|
|||
if ((ev->keyboard.keycode == ALLEGRO_KEY_TILDE) || (ev->keyboard.keycode == ALLEGRO_KEY_BACKQUOTE)) {
|
||||
#endif
|
||||
game->_priv.showconsole = !game->_priv.showconsole;
|
||||
if ((ev->keyboard.modifiers & ALLEGRO_KEYMOD_CTRL) && (game->config.debug)) {
|
||||
if ((ev->keyboard.modifiers & ALLEGRO_KEYMOD_CTRL) && (game->config.debug.enabled)) {
|
||||
game->_priv.showtimeline = game->_priv.showconsole;
|
||||
}
|
||||
}
|
||||
|
@ -131,15 +131,15 @@ static inline void HandleEvent(struct Game* game, ALLEGRO_EVENT* ev) {
|
|||
static inline void HandleDebugEvent(struct Game* game, ALLEGRO_EVENT* ev) {
|
||||
switch (ev->type) {
|
||||
case ALLEGRO_EVENT_DISPLAY_SWITCH_OUT:
|
||||
if (game->_priv.debug.autopause) {
|
||||
if (game->config.debug.autopause) {
|
||||
PrintConsole(game, "DEBUG: autopause");
|
||||
PauseExecution(game);
|
||||
}
|
||||
break;
|
||||
|
||||
case ALLEGRO_EVENT_DISPLAY_SWITCH_IN:
|
||||
if (game->_priv.debug.autopause) {
|
||||
if (game->_priv.debug.livereload) {
|
||||
if (game->config.debug.autopause) {
|
||||
if (game->config.debug.livereload) {
|
||||
ReloadCode(game);
|
||||
}
|
||||
ResumeExecution(game);
|
||||
|
@ -424,7 +424,7 @@ static inline bool MainloopEvents(struct Game* game) {
|
|||
|
||||
HandleEvent(game, &ev);
|
||||
|
||||
if (game->config.debug) {
|
||||
if (game->config.debug.enabled) {
|
||||
HandleDebugEvent(game, &ev);
|
||||
}
|
||||
|
||||
|
|
|
@ -429,10 +429,10 @@ SYMBOL_EXPORT void PrintConsoleWithContext(struct Game* game, int line, const ch
|
|||
SUPPRESS_END
|
||||
|
||||
#if !defined(__EMSCRIPTEN__) && !defined(ALLEGRO_ANDROID)
|
||||
if (game->config.debug)
|
||||
if (game->config.debug.enabled)
|
||||
#endif
|
||||
{
|
||||
if (game->_priv.debug.verbose) {
|
||||
if (game->config.debug.verbose) {
|
||||
printf("%s:%d ", file, line);
|
||||
}
|
||||
printf("[%s] %s\n", func, text);
|
||||
|
|
Loading…
Reference in a new issue