mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-04 16:28:00 +01:00
some stuff blocked by allegro bugs
This commit is contained in:
parent
e04a52ea35
commit
fbedd1c7e7
4 changed files with 51 additions and 2 deletions
|
@ -555,7 +555,11 @@ SYMBOL_INTERNAL void PauseExecution(struct Game* game) {
|
|||
}
|
||||
game->_priv.paused = true;
|
||||
al_stop_timer(game->_priv.timer);
|
||||
if (game->audio.v) {
|
||||
al_detach_voice(game->audio.v);
|
||||
}
|
||||
al_set_default_voice(NULL);
|
||||
game->audio.v = NULL;
|
||||
FreezeGamestates(game);
|
||||
PrintConsole(game, "Engine halted.");
|
||||
}
|
||||
|
@ -589,7 +593,26 @@ SYMBOL_INTERNAL void ResumeExecution(struct Game* game) {
|
|||
return;
|
||||
}
|
||||
UnfreezeGamestates(game);
|
||||
al_attach_mixer_to_voice(game->audio.mixer, game->audio.v);
|
||||
ALLEGRO_AUDIO_DEPTH depth = ALLEGRO_AUDIO_DEPTH_FLOAT32;
|
||||
#ifdef ALLEGRO_ANDROID
|
||||
depth = ALLEGRO_AUDIO_DEPTH_INT16;
|
||||
#endif
|
||||
game->audio.v = al_create_voice(44100, depth, ALLEGRO_CHANNEL_CONF_2);
|
||||
if (!game->audio.v) {
|
||||
// fallback
|
||||
depth = (depth == ALLEGRO_AUDIO_DEPTH_FLOAT32) ? ALLEGRO_AUDIO_DEPTH_INT16 : ALLEGRO_AUDIO_DEPTH_FLOAT32;
|
||||
game->audio.v = al_create_voice(44100, depth, ALLEGRO_CHANNEL_CONF_2);
|
||||
}
|
||||
al_set_default_voice(game->audio.v);
|
||||
if (game->audio.v) {
|
||||
al_attach_mixer_to_voice(game->audio.mixer, game->audio.v);
|
||||
} else {
|
||||
PrintConsole(game, "AUUUDIOOOOOOO DIDN'T WOOOORK");
|
||||
}
|
||||
//al_set_mixer_playing(game->audio.mixer, true);
|
||||
//al_set_mixer_playing(game->audio.music, true);
|
||||
//al_set_mixer_playing(game->audio.fx, true);
|
||||
//al_set_mixer_playing(game->audio.voice, true);
|
||||
al_resume_timer(game->_priv.timer);
|
||||
game->_priv.paused = false;
|
||||
game->_priv.timestamp = al_get_time();
|
||||
|
|
|
@ -96,6 +96,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
|||
game->_priv.shaders = NULL;
|
||||
|
||||
game->_priv.paused = false;
|
||||
game->_priv.candraw = true;
|
||||
|
||||
game->handlers.event = NULL;
|
||||
game->handlers.destroy = NULL;
|
||||
|
@ -301,6 +302,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
|||
al_set_mixer_gain(game->audio.music, game->config.music / 10.0);
|
||||
al_set_mixer_gain(game->audio.voice, game->config.voice / 10.0);
|
||||
al_set_mixer_gain(game->audio.mixer, game->config.mute ? 0.0 : 1.0);
|
||||
al_set_default_voice(game->audio.v);
|
||||
al_set_default_mixer(game->audio.mixer);
|
||||
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
|
|
@ -143,6 +143,7 @@ struct Game {
|
|||
} clip_rect;
|
||||
|
||||
bool paused;
|
||||
bool candraw;
|
||||
|
||||
volatile bool texture_sync;
|
||||
ALLEGRO_MUTEX* texture_sync_mutex;
|
||||
|
|
|
@ -32,15 +32,35 @@ static inline void HandleEvent(struct Game* game, ALLEGRO_EVENT* ev) {
|
|||
break;
|
||||
|
||||
case ALLEGRO_EVENT_DISPLAY_HALT_DRAWING:
|
||||
PauseExecution(game);
|
||||
PrintConsole(game, "ALLEGRO_EVENT_DISPLAY_HALT_DRAWING");
|
||||
al_acknowledge_drawing_halt(game->display);
|
||||
PauseExecution(game);
|
||||
game->_priv.candraw = false;
|
||||
break;
|
||||
|
||||
case ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING:
|
||||
PrintConsole(game, "ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING");
|
||||
al_acknowledge_drawing_resume(game->display);
|
||||
game->_priv.candraw = true;
|
||||
ReloadGamestates(game);
|
||||
ResumeExecution(game);
|
||||
break;
|
||||
|
||||
#ifdef ALLEGRO_ANDROID
|
||||
/*
|
||||
case ALLEGRO_EVENT_DISPLAY_SWITCH_OUT:
|
||||
PrintConsole(game, "ALLEGRO_EVENT_DISPLAY_SWITCH_OUT");
|
||||
PauseExecution(game);
|
||||
break;
|
||||
|
||||
case ALLEGRO_EVENT_DISPLAY_SWITCH_IN:
|
||||
PrintConsole(game, "ALLEGRO_EVENT_DISPLAY_SWITCH_IN");
|
||||
if (game->_priv.candraw) {
|
||||
ResumeExecution(game);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
#endif
|
||||
|
||||
case ALLEGRO_EVENT_DISPLAY_RESIZE:
|
||||
al_acknowledge_resize(game->display);
|
||||
|
@ -353,10 +373,13 @@ static inline bool MainloopEvents(struct Game* game) {
|
|||
|
||||
if (game->_priv.paused) {
|
||||
// there's no frame flipping when paused, so avoid pointless busylooping
|
||||
PrintConsole(game, "waiting for events");
|
||||
al_wait_for_event(game->_priv.event_queue, &ev);
|
||||
} else if (!al_get_next_event(game->_priv.event_queue, &ev)) {
|
||||
PrintConsole(game, "breaking from events");
|
||||
break;
|
||||
}
|
||||
PrintConsole(game, "handling an event");
|
||||
|
||||
if (game->handlers.event) {
|
||||
if ((*game->handlers.event)(game, &ev)) {
|
||||
|
|
Loading…
Reference in a new issue