1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00

vsync & fps buttons, sound volume apply fix

This commit is contained in:
scrawl 2012-05-24 11:50:48 +02:00
parent cbe89f7e32
commit 6ea7bdb224
6 changed files with 92 additions and 45 deletions

View file

@ -10,10 +10,24 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwworld/world.hpp" #include "../mwworld/world.hpp"
#include "../mwsound/soundmanager.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "confirmationdialog.hpp" #include "confirmationdialog.hpp"
namespace
{
std::string fpsLevelToStr(int level)
{
if (level == 0)
return "#{sOff}";
else if (level == 1)
return "Basic";
else
return "Detailed";
}
}
namespace MWGui namespace MWGui
{ {
SettingsWindow::SettingsWindow(WindowManager& parWindowManager) : SettingsWindow::SettingsWindow(WindowManager& parWindowManager) :
@ -24,6 +38,8 @@ namespace MWGui
getWidget(mMenuTransparencySlider, "MenuTransparencySlider"); getWidget(mMenuTransparencySlider, "MenuTransparencySlider");
getWidget(mViewDistanceSlider, "ViewDistanceSlider"); getWidget(mViewDistanceSlider, "ViewDistanceSlider");
getWidget(mFullscreenButton, "FullscreenButton"); getWidget(mFullscreenButton, "FullscreenButton");
getWidget(mVSyncButton, "VSyncButton");
getWidget(mFPSButton, "FPSButton");
getWidget(mMasterVolumeSlider, "MasterVolume"); getWidget(mMasterVolumeSlider, "MasterVolume");
getWidget(mVoiceVolumeSlider, "VoiceVolume"); getWidget(mVoiceVolumeSlider, "VoiceVolume");
getWidget(mEffectsVolumeSlider, "EffectsVolume"); getWidget(mEffectsVolumeSlider, "EffectsVolume");
@ -32,6 +48,8 @@ namespace MWGui
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);
mVSyncButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mFPSButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onFpsToggled);
mMenuTransparencySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); mMenuTransparencySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
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);
@ -71,10 +89,9 @@ namespace MWGui
mFootstepsVolumeSlider->setScrollPosition(Settings::Manager::getFloat("footsteps volume", "Sound") * (mFootstepsVolumeSlider->getScrollRange()-1)); mFootstepsVolumeSlider->setScrollPosition(Settings::Manager::getFloat("footsteps volume", "Sound") * (mFootstepsVolumeSlider->getScrollRange()-1));
mVoiceVolumeSlider->setScrollPosition(Settings::Manager::getFloat("voice volume", "Sound") * (mVoiceVolumeSlider->getScrollRange()-1)); mVoiceVolumeSlider->setScrollPosition(Settings::Manager::getFloat("voice volume", "Sound") * (mVoiceVolumeSlider->getScrollRange()-1));
std::string on = mWindowManager.getGameSettingString("sOn", "On"); mFullscreenButton->setCaptionWithReplacing(Settings::Manager::getBool("fullscreen", "Video") ? "#{sOn}" : "#{sOff}");
std::string off = mWindowManager.getGameSettingString("sOff", "On"); mVSyncButton->setCaptionWithReplacing(Settings::Manager::getBool("vsync", "Video") ? "#{sOn}": "#{sOff}");
mFPSButton->setCaptionWithReplacing(fpsLevelToStr(Settings::Manager::getInt("fps", "HUD")));
mFullscreenButton->setCaption(Settings::Manager::getBool("fullscreen", "Video") ? on : off);
} }
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender) void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
@ -128,6 +145,20 @@ namespace MWGui
if (_sender == mFullscreenButton) if (_sender == mFullscreenButton)
Settings::Manager::setBool("fullscreen", "Video", newState); Settings::Manager::setBool("fullscreen", "Video", newState);
else if (_sender == mVSyncButton)
{
Settings::Manager::setBool("vsync", "Video", newState);
MWBase::Environment::get().getWindowManager()->
messageBox("VSync will be applied after a restart", std::vector<std::string>());
}
}
void SettingsWindow::onFpsToggled(MyGUI::Widget* _sender)
{
int newLevel = (Settings::Manager::getInt("fps", "HUD") + 1) % 3;
Settings::Manager::setInt("fps", "HUD", newLevel);
mFPSButton->setCaptionWithReplacing(fpsLevelToStr(newLevel));
apply();
} }
void SettingsWindow::onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos) void SettingsWindow::onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
@ -155,6 +186,7 @@ namespace MWGui
{ {
const Settings::CategorySettingVector changed = Settings::Manager::apply(); const Settings::CategorySettingVector changed = Settings::Manager::apply();
MWBase::Environment::get().getWorld()->processChangedSettings(changed); MWBase::Environment::get().getWorld()->processChangedSettings(changed);
MWBase::Environment::get().getWorld()->processChangedSettings(changed); MWBase::Environment::get().getSoundManager()->processChangedSettings(changed);
MWBase::Environment::get().getWindowManager()->processChangedSettings(changed);
} }
} }

