- Added ability to disable sound for poor users with non-functional sound
This commit is contained in:
parent
0089cc7d31
commit
1e077512d8
|
@ -57,6 +57,18 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
leftline-=30;
|
leftline-=30;
|
||||||
|
|
||||||
//soundboxes
|
//soundboxes
|
||||||
|
labelSoundFactory.init(leftLabelStart, leftline);
|
||||||
|
labelSoundFactory.setText(lang.get("SoundAndMusic"));
|
||||||
|
listBoxSoundFactory.init(leftColumnStart, leftline, 80);
|
||||||
|
listBoxSoundFactory.pushBackItem("None");
|
||||||
|
listBoxSoundFactory.pushBackItem("OpenAL");
|
||||||
|
#ifdef WIN32
|
||||||
|
listBoxSoundFactory.pushBackItem("DirectSound8");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
listBoxSoundFactory.setSelectedItem(config.getString("FactorySound"));
|
||||||
|
leftline-=30;
|
||||||
|
|
||||||
labelVolumeFx.init(leftLabelStart, leftline);
|
labelVolumeFx.init(leftLabelStart, leftline);
|
||||||
labelVolumeFx.setText(lang.get("FxVolume"));
|
labelVolumeFx.setText(lang.get("FxVolume"));
|
||||||
listBoxVolumeFx.init(leftColumnStart, leftline, 80);
|
listBoxVolumeFx.init(leftColumnStart, leftline, 80);
|
||||||
|
@ -330,6 +342,7 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
listBoxTextures3D.mouseClick(x, y);
|
listBoxTextures3D.mouseClick(x, y);
|
||||||
listBoxUnitParticles.mouseClick(x, y);
|
listBoxUnitParticles.mouseClick(x, y);
|
||||||
listBoxLights.mouseClick(x, y);
|
listBoxLights.mouseClick(x, y);
|
||||||
|
listBoxSoundFactory.mouseClick(x, y);
|
||||||
listBoxVolumeFx.mouseClick(x, y);
|
listBoxVolumeFx.mouseClick(x, y);
|
||||||
listBoxVolumeAmbient.mouseClick(x, y);
|
listBoxVolumeAmbient.mouseClick(x, y);
|
||||||
listBoxVolumeMusic.mouseClick(x, y);
|
listBoxVolumeMusic.mouseClick(x, y);
|
||||||
|
@ -348,6 +361,7 @@ void MenuStateOptions::mouseMove(int x, int y, const MouseState *ms){
|
||||||
buttonAutoConfig.mouseMove(x, y);
|
buttonAutoConfig.mouseMove(x, y);
|
||||||
buttonVideoInfo.mouseMove(x, y);
|
buttonVideoInfo.mouseMove(x, y);
|
||||||
listBoxLang.mouseMove(x, y);
|
listBoxLang.mouseMove(x, y);
|
||||||
|
listBoxSoundFactory.mouseMove(x, y);
|
||||||
listBoxVolumeFx.mouseMove(x, y);
|
listBoxVolumeFx.mouseMove(x, y);
|
||||||
listBoxVolumeAmbient.mouseMove(x, y);
|
listBoxVolumeAmbient.mouseMove(x, y);
|
||||||
listBoxVolumeMusic.mouseMove(x, y);
|
listBoxVolumeMusic.mouseMove(x, y);
|
||||||
|
@ -409,6 +423,7 @@ void MenuStateOptions::render(){
|
||||||
renderer.renderListBox(&listBoxUnitParticles);
|
renderer.renderListBox(&listBoxUnitParticles);
|
||||||
renderer.renderListBox(&listBoxLights);
|
renderer.renderListBox(&listBoxLights);
|
||||||
renderer.renderListBox(&listBoxFilter);
|
renderer.renderListBox(&listBoxFilter);
|
||||||
|
renderer.renderListBox(&listBoxSoundFactory);
|
||||||
renderer.renderListBox(&listBoxVolumeFx);
|
renderer.renderListBox(&listBoxVolumeFx);
|
||||||
renderer.renderListBox(&listBoxVolumeAmbient);
|
renderer.renderListBox(&listBoxVolumeAmbient);
|
||||||
renderer.renderListBox(&listBoxVolumeMusic);
|
renderer.renderListBox(&listBoxVolumeMusic);
|
||||||
|
@ -420,6 +435,7 @@ void MenuStateOptions::render(){
|
||||||
renderer.renderLabel(&labelUnitParticles);
|
renderer.renderLabel(&labelUnitParticles);
|
||||||
renderer.renderLabel(&labelLights);
|
renderer.renderLabel(&labelLights);
|
||||||
renderer.renderLabel(&labelFilter);
|
renderer.renderLabel(&labelFilter);
|
||||||
|
renderer.renderLabel(&labelSoundFactory);
|
||||||
renderer.renderLabel(&labelVolumeFx);
|
renderer.renderLabel(&labelVolumeFx);
|
||||||
renderer.renderLabel(&labelVolumeAmbient);
|
renderer.renderLabel(&labelVolumeAmbient);
|
||||||
renderer.renderLabel(&labelVolumeMusic);
|
renderer.renderLabel(&labelVolumeMusic);
|
||||||
|
@ -460,6 +476,7 @@ void MenuStateOptions::saveConfig(){
|
||||||
config.setBool("Textures3D", listBoxTextures3D.getSelectedItemIndex());
|
config.setBool("Textures3D", listBoxTextures3D.getSelectedItemIndex());
|
||||||
config.setBool("UnitParticles", listBoxUnitParticles.getSelectedItemIndex());
|
config.setBool("UnitParticles", listBoxUnitParticles.getSelectedItemIndex());
|
||||||
config.setInt("MaxLights", listBoxLights.getSelectedItemIndex()+1);
|
config.setInt("MaxLights", listBoxLights.getSelectedItemIndex()+1);
|
||||||
|
config.setString("FactorySound", listBoxSoundFactory.getSelectedItem());
|
||||||
config.setString("SoundVolumeFx", listBoxVolumeFx.getSelectedItem());
|
config.setString("SoundVolumeFx", listBoxVolumeFx.getSelectedItem());
|
||||||
config.setString("SoundVolumeAmbient", listBoxVolumeAmbient.getSelectedItem());
|
config.setString("SoundVolumeAmbient", listBoxVolumeAmbient.getSelectedItem());
|
||||||
config.setString("FontSizeAdjustment", listFontSizeAdjustment.getSelectedItem());
|
config.setString("FontSizeAdjustment", listFontSizeAdjustment.getSelectedItem());
|
||||||
|
@ -480,8 +497,14 @@ void MenuStateOptions::saveConfig(){
|
||||||
}
|
}
|
||||||
|
|
||||||
config.save();
|
config.save();
|
||||||
SoundRenderer::getInstance().loadConfig();
|
|
||||||
SoundRenderer::getInstance().setMusicVolume(CoreData::getInstance().getMenuMusic());
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
|
soundRenderer.stopAllSounds();
|
||||||
|
bool initOk = soundRenderer.init(program->getWindow());
|
||||||
|
soundRenderer.loadConfig();
|
||||||
|
soundRenderer.setMusicVolume(CoreData::getInstance().getMenuMusic());
|
||||||
|
soundRenderer.playMusic(CoreData::getInstance().getMenuMusic());
|
||||||
|
|
||||||
Renderer::getInstance().loadConfig();
|
Renderer::getInstance().loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ private:
|
||||||
GraphicLabel labelTextures3D;
|
GraphicLabel labelTextures3D;
|
||||||
GraphicLabel labelLights;
|
GraphicLabel labelLights;
|
||||||
GraphicLabel labelUnitParticles;
|
GraphicLabel labelUnitParticles;
|
||||||
|
GraphicLabel labelSoundFactory;
|
||||||
GraphicLabel labelVolumeFx;
|
GraphicLabel labelVolumeFx;
|
||||||
GraphicLabel labelVolumeAmbient;
|
GraphicLabel labelVolumeAmbient;
|
||||||
GraphicLabel labelVolumeMusic;
|
GraphicLabel labelVolumeMusic;
|
||||||
|
@ -42,6 +43,7 @@ private:
|
||||||
GraphicListBox listBoxTextures3D;
|
GraphicListBox listBoxTextures3D;
|
||||||
GraphicListBox listBoxLights;
|
GraphicListBox listBoxLights;
|
||||||
GraphicListBox listBoxUnitParticles;
|
GraphicListBox listBoxUnitParticles;
|
||||||
|
GraphicListBox listBoxSoundFactory;
|
||||||
GraphicListBox listBoxVolumeFx;
|
GraphicListBox listBoxVolumeFx;
|
||||||
GraphicListBox listBoxVolumeAmbient;
|
GraphicListBox listBoxVolumeAmbient;
|
||||||
GraphicListBox listBoxVolumeMusic;
|
GraphicListBox listBoxVolumeMusic;
|
||||||
|
|
|
@ -50,17 +50,18 @@ bool SoundRenderer::init(Window *window) {
|
||||||
runThreadSafe = config.getBool("ThreadedSoundStream","false");
|
runThreadSafe = config.getBool("ThreadedSoundStream","false");
|
||||||
|
|
||||||
//if(soundPlayer == NULL) {
|
//if(soundPlayer == NULL) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
si.setFactory(fr.getSoundFactory(config.getString("FactorySound")));
|
si.setFactory(fr.getSoundFactory(config.getString("FactorySound")));
|
||||||
|
|
||||||
stopAllSounds();
|
stopAllSounds();
|
||||||
|
|
||||||
soundPlayer= si.newSoundPlayer();
|
soundPlayer= si.newSoundPlayer();
|
||||||
|
if(soundPlayer != NULL) {
|
||||||
SoundPlayerParams soundPlayerParams;
|
SoundPlayerParams soundPlayerParams;
|
||||||
soundPlayerParams.staticBufferCount= config.getInt("SoundStaticBuffers");
|
soundPlayerParams.staticBufferCount= config.getInt("SoundStaticBuffers");
|
||||||
soundPlayerParams.strBufferCount= config.getInt("SoundStreamingBuffers");
|
soundPlayerParams.strBufferCount= config.getInt("SoundStreamingBuffers");
|
||||||
soundPlayer->init(&soundPlayerParams);
|
soundPlayer->init(&soundPlayerParams);
|
||||||
|
}
|
||||||
//}
|
//}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -73,6 +74,13 @@ bool SoundRenderer::wasInitOk() const {
|
||||||
if(soundPlayer != NULL) {
|
if(soundPlayer != NULL) {
|
||||||
result = soundPlayer->wasInitOk();
|
result = soundPlayer->wasInitOk();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Config &config= Config::getInstance();
|
||||||
|
if(config.getString("FactorySound") == "" ||
|
||||||
|
config.getString("FactorySound") == "None") {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "sound_factory_openal.h"
|
#include "sound_factory_openal.h"
|
||||||
|
#include "sound_factory_none.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ using Shared::Sound::Ds8::SoundFactoryDs8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using Shared::Sound::OpenAL::SoundFactoryOpenAL;
|
using Shared::Sound::OpenAL::SoundFactoryOpenAL;
|
||||||
|
using Shared::Sound::SoundFactoryNone;
|
||||||
|
|
||||||
namespace Shared{ namespace Platform{
|
namespace Shared{ namespace Platform{
|
||||||
|
|
||||||
|
@ -66,6 +68,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SoundFactoryOpenAL soundFactoryOpenAL;
|
SoundFactoryOpenAL soundFactoryOpenAL;
|
||||||
|
SoundFactoryNone soundFactoryNone;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static FactoryRepository &getInstance();
|
static FactoryRepository &getInstance();
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
// ==============================================================
|
||||||
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||||
|
//
|
||||||
|
// You can redistribute this code and/or modify it under
|
||||||
|
// the terms of the GNU General Public License as published
|
||||||
|
// by the Free Software Foundation; either version 2 of the
|
||||||
|
// License, or (at your option) any later version
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#include "factory_repository.h"
|
||||||
|
|
||||||
|
namespace Shared{ namespace Platform{
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class FactoryRepository
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
FactoryRepository &FactoryRepository::getInstance() {
|
||||||
|
static FactoryRepository factoryRepository;
|
||||||
|
return factoryRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphicsFactory *FactoryRepository::getGraphicsFactory(const string &name) {
|
||||||
|
if(name == "OpenGL") {
|
||||||
|
return &graphicsFactoryGl;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw runtime_error("Unknown graphics factory: " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
SoundFactory *FactoryRepository::getSoundFactory(const string &name) {
|
||||||
|
if(name == "OpenAL") {
|
||||||
|
return &soundFactoryOpenAL;
|
||||||
|
}
|
||||||
|
else if(name == "" || name == "None") {
|
||||||
|
return &soundFactoryNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw runtime_error("Unknown sound factory: " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}}//end namespace
|
|
@ -1,7 +1,7 @@
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
// Copyright (C) 2001-2008 Martio Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
|
@ -39,9 +39,12 @@ SoundFactory *FactoryRepository::getSoundFactory(const string &name){
|
||||||
if(name == "DirectSound8"){
|
if(name == "DirectSound8"){
|
||||||
return &soundFactoryDs8;
|
return &soundFactoryDs8;
|
||||||
}
|
}
|
||||||
if(name == "OpenAL") {
|
else if(name == "OpenAL") {
|
||||||
return &soundFactoryOpenAL;
|
return &soundFactoryOpenAL;
|
||||||
}
|
}
|
||||||
|
else if(name == "" || name == "None") {
|
||||||
|
return &soundFactoryNone;
|
||||||
|
}
|
||||||
|
|
||||||
throw runtime_error("Unknown sound factory: " + name);
|
throw runtime_error("Unknown sound factory: " + name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue