mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
add QuitGame function for quiting or sending game to the background (depending on the platform)
This commit is contained in:
parent
8ff2a57b64
commit
a730281bb8
3 changed files with 20 additions and 0 deletions
|
@ -39,6 +39,7 @@ struct GamestateResources;
|
|||
#include <allegro5/allegro_ttf.h>
|
||||
#include <allegro5/allegro_video.h>
|
||||
#ifdef ALLEGRO_ANDROID
|
||||
#define ALLEGRO_UNSTABLE
|
||||
#include <allegro5/allegro_android.h>
|
||||
#endif
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
|
16
src/utils.c
16
src/utils.c
|
@ -528,3 +528,19 @@ SYMBOL_EXPORT char* PunchNumber(struct Game* game, char* text, char ch, int numb
|
|||
};
|
||||
return AddGarbage(game, txt);
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void QuitGame(struct Game* game, bool allow_pausing) {
|
||||
#ifdef ALLEGRO_ANDROID
|
||||
if (allow_pausing) {
|
||||
JNIEnv* env = al_android_get_jni_env();
|
||||
jclass class_id = (*env)->GetObjectClass(env, al_android_get_activity());
|
||||
jmethodID method_id = (*env)->GetMethodID(env, class_id, "moveTaskToBack",
|
||||
"(Z)Z");
|
||||
jvalue jdata;
|
||||
jdata.z = JNI_TRUE;
|
||||
(*env)->CallBooleanMethodA(env, al_android_get_activity(), method_id, &jdata);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
UnloadAllGamestates(game);
|
||||
}
|
||||
|
|
|
@ -92,4 +92,7 @@ void DisableCompositor(struct Game* game);
|
|||
|
||||
char* PunchNumber(struct Game* game, char* text, char ch, int number);
|
||||
|
||||
/*! \brief Quits the game. On platforms that allow it, brings the game to the background without quiting if <allow_pausing> is true. */
|
||||
void QuitGame(struct Game* game, bool allow_pausing);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue