forked from mirror/openmw-tes3mp
pressing enter when a messagebox is prompting for "ok", will activate ok button
This commit is contained in:
parent
814969dcae
commit
158c6fc9fa
7 changed files with 50 additions and 2 deletions
|
@ -199,6 +199,7 @@ namespace MWBase
|
||||||
///< Hides dialog and schedules dialog to be deleted.
|
///< Hides dialog and schedules dialog to be deleted.
|
||||||
|
|
||||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons) = 0;
|
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons) = 0;
|
||||||
|
virtual void enterPressed () = 0;
|
||||||
virtual int readPressedButton() = 0;
|
virtual int readPressedButton() = 0;
|
||||||
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <components/misc/stringops.hpp>
|
||||||
|
|
||||||
#include "messagebox.hpp"
|
#include "messagebox.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
@ -133,6 +135,10 @@ void MessageBoxManager::setMessageBoxSpeed (int speed)
|
||||||
mMessageBoxSpeed = speed;
|
mMessageBoxSpeed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageBoxManager::enterPressed ()
|
||||||
|
{
|
||||||
|
mInterMessageBoxe->enterPressed();
|
||||||
|
}
|
||||||
|
|
||||||
int MessageBoxManager::readPressedButton ()
|
int MessageBoxManager::readPressedButton ()
|
||||||
{
|
{
|
||||||
|
@ -359,7 +365,25 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InteractiveMessageBox::enterPressed()
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string ok = Misc::StringUtils::lowerCase(MyGUI::LanguageManager::getInstance().replaceTags("#{sOK}"));
|
||||||
|
std::vector<MyGUI::ButtonPtr>::const_iterator button;
|
||||||
|
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||||
|
{
|
||||||
|
if(Misc::StringUtils::lowerCase((*button)->getCaption()) == ok)
|
||||||
|
buttonActivated(*button);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed)
|
void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed)
|
||||||
|
{
|
||||||
|
buttonActivated (pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteractiveMessageBox::buttonActivated (MyGUI::Widget* pressed)
|
||||||
{
|
{
|
||||||
mMarkedToDelete = true;
|
mMarkedToDelete = true;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace MWGui
|
||||||
bool removeMessageBox (MessageBox *msgbox);
|
bool removeMessageBox (MessageBox *msgbox);
|
||||||
void setMessageBoxSpeed (int speed);
|
void setMessageBoxSpeed (int speed);
|
||||||
|
|
||||||
|
void enterPressed();
|
||||||
int readPressedButton ();
|
int readPressedButton ();
|
||||||
|
|
||||||
MWBase::WindowManager *mWindowManager;
|
MWBase::WindowManager *mWindowManager;
|
||||||
|
@ -70,12 +71,15 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
|
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
|
||||||
|
void enterPressed ();
|
||||||
void mousePressed (MyGUI::Widget* _widget);
|
void mousePressed (MyGUI::Widget* _widget);
|
||||||
int readPressedButton ();
|
int readPressedButton ();
|
||||||
|
|
||||||
bool mMarkedToDelete;
|
bool mMarkedToDelete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void buttonActivated (MyGUI::Widget* _widget);
|
||||||
|
|
||||||
MessageBoxManager& mMessageBoxManager;
|
MessageBoxManager& mMessageBoxManager;
|
||||||
MyGUI::EditPtr mMessageWidget;
|
MyGUI::EditPtr mMessageWidget;
|
||||||
MyGUI::WidgetPtr mButtonsWidget;
|
MyGUI::WidgetPtr mButtonsWidget;
|
||||||
|
|
|
@ -560,6 +560,11 @@ void WindowManager::messageBox (const std::string& message, const std::vector<st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::enterPressed ()
|
||||||
|
{
|
||||||
|
mMessageBoxManager->enterPressed();
|
||||||
|
}
|
||||||
|
|
||||||
int WindowManager::readPressedButton ()
|
int WindowManager::readPressedButton ()
|
||||||
{
|
{
|
||||||
return mMessageBoxManager->readPressedButton();
|
return mMessageBoxManager->readPressedButton();
|
||||||
|
|
|
@ -189,6 +189,7 @@ namespace MWGui
|
||||||
virtual void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted.
|
virtual void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted.
|
||||||
|
|
||||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
||||||
|
virtual void enterPressed ();
|
||||||
virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||||
|
|
||||||
virtual void onFrame (float frameDuration);
|
virtual void onFrame (float frameDuration);
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace MWInput
|
||||||
, mUIYMultiplier (Settings::Manager::getFloat("ui y multiplier", "Input"))
|
, mUIYMultiplier (Settings::Manager::getFloat("ui y multiplier", "Input"))
|
||||||
, mPreviewPOVDelay(0.f)
|
, mPreviewPOVDelay(0.f)
|
||||||
, mTimeIdle(0.f)
|
, mTimeIdle(0.f)
|
||||||
|
, mEnterPressed(false)
|
||||||
{
|
{
|
||||||
Ogre::RenderWindow* window = ogre.getWindow ();
|
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||||
size_t windowHnd;
|
size_t windowHnd;
|
||||||
|
@ -239,6 +240,10 @@ namespace MWInput
|
||||||
|
|
||||||
void InputManager::update(float dt, bool loading)
|
void InputManager::update(float dt, bool loading)
|
||||||
{
|
{
|
||||||
|
// Pressing enter when a messagebox is prompting for "ok" will activate the ok button
|
||||||
|
if(mEnterPressed && MWBase::Environment::get().getWindowManager()->isGuiMode() && MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_InterMessageBox)
|
||||||
|
MWBase::Environment::get().getWindowManager()->enterPressed();
|
||||||
|
|
||||||
// Tell OIS to handle all input events
|
// Tell OIS to handle all input events
|
||||||
mKeyboard->capture();
|
mKeyboard->capture();
|
||||||
mMouse->capture();
|
mMouse->capture();
|
||||||
|
@ -426,6 +431,9 @@ namespace MWInput
|
||||||
|
|
||||||
bool InputManager::keyPressed( const OIS::KeyEvent &arg )
|
bool InputManager::keyPressed( const OIS::KeyEvent &arg )
|
||||||
{
|
{
|
||||||
|
if(arg.key == OIS::KC_RETURN && MWBase::Environment::get().getWindowManager()->isGuiMode() && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_Console)
|
||||||
|
mEnterPressed = true;
|
||||||
|
|
||||||
mInputCtrl->keyPressed (arg);
|
mInputCtrl->keyPressed (arg);
|
||||||
unsigned int text = arg.text;
|
unsigned int text = arg.text;
|
||||||
#ifdef __APPLE__ // filter \016 symbol for F-keys on OS X
|
#ifdef __APPLE__ // filter \016 symbol for F-keys on OS X
|
||||||
|
@ -442,6 +450,9 @@ namespace MWInput
|
||||||
|
|
||||||
bool InputManager::keyReleased( const OIS::KeyEvent &arg )
|
bool InputManager::keyReleased( const OIS::KeyEvent &arg )
|
||||||
{
|
{
|
||||||
|
if(arg.key == OIS::KC_RETURN)
|
||||||
|
mEnterPressed = false;
|
||||||
|
|
||||||
mInputCtrl->keyReleased (arg);
|
mInputCtrl->keyReleased (arg);
|
||||||
|
|
||||||
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(arg.key));
|
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(arg.key));
|
||||||
|
|
|
@ -151,6 +151,8 @@ namespace MWInput
|
||||||
|
|
||||||
std::map<std::string, bool> mControlSwitch;
|
std::map<std::string, bool> mControlSwitch;
|
||||||
|
|
||||||
|
bool mEnterPressed;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void adjustMouseRegion(int width, int height);
|
void adjustMouseRegion(int width, int height);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue