diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp index 510480db..5bf1ccff 100644 --- a/src/client/inputhandler.cpp +++ b/src/client/inputhandler.cpp @@ -22,8 +22,15 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inputhandler.h" #include "mainmenumanager.h" +#if defined(__ANDROID__) +#include "porting_android.h" +#endif + #ifdef __IOS__ #include "porting_ios.h" +#endif + +#if defined(__ANDROID__) || defined(__IOS__) extern void external_pause_game(); #endif @@ -34,9 +41,8 @@ bool MyEventReceiver::OnEvent(const SEvent &event) */ if (isMenuActive()) { #ifdef HAVE_TOUCHSCREENGUI - if (m_touchscreengui) { + if (m_touchscreengui) m_touchscreengui->Toggle(false); - } #endif return g_menumgr.preprocessEvent(event); } @@ -63,6 +69,11 @@ bool MyEventReceiver::OnEvent(const SEvent &event) } #endif +#if defined(__ANDROID__) + if (event.SystemEvent.AndroidCmd.Cmd == APP_CMD_TERM_WINDOW) + external_pause_game(); +#endif + #ifdef __IOS__ if (event.EventType == irr::EET_APPLICATION_EVENT) { if (event.ApplicationEvent.EventType == irr::EAET_DID_PAUSE) { diff --git a/src/game.cpp b/src/game.cpp index cc9988d3..70d5f569 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1229,8 +1229,11 @@ public: void run(); void shutdown(); -#ifdef __IOS__ +#if defined(__ANDROID__) || defined(__IOS__) void pauseGame(); +#endif + +#ifdef __IOS__ void customStatustext(const std::wstring &text, float time); #endif void pauseAnimation(bool is_paused); @@ -1747,13 +1750,17 @@ void Game::run() void Game::shutdown() { #if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8 - if (g_settings->get("3d_mode") == "pageflip") { + if (g_settings->get("3d_mode") == "pageflip") driver->setRenderTarget(irr::video::ERT_STEREO_BOTH_BUFFERS); - } #endif + if (current_formspec) current_formspec->quitMenu(); +#ifdef HAVE_TOUCHSCREENGUI + g_touchscreengui->hide(); +#endif + showOverlayMessage(wgettext("Shutting down..."), 0, 0, false); if (clouds) @@ -4626,7 +4633,7 @@ void Game::readSettings() } -#ifdef __IOS__ +#if defined(__ANDROID__) || defined(__IOS__) void Game::pauseGame() { g_touchscreengui->handleReleaseAll(); @@ -4635,7 +4642,9 @@ void Game::pauseGame() showPauseMenu(); runData.pause_game_timer = 0; } +#endif +#ifdef __IOS__ void Game::customStatustext(const std::wstring &text, float time) { m_statustext = text; @@ -4914,14 +4923,16 @@ void the_game(bool *kill, g_game = NULL; } -#ifdef __IOS__ +#if defined(__ANDROID__) || defined(__IOS__) void external_pause_game() { if (!g_game) return; g_game->pauseGame(); } +#endif +#ifdef __IOS__ void external_statustext(const char *text, float duration) { if (!g_game) diff --git a/src/touchscreengui.cpp b/src/touchscreengui.cpp index 0adbf523..1cbb0149 100644 --- a/src/touchscreengui.cpp +++ b/src/touchscreengui.cpp @@ -524,7 +524,6 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id) { } } -#ifdef __IOS__ void TouchScreenGUI::handleReleaseAll() { m_known_ids.clear(); @@ -533,7 +532,6 @@ void TouchScreenGUI::handleReleaseAll() for(int i = 0; i < after_last_element_id; i++) m_buttons[i].ids.clear(); } -#endif void TouchScreenGUI::translateEvent(const SEvent &event) { if (!m_visible) { diff --git a/src/touchscreengui.h b/src/touchscreengui.h index fd8a5598..a7d18afe 100644 --- a/src/touchscreengui.h +++ b/src/touchscreengui.h @@ -109,9 +109,7 @@ public: void show(); -#ifdef __IOS__ void handleReleaseAll(); -#endif private: IrrlichtDevice *m_device;