vsync & fps buttons, sound volume apply fix

actorid
scrawl 13 years ago
parent cbe89f7e32
commit 6ea7bdb224

@ -10,10 +10,24 @@
#include "../mwbase/environment.hpp"
#include "../mwworld/world.hpp"
#include "../mwsound/soundmanager.hpp"
#include "window_manager.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
{
SettingsWindow::SettingsWindow(WindowManager& parWindowManager) :
@ -24,6 +38,8 @@ namespace MWGui
getWidget(mMenuTransparencySlider, "MenuTransparencySlider");
getWidget(mViewDistanceSlider, "ViewDistanceSlider");
getWidget(mFullscreenButton, "FullscreenButton");
getWidget(mVSyncButton, "VSyncButton");
getWidget(mFPSButton, "FPSButton");
getWidget(mMasterVolumeSlider, "MasterVolume");
getWidget(mVoiceVolumeSlider, "VoiceVolume");
getWidget(mEffectsVolumeSlider, "EffectsVolume");
@ -32,6 +48,8 @@ namespace MWGui
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
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);
mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
@ -71,10 +89,9 @@ namespace MWGui
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");
mFullscreenButton->setCaption(Settings::Manager::getBool("fullscreen", "Video") ? on : off);
mFullscreenButton->setCaptionWithReplacing(Settings::Manager::getBool("fullscreen", "Video") ? "#{sOn}" : "#{sOff}");
mVSyncButton->setCaptionWithReplacing(Settings::Manager::getBool("vsync", "Video") ? "#{sOn}": "#{sOff}");
mFPSButton->setCaptionWithReplacing(fpsLevelToStr(Settings::Manager::getInt("fps", "HUD")));
}
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
@ -128,6 +145,20 @@ namespace MWGui
if (_sender == mFullscreenButton)
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)
@ -155,6 +186,7 @@ namespace MWGui
{
const Settings::CategorySettingVector changed = Settings::Manager::apply();
MWBase::Environment::get().getWorld()->processChangedSettings(changed);
MWBase::Environment::get().getWorld()->processChangedSettings(changed);
MWBase::Environment::get().getSoundManager()->processChangedSettings(changed);
MWBase::Environment::get().getWindowManager()->processChangedSettings(changed);
}
}

@ -17,9 +17,14 @@ namespace MWGui
protected:
MyGUI::Button* mOkButton;
MyGUI::ScrollBar* mMenuTransparencySlider;
// graphics
MyGUI::ListBox* mResolutionList;
MyGUI::Button* mFullscreenButton;
MyGUI::ScrollBar* mMenuTransparencySlider;
MyGUI::Button* mVSyncButton;
MyGUI::Button* mFPSButton;
MyGUI::ScrollBar* mViewDistanceSlider;
// audio
@ -30,6 +35,7 @@ namespace MWGui
MyGUI::ScrollBar* mMusicVolumeSlider;
void onOkButtonClicked(MyGUI::Widget* _sender);
void onFpsToggled(MyGUI::Widget* _sender);
void onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
void onButtonToggled(MyGUI::Widget* _sender);
void onResolutionSelected(MyGUI::ListBox* _sender, size_t index);

@ -554,14 +554,6 @@ void WindowManager::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)
{
mToolTips->setFocusObject(focus);
@ -611,3 +603,8 @@ void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _r
else
_result = _tag;
}
void WindowManager::processChangedSettings(const Settings::CategorySettingVector& changed)
{
hud->setFpsLevel(Settings::Manager::getInt("fps", "HUD"));
}

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

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

@ -68,25 +68,47 @@
<Widget type="TabItem" skin="" position="4 28 360 312">
<Property key="Caption" value=" #{sVideo} "/>
<Widget type="ListBox" skin="MW_List" position="4 4 200 110" align="Left Top" name="ResolutionList"/>
<Widget type="TextBox" skin="SandText" position="252 4 120 24" align="Left Top">
<Property key="Caption" value="Fullscreen"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="212 4 34 24" align="Left Top" name="FullscreenButton"/>
<Widget type="TabControl" skin="TabControl" position="4 4 352 304" align="Left Top">
<Property key="ButtonAutoWidth" value="true"/>
<Widget type="TextBox" skin="NormalText" position="4 130 352 18" align="Left Top">
<Property key="Caption" value="#{sRender_Distance}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="4 154 352 18" align="Left Top" name="ViewDistanceSlider">
<Property key="Range" value="1000000"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 178 352 18" align="Left Top">
<Property key="Caption" value="#{sNear}"/>
<Property key="TextAlign" value="Left"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 178 352 18" align="Left Top">
<Property key="Caption" value="#{sFar}"/>
<Property key="TextAlign" value="Right"/>
<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">
<Property key="Caption" value="Fullscreen"/>
</Widget>
<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}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="4 154 322 18" align="Left Top" name="ViewDistanceSlider">
<Property key="Range" value="1000000"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 178 332 18" align="Left Top">
<Property key="Caption" value="#{sNear}"/>
<Property key="TextAlign" value="Left"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 178 332 18" align="Left Top">
<Property key="Caption" value="#{sFar}"/>
<Property key="TextAlign" value="Right"/>
</Widget>
</Widget>
</Widget>
</Widget>
</Widget>

Loading…
Cancel
Save