From 63451eb858ba72264ae652ced2c6c22beb146725 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Sat, 20 Aug 2016 03:32:09 +0200 Subject: [PATCH] add ChangeGamestate/ChangeCurrentGamestate API for replacing gamestates without unloading --- src/gamestate.c | 10 ++++++++++ src/gamestate.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/gamestate.c b/src/gamestate.c index 6929ecd..0691123 100644 --- a/src/gamestate.c +++ b/src/gamestate.c @@ -197,6 +197,16 @@ SYMBOL_EXPORT void SwitchGamestate(struct Game *game, const char* current, const StartGamestate(game, n); } +SYMBOL_EXPORT void ChangeGamestate(struct Game *game, const char* current, const char* n) { + StopGamestate(game, current); + LoadGamestate(game, n); + StartGamestate(game, n); +} + SYMBOL_EXPORT void SwitchCurrentGamestate(struct Game *game, const char* n) { SwitchGamestate(game, game->_priv.current_gamestate->name, n); } + +SYMBOL_EXPORT void ChangeCurrentGamestate(struct Game *game, const char* n) { + ChangeGamestate(game, game->_priv.current_gamestate->name, n); +} diff --git a/src/gamestate.h b/src/gamestate.h index d391a91..58e3f58 100644 --- a/src/gamestate.h +++ b/src/gamestate.h @@ -64,5 +64,7 @@ void ResumeGamestate(struct Game *game, const char* name); 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); #endif