mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 13:53:53 +00:00
added field of view and texture filtering to settings window
This commit is contained in:
parent
6945afe95b
commit
5d03e86613
9 changed files with 151 additions and 11 deletions
|
@ -27,6 +27,18 @@ namespace
|
|||
else
|
||||
return "Detailed";
|
||||
}
|
||||
|
||||
std::string textureFilteringToStr(const std::string& val)
|
||||
{
|
||||
if (val == "none")
|
||||
return "None";
|
||||
else if (val == "anisotropic")
|
||||
return "Anisotropic";
|
||||
else if (val == "bilinear")
|
||||
return "Bilinear";
|
||||
else
|
||||
return "Trilinear";
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
|
@ -42,20 +54,28 @@ namespace MWGui
|
|||
getWidget(mFullscreenButton, "FullscreenButton");
|
||||
getWidget(mVSyncButton, "VSyncButton");
|
||||
getWidget(mFPSButton, "FPSButton");
|
||||
getWidget(mFOVSlider, "FOVSlider");
|
||||
getWidget(mMasterVolumeSlider, "MasterVolume");
|
||||
getWidget(mVoiceVolumeSlider, "VoiceVolume");
|
||||
getWidget(mEffectsVolumeSlider, "EffectsVolume");
|
||||
getWidget(mFootstepsVolumeSlider, "FootstepsVolume");
|
||||
getWidget(mMusicVolumeSlider, "MusicVolume");
|
||||
getWidget(mAnisotropySlider, "AnisotropySlider");
|
||||
getWidget(mTextureFilteringButton, "TextureFilteringButton");
|
||||
getWidget(mAnisotropyLabel, "AnisotropyLabel");
|
||||
getWidget(mAnisotropyBox, "AnisotropyBox");
|
||||
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
||||
mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mTextureFilteringButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onTextureFilteringToggled);
|
||||
mVSyncButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mFPSButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onFpsToggled);
|
||||
mMenuTransparencySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mFOVSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mToolTipDelaySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected);
|
||||
mAnisotropySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
|
||||
mMasterVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
mVoiceVolumeSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
|
||||
|
@ -84,7 +104,20 @@ namespace MWGui
|
|||
int tooltip_delay = (mToolTipDelaySlider->getScrollRange()-1) * Settings::Manager::getFloat("tooltip delay", "GUI");
|
||||
mToolTipDelaySlider->setScrollPosition(tooltip_delay);
|
||||
|
||||
float val = (Settings::Manager::getFloat("max viewing distance", "Viewing distance")-2000)/(5600-2000);
|
||||
float fovVal = (Settings::Manager::getFloat("field of view", "General")-sFovMin)/(sFovMax-sFovMin);
|
||||
mFOVSlider->setScrollPosition(fovVal * (mFOVSlider->getScrollRange()-1));
|
||||
MyGUI::TextBox* fovText;
|
||||
getWidget(fovText, "FovText");
|
||||
fovText->setCaption("Field of View (" + boost::lexical_cast<std::string>(int(Settings::Manager::getFloat("field of view", "General"))) + ")");
|
||||
|
||||
float anisotropyVal = Settings::Manager::getInt("anisotropy", "General") / 16.0;
|
||||
mAnisotropySlider->setScrollPosition(anisotropyVal * (mAnisotropySlider->getScrollRange()-1));
|
||||
std::string tf = Settings::Manager::getString("texture filtering", "General");
|
||||
mTextureFilteringButton->setCaption(textureFilteringToStr(tf));
|
||||
mAnisotropyLabel->setCaption("Anisotropy (" + boost::lexical_cast<std::string>(Settings::Manager::getInt("anisotropy", "General")) + ")");
|
||||
mAnisotropyBox->setVisible(tf == "anisotropic");
|
||||
|
||||
float val = (Settings::Manager::getFloat("max viewing distance", "Viewing distance")-sViewDistMin)/(sViewDistMax-sViewDistMin);
|
||||
int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val;
|
||||
mViewDistanceSlider->setScrollPosition(viewdist);
|
||||
|
||||
|
@ -205,6 +238,26 @@ namespace MWGui
|
|||
apply();
|
||||
}
|
||||
|
||||
void SettingsWindow::onTextureFilteringToggled(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::string current = Settings::Manager::getString("texture filtering", "General");
|
||||
std::string next;
|
||||
if (current == "none")
|
||||
next = "bilinear";
|
||||
else if (current == "bilinear")
|
||||
next = "trilinear";
|
||||
else if (current == "trilinear")
|
||||
next = "anisotropic";
|
||||
else
|
||||
next = "none";
|
||||
|
||||
mTextureFilteringButton->setCaption(textureFilteringToStr(next));
|
||||
mAnisotropyBox->setVisible(next == "anisotropic");
|
||||
|
||||
Settings::Manager::setString("texture filtering", "General", next);
|
||||
apply();
|
||||
}
|
||||
|
||||
void SettingsWindow::onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
|
||||
{
|
||||
float val = pos / float(scroller->getScrollRange()-1);
|
||||
|
@ -213,7 +266,19 @@ namespace MWGui
|
|||
else if (scroller == mToolTipDelaySlider)
|
||||
Settings::Manager::setFloat("tooltip delay", "GUI", val);
|
||||
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) * sViewDistMin + val * sViewDistMax);
|
||||
else if (scroller == mFOVSlider)
|
||||
{
|
||||
MyGUI::TextBox* fovText;
|
||||
getWidget(fovText, "FovText");
|
||||
fovText->setCaption("Field of View (" + boost::lexical_cast<std::string>(int((1-val) * sFovMin + val * sFovMax)) + ")");
|
||||
Settings::Manager::setFloat("field of view", "General", (1-val) * sFovMin + val * sFovMax);
|
||||
}
|
||||
else if (scroller == mAnisotropySlider)
|
||||
{
|
||||
mAnisotropyLabel->setCaption("Anisotropy (" + boost::lexical_cast<std::string>(int(val*16)) + ")");
|
||||
Settings::Manager::setInt("anisotropy", "General", val * 16);
|
||||
}
|
||||
else if (scroller == mMasterVolumeSlider)
|
||||
Settings::Manager::setFloat("master volume", "Sound", val);
|
||||
else if (scroller == mVoiceVolumeSlider)
|
||||
|
|
|
@ -15,6 +15,12 @@ namespace MWGui
|
|||
public:
|
||||
SettingsWindow(WindowManager& parWindowManager);
|
||||
|
||||
private:
|
||||
static const float sFovMin = 30;
|
||||
static const float sFovMax = 140;
|
||||
static const float sViewDistMin = 2000;
|
||||
static const float sViewDistMax = 5600;
|
||||
|
||||
protected:
|
||||
MyGUI::Button* mOkButton;
|
||||
|
||||
|
@ -27,6 +33,11 @@ namespace MWGui
|
|||
MyGUI::Button* mVSyncButton;
|
||||
MyGUI::Button* mFPSButton;
|
||||
MyGUI::ScrollBar* mViewDistanceSlider;
|
||||
MyGUI::ScrollBar* mFOVSlider;
|
||||
MyGUI::ScrollBar* mAnisotropySlider;
|
||||
MyGUI::Button* mTextureFilteringButton;
|
||||
MyGUI::TextBox* mAnisotropyLabel;
|
||||
MyGUI::Widget* mAnisotropyBox;
|
||||
|
||||
// audio
|
||||
MyGUI::ScrollBar* mMasterVolumeSlider;
|
||||
|
@ -37,6 +48,7 @@ namespace MWGui
|
|||
|
||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||
void onFpsToggled(MyGUI::Widget* _sender);
|
||||
void onTextureFilteringToggled(MyGUI::Widget* _sender);
|
||||
void onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
|
||||
void onButtonToggled(MyGUI::Widget* _sender);
|
||||
void onResolutionSelected(MyGUI::ListBox* _sender, size_t index);
|
||||
|
|
|
@ -590,6 +590,21 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
|
|||
|| it->second == "resolution y"
|
||||
|| it->second == "fullscreen"))
|
||||
changeRes = true;
|
||||
else if (it->second == "field of view" && it->first == "General")
|
||||
mRendering.setFov(Settings::Manager::getFloat("field of view", "General"));
|
||||
else if ((it->second == "texture filtering" && it->first == "General")
|
||||
|| (it->second == "anisotropy" && it->first == "General"))
|
||||
{
|
||||
TextureFilterOptions tfo;
|
||||
std::string filter = Settings::Manager::getString("texture filtering", "General");
|
||||
if (filter == "anisotropic") tfo = TFO_ANISOTROPIC;
|
||||
else if (filter == "trilinear") tfo = TFO_TRILINEAR;
|
||||
else if (filter == "bilinear") tfo = TFO_BILINEAR;
|
||||
else if (filter == "none") tfo = TFO_NONE;
|
||||
|
||||
MaterialManager::getSingleton().setDefaultTextureFiltering(tfo);
|
||||
MaterialManager::getSingleton().setDefaultAnisotropy( (filter == "anisotropic") ? Settings::Manager::getInt("anisotropy", "General") : 1 );
|
||||
}
|
||||
}
|
||||
|
||||
if (changeRes)
|
||||
|
|
|
@ -60,9 +60,9 @@
|
|||
|
||||
<!-- Available ingredients -->
|
||||
<Widget type="Widget" skin="MW_Box" position="8 126 247 238" name="box" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 239 220" name="ItemView" align="Left Top Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 239 230" name="ItemView" align="Left Top Stretch">
|
||||
<Property key="CanvasAlign" value="Left Top"/>
|
||||
<Widget type="Button" skin="" name="Items" position="0 0 239 220" name="Items" align="Left Top Stretch"/>
|
||||
<Widget type="Button" skin="" name="Items" position="0 0 239 230" name="Items" align="Left Top Stretch"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
|
|
|
@ -100,15 +100,44 @@
|
|||
</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">
|
||||
<Widget type="TextBox" skin="SandText" position="74 163 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 type="Button" skin="MW_Button" position="4 163 64 24" align="Left Top" name="FPSButton"/>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="4 198 329 18" align="Left Top" name="FovText">
|
||||
<Property key="Caption" value="Field of View"/>
|
||||
</Widget>
|
||||
<Widget type="ScrollBar" skin="MW_HSlider" position="4 222 329 18" align="Left Top" name="FOVSlider">
|
||||
<Property key="Range" value="1000000"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="4 246 329 18" align="Left Top">
|
||||
<Property key="Caption" value="Low"/>
|
||||
<Property key="TextAlign" value="Left"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="4 246 329 18" align="Left Top">
|
||||
<Property key="Caption" value="High"/>
|
||||
<Property key="TextAlign" value="Right"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="TabItem" skin="" position="4 28 344 272">
|
||||
<Property key="Caption" value=" Detail "/>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="4 4 300 24" align="Left Top">
|
||||
<Property key="Caption" value="Texture filtering"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="18 28 140 24" align="Left Top" name="TextureFilteringButton"/>
|
||||
|
||||
<Widget type="Widget" skin="" position="184 4 300 50" align="Left Top" name="AnisotropyBox">
|
||||
<Widget type="TextBox" skin="SandText" position="0 0 300 24" align="Left Top" name="AnisotropyLabel">
|
||||
<Property key="Caption" value="Anisotropy"/>
|
||||
</Widget>
|
||||
<Widget type="ScrollBar" skin="MW_HSlider" position="0 28 150 18" align="Left Top" name="AnisotropySlider">
|
||||
<Property key="Range" value="1000000"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="4 130 322 18" align="Left Top">
|
||||
<Property key="Caption" value="#{sRender_Distance}"/>
|
||||
</Widget>
|
||||
|
|
|
@ -9,8 +9,13 @@ using namespace OEngine::GUI;
|
|||
|
||||
EventInjector::EventInjector(MyGUI::Gui *g)
|
||||
: gui(g), enabled(true)
|
||||
, mMouseX(0)
|
||||
, mMouseY(0)
|
||||
{
|
||||
assert(gui);
|
||||
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
mMouseX = viewSize.width/2;
|
||||
mMouseY = viewSize.height/2;
|
||||
}
|
||||
|
||||
void EventInjector::event(Type type, int index, const void *p)
|
||||
|
@ -54,15 +59,19 @@ void EventInjector::event(Type type, int index, const void *p)
|
|||
MouseEvent *mouse = (MouseEvent*)p;
|
||||
MyGUI::MouseButton id = MyGUI::MouseButton::Enum(index);
|
||||
|
||||
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
|
||||
// Update mouse position
|
||||
int mouseX = mouse->state.X.abs;
|
||||
int mouseY = mouse->state.Y.abs;
|
||||
mMouseX += mouse->state.X.rel;
|
||||
mMouseY += mouse->state.Y.rel;
|
||||
mMouseX = std::max(0, std::min(mMouseX, viewSize.width));
|
||||
mMouseY = std::max(0, std::min(mMouseY, viewSize.height));
|
||||
|
||||
if(type == EV_MouseDown)
|
||||
MyGUI::InputManager::getInstance().injectMousePress(mouseX, mouseY, id);
|
||||
MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, id);
|
||||
else if(type == EV_MouseUp)
|
||||
MyGUI::InputManager::getInstance().injectMouseRelease(mouseX, mouseY, id);
|
||||
MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, id);
|
||||
else
|
||||
MyGUI::InputManager::getInstance().injectMouseMove(mouseX, mouseY, mouse->state.Z.abs);
|
||||
MyGUI::InputManager::getInstance().injectMouseMove(mMouseX, mMouseY, mouse->state.Z.abs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,9 @@ namespace GUI
|
|||
{
|
||||
MyGUI::Gui *gui;
|
||||
|
||||
int mMouseX;
|
||||
int mMouseY;
|
||||
|
||||
public:
|
||||
bool enabled;
|
||||
|
||||
|
|
|
@ -155,3 +155,8 @@ void OgreRenderer::setWindowEventListener(Ogre::WindowEventListener* listener)
|
|||
{
|
||||
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, listener);
|
||||
}
|
||||
|
||||
void OgreRenderer::setFov(float fov)
|
||||
{
|
||||
mCamera->setFOVy(Degree(fov));
|
||||
}
|
||||
|
|
|
@ -124,6 +124,8 @@ namespace OEngine
|
|||
float nearClip=5 // Near clip distance
|
||||
);
|
||||
|
||||
void setFov(float fov);
|
||||
|
||||
/// Kill the renderer.
|
||||
void cleanup();
|
||||
|
||||
|
|
Loading…
Reference in a new issue