diff options
author | rubenwardy <rw@rubenwardy.com> | 2017-09-10 03:17:47 +0100 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-12-26 21:53:45 +0000 |
commit | 0bcc2f33ebe382a1dafbe6edaf00f476f2584b74 (patch) | |
tree | d5dd0822bdee5ed00f87ba566e1e3c2ff9bfaa2f | |
parent | 2153965cf92ab61b0d7e095cf3c2755924fdc221 (diff) | |
download | minetest-0bcc2f33ebe382a1dafbe6edaf00f476f2584b74.tar.gz minetest-0bcc2f33ebe382a1dafbe6edaf00f476f2584b74.tar.bz2 minetest-0bcc2f33ebe382a1dafbe6edaf00f476f2584b74.zip |
Add check to pause game on lost window focus
-rw-r--r-- | builtin/settingtypes.txt | 3 | ||||
-rw-r--r-- | minetest.conf.example | 4 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 1 | ||||
-rw-r--r-- | src/game.cpp | 7 |
4 files changed, 15 insertions, 0 deletions
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 0d5978911..024018869 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -536,6 +536,9 @@ fps_max (Maximum FPS) int 60 # Maximum FPS when game is paused. pause_fps_max (FPS in pause menu) int 20 +# Open the pause menu when the window's focus is lost. Does not pause if a formspec is open. +pause_on_lost_focus (Pause on lost window focus) bool false + # View distance in nodes. viewing_range (Viewing range) int 100 20 4000 diff --git a/minetest.conf.example b/minetest.conf.example index a112ce0e6..46d9ffe65 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -994,6 +994,10 @@ # type: int # max_out_chat_queue_size = 20 +# Open the pause menu when the window's focus is lost. Does not pause if a formspec is open. +# type: bool +# pause_on_lost_focus = false + ## Advanced # Timeout for client to remove unused map data from memory. diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 3bd4f4ac6..130bb4a19 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -58,6 +58,7 @@ void set_default_settings(Settings *settings) settings->setDefault("enable_remote_media_server", "true"); settings->setDefault("enable_client_modding", "false"); settings->setDefault("max_out_chat_queue_size", "20"); + settings->setDefault("pause_on_lost_focus", "false"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/game.cpp b/src/game.cpp index f7d4164ae..ac50e9aba 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1487,6 +1487,8 @@ private: bool m_first_loop_after_window_activation = false; bool m_camera_offset_changed = false; + bool m_does_lost_focus_pause_game = false; + #ifdef __ANDROID__ bool m_cache_hold_aux1; bool m_android_chat_open; @@ -1741,6 +1743,10 @@ void Game::run() // Update if minimap has been disabled by the server flags.show_minimap &= client->shouldShowMinimap(); + + if (m_does_lost_focus_pause_game && !device->isWindowFocused() && !isMenuActive()) { + showPauseMenu(); + } } } @@ -4638,6 +4644,7 @@ void Game::readSettings() m_cache_cam_smoothing = rangelim(m_cache_cam_smoothing, 0.01f, 1.0f); m_cache_mouse_sensitivity = rangelim(m_cache_mouse_sensitivity, 0.001, 100.0); + m_does_lost_focus_pause_game = g_settings->getBool("pause_on_lost_focus"); } /****************************************************************************/ |