1) Made the maximum number of fps configurable (default=120).
2) Added a setting to change the volumne of sfx. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1866 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -81,9 +81,9 @@ void GameManager::run()
|
||||
static const float max_elapsed_time = 3.0f*1.0f/60.0f*1000.0f; /* time 3 internal substeps take */
|
||||
if(dt > max_elapsed_time) dt=max_elapsed_time;
|
||||
|
||||
//This avoid wasting CPU cycles
|
||||
//1000 miliseconds / 125 frames = 125 miliseconds per frame
|
||||
if( dt < 8.0f)
|
||||
// Throttle fps if more than maximum, which can reduce
|
||||
// the noise the fan on a graphics card makes
|
||||
if( dt*user_config->m_max_fps < 1000.0f)
|
||||
{
|
||||
//SDL_Delay has a granularity of 10ms on most platforms, so
|
||||
//most likely when frames go faster than 125 frames, at times
|
||||
|
||||
@@ -32,8 +32,7 @@
|
||||
|
||||
#include "sfx_openal.hpp"
|
||||
#include "file_manager.hpp"
|
||||
|
||||
|
||||
#include "user_config.hpp"
|
||||
|
||||
SFXImpl::SFXImpl(const char* filename)
|
||||
{
|
||||
@@ -53,6 +52,7 @@ SFXImpl::~SFXImpl()
|
||||
//-----------------------------------------------------------------------------
|
||||
void SFXImpl::play()
|
||||
{
|
||||
alSourcef(m_soundSource,AL_GAIN,user_config->m_sfx_volume);
|
||||
alSourcePlay(m_soundSource);
|
||||
|
||||
// Check (and clear) the error flag
|
||||
|
||||
@@ -105,6 +105,8 @@ void UserConfig::setDefaults()
|
||||
m_background_music = "";
|
||||
m_profile = 0;
|
||||
m_skidding = false;
|
||||
m_max_fps = 120;
|
||||
m_sfx_volume = 1.0f;
|
||||
m_use_kph = false;
|
||||
m_replay_history = false;
|
||||
m_width = 800;
|
||||
@@ -414,6 +416,8 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
lisp->get("displayFPS", m_display_fps);
|
||||
lisp->get("herringStyle", m_herring_style);
|
||||
lisp->get("background-music", m_background_music);
|
||||
lisp->get("max-fps", m_max_fps);
|
||||
lisp->get("sfx-volume", m_sfx_volume);
|
||||
lisp->get("useKPH", m_use_kph);
|
||||
|
||||
/*get resolution width/height*/
|
||||
@@ -655,6 +659,10 @@ void UserConfig::saveConfig(const std::string& filename)
|
||||
writer->write("background-music\t", m_background_music);
|
||||
writer->writeComment("Use of kilometers per hours (km/h) instead of mph");
|
||||
writer->write("useKPH\t", m_use_kph);
|
||||
writer->writeComment("maximum fps, should be at least 60");
|
||||
writer->write("max-fps\t", m_max_fps);
|
||||
writer->writeComment("Volume for sound effects, see openal AL_GAIN for interpretation");
|
||||
writer->write("sfx-volumet", m_sfx_volume);
|
||||
|
||||
writer->writeComment("screen resolution and windowing mode");
|
||||
writer->write("width\t", m_width);
|
||||
|
||||
@@ -170,6 +170,8 @@ public:
|
||||
int m_profile; // Positive number: time in seconds, neg: # laps
|
||||
// 0 if no profiling. Never saved in config file!
|
||||
bool m_skidding;
|
||||
float m_sfx_volume;
|
||||
int m_max_fps;
|
||||
std::string m_herring_style;
|
||||
std::string m_username;
|
||||
std::string m_background_music;
|
||||
|
||||
Reference in New Issue
Block a user