mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
add a bunch of new gamestate lifecycle methods to simplify game pausing
This commit is contained in:
parent
d9a1484084
commit
b927a0c130
4 changed files with 37 additions and 25 deletions
|
@ -190,6 +190,26 @@ SYMBOL_EXPORT void UnloadAllGamestates(struct Game *game) {
|
|||
}
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void PauseAllGamestates(struct Game *game) {
|
||||
struct Gamestate *tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if (tmp->started || !tmp->paused) {
|
||||
PauseGamestate(game, tmp->name);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void ResumeAllGamestates(struct Game *game) {
|
||||
struct Gamestate *tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if (tmp->paused) {
|
||||
ResumeGamestate(game, tmp->name);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void SwitchGamestate(struct Game *game, const char* current, const char* n) {
|
||||
StopGamestate(game, current);
|
||||
UnloadGamestate(game, current);
|
||||
|
@ -210,3 +230,15 @@ SYMBOL_EXPORT void SwitchCurrentGamestate(struct Game *game, const char* n) {
|
|||
SYMBOL_EXPORT void ChangeCurrentGamestate(struct Game *game, const char* n) {
|
||||
ChangeGamestate(game, game->_priv.current_gamestate->name, n);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void StopCurrentGamestate(struct Game *game) {
|
||||
StopGamestate(game, game->_priv.current_gamestate->name);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void PauseCurrentGamestate(struct Game *game) {
|
||||
PauseGamestate(game, game->_priv.current_gamestate->name);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void UnloadCurrentGamestate(struct Game *game) {
|
||||
UnloadGamestate(game, game->_priv.current_gamestate->name);
|
||||
}
|
||||
|
|
|
@ -61,10 +61,15 @@ void StartGamestate(struct Game *game, const char* name);
|
|||
void StopGamestate(struct Game *game, const char* name);
|
||||
void PauseGamestate(struct Game *game, const char* name);
|
||||
void ResumeGamestate(struct Game *game, const char* name);
|
||||
void PauseAllGamestates(struct Game *game);
|
||||
void ResumeAllGamestates(struct Game *game);
|
||||
void UnloadAllGamestates(struct Game *game);
|
||||
void SwitchGamestate(struct Game *game, const char* current, const char* n);
|
||||
void SwitchCurrentGamestate(struct Game *game, const char* n);
|
||||
void ChangeGamestate(struct Game *game, const char* current, const char* n);
|
||||
void ChangeCurrentGamestate(struct Game *game, const char* n);
|
||||
void StopCurrentGamestate(struct Game *game);
|
||||
void PauseCurrentGamestate(struct Game *game);
|
||||
void UnloadCurrentGamestate(struct Game *game);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -58,29 +58,6 @@ SYMBOL_INTERNAL void EventGamestates(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
}
|
||||
}
|
||||
|
||||
SYMBOL_INTERNAL void PauseGamestates(struct Game *game) {
|
||||
struct Gamestate *tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if ((tmp->loaded) && (tmp->started)) {
|
||||
game->_priv.current_gamestate = tmp;
|
||||
(*tmp->api->Gamestate_Pause)(game, tmp->data);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SYMBOL_INTERNAL void ResumeGamestates(struct Game *game) {
|
||||
struct Gamestate *tmp = game->_priv.gamestates;
|
||||
while (tmp) {
|
||||
if ((tmp->loaded) && (tmp->started)) {
|
||||
game->_priv.current_gamestate = tmp;
|
||||
(*tmp->api->Gamestate_Resume)(game, tmp->data);
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
|
||||
SYMBOL_INTERNAL void DrawConsole(struct Game *game) {
|
||||
if (game->_priv.showconsole) {
|
||||
al_set_target_backbuffer(game->display);
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
void DrawGamestates(struct Game *game);
|
||||
void LogicGamestates(struct Game *game);
|
||||
void EventGamestates(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void PauseGamestates(struct Game *game);
|
||||
void ResumeGamestates(struct Game *game);
|
||||
void DrawConsole(struct Game *game);
|
||||
void Console_Load(struct Game *game);
|
||||
void Console_Unload(struct Game *game);
|
||||
|
|
Loading…
Reference in a new issue