forked from Mirrorlandia_minetest/minetest
master #4
@ -623,6 +623,9 @@ bloom_radius (Bloom Radius) float 1 0.1 8
|
|||||||
# Requires the sound system to be enabled.
|
# Requires the sound system to be enabled.
|
||||||
sound_volume (Volume) float 0.8 0.0 1.0
|
sound_volume (Volume) float 0.8 0.0 1.0
|
||||||
|
|
||||||
|
# Volume multiplier when the window is unfocused.
|
||||||
|
sound_volume_unfocused (Volume when unfocused) float 0.3 0.0 1.0
|
||||||
|
|
||||||
# Whether to mute sounds. You can unmute sounds at any time, unless the
|
# Whether to mute sounds. You can unmute sounds at any time, unless the
|
||||||
# sound system is disabled (enable_sound=false).
|
# sound system is disabled (enable_sound=false).
|
||||||
# In-game, you can toggle the mute state with the mute key or by using the
|
# In-game, you can toggle the mute state with the mute key or by using the
|
||||||
|
@ -393,8 +393,8 @@ void Client::connect(Address address, bool is_local_server)
|
|||||||
void Client::step(float dtime)
|
void Client::step(float dtime)
|
||||||
{
|
{
|
||||||
// Limit a bit
|
// Limit a bit
|
||||||
if (dtime > 2.0)
|
if (dtime > DTIME_LIMIT)
|
||||||
dtime = 2.0;
|
dtime = DTIME_LIMIT;
|
||||||
|
|
||||||
m_animation_time += dtime;
|
m_animation_time += dtime;
|
||||||
if(m_animation_time > 60.0)
|
if(m_animation_time > 60.0)
|
||||||
|
@ -3209,19 +3209,7 @@ void Game::updateSound(f32 dtime)
|
|||||||
camera->getDirection(),
|
camera->getDirection(),
|
||||||
camera->getCameraNode()->getUpVector());
|
camera->getCameraNode()->getUpVector());
|
||||||
|
|
||||||
bool mute_sound = g_settings->getBool("mute_sound");
|
sound_volume_control(sound_manager.get(), device->isWindowActive());
|
||||||
if (mute_sound) {
|
|
||||||
sound_manager->setListenerGain(0.0f);
|
|
||||||
} else {
|
|
||||||
// Check if volume is in the proper range, else fix it.
|
|
||||||
float old_volume = g_settings->getFloat("sound_volume");
|
|
||||||
float new_volume = rangelim(old_volume, 0.0f, 1.0f);
|
|
||||||
sound_manager->setListenerGain(new_volume);
|
|
||||||
|
|
||||||
if (old_volume != new_volume) {
|
|
||||||
g_settings->setFloat("sound_volume", new_volume);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tell the sound maker whether to make footstep sounds
|
// Tell the sound maker whether to make footstep sounds
|
||||||
soundmaker->makes_footstep_sound = player->makes_footstep_sound;
|
soundmaker->makes_footstep_sound = player->makes_footstep_sound;
|
||||||
@ -4124,6 +4112,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (formspec->getReferenceCount() == 1) {
|
if (formspec->getReferenceCount() == 1) {
|
||||||
|
// See GUIFormSpecMenu::create what refcnt = 1 means
|
||||||
m_game_ui->deleteFormspec();
|
m_game_ui->deleteFormspec();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "filesys.h"
|
#include "filesys.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
|
#include "settings.h"
|
||||||
#include "util/numeric.h"
|
#include "util/numeric.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -95,3 +96,26 @@ void ISoundManager::freeId(sound_handle_t id, u32 num_owners)
|
|||||||
else
|
else
|
||||||
it->second -= num_owners;
|
it->second -= num_owners;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sound_volume_control(ISoundManager *sound_mgr, bool is_window_active)
|
||||||
|
{
|
||||||
|
bool mute_sound = g_settings->getBool("mute_sound");
|
||||||
|
if (mute_sound) {
|
||||||
|
sound_mgr->setListenerGain(0.0f);
|
||||||
|
} else {
|
||||||
|
// Check if volume is in the proper range, else fix it.
|
||||||
|
float old_volume = g_settings->getFloat("sound_volume");
|
||||||
|
float new_volume = rangelim(old_volume, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
if (old_volume != new_volume) {
|
||||||
|
g_settings->setFloat("sound_volume", new_volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_window_active) {
|
||||||
|
new_volume *= g_settings->getFloat("sound_volume_unfocused");
|
||||||
|
new_volume = rangelim(new_volume, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
sound_mgr->setListenerGain(new_volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -184,3 +184,9 @@ public:
|
|||||||
void fadeSound(sound_handle_t sound, f32 step, f32 target_gain) override {}
|
void fadeSound(sound_handle_t sound, f32 step, f32 target_gain) override {}
|
||||||
void updateSoundPosVel(sound_handle_t sound, const v3f &pos, const v3f &vel) override {}
|
void updateSoundPosVel(sound_handle_t sound, const v3f &pos, const v3f &vel) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper function to control sound volume based on some values: sound volume
|
||||||
|
* settings, mute sound setting, and window activity.
|
||||||
|
*/
|
||||||
|
void sound_volume_control(ISoundManager *sound_mgr, bool is_window_active);
|
||||||
|
@ -241,13 +241,13 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
|
|||||||
/*
|
/*
|
||||||
Calculate new velocity
|
Calculate new velocity
|
||||||
*/
|
*/
|
||||||
if (dtime > 0.5f) {
|
if (dtime > DTIME_LIMIT) {
|
||||||
if (!time_notification_done) {
|
if (!time_notification_done) {
|
||||||
time_notification_done = true;
|
time_notification_done = true;
|
||||||
infostream << "collisionMoveSimple: maximum step interval exceeded,"
|
warningstream << "collisionMoveSimple: maximum step interval exceeded,"
|
||||||
" lost movement details!"<<std::endl;
|
" lost movement details!"<<std::endl;
|
||||||
}
|
}
|
||||||
dtime = 0.5f;
|
dtime = DTIME_LIMIT;
|
||||||
} else {
|
} else {
|
||||||
time_notification_done = false;
|
time_notification_done = false;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
// Override for the previous one when distance of block is very low
|
// Override for the previous one when distance of block is very low
|
||||||
#define BLOCK_SEND_DISABLE_LIMITS_MAX_D 1
|
#define BLOCK_SEND_DISABLE_LIMITS_MAX_D 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
Client/Server
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Limit maximum dtime in client/server step(...) and for collision detection
|
||||||
|
#define DTIME_LIMIT 2.5f
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Map-related things
|
Map-related things
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +40,7 @@ void set_default_settings()
|
|||||||
settings->setDefault("address", "");
|
settings->setDefault("address", "");
|
||||||
settings->setDefault("enable_sound", "true");
|
settings->setDefault("enable_sound", "true");
|
||||||
settings->setDefault("sound_volume", "0.8");
|
settings->setDefault("sound_volume", "0.8");
|
||||||
|
settings->setDefault("sound_volume_unfocused", "0.3");
|
||||||
settings->setDefault("mute_sound", "false");
|
settings->setDefault("mute_sound", "false");
|
||||||
settings->setDefault("enable_mesh_cache", "false");
|
settings->setDefault("enable_mesh_cache", "false");
|
||||||
settings->setDefault("mesh_generation_interval", "0");
|
settings->setDefault("mesh_generation_interval", "0");
|
||||||
|
@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <ICameraSceneNode.h>
|
#include <ICameraSceneNode.h>
|
||||||
#include "client/renderingengine.h"
|
#include "client/renderingengine.h"
|
||||||
#include "scripting_mainmenu.h"
|
#include "scripting_mainmenu.h"
|
||||||
#include "util/numeric.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
@ -296,6 +295,7 @@ void GUIEngine::run()
|
|||||||
driver->endScene();
|
driver->endScene();
|
||||||
|
|
||||||
IrrlichtDevice *device = m_rendering_engine->get_raw_device();
|
IrrlichtDevice *device = m_rendering_engine->get_raw_device();
|
||||||
|
|
||||||
u32 frametime_min = 1000 / (device->isWindowFocused()
|
u32 frametime_min = 1000 / (device->isWindowFocused()
|
||||||
? g_settings->getFloat("fps_max")
|
? g_settings->getFloat("fps_max")
|
||||||
: g_settings->getFloat("fps_max_unfocused"));
|
: g_settings->getFloat("fps_max_unfocused"));
|
||||||
@ -310,6 +310,8 @@ void GUIEngine::run()
|
|||||||
|
|
||||||
m_script->step();
|
m_script->step();
|
||||||
|
|
||||||
|
sound_volume_control(m_sound_manager.get(), device->isWindowActive());
|
||||||
|
|
||||||
m_sound_manager->step(dtime);
|
m_sound_manager->step(dtime);
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
|
@ -138,11 +138,23 @@ void GUIFormSpecMenu::create(GUIFormSpecMenu *&cur_formspec, Client *client,
|
|||||||
gui::IGUIEnvironment *guienv, JoystickController *joystick, IFormSource *fs_src,
|
gui::IGUIEnvironment *guienv, JoystickController *joystick, IFormSource *fs_src,
|
||||||
TextDest *txt_dest, const std::string &formspecPrepend, ISoundManager *sound_manager)
|
TextDest *txt_dest, const std::string &formspecPrepend, ISoundManager *sound_manager)
|
||||||
{
|
{
|
||||||
|
if (cur_formspec && cur_formspec->getReferenceCount() == 1) {
|
||||||
|
/*
|
||||||
|
Why reference count == 1? Reason:
|
||||||
|
1 on creation (see "drop()" remark below)
|
||||||
|
+1 for being a guiroot child
|
||||||
|
+1 when focused (CGUIEnvironment::setFocus)
|
||||||
|
|
||||||
|
Hence re-create the formspec when it's existing without any parent.
|
||||||
|
*/
|
||||||
|
cur_formspec->drop();
|
||||||
|
cur_formspec = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (cur_formspec == nullptr) {
|
if (cur_formspec == nullptr) {
|
||||||
cur_formspec = new GUIFormSpecMenu(joystick, guiroot, -1, &g_menumgr,
|
cur_formspec = new GUIFormSpecMenu(joystick, guiroot, -1, &g_menumgr,
|
||||||
client, guienv, client->getTextureSource(), sound_manager, fs_src,
|
client, guienv, client->getTextureSource(), sound_manager, fs_src,
|
||||||
txt_dest, formspecPrepend);
|
txt_dest, formspecPrepend);
|
||||||
cur_formspec->doPause = false;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Caution: do not call (*cur_formspec)->drop() here --
|
Caution: do not call (*cur_formspec)->drop() here --
|
||||||
@ -151,12 +163,13 @@ void GUIFormSpecMenu::create(GUIFormSpecMenu *&cur_formspec, Client *client,
|
|||||||
remaining reference (i.e. the menu was removed)
|
remaining reference (i.e. the menu was removed)
|
||||||
and delete it in that case.
|
and delete it in that case.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cur_formspec->setFormspecPrepend(formspecPrepend);
|
cur_formspec->setFormspecPrepend(formspecPrepend);
|
||||||
cur_formspec->setFormSource(fs_src);
|
cur_formspec->setFormSource(fs_src);
|
||||||
cur_formspec->setTextDest(txt_dest);
|
cur_formspec->setTextDest(txt_dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_formspec->doPause = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIFormSpecMenu::removeTooltip()
|
void GUIFormSpecMenu::removeTooltip()
|
||||||
|
@ -577,8 +577,8 @@ void Server::stop()
|
|||||||
void Server::step(float dtime)
|
void Server::step(float dtime)
|
||||||
{
|
{
|
||||||
// Limit a bit
|
// Limit a bit
|
||||||
if (dtime > 2.0)
|
if (dtime > DTIME_LIMIT)
|
||||||
dtime = 2.0;
|
dtime = DTIME_LIMIT;
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(m_step_dtime_mutex);
|
MutexAutoLock lock(m_step_dtime_mutex);
|
||||||
m_step_dtime += dtime;
|
m_step_dtime += dtime;
|
||||||
|
Loading…
Reference in New Issue
Block a user