Android: open Pause when losing focus
This commit is contained in:
parent
a659963c24
commit
a24f1c0f99
@ -22,8 +22,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "inputhandler.h"
|
#include "inputhandler.h"
|
||||||
#include "mainmenumanager.h"
|
#include "mainmenumanager.h"
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
#include "porting_android.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
#include "porting_ios.h"
|
#include "porting_ios.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__ANDROID__) || defined(__IOS__)
|
||||||
extern void external_pause_game();
|
extern void external_pause_game();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -34,9 +41,8 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
|
|||||||
*/
|
*/
|
||||||
if (isMenuActive()) {
|
if (isMenuActive()) {
|
||||||
#ifdef HAVE_TOUCHSCREENGUI
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
if (m_touchscreengui) {
|
if (m_touchscreengui)
|
||||||
m_touchscreengui->Toggle(false);
|
m_touchscreengui->Toggle(false);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return g_menumgr.preprocessEvent(event);
|
return g_menumgr.preprocessEvent(event);
|
||||||
}
|
}
|
||||||
@ -63,6 +69,11 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
if (event.SystemEvent.AndroidCmd.Cmd == APP_CMD_TERM_WINDOW)
|
||||||
|
external_pause_game();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __IOS__
|
#ifdef __IOS__
|
||||||
if (event.EventType == irr::EET_APPLICATION_EVENT) {
|
if (event.EventType == irr::EET_APPLICATION_EVENT) {
|
||||||
if (event.ApplicationEvent.EventType == irr::EAET_DID_PAUSE) {
|
if (event.ApplicationEvent.EventType == irr::EAET_DID_PAUSE) {
|
||||||
|
21
src/game.cpp
21
src/game.cpp
@ -1229,8 +1229,11 @@ public:
|
|||||||
|
|
||||||
void run();
|
void run();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
#ifdef __IOS__
|
#if defined(__ANDROID__) || defined(__IOS__)
|
||||||
void pauseGame();
|
void pauseGame();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __IOS__
|
||||||
void customStatustext(const std::wstring &text, float time);
|
void customStatustext(const std::wstring &text, float time);
|
||||||
#endif
|
#endif
|
||||||
void pauseAnimation(bool is_paused);
|
void pauseAnimation(bool is_paused);
|
||||||
@ -1747,13 +1750,17 @@ void Game::run()
|
|||||||
void Game::shutdown()
|
void Game::shutdown()
|
||||||
{
|
{
|
||||||
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 8
|
#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);
|
driver->setRenderTarget(irr::video::ERT_STEREO_BOTH_BUFFERS);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (current_formspec)
|
if (current_formspec)
|
||||||
current_formspec->quitMenu();
|
current_formspec->quitMenu();
|
||||||
|
|
||||||
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
|
g_touchscreengui->hide();
|
||||||
|
#endif
|
||||||
|
|
||||||
showOverlayMessage(wgettext("Shutting down..."), 0, 0, false);
|
showOverlayMessage(wgettext("Shutting down..."), 0, 0, false);
|
||||||
|
|
||||||
if (clouds)
|
if (clouds)
|
||||||
@ -4626,7 +4633,7 @@ void Game::readSettings()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __IOS__
|
#if defined(__ANDROID__) || defined(__IOS__)
|
||||||
void Game::pauseGame()
|
void Game::pauseGame()
|
||||||
{
|
{
|
||||||
g_touchscreengui->handleReleaseAll();
|
g_touchscreengui->handleReleaseAll();
|
||||||
@ -4635,7 +4642,9 @@ void Game::pauseGame()
|
|||||||
showPauseMenu();
|
showPauseMenu();
|
||||||
runData.pause_game_timer = 0;
|
runData.pause_game_timer = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __IOS__
|
||||||
void Game::customStatustext(const std::wstring &text, float time)
|
void Game::customStatustext(const std::wstring &text, float time)
|
||||||
{
|
{
|
||||||
m_statustext = text;
|
m_statustext = text;
|
||||||
@ -4914,14 +4923,16 @@ void the_game(bool *kill,
|
|||||||
g_game = NULL;
|
g_game = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __IOS__
|
#if defined(__ANDROID__) || defined(__IOS__)
|
||||||
void external_pause_game()
|
void external_pause_game()
|
||||||
{
|
{
|
||||||
if (!g_game)
|
if (!g_game)
|
||||||
return;
|
return;
|
||||||
g_game->pauseGame();
|
g_game->pauseGame();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __IOS__
|
||||||
void external_statustext(const char *text, float duration)
|
void external_statustext(const char *text, float duration)
|
||||||
{
|
{
|
||||||
if (!g_game)
|
if (!g_game)
|
||||||
|
@ -524,7 +524,6 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __IOS__
|
|
||||||
void TouchScreenGUI::handleReleaseAll()
|
void TouchScreenGUI::handleReleaseAll()
|
||||||
{
|
{
|
||||||
m_known_ids.clear();
|
m_known_ids.clear();
|
||||||
@ -533,7 +532,6 @@ void TouchScreenGUI::handleReleaseAll()
|
|||||||
for(int i = 0; i < after_last_element_id; i++)
|
for(int i = 0; i < after_last_element_id; i++)
|
||||||
m_buttons[i].ids.clear();
|
m_buttons[i].ids.clear();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void TouchScreenGUI::translateEvent(const SEvent &event) {
|
void TouchScreenGUI::translateEvent(const SEvent &event) {
|
||||||
if (!m_visible) {
|
if (!m_visible) {
|
||||||
|
@ -109,9 +109,7 @@ public:
|
|||||||
|
|
||||||
void show();
|
void show();
|
||||||
|
|
||||||
#ifdef __IOS__
|
|
||||||
void handleReleaseAll();
|
void handleReleaseAll();
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IrrlichtDevice *m_device;
|
IrrlichtDevice *m_device;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user