mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 11:53:53 +00:00
audio tab with volume sliders
This commit is contained in:
parent
cb35f4d208
commit
9b94edd561
6 changed files with 109 additions and 15 deletions
|
@ -24,6 +24,11 @@ namespace MWGui
|
||||||
getWidget(mMenuTransparencySlider, "MenuTransparencySlider");
|
getWidget(mMenuTransparencySlider, "MenuTransparencySlider");
|
||||||
getWidget(mViewDistanceSlider, "ViewDistanceSlider");
|
getWidget(mViewDistanceSlider, "ViewDistanceSlider");
|
||||||
getWidget(mFullscreenButton, "FullscreenButton");
|
getWidget(mFullscreenButton, "FullscreenButton");
|
||||||
|
getWidget(mMasterVolumeSlider, "MasterVolume");
|
||||||
|
getWidget(mVoiceVolumeSlider, "VoiceVolume");
|
||||||
|
getWidget(mEffectsVolumeSlider, "EffectsVolume");
|
||||||
|
getWidget(mFootstepsVolumeSlider, "FootstepsVolume");
|
||||||
|
getWidget(mMusicVolumeSlider, "MusicVolume");
|
||||||
|
|
||||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
||||||
mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||||
|
@ -31,6 +36,12 @@ namespace MWGui
|
||||||
mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||||
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
|
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
|
||||||
|
|
||||||
|
mMasterVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||||
|
mVoiceVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||||
|
mEffectsVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||||
|
mFootstepsVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||||
|
mMusicVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||||
|
|
||||||
center();
|
center();
|
||||||
|
|
||||||
int okSize = mOkButton->getTextSize().width + 24;
|
int okSize = mOkButton->getTextSize().width + 24;
|
||||||
|
@ -54,6 +65,12 @@ namespace MWGui
|
||||||
int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val;
|
int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val;
|
||||||
mViewDistanceSlider->setScrollPosition(viewdist);
|
mViewDistanceSlider->setScrollPosition(viewdist);
|
||||||
|
|
||||||
|
mMasterVolumeSlider->setScrollPosition(Settings::Manager::getFloat("master volume", "Sound") * (mMasterVolumeSlider->getScrollRange()-1));
|
||||||
|
mMusicVolumeSlider->setScrollPosition(Settings::Manager::getFloat("music volume", "Sound") * (mMusicVolumeSlider->getScrollRange()-1));
|
||||||
|
mEffectsVolumeSlider->setScrollPosition(Settings::Manager::getFloat("sfx volume", "Sound") * (mEffectsVolumeSlider->getScrollRange()-1));
|
||||||
|
mFootstepsVolumeSlider->setScrollPosition(Settings::Manager::getFloat("footsteps volume", "Sound") * (mFootstepsVolumeSlider->getScrollRange()-1));
|
||||||
|
mVoiceVolumeSlider->setScrollPosition(Settings::Manager::getFloat("voice volume", "Sound") * (mVoiceVolumeSlider->getScrollRange()-1));
|
||||||
|
|
||||||
std::string on = mWindowManager.getGameSettingString("sOn", "On");
|
std::string on = mWindowManager.getGameSettingString("sOn", "On");
|
||||||
std::string off = mWindowManager.getGameSettingString("sOff", "On");
|
std::string off = mWindowManager.getGameSettingString("sOff", "On");
|
||||||
|
|
||||||
|
@ -90,7 +107,7 @@ namespace MWGui
|
||||||
Settings::Manager::setInt("resolution x", "Video", resX);
|
Settings::Manager::setInt("resolution x", "Video", resX);
|
||||||
Settings::Manager::setInt("resolution y", "Video", resY);
|
Settings::Manager::setInt("resolution y", "Video", resY);
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->processChangedSettings(Settings::Manager::apply());
|
apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
|
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
|
||||||
|
@ -117,14 +134,27 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
float val = pos / float(scroller->getScrollRange()-1);
|
float val = pos / float(scroller->getScrollRange()-1);
|
||||||
if (scroller == mMenuTransparencySlider)
|
if (scroller == mMenuTransparencySlider)
|
||||||
{
|
|
||||||
Settings::Manager::setFloat("menu transparency", "GUI", val);
|
Settings::Manager::setFloat("menu transparency", "GUI", val);
|
||||||
}
|
|
||||||
else if (scroller == mViewDistanceSlider)
|
else if (scroller == mViewDistanceSlider)
|
||||||
{
|
|
||||||
Settings::Manager::setFloat("max viewing distance", "Viewing distance", (1-val) * 2000 + val * 5600);
|
Settings::Manager::setFloat("max viewing distance", "Viewing distance", (1-val) * 2000 + val * 5600);
|
||||||
}
|
else if (scroller == mMasterVolumeSlider)
|
||||||
|
Settings::Manager::setFloat("master volume", "Sound", val);
|
||||||
|
else if (scroller == mVoiceVolumeSlider)
|
||||||
|
Settings::Manager::setFloat("voice volume", "Sound", val);
|
||||||
|
else if (scroller == mEffectsVolumeSlider)
|
||||||
|
Settings::Manager::setFloat("sfx volume", "Sound", val);
|
||||||
|
else if (scroller == mFootstepsVolumeSlider)
|
||||||
|
Settings::Manager::setFloat("footsteps volume", "Sound", val);
|
||||||
|
else if (scroller == mMusicVolumeSlider)
|
||||||
|
Settings::Manager::setFloat("music volume", "Sound", val);
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->processChangedSettings(Settings::Manager::apply());
|
apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsWindow::apply()
|
||||||
|
{
|
||||||
|
const Settings::CategorySettingVector changed = Settings::Manager::apply();
|
||||||
|
MWBase::Environment::get().getWorld()->processChangedSettings(changed);
|
||||||
|
MWBase::Environment::get().getWorld()->processChangedSettings(changed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,20 @@ namespace MWGui
|
||||||
MyGUI::ScrollBar* mMenuTransparencySlider;
|
MyGUI::ScrollBar* mMenuTransparencySlider;
|
||||||
MyGUI::ScrollBar* mViewDistanceSlider;
|
MyGUI::ScrollBar* mViewDistanceSlider;
|
||||||
|
|
||||||
|
// audio
|
||||||
|
MyGUI::ScrollBar* mMasterVolumeSlider;
|
||||||
|
MyGUI::ScrollBar* mVoiceVolumeSlider;
|
||||||
|
MyGUI::ScrollBar* mEffectsVolumeSlider;
|
||||||
|
MyGUI::ScrollBar* mFootstepsVolumeSlider;
|
||||||
|
MyGUI::ScrollBar* mMusicVolumeSlider;
|
||||||
|
|
||||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
|
void onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
|
||||||
void onButtonToggled(MyGUI::Widget* _sender);
|
void onButtonToggled(MyGUI::Widget* _sender);
|
||||||
void onResolutionSelected(MyGUI::ListBox* _sender, size_t index);
|
void onResolutionSelected(MyGUI::ListBox* _sender, size_t index);
|
||||||
void onResolutionAccept();
|
void onResolutionAccept();
|
||||||
|
|
||||||
|
void apply();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
|
||||||
|
@ -53,6 +52,8 @@ namespace MWSound
|
||||||
, mMasterVolume(1.0f)
|
, mMasterVolume(1.0f)
|
||||||
, mSFXVolume(1.0f)
|
, mSFXVolume(1.0f)
|
||||||
, mMusicVolume(1.0f)
|
, mMusicVolume(1.0f)
|
||||||
|
, mFootstepsVolume(1.0f)
|
||||||
|
, mVoiceVolume(1.0f)
|
||||||
{
|
{
|
||||||
if(!useSound)
|
if(!useSound)
|
||||||
return;
|
return;
|
||||||
|
@ -210,7 +211,7 @@ namespace MWSound
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// The range values are not tested
|
// The range values are not tested
|
||||||
float basevol = mMasterVolume * mSFXVolume;
|
float basevol = mMasterVolume * mVoiceVolume;
|
||||||
std::string filePath = "Sound/"+filename;
|
std::string filePath = "Sound/"+filename;
|
||||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||||
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||||
|
@ -234,7 +235,7 @@ namespace MWSound
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
float basevol = mMasterVolume * mSFXVolume;
|
float basevol = mMasterVolume * mVoiceVolume;
|
||||||
std::string filePath = "Sound/"+filename;
|
std::string filePath = "Sound/"+filename;
|
||||||
|
|
||||||
SoundPtr sound = mOutput->playSound(filePath, basevol, 1.0f, Play_Normal);
|
SoundPtr sound = mOutput->playSound(filePath, basevol, 1.0f, Play_Normal);
|
||||||
|
@ -527,6 +528,15 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SoundManager::processChangedSettings(const Settings::CategorySettingVector& settings)
|
||||||
|
{
|
||||||
|
mMasterVolume = Settings::Manager::getFloat("master volume", "Sound");
|
||||||
|
mMusicVolume = Settings::Manager::getFloat("music volume", "Sound");
|
||||||
|
mSFXVolume = Settings::Manager::getFloat("sfx volume", "Sound");
|
||||||
|
mFootstepsVolume = Settings::Manager::getFloat("footsteps volume", "Sound");
|
||||||
|
mVoiceVolume = Settings::Manager::getFloat("voice volume", "Sound");
|
||||||
|
}
|
||||||
|
|
||||||
// Default readAll implementation, for decoders that can't do anything
|
// Default readAll implementation, for decoders that can't do anything
|
||||||
// better
|
// better
|
||||||
void Sound_Decoder::readAll(std::vector<char> &output)
|
void Sound_Decoder::readAll(std::vector<char> &output)
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include <OgreResourceGroupManager.h>
|
#include <OgreResourceGroupManager.h>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,6 +54,10 @@ namespace MWSound
|
||||||
float mMasterVolume;
|
float mMasterVolume;
|
||||||
float mSFXVolume;
|
float mSFXVolume;
|
||||||
float mMusicVolume;
|
float mMusicVolume;
|
||||||
|
float mVoiceVolume;
|
||||||
|
|
||||||
|
// not implemented
|
||||||
|
float mFootstepsVolume;
|
||||||
|
|
||||||
boost::shared_ptr<Sound> mMusic;
|
boost::shared_ptr<Sound> mMusic;
|
||||||
std::string mCurrentPlaylist;
|
std::string mCurrentPlaylist;
|
||||||
|
@ -78,6 +84,8 @@ namespace MWSound
|
||||||
SoundManager(bool useSound);
|
SoundManager(bool useSound);
|
||||||
~SoundManager();
|
~SoundManager();
|
||||||
|
|
||||||
|
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
||||||
|
|
||||||
void stopMusic();
|
void stopMusic();
|
||||||
///< Stops music if it's playing
|
///< Stops music if it's playing
|
||||||
|
|
||||||
|
|
|
@ -9,23 +9,58 @@
|
||||||
<Widget type="TabItem" skin="" position="4 28 360 312">
|
<Widget type="TabItem" skin="" position="4 28 360 312">
|
||||||
<Property key="Caption" value=" #{sPrefs} "/>
|
<Property key="Caption" value=" #{sPrefs} "/>
|
||||||
|
|
||||||
<Widget type="TextBox" skin="NormalText" position="4 10 352 18" align="Left Top">
|
<Widget type="TextBox" skin="NormalText" position="4 4 352 18" align="Left Top">
|
||||||
<Property key="Caption" value="#{sTransparency_Menu}"/>
|
<Property key="Caption" value="#{sTransparency_Menu}"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="ScrollBar" skin="MW_HSlider" position="4 34 352 18" align="Left Top" name="MenuTransparencySlider">
|
<Widget type="ScrollBar" skin="MW_HSlider" position="4 28 352 18" align="Left Top" name="MenuTransparencySlider">
|
||||||
<Property key="Range" value="1000000"/>
|
<Property key="Range" value="1000000"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="TextBox" skin="SandText" position="4 58 352 18" align="Left Top">
|
<Widget type="TextBox" skin="SandText" position="4 52 352 18" align="Left Top">
|
||||||
<Property key="Caption" value="#{sFull}"/>
|
<Property key="Caption" value="#{sFull}"/>
|
||||||
<Property key="TextAlign" value="Left"/>
|
<Property key="TextAlign" value="Left"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="TextBox" skin="SandText" position="4 58 352 18" align="Left Top">
|
<Widget type="TextBox" skin="SandText" position="4 52 352 18" align="Left Top">
|
||||||
<Property key="Caption" value="#{sNone}"/>
|
<Property key="Caption" value="#{sNone}"/>
|
||||||
<Property key="TextAlign" value="Right"/>
|
<Property key="TextAlign" value="Right"/>
|
||||||
</Widget>
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="TabItem" skin="" position="4 28 360 312">
|
<Widget type="TabItem" skin="" position="4 28 360 312">
|
||||||
<Property key="Caption" value=" #{sAudio} "/>
|
<Property key="Caption" value=" #{sAudio} "/>
|
||||||
|
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="4 4 352 18" align="Left Top">
|
||||||
|
<Property key="Caption" value="#{sMaster}"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HSlider" position="4 28 352 18" align="Left Top" name="MasterVolume">
|
||||||
|
<Property key="Range" value="1000000"/>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="4 54 352 18" align="Left Top">
|
||||||
|
<Property key="Caption" value="#{sVoice}"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HSlider" position="4 78 352 18" align="Left Top" name="VoiceVolume">
|
||||||
|
<Property key="Range" value="1000000"/>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="4 104 352 18" align="Left Top">
|
||||||
|
<Property key="Caption" value="#{sEffects}"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HSlider" position="4 128 352 18" align="Left Top" name="EffectsVolume">
|
||||||
|
<Property key="Range" value="1000000"/>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="4 154 352 18" align="Left Top">
|
||||||
|
<Property key="Caption" value="#{sFootsteps}"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HSlider" position="4 178 352 18" align="Left Top" name="FootstepsVolume">
|
||||||
|
<Property key="Range" value="1000000"/>
|
||||||
|
</Widget>
|
||||||
|
|
||||||
|
<Widget type="TextBox" skin="NormalText" position="4 204 352 18" align="Left Top">
|
||||||
|
<Property key="Caption" value="#{sMusic}"/>
|
||||||
|
</Widget>
|
||||||
|
<Widget type="ScrollBar" skin="MW_HSlider" position="4 228 352 18" align="Left Top" name="MusicVolume">
|
||||||
|
<Property key="Range" value="1000000"/>
|
||||||
|
</Widget>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget type="TabItem" skin="" position="4 28 360 312">
|
<Widget type="TabItem" skin="" position="4 28 360 312">
|
||||||
<Property key="Caption" value=" #{sControls} "/>
|
<Property key="Caption" value=" #{sControls} "/>
|
||||||
|
|
|
@ -131,7 +131,9 @@ underwater effect = true
|
||||||
# Device name. Blank means default
|
# Device name. Blank means default
|
||||||
device =
|
device =
|
||||||
|
|
||||||
# Volumes. Sfx and music volumes are both affected by the master volume
|
# Volumes. master volume affects all other volumes.
|
||||||
master volume = 1.0
|
master volume = 1.0
|
||||||
sfx volume = 1.0
|
sfx volume = 1.0
|
||||||
music volume = 0.4
|
music volume = 0.4
|
||||||
|
footsteps volume = 0.6
|
||||||
|
voice volume = 1.0
|
||||||
|
|
Loading…
Reference in a new issue