move showconsole variable to public struct

This commit is contained in:
Sebastian Krzyszkowiak 2019-12-08 09:23:56 +01:00
parent 9ce1957968
commit 1d8fb9f2f3
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
4 changed files with 13 additions and 12 deletions

View file

@ -215,7 +215,7 @@ SYMBOL_INTERNAL int SetupAudio(struct Game* game) {
SYMBOL_INTERNAL void DrawConsole(struct Game* game) {
double game_time = al_get_time();
if (game->_priv.showconsole) {
if (game->show_console) {
al_set_target_backbuffer(game->display);
ALLEGRO_TRANSFORM trans;
al_identity_transform(&trans);
@ -290,7 +290,7 @@ SYMBOL_INTERNAL void* GamestateLoadingThread(void* arg) {
#ifndef LIBSUPERDERPY_SINGLE_THREAD
if (data->game->config.debug.enabled) {
PrintConsole(data->game, "(sleeping for 3 seconds...)");
data->game->_priv.showconsole = true;
data->game->show_console = true;
al_rest(3.0);
}
#endif
@ -595,7 +595,7 @@ static void DrawTimeline(struct Game* game, struct Timeline* timeline, int pos)
}
SYMBOL_INTERNAL void DrawTimelines(struct Game* game) {
if (!game->_priv.showtimeline) {
if (!game->_priv.show_timeline) {
return;
}
struct List* tmp = game->_priv.timelines;

View file

@ -160,8 +160,8 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
}
}
game->_priv.showconsole = game->config.debug.enabled;
game->_priv.showtimeline = false;
game->show_console = game->config.debug.enabled;
game->_priv.show_timeline = false;
if (!al_init_image_addon()) {
fprintf(stderr, "failed to initialize image addon!\n");

View file

@ -183,6 +183,8 @@ struct Game {
} debug; /*!< Debug mode settings. */
} config; /*!< Configuration values from the config file. */
bool show_console; /*!< If true, game console is rendered on screen. */
struct {
int x, y;
int w, h;
@ -211,8 +213,7 @@ struct Game {
char console[5][1024];
unsigned int console_pos;
ALLEGRO_EVENT_QUEUE* event_queue; /*!< Main event queue. */
bool showconsole; /*!< If true, game console is rendered on screen. */
bool showtimeline;
bool show_timeline;
double speed; /*!< Speed of the game in FPS. 60 == 1x */

View file

@ -72,9 +72,9 @@ static inline bool HandleEvent(struct Game* game, ALLEGRO_EVENT* ev) {
#else
if ((ev->keyboard.keycode == ALLEGRO_KEY_TILDE) || (ev->keyboard.keycode == ALLEGRO_KEY_BACKQUOTE)) {
#endif
game->_priv.showconsole = !game->_priv.showconsole;
game->show_console = !game->show_console;
if ((ev->keyboard.modifiers & ALLEGRO_KEYMOD_CTRL) && (game->config.debug.enabled)) {
game->_priv.showtimeline = game->_priv.showconsole;
game->_priv.show_timeline = game->show_console;
}
}
@ -183,7 +183,7 @@ static inline void HandleDebugEvent(struct Game* game, ALLEGRO_EVENT* ev) {
break;
case ALLEGRO_KEY_F9:
game->_priv.speed = ALLEGRO_BPS_TO_SECS(60.0);
game->_priv.showconsole = true;
game->show_console = true;
PrintConsole(game, "DEBUG: Gameplay speed: 1.00x");
break;
case ALLEGRO_KEY_F10: {
@ -191,7 +191,7 @@ static inline void HandleDebugEvent(struct Game* game, ALLEGRO_EVENT* ev) {
speed -= 10;
if (speed < 10) { speed = 10; }
game->_priv.speed = ALLEGRO_BPS_TO_SECS(speed);
game->_priv.showconsole = true;
game->show_console = true;
PrintConsole(game, "DEBUG: Gameplay speed: %.2fx", speed / 60.0);
} break;
case ALLEGRO_KEY_F11: {
@ -199,7 +199,7 @@ static inline void HandleDebugEvent(struct Game* game, ALLEGRO_EVENT* ev) {
speed += 10;
if (speed > 600) { speed = 600; }
game->_priv.speed = ALLEGRO_BPS_TO_SECS(speed);
game->_priv.showconsole = true;
game->show_console = true;
PrintConsole(game, "DEBUG: Gameplay speed: %.2fx", speed / 60.0);
} break;
}