mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
debug: decouple livereload from autopause
This commit is contained in:
parent
7d4575308d
commit
916094b371
3 changed files with 13 additions and 2 deletions
|
@ -553,12 +553,12 @@ SYMBOL_INTERNAL void PauseExecution(struct Game* game) {
|
|||
PrintConsole(game, "DEBUG: game execution paused.");
|
||||
}
|
||||
|
||||
SYMBOL_INTERNAL void ResumeExecution(struct Game* game) {
|
||||
SYMBOL_INTERNAL void ReloadCode(struct Game* game) {
|
||||
ReloadShaders(game, true);
|
||||
PrintConsole(game, "DEBUG: reloading the gamestates...");
|
||||
struct Gamestate* tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if (game->_priv.debug.livereload && tmp->fromlib) {
|
||||
if (tmp->fromlib) {
|
||||
char* name = strdup(tmp->name);
|
||||
CloseGamestate(game, tmp);
|
||||
tmp->name = name;
|
||||
|
@ -571,7 +571,13 @@ SYMBOL_INTERNAL void ResumeExecution(struct Game* game) {
|
|||
tmp->loaded = false;
|
||||
}
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
SYMBOL_INTERNAL void ResumeExecution(struct Game* game) {
|
||||
struct Gamestate* tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if (!tmp->paused && tmp->loaded && tmp->started && tmp->api->Gamestate_Resume) {
|
||||
tmp->api->Gamestate_Resume(game, tmp->data);
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ void CloseGamestate(struct Game* game, struct Gamestate* gamestate);
|
|||
struct Gamestate* AllocateGamestate(struct Game* game, const char* name);
|
||||
char* GetLibraryPath(struct Game* game, char* filename);
|
||||
void PauseExecution(struct Game* game);
|
||||
void ReloadCode(struct Game* game);
|
||||
void ResumeExecution(struct Game* game);
|
||||
void ReloadShaders(struct Game* game, bool force);
|
||||
void DestroyShaders(struct Game* game);
|
||||
|
|
|
@ -573,6 +573,9 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) {
|
|||
} else if ((game->config.debug) && (game->_priv.debug.autopause) && (ev.type == ALLEGRO_EVENT_DISPLAY_SWITCH_OUT)) {
|
||||
PauseExecution(game);
|
||||
} else if ((game->config.debug) && (game->_priv.debug.autopause) && (ev.type == ALLEGRO_EVENT_DISPLAY_SWITCH_IN)) {
|
||||
if (game->_priv.debug.livereload) {
|
||||
ReloadCode(game);
|
||||
}
|
||||
ResumeExecution(game);
|
||||
}
|
||||
#ifdef ALLEGRO_ANDROID
|
||||
|
@ -588,6 +591,7 @@ SYMBOL_INTERNAL void libsuperderpy_mainloop(void* g) {
|
|||
if (!game->_priv.paused) {
|
||||
PauseExecution(game);
|
||||
} else {
|
||||
ReloadCode(game);
|
||||
ResumeExecution(game);
|
||||
}
|
||||
} else if ((ev.type == ALLEGRO_EVENT_KEY_DOWN) && (game->config.debug) && (ev.keyboard.keycode == ALLEGRO_KEY_F9)) {
|
||||
|
|
Loading…
Reference in a new issue