mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07: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(mViewDistanceSlider, "ViewDistanceSlider");
|
||||
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);
|
||||
mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
|
@ -31,6 +36,12 @@ namespace MWGui
|
|||
mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
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();
|
||||
|
||||
int okSize = mOkButton->getTextSize().width + 24;
|
||||
|
@ -54,6 +65,12 @@ namespace MWGui
|
|||
int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val;
|
||||
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 off = mWindowManager.getGameSettingString("sOff", "On");
|
||||
|
||||
|
@ -90,7 +107,7 @@ namespace MWGui
|
|||
Settings::Manager::setInt("resolution x", "Video", resX);
|
||||
Settings::Manager::setInt("resolution y", "Video", resY);
|
||||
|
||||
MWBase::Environment::get().getWorld()->processChangedSettings(Settings::Manager::apply());
|
||||
apply();
|
||||
}
|
||||
|
||||
void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender)
|
||||
|
@ -117,14 +134,27 @@ namespace MWGui
|
|||
{
|
||||
float val = pos / float(scroller->getScrollRange()-1);
|
||||
if (scroller == mMenuTransparencySlider)
|
||||
{
|
||||
Settings::Manager::setFloat("menu transparency", "GUI", val);
|
||||
}
|
||||
else if (scroller == mViewDistanceSlider)
|
||||
{
|
||||
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);
|
||||
|
||||
apply();
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWorld()->processChangedSettings(Settings::Manager::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* mViewDistanceSlider;
|
||||
|
||||
// audio
|
||||
MyGUI::ScrollBar* mMasterVolumeSlider;
|
||||
MyGUI::ScrollBar* mVoiceVolumeSlider;
|
||||
MyGUI::ScrollBar* mEffectsVolumeSlider;
|
||||
MyGUI::ScrollBar* mFootstepsVolumeSlider;
|
||||
MyGUI::ScrollBar* mMusicVolumeSlider;
|
||||
|
||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||
void onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
|
||||
void onButtonToggled(MyGUI::Widget* _sender);
|
||||
void onResolutionSelected(MyGUI::ListBox* _sender, size_t index);
|
||||
void onResolutionAccept();
|
||||
|
||||
void apply();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <OgreRoot.h>
|
||||
|
||||
#include <components/esm_store/store.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
|
@ -53,6 +52,8 @@ namespace MWSound
|
|||
, mMasterVolume(1.0f)
|
||||
, mSFXVolume(1.0f)
|
||||
, mMusicVolume(1.0f)
|
||||
, mFootstepsVolume(1.0f)
|
||||
, mVoiceVolume(1.0f)
|
||||
{
|
||||
if(!useSound)
|
||||
return;
|
||||
|
@ -210,7 +211,7 @@ namespace MWSound
|
|||
try
|
||||
{
|
||||
// The range values are not tested
|
||||
float basevol = mMasterVolume * mSFXVolume;
|
||||
float basevol = mMasterVolume * mVoiceVolume;
|
||||
std::string filePath = "Sound/"+filename;
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||
|
@ -234,7 +235,7 @@ namespace MWSound
|
|||
return;
|
||||
try
|
||||
{
|
||||
float basevol = mMasterVolume * mSFXVolume;
|
||||
float basevol = mMasterVolume * mVoiceVolume;
|
||||
std::string filePath = "Sound/"+filename;
|
||||
|
||||
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
|
||||
// better
|
||||
void Sound_Decoder::readAll(std::vector<char> &output)
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <OgreResourceGroupManager.h>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
|
||||
|
@ -52,6 +54,10 @@ namespace MWSound
|
|||
float mMasterVolume;
|
||||
float mSFXVolume;
|
||||
float mMusicVolume;
|
||||
float mVoiceVolume;
|
||||
|
||||
// not implemented
|
||||
float mFootstepsVolume;
|
||||
|
||||
boost::shared_ptr<Sound> mMusic;
|
||||
std::string mCurrentPlaylist;
|
||||
|
@ -78,6 +84,8 @@ namespace MWSound
|
|||
SoundManager(bool useSound);
|
||||
~SoundManager();
|
||||
|
||||
void processChangedSettings(const Settings::CategorySettingVector& settings);
|
||||
|
||||
void stopMusic();
|
||||
///< Stops music if it's playing
|
||||
|
||||
|
|
|
@ -9,23 +9,58 @@
|
|||
<Widget type="TabItem" skin="" position="4 28 360 312">
|
||||
<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}"/>
|
||||
</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"/>
|
||||
</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="TextAlign" value="Left"/>
|
||||
</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="TextAlign" value="Right"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget type="TabItem" skin="" position="4 28 360 312">
|
||||
<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 type="TabItem" skin="" position="4 28 360 312">
|
||||
<Property key="Caption" value=" #{sControls} "/>
|
||||
|
|
|
@ -131,7 +131,9 @@ underwater effect = true
|
|||
# Device name. Blank means default
|
||||
device =
|
||||
|
||||
# Volumes. Sfx and music volumes are both affected by the master volume
|
||||
# Volumes. master volume affects all other volumes.
|
||||
master volume = 1.0
|
||||
sfx volume = 1.0
|
||||
music volume = 0.4
|
||||
footsteps volume = 0.6
|
||||
voice volume = 1.0
|
||||
|
|
Loading…
Reference in a new issue