View file

@ -17,9 +17,14 @@ namespace MWGui
protected: protected:
MyGUI::Button* mOkButton; MyGUI::Button* mOkButton;
MyGUI::ScrollBar* mMenuTransparencySlider;
// graphics
MyGUI::ListBox* mResolutionList; MyGUI::ListBox* mResolutionList;
MyGUI::Button* mFullscreenButton; MyGUI::Button* mFullscreenButton;
MyGUI::ScrollBar* mMenuTransparencySlider; MyGUI::Button* mVSyncButton;
MyGUI::Button* mFPSButton;
MyGUI::ScrollBar* mViewDistanceSlider; MyGUI::ScrollBar* mViewDistanceSlider;
// audio // audio
@ -30,6 +35,7 @@ namespace MWGui
MyGUI::ScrollBar* mMusicVolumeSlider; MyGUI::ScrollBar* mMusicVolumeSlider;
void onOkButtonClicked(MyGUI::Widget* _sender); void onOkButtonClicked(MyGUI::Widget* _sender);
void onFpsToggled(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);

View file

@ -554,14 +554,6 @@ void WindowManager::toggleFogOfWar()
hud->toggleFogOfWar(); hud->toggleFogOfWar();
} }
int WindowManager::toggleFps()
{
showFPSLevel = (showFPSLevel+1)%3;
hud->setFpsLevel(showFPSLevel);
Settings::Manager::setInt("fps", "HUD", showFPSLevel);
return showFPSLevel;
}
void WindowManager::setFocusObject(const MWWorld::Ptr& focus) void WindowManager::setFocusObject(const MWWorld::Ptr& focus)
{ {
mToolTips->setFocusObject(focus); mToolTips->setFocusObject(focus);
@ -611,3 +603,8 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r
else else
_result = _tag; _result = _tag;
} }
void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed)
{
hud->setFpsLevel(Settings::Manager::getInt("fps", "HUD"));
}

View file

@ -17,6 +17,7 @@
#include "MyGUI_UString.h" #include "MyGUI_UString.h"
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include <components/settings/settings.hpp>
#include <openengine/ogre/renderer.hpp> #include <openengine/ogre/renderer.hpp>
#include <openengine/gui/manager.hpp> #include <openengine/gui/manager.hpp>
@ -182,9 +183,6 @@ namespace MWGui
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script) void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const; bool getFullHelp() const;
int toggleFps();
///< toggle fps display @return resulting fps level
void setInteriorMapTexture(const int x, const int y); void setInteriorMapTexture(const int x, const int y);
///< set the index of the map texture that should be used (for interiors) ///< set the index of the map texture that should be used (for interiors)
@ -215,6 +213,8 @@ namespace MWGui
const ESMS::ESMStore& getStore() const; const ESMS::ESMStore& getStore() const;
void processChangedSettings(const Settings::CategorySettingVector& changed);
private: private:
OEngine::GUI::MyGUIManager *mGuiManager; OEngine::GUI::MyGUIManager *mGuiManager;
HUD *hud; HUD *hud;

View file

@ -69,8 +69,6 @@ namespace MWInput
A_ToggleWeapon, A_ToggleWeapon,
A_ToggleSpell, A_ToggleSpell,
A_ToggleFps, // Toggle FPS display (this is temporary)
A_Settings, // Temporary hotkey A_Settings, // Temporary hotkey
A_LAST // Marker for the last item A_LAST // Marker for the last item
@ -95,11 +93,6 @@ namespace MWInput
/* InputImpl Methods */ /* InputImpl Methods */
void toggleFps()
{
windows.toggleFps();
}
void toggleSpell() void toggleSpell()
{ {
if (windows.isGuiMode()) return; if (windows.isGuiMode()) return;
@ -271,8 +264,6 @@ namespace MWInput
"Draw Weapon"); "Draw Weapon");
disp->funcs.bind(A_ToggleSpell,boost::bind(&InputImpl::toggleSpell,this), disp->funcs.bind(A_ToggleSpell,boost::bind(&InputImpl::toggleSpell,this),
"Ready hands"); "Ready hands");
disp->funcs.bind(A_ToggleFps, boost::bind(&InputImpl::toggleFps, this),
"Toggle FPS display");
disp->funcs.bind(A_Settings, boost::bind(&InputImpl::showSettings, this), disp->funcs.bind(A_Settings, boost::bind(&InputImpl::showSettings, this),
"Show settings window"); "Show settings window");
// Add the exit listener // Add the exit listener
@ -321,7 +312,6 @@ namespace MWInput
disp->bind(A_ToggleWalk, KC_C); disp->bind(A_ToggleWalk, KC_C);
disp->bind(A_ToggleWeapon,KC_F); disp->bind(A_ToggleWeapon,KC_F);
disp->bind(A_ToggleSpell,KC_R); disp->bind(A_ToggleSpell,KC_R);
disp->bind(A_ToggleFps, KC_F10);
disp->bind(A_Settings, KC_F2); disp->bind(A_Settings, KC_F2);
// Key bindings for polled keys // Key bindings for polled keys

