Browse Source

Pause on lost focus.

This  Final Minetest commit adds  "luk3yx's" version of the "pause
on lost focus" feature.

It's a  merge of  the following commits from  "luk3yx's"  Minetest
0.4.X fork and Trolltest:

Commit: 61e806f312
From:   luk3yx <luk3yx@users.noreply.github.com>
Date:   Tue, 12 Mar 2019 17:10:29 +1300
Notes:  Add pause menu background and the image "gui_formbg.png"

Commit: 7ffdd430bb
From:   luk3yx <luk3yx@users.noreply.github.com>
Date:   Wed, 6 Mar 2019 15:44:51 +1300
Notes:  Set "pause_on_lost_focus" to true by default

Commit: 397a7e1dd1
From:   rubenwardy <rw@rubenwardy.com>
Date:   Sun, 10 Sep 2017 03:17:47 +0100
Notes:  Add check to pause game on lost window focus
master
OldCoder 1 month ago
parent
commit
cd9a8ea5e3
5 changed files with 16 additions and 2 deletions
  1. 4
    1
      LICENSE.txt
  2. 3
    0
      builtin/settingtypes.txt
  3. 1
    0
      src/defaultsettings.cpp
  4. 8
    1
      src/game.cpp
  5. BIN
      textures/base/pack/gui_formbg.png

+ 4
- 1
LICENSE.txt View File

@@ -1,4 +1,3 @@

License of Minetest textures and sounds
---------------------------------------

@@ -13,9 +12,13 @@ https://www.apache.org/licenses/LICENSE-2.0.html

Authors of media files
-----------------------

Everything not listed in here:
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>

BlockMen, modified by davidgumberg and kilbith:
textures/base/pack/gui_formbg.png

ShadowNinja:
textures/base/pack/smoke_puff.png


+ 3
- 0
builtin/settingtypes.txt View File

@@ -565,6 +565,9 @@ fps_max (Maximum FPS) int 60 1
# Maximum FPS when game is paused.
pause_fps_max (FPS in pause menu) int 20 1

# 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 true

# View distance in nodes.
viewing_range (Viewing range) int 100 20 4000


+ 1
- 0
src/defaultsettings.cpp View File

@@ -66,6 +66,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", "true");

// Keymap
settings->setDefault("remote_port", "30000");

+ 8
- 1
src/game.cpp View File

@@ -1501,6 +1501,7 @@ private:
bool m_invert_mouse;
bool m_first_loop_after_window_activation;
bool m_camera_offset_changed;
bool m_does_lost_focus_pause_game = false;

#ifdef __ANDROID__
bool m_cache_hold_aux1;
@@ -1760,6 +1761,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();
}
}
}

@@ -4662,6 +4667,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");
}

/****************************************************************************/
@@ -4746,7 +4752,8 @@ void Game::showPauseMenu()
float ypos = simple_singleplayer_mode ? 0.7f : 0.1f;
std::ostringstream os;

os << FORMSPEC_VERSION_STRING << SIZE_TAG
os << FORMSPEC_VERSION_STRING << SIZE_TAG
<< "bgcolor[#080808BB;true]background[5,5;1,1;gui_formbg.png;true]"
<< "button_exit[4," << (ypos++) << ";3,0.5;btn_continue;"
<< strgettext("Continue") << "]";


BIN
textures/base/pack/gui_formbg.png View File


Loading…
Cancel
Save