Actually pause singleplayer game in pause menu and use lower maximum FPS in it
authorPerttu Ahola <celeron55@gmail.com>
Mon, 6 Jan 2014 15:37:23 +0000 (17:37 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 6 Jan 2014 15:39:44 +0000 (17:39 +0200)
minetest.conf.example
src/defaultsettings.cpp
src/game.cpp
src/guiPauseMenu.h
src/guiVolumeChange.h
src/mainmenumanager.h
src/modalMenu.h

index 243c84f3a0e60fd3eb96eef5adf8162bc71f0b74..fa54bde8dc0cdecd9b64c06992b0b06afdd61302 100644 (file)
@@ -68,6 +68,8 @@
 # If FPS would go higher than this, limit it by sleeping
 # (to not waste CPU power for no benefit)
 #fps_max = 60
+# Maximum FPS when game is paused
+#pause_fps_max = 20
 # The allowed adjustment range for the automatic rendering range adjustment
 #viewing_range_nodes_max = 160
 #viewing_range_nodes_min = 35
index 5a1dabebf77443201b5c0d9df6e0f75319e47e2c..a7187faea9a662868e0669faf2c4954076e26cb0 100644 (file)
@@ -77,6 +77,7 @@ void set_default_settings(Settings *settings)
 
        settings->setDefault("wanted_fps", "30");
        settings->setDefault("fps_max", "60");
+       settings->setDefault("pause_fps_max", "20");
        // A bit more than the server will send around the player, to make fog blend well
        settings->setDefault("viewing_range_nodes_max", "240");
        settings->setDefault("viewing_range_nodes_min", "35");
index c768440d3deabf62450e1febda54871e87a681c4..b751a2b627e8eef9955a5b1f0bad0fdb3e2ab6d0 100644 (file)
@@ -1513,7 +1513,9 @@ void the_game(
                */
 
                {
-                       float fps_max = g_settings->getFloat("fps_max");
+                       float fps_max = g_menumgr.pausesGame() ?
+                                       g_settings->getFloat("pause_fps_max") :
+                                       g_settings->getFloat("fps_max");
                        u32 frametime_min = 1000./fps_max;
                        
                        if(busytime_u32 < frametime_min)
@@ -2192,25 +2194,28 @@ void the_game(
                        LocalPlayer* player = client.getEnv().getLocalPlayer();
                        player->keyPressed=keyPressed;
                }
-               
+
                /*
-                       Run server
+                       Run server, client (and process environments)
                */
-
-               if(server != NULL)
+               bool can_be_and_is_paused =
+                               (simple_singleplayer_mode && g_menumgr.pausesGame());
+               if(can_be_and_is_paused)
                {
-                       //TimeTaker timer("server->step(dtime)");
-                       server->step(dtime);
+                       // No time passes
+                       dtime = 0;
                }
-
-               /*
-                       Process environment
-               */
-               
+               else
                {
-                       //TimeTaker timer("client.step(dtime)");
-                       client.step(dtime);
-                       //client.step(dtime_avg1);
+                       if(server != NULL)
+                       {
+                               //TimeTaker timer("server->step(dtime)");
+                               server->step(dtime);
+                       }
+                       {
+                               //TimeTaker timer("client.step(dtime)");
+                               client.step(dtime);
+                       }
                }
 
                {
index 25011a34ad5fbcb00fd04e4b339830c8371b56b2..2808c93b158b86af9e9e6eaa45dfc913b81e98e6 100644 (file)
@@ -51,7 +51,9 @@ public:
        void drawMenu();
 
        bool OnEvent(const SEvent& event);
-       
+
+       bool pausesGame(){ return true; }
+
 private:
        IGameCallback *m_gamecallback;
        bool m_simple_singleplayer_mode;
index 1dcc7fbde8a641db501d3e4905831624fe55d649..5258ee1071be7bdda4ccceb55babc1debf8bf175 100644 (file)
@@ -44,6 +44,8 @@ public:
 
        bool OnEvent(const SEvent& event);
        
+       bool pausesGame(){ return true; }
+
 private:
        Client* m_client;
 
index d151cf48d663b33958e8be9defacb316b9f81e0a..ecfb89fd3111091184eaedaf2b97fde710a8c7a2 100644 (file)
@@ -91,6 +91,17 @@ public:
                return m_stack.size();
        }
 
+       bool pausesGame()
+       {
+               for(std::list<GUIModalMenu*>::iterator
+                               i = m_stack.begin(); i != m_stack.end(); ++i)
+               {
+                       if((*i)->pausesGame())
+                               return true;
+               }
+               return false;
+       }
+
        std::list<GUIModalMenu*> m_stack;
 };
 
index c8b45a247a8cb233de94e1eb0b790deecb9190f4..251b7aa3b60a86af18524631f8377621974320dd 100644 (file)
@@ -124,6 +124,7 @@ public:
        virtual void drawMenu() = 0;
        virtual bool preprocessEvent(const SEvent& event) { return false; };
        virtual bool OnEvent(const SEvent& event) { return false; };
+       virtual bool pausesGame(){ return false; } // Used for pause menu
 
 protected:
        //bool m_force_regenerate_gui;