forked from mirror/openmw-tes3mp
"reset to defaults" button, invert y axis button
This commit is contained in:
parent
bc6e4feedc
commit
c7b8787c32
7 changed files with 88 additions and 12 deletions
|
@ -37,6 +37,7 @@ namespace MWBase
|
|||
virtual std::vector<int> getActionSorting () = 0;
|
||||
virtual int getNumActions() = 0;
|
||||
virtual void enableDetectingBindingMode (int action) = 0;
|
||||
virtual void resetToDefaultBindings() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,10 @@ namespace MWGui
|
|||
getWidget(mShadowsDebug, "ShadowsDebug");
|
||||
getWidget(mUnderwaterButton, "UnderwaterButton");
|
||||
getWidget(mControlsBox, "ControlsBox");
|
||||
getWidget(mResetControlsButton, "ResetControlsButton");
|
||||
getWidget(mInvertYButton, "InvertYButton");
|
||||
|
||||
mInvertYButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
||||
mUnderwaterButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled);
|
||||
|
@ -155,6 +158,9 @@ namespace MWGui
|
|||
mOkButton->setCoord(mMainWidget->getWidth()-16-okSize, mOkButton->getTop(),
|
||||
okSize, mOkButton->getHeight());
|
||||
|
||||
mResetControlsButton->setSize (mResetControlsButton->getTextSize ().width + 24, mResetControlsButton->getHeight());
|
||||
mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
|
||||
|
||||
// fill resolution list
|
||||
Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
|
||||
Ogre::StringVector videoModes = rs->getConfigOptions()["Video Mode"].possibleValues;
|
||||
|
@ -220,6 +226,8 @@ namespace MWGui
|
|||
mMiscShadows->setCaptionWithReplacing(Settings::Manager::getBool("misc shadows", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
mShadowsDebug->setCaptionWithReplacing(Settings::Manager::getBool("debug", "Shadows") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
mInvertYButton->setCaptionWithReplacing(Settings::Manager::getBool("invert y axis", "Input") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
std::string shaders;
|
||||
if (!Settings::Manager::getBool("shaders", "Objects"))
|
||||
shaders = "off";
|
||||
|
@ -383,6 +391,8 @@ namespace MWGui
|
|||
Settings::Manager::setBool("misc shadows", "Shadows", newState);
|
||||
else if (_sender == mShadowsDebug)
|
||||
Settings::Manager::setBool("debug", "Shadows", newState);
|
||||
else if (_sender == mInvertYButton)
|
||||
Settings::Manager::setBool("invert y axis", "Input", newState);
|
||||
|
||||
apply();
|
||||
}
|
||||
|
@ -521,8 +531,8 @@ namespace MWGui
|
|||
std::vector<int> actions = MWBase::Environment::get().getInputManager()->getActionSorting ();
|
||||
|
||||
const int h = 18;
|
||||
const int w = mControlsBox->getWidth() - 34;
|
||||
int curH = 6;
|
||||
const int w = mControlsBox->getWidth() - 28;
|
||||
int curH = 0;
|
||||
for (std::vector<int>::const_iterator it = actions.begin(); it != actions.end(); ++it)
|
||||
{
|
||||
std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (*it);
|
||||
|
@ -539,6 +549,7 @@ namespace MWGui
|
|||
rightText->setTextAlign (MyGUI::Align::Right);
|
||||
rightText->setUserData(*it); // save the action id for callbacks
|
||||
rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction);
|
||||
rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel);
|
||||
curH += h;
|
||||
}
|
||||
|
||||
|
@ -558,6 +569,29 @@ namespace MWGui
|
|||
|
||||
}
|
||||
|
||||
void SettingsWindow::onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel)
|
||||
{
|
||||
if (mControlsBox->getViewOffset().top + _rel*0.3 > 0)
|
||||
mControlsBox->setViewOffset(MyGUI::IntPoint(0, 0));
|
||||
else
|
||||
mControlsBox->setViewOffset(MyGUI::IntPoint(0, mControlsBox->getViewOffset().top + _rel*0.3));
|
||||
}
|
||||
|
||||
void SettingsWindow::onResetDefaultBindings(MyGUI::Widget* _sender)
|
||||
{
|
||||
ConfirmationDialog* dialog = mWindowManager.getConfirmationDialog();
|
||||
dialog->open("#{sNotifyMessage66}");
|
||||
dialog->eventOkClicked.clear();
|
||||
dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindingsAccept);
|
||||
dialog->eventCancelClicked.clear();
|
||||
}
|
||||
|
||||
void SettingsWindow::onResetDefaultBindingsAccept()
|
||||
{
|
||||
MWBase::Environment::get().getInputManager ()->resetToDefaultBindings ();
|
||||
updateControlsBox ();
|
||||
}
|
||||
|
||||
void SettingsWindow::open()
|
||||
{
|
||||
updateControlsBox ();
|
||||
|
|
|
@ -66,6 +66,8 @@ namespace MWGui
|
|||
|
||||
// controls
|
||||
MyGUI::ScrollView* mControlsBox;
|
||||
MyGUI::Button* mResetControlsButton;
|
||||
MyGUI::Button* mInvertYButton;
|
||||
|
||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||
void onFpsToggled(MyGUI::Widget* _sender);
|
||||
|
@ -80,6 +82,9 @@ namespace MWGui
|
|||
void onShadowTextureSize(MyGUI::Widget* _sender);
|
||||
|
||||
void onRebindAction(MyGUI::Widget* _sender);
|
||||
void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||
void onResetDefaultBindings(MyGUI::Widget* _sender);
|
||||
void onResetDefaultBindingsAccept ();
|
||||
|
||||
void apply();
|
||||
};
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace MWInput
|
|||
, mUserFile(userFile)
|
||||
, mDragDrop(false)
|
||||
, mGuiCursorEnabled(false)
|
||||
, mInvertY (Settings::Manager::getBool("invert y axis", "Input"))
|
||||
{
|
||||
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||
size_t windowHnd;
|
||||
|
@ -280,6 +281,9 @@ namespace MWInput
|
|||
{
|
||||
if (it->first == "Video" && (it->second == "resolution x" || it->second == "resolution y"))
|
||||
changeRes = true;
|
||||
|
||||
if (it->first == "Input" && it->second == "invert y axis")
|
||||
mInvertY = Settings::Manager::getBool("invert y axis", "Input");
|
||||
}
|
||||
|
||||
if (changeRes)
|
||||
|
@ -374,7 +378,7 @@ namespace MWInput
|
|||
if (mMouseLookEnabled)
|
||||
{
|
||||
float x = arg.state.X.rel * 0.2;
|
||||
float y = arg.state.Y.rel * 0.2;
|
||||
float y = arg.state.Y.rel * 0.2 * (mInvertY ? -1 : 1);
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
world->rotateObject(world->getPlayer().getPlayer(), -y, 0.f, x, true);
|
||||
|
@ -504,7 +508,7 @@ namespace MWInput
|
|||
return mInputCtrl->getChannel (id)->getValue () == 1;
|
||||
}
|
||||
|
||||
void InputManager::loadKeyDefaults ()
|
||||
void InputManager::loadKeyDefaults (bool force)
|
||||
{
|
||||
// using hardcoded key defaults is inevitable, if we want the configuration files to stay valid
|
||||
// across different versions of OpenMW (in the case where another input action is added)
|
||||
|
@ -530,16 +534,27 @@ namespace MWInput
|
|||
|
||||
for (int i = 0; i < A_Last; ++i)
|
||||
{
|
||||
if (mInputCtrl->getChannel(i)->getControlsCount () == 0)
|
||||
ICS::Control* control;
|
||||
bool controlExists = mInputCtrl->getChannel(i)->getControlsCount () != 0;
|
||||
if (!controlExists)
|
||||
{
|
||||
ICS::Control* control1 = new ICS::Control(boost::lexical_cast<std::string>(i), false, true, 0, ICS::ICS_MAX, ICS::ICS_MAX);
|
||||
mInputCtrl->addControl(control1);
|
||||
control1->attachChannel(mInputCtrl->getChannel(i), ICS::Channel::DIRECT);
|
||||
control = new ICS::Control(boost::lexical_cast<std::string>(i), false, true, 0, ICS::ICS_MAX, ICS::ICS_MAX);
|
||||
mInputCtrl->addControl(control);
|
||||
control->attachChannel(mInputCtrl->getChannel(i), ICS::Channel::DIRECT);
|
||||
}
|
||||
else
|
||||
{
|
||||
control = mInputCtrl->getChannel(i)->getAttachedControls ().front().control;
|
||||
}
|
||||
|
||||
if (!controlExists || force)
|
||||
{
|
||||
clearAllBindings (control);
|
||||
|
||||
if (defaultKeyBindings.find(i) != defaultKeyBindings.end())
|
||||
mInputCtrl->addKeyBinding(control1, static_cast<OIS::KeyCode>(defaultKeyBindings[i]), ICS::Control::INCREASE);
|
||||
mInputCtrl->addKeyBinding(control, static_cast<OIS::KeyCode>(defaultKeyBindings[i]), ICS::Control::INCREASE);
|
||||
else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end())
|
||||
mInputCtrl->addMouseButtonBinding (control1, defaultMouseButtonBindings[i], ICS::Control::INCREASE);
|
||||
mInputCtrl->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -597,6 +612,7 @@ namespace MWInput
|
|||
ret.push_back(A_Crouch);
|
||||
ret.push_back(A_Activate);
|
||||
ret.push_back(A_ToggleWeapon);
|
||||
ret.push_back(A_ToggleSpell);
|
||||
ret.push_back(A_AutoMove);
|
||||
ret.push_back(A_Jump);
|
||||
ret.push_back(A_Inventory);
|
||||
|
@ -681,4 +697,9 @@ namespace MWInput
|
|||
/// \todo add joysticks here once they are added
|
||||
}
|
||||
|
||||
void InputManager::resetToDefaultBindings()
|
||||
{
|
||||
loadKeyDefaults(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ namespace MWInput
|
|||
virtual int getNumActions() { return A_Last; }
|
||||
virtual std::vector<int> getActionSorting ();
|
||||
virtual void enableDetectingBindingMode (int action);
|
||||
virtual void resetToDefaultBindings();
|
||||
|
||||
|
||||
public:
|
||||
|
@ -132,6 +133,8 @@ namespace MWInput
|
|||
|
||||
bool mDragDrop;
|
||||
|
||||
bool mInvertY;
|
||||
|
||||
bool mMouseLookEnabled;
|
||||
bool mGuiCursorEnabled;
|
||||
|
||||
|
@ -159,7 +162,7 @@ namespace MWInput
|
|||
|
||||
bool actionIsActive (int id);
|
||||
|
||||
void loadKeyDefaults();
|
||||
void loadKeyDefaults(bool force = false);
|
||||
|
||||
private:
|
||||
enum Actions
|
||||
|
|
|
@ -84,9 +84,16 @@
|
|||
<Property key="Caption" value=" #{sControls} "/>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="8 8 344 180">
|
||||
|
||||
<Widget type="ScrollView" skin="MW_ScrollView" name="ControlsBox" position="4 4 336 172"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" skin="MW_Button" name="ResetControlsButton" position="4 192 100 24">
|
||||
<Property key="Caption" value="#{sControlsMenu1}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Button" skin="MW_Button" name="InvertYButton" position="4 222 32 24"/>
|
||||
<Widget type="TextBox" skin="SandText" position="40 222 200 24">
|
||||
<Property key="Caption" value="#{sMouseFlip}"/>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
|
|
|
@ -144,3 +144,8 @@ sfx volume = 1.0
|
|||
music volume = 0.4
|
||||
footsteps volume = 0.6
|
||||
voice volume = 1.0
|
||||
|
||||
|
||||
[Input]
|
||||
|
||||
invert y axis = false
|
||||
|
|
Loading…
Reference in a new issue