From 67577c61924860e1c67ccb303ef17149e42f9f39 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 13 Aug 2012 18:48:50 +0200 Subject: [PATCH] UI cursor & camera sensitivity sliders --- apps/openmw/mwgui/settingswindow.cpp | 14 +++++++ apps/openmw/mwgui/settingswindow.hpp | 2 + apps/openmw/mwinput/inputmanagerimp.cpp | 23 +++++++---- apps/openmw/mwinput/inputmanagerimp.hpp | 5 +++ files/mygui/openmw_settings_window.layout | 48 +++++++++++++++++++---- files/settings-default.cfg | 8 ++++ 6 files changed, 85 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 5bcec9f70..4039136a1 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -118,6 +118,8 @@ namespace MWGui getWidget(mControlsBox, "ControlsBox"); getWidget(mResetControlsButton, "ResetControlsButton"); getWidget(mInvertYButton, "InvertYButton"); + getWidget(mUISensitivitySlider, "UISensitivitySlider"); + getWidget(mCameraSensitivitySlider, "CameraSensitivitySlider"); mInvertYButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked); @@ -226,6 +228,14 @@ namespace MWGui mMiscShadows->setCaptionWithReplacing(Settings::Manager::getBool("misc shadows", "Shadows") ? "#{sOn}" : "#{sOff}"); mShadowsDebug->setCaptionWithReplacing(Settings::Manager::getBool("debug", "Shadows") ? "#{sOn}" : "#{sOff}"); + float cameraSens = (Settings::Manager::getFloat("camera sensitivity", "Input")-0.2)/(5.0-0.2); + mCameraSensitivitySlider->setScrollPosition (cameraSens * (mCameraSensitivitySlider->getScrollRange()-1)); + float uiSens = (Settings::Manager::getFloat("ui sensitivity", "Input")-0.2)/(5.0-0.2); + mUISensitivitySlider->setScrollPosition (uiSens * (mUISensitivitySlider->getScrollRange()-1)); + mCameraSensitivitySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); + mUISensitivitySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); + + mInvertYButton->setCaptionWithReplacing(Settings::Manager::getBool("invert y axis", "Input") ? "#{sOn}" : "#{sOff}"); std::string shaders; @@ -510,6 +520,10 @@ namespace MWGui Settings::Manager::setFloat("footsteps volume", "Sound", val); else if (scroller == mMusicVolumeSlider) Settings::Manager::setFloat("music volume", "Sound", val); + else if (scroller == mUISensitivitySlider) + Settings::Manager::setFloat("ui sensitivity", "Input", (1-val) * 0.2 + val * 5.f); + else if (scroller == mCameraSensitivitySlider) + Settings::Manager::setFloat("camera sensitivity", "Input", (1-val) * 0.2 + val * 5.f); apply(); } diff --git a/apps/openmw/mwgui/settingswindow.hpp b/apps/openmw/mwgui/settingswindow.hpp index aad37826e..159d52bdc 100644 --- a/apps/openmw/mwgui/settingswindow.hpp +++ b/apps/openmw/mwgui/settingswindow.hpp @@ -68,6 +68,8 @@ namespace MWGui MyGUI::ScrollView* mControlsBox; MyGUI::Button* mResetControlsButton; MyGUI::Button* mInvertYButton; + MyGUI::ScrollBar* mUISensitivitySlider; + MyGUI::ScrollBar* mCameraSensitivitySlider; void onOkButtonClicked(MyGUI::Widget* _sender); void onFpsToggled(MyGUI::Widget* _sender); diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 9f757c686..febe528c0 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -41,6 +41,10 @@ namespace MWInput , mDragDrop(false) , mGuiCursorEnabled(false) , mInvertY (Settings::Manager::getBool("invert y axis", "Input")) + , mCameraSensitivity (Settings::Manager::getFloat("camera sensitivity", "Input")) + , mUISensitivity (Settings::Manager::getFloat("ui sensitivity", "Input")) + , mCameraYMultiplier (Settings::Manager::getFloat("camera y multiplier", "Input")) + , mUIYMultiplier (Settings::Manager::getFloat("ui y multiplier", "Input")) { Ogre::RenderWindow* window = ogre.getWindow (); size_t windowHnd; @@ -284,6 +288,13 @@ namespace MWInput if (it->first == "Input" && it->second == "invert y axis") mInvertY = Settings::Manager::getBool("invert y axis", "Input"); + + if (it->first == "Input" && it->second == "camera sensitivity") + mCameraSensitivity = Settings::Manager::getFloat("camera sensitivity", "Input"); + + if (it->first == "Input" && it->second == "ui sensitivity") + mUISensitivity = Settings::Manager::getFloat("ui sensitivity", "Input"); + } if (changeRes) @@ -367,8 +378,8 @@ namespace MWInput // We keep track of our own mouse position, so that moving the mouse while in // game mode does not move the position of the GUI cursor - mMouseX += arg.state.X.rel; - mMouseY += arg.state.Y.rel; + mMouseX += arg.state.X.rel * mUISensitivity; + mMouseY += arg.state.Y.rel * mUISensitivity * mUIYMultiplier; mMouseX = std::max(0, std::min(mMouseX, viewSize.width)); mMouseY = std::max(0, std::min(mMouseY, viewSize.height)); @@ -377,8 +388,8 @@ namespace MWInput if (mMouseLookEnabled) { - float x = arg.state.X.rel * 0.2; - float y = arg.state.Y.rel * 0.2 * (mInvertY ? -1 : 1); + float x = arg.state.X.rel * mCameraSensitivity * 0.2; + float y = arg.state.Y.rel * mCameraSensitivity * 0.2 * (mInvertY ? -1 : 1) * mUIYMultiplier; MWBase::World *world = MWBase::Environment::get().getWorld(); world->rotateObject(world->getPlayer().getPlayer(), -y, 0.f, x, true); @@ -578,9 +589,6 @@ namespace MWInput descriptions[A_Rest] = "sRestKey"; descriptions[A_Inventory] = "sInventory"; - if (action == A_GameMenu) - return "Menu"; // not configurable in morrowind so no GMST - if (descriptions[action] == "") return ""; // not configurable @@ -619,7 +627,6 @@ namespace MWInput ret.push_back(A_Journal); ret.push_back(A_Rest); ret.push_back(A_Console); - ret.push_back(A_GameMenu); return ret; } diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 42c90a73a..79e5a70fc 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -135,6 +135,11 @@ namespace MWInput bool mInvertY; + float mCameraSensitivity; + float mUISensitivity; + float mCameraYMultiplier; + float mUIYMultiplier; + bool mMouseLookEnabled; bool mGuiCursorEnabled; diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout index 5908c16f9..ad906d2a1 100644 --- a/files/mygui/openmw_settings_window.layout +++ b/files/mygui/openmw_settings_window.layout @@ -83,19 +83,53 @@ - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -135,11 +169,11 @@ - + - + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index fd0c6e7af..effd9f3da 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -149,3 +149,11 @@ voice volume = 1.0 [Input] invert y axis = false + +camera sensitivity = 1.0 + +ui sensitivity = 1.0 + +camera y multiplier = 1.0 + +ui y multiplier = 1.0