View file

@ -68,28 +68,50 @@
<Widget type="TabItem" skin="" position="4 28 360 312"> <Widget type="TabItem" skin="" position="4 28 360 312">
<Property key="Caption" value=" #{sVideo} "/> <Property key="Caption" value=" #{sVideo} "/>
<Widget type="ListBox" skin="MW_List" position="4 4 200 110" align="Left Top" name="ResolutionList"/> <Widget type="TabControl" skin="TabControl" position="4 4 352 304" align="Left Top">
<Property key="ButtonAutoWidth" value="true"/>
<Widget type="TabItem" skin="" position="4 28 344 272">
<Property key="Caption" value=" Video "/>
<Widget type="ListBox" skin="MW_List" position="4 4 200 150" align="Left Top" name="ResolutionList"/>
<Widget type="TextBox" skin="SandText" position="252 4 120 24" align="Left Top"> <Widget type="TextBox" skin="SandText" position="252 4 120 24" align="Left Top">
<Property key="Caption" value="Fullscreen"/> <Property key="Caption" value="Fullscreen"/>
</Widget> </Widget>
<Widget type="Button" skin="MW_Button" position="212 4 34 24" align="Left Top" name="FullscreenButton"/>
<Widget type="TextBox" skin="NormalText" position="4 130 352 18" align="Left Top"> <Widget type="Button" skin="MW_Button" position="212 4 34 24" align="Left Top" name="FullscreenButton"/>
<Widget type="TextBox" skin="SandText" position="252 34 120 24" align="Left Top">
<Property key="Caption" value="VSync"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="212 34 34 24" align="Left Top" name="VSyncButton"/>
<Widget type="TextBox" skin="SandText" position="74 170 250 24" align="Left Top">
<Property key="Caption" value="Show frames per second"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="4 170 64 24" align="Left Top" name="FPSButton"/>
</Widget>
<Widget type="TabItem" skin="" position="4 28 344 272">
<Property key="Caption" value=" Detail "/>
<Widget type="TextBox" skin="NormalText" position="4 130 322 18" align="Left Top">
<Property key="Caption" value="#{sRender_Distance}"/> <Property key="Caption" value="#{sRender_Distance}"/>
</Widget> </Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="4 154 352 18" align="Left Top" name="ViewDistanceSlider"> <Widget type="ScrollBar" skin="MW_HSlider" position="4 154 322 18" align="Left Top" name="ViewDistanceSlider">
<Property key="Range" value="1000000"/> <Property key="Range" value="1000000"/>
</Widget> </Widget>
<Widget type="TextBox" skin="SandText" position="4 178 352 18" align="Left Top"> <Widget type="TextBox" skin="SandText" position="4 178 332 18" align="Left Top">
<Property key="Caption" value="#{sNear}"/> <Property key="Caption" value="#{sNear}"/>
<Property key="TextAlign" value="Left"/> <Property key="TextAlign" value="Left"/>
</Widget> </Widget>
<Widget type="TextBox" skin="SandText" position="4 178 352 18" align="Left Top"> <Widget type="TextBox" skin="SandText" position="4 178 332 18" align="Left Top">
<Property key="Caption" value="#{sFar}"/> <Property key="Caption" value="#{sFar}"/>
<Property key="TextAlign" value="Right"/> <Property key="TextAlign" value="Right"/>
</Widget> </Widget>
</Widget> </Widget>
</Widget> </Widget>
</Widget>
</Widget>
<Widget type="Button" skin="MW_Button" position="0 351 60 24" name="OkButton" align="Right Bottom"> <Widget type="Button" skin="MW_Button" position="0 351 60 24" name="OkButton" align="Right Bottom">
<Property key="Caption" value="#{sOk}"/> <Property key="Caption" value="#{sOk}"/>