mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Actually pause singleplayer game in pause menu and use lower maximum FPS in it
This commit is contained in:
parent
6833e04bc5
commit
92aa38bdfc
@ -68,6 +68,8 @@
|
|||||||
# If FPS would go higher than this, limit it by sleeping
|
# If FPS would go higher than this, limit it by sleeping
|
||||||
# (to not waste CPU power for no benefit)
|
# (to not waste CPU power for no benefit)
|
||||||
#fps_max = 60
|
#fps_max = 60
|
||||||
|
# Maximum FPS when game is paused
|
||||||
|
#pause_fps_max = 20
|
||||||
# The allowed adjustment range for the automatic rendering range adjustment
|
# The allowed adjustment range for the automatic rendering range adjustment
|
||||||
#viewing_range_nodes_max = 160
|
#viewing_range_nodes_max = 160
|
||||||
#viewing_range_nodes_min = 35
|
#viewing_range_nodes_min = 35
|
||||||
|
@ -77,6 +77,7 @@ void set_default_settings(Settings *settings)
|
|||||||
|
|
||||||
settings->setDefault("wanted_fps", "30");
|
settings->setDefault("wanted_fps", "30");
|
||||||
settings->setDefault("fps_max", "60");
|
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
|
// 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_max", "240");
|
||||||
settings->setDefault("viewing_range_nodes_min", "35");
|
settings->setDefault("viewing_range_nodes_min", "35");
|
||||||
|
23
src/game.cpp
23
src/game.cpp
@ -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;
|
u32 frametime_min = 1000./fps_max;
|
||||||
|
|
||||||
if(busytime_u32 < frametime_min)
|
if(busytime_u32 < frametime_min)
|
||||||
@ -2194,23 +2196,26 @@ void the_game(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Run server
|
Run server, client (and process environments)
|
||||||
*/
|
*/
|
||||||
|
bool can_be_and_is_paused =
|
||||||
|
(simple_singleplayer_mode && g_menumgr.pausesGame());
|
||||||
|
if(can_be_and_is_paused)
|
||||||
|
{
|
||||||
|
// No time passes
|
||||||
|
dtime = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if(server != NULL)
|
if(server != NULL)
|
||||||
{
|
{
|
||||||
//TimeTaker timer("server->step(dtime)");
|
//TimeTaker timer("server->step(dtime)");
|
||||||
server->step(dtime);
|
server->step(dtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Process environment
|
|
||||||
*/
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//TimeTaker timer("client.step(dtime)");
|
//TimeTaker timer("client.step(dtime)");
|
||||||
client.step(dtime);
|
client.step(dtime);
|
||||||
//client.step(dtime_avg1);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,8 @@ public:
|
|||||||
|
|
||||||
bool OnEvent(const SEvent& event);
|
bool OnEvent(const SEvent& event);
|
||||||
|
|
||||||
|
bool pausesGame(){ return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IGameCallback *m_gamecallback;
|
IGameCallback *m_gamecallback;
|
||||||
bool m_simple_singleplayer_mode;
|
bool m_simple_singleplayer_mode;
|
||||||
|
@ -44,6 +44,8 @@ public:
|
|||||||
|
|
||||||
bool OnEvent(const SEvent& event);
|
bool OnEvent(const SEvent& event);
|
||||||
|
|
||||||
|
bool pausesGame(){ return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Client* m_client;
|
Client* m_client;
|
||||||
|
|
||||||
|
@ -91,6 +91,17 @@ public:
|
|||||||
return m_stack.size();
|
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;
|
std::list<GUIModalMenu*> m_stack;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ public:
|
|||||||
virtual void drawMenu() = 0;
|
virtual void drawMenu() = 0;
|
||||||
virtual bool preprocessEvent(const SEvent& event) { return false; };
|
virtual bool preprocessEvent(const SEvent& event) { return false; };
|
||||||
virtual bool OnEvent(const SEvent& event) { return false; };
|
virtual bool OnEvent(const SEvent& event) { return false; };
|
||||||
|
virtual bool pausesGame(){ return false; } // Used for pause menu
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//bool m_force_regenerate_gui;
|
//bool m_force_regenerate_gui;
|
||||||
|
Loading…
Reference in New Issue
Block a user