mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:23:52 +00:00
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.
|
||||
|
||||
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons) = 0;
|
||||
virtual void enterPressed () = 0;
|
||||
virtual int readPressedButton() = 0;
|
||||
///< 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"
|
||||
|
||||
using namespace MWGui;
|
||||
|
@ -133,6 +135,10 @@ void MessageBoxManager::setMessageBoxSpeed (int speed)
|
|||
mMessageBoxSpeed = speed;
|
||||
}
|
||||
|
||||
void MessageBoxManager::enterPressed ()
|
||||
{
|
||||
mInterMessageBoxe->enterPressed();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
buttonActivated (pressed);
|
||||
}
|
||||
|
||||
void InteractiveMessageBox::buttonActivated (MyGUI::Widget* pressed)
|
||||
{
|
||||
mMarkedToDelete = true;
|
||||
int index = 0;
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace MWGui
|
|||
bool removeMessageBox (MessageBox *msgbox);
|
||||
void setMessageBoxSpeed (int speed);
|
||||
|
||||
void enterPressed();
|
||||
int readPressedButton ();
|
||||
|
||||
MWBase::WindowManager *mWindowManager;
|
||||
|
@ -70,12 +71,15 @@ namespace MWGui
|
|||
{
|
||||
public:
|
||||
InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
|
||||
void enterPressed ();
|
||||
void mousePressed (MyGUI::Widget* _widget);
|
||||
int readPressedButton ();
|
||||
|
||||
bool mMarkedToDelete;
|
||||
|
||||
private:
|
||||
void buttonActivated (MyGUI::Widget* _widget);
|
||||
|
||||
MessageBoxManager& mMessageBoxManager;
|
||||
MyGUI::EditPtr mMessageWidget;
|
||||
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 ()
|
||||
{
|
||||
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 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 void onFrame (float frameDuration);
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace MWInput
|
|||
, mUIYMultiplier (Settings::Manager::getFloat("ui y multiplier", "Input"))
|
||||
, mPreviewPOVDelay(0.f)
|
||||
, mTimeIdle(0.f)
|
||||
, mEnterPressed(false)
|
||||
{
|
||||
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||
size_t windowHnd;
|
||||
|
@ -239,6 +240,10 @@ namespace MWInput
|
|||
|
||||
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
|
||||
mKeyboard->capture();
|
||||
mMouse->capture();
|
||||
|
@ -426,6 +431,9 @@ namespace MWInput
|
|||
|
||||
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);
|
||||
unsigned int text = arg.text;
|
||||
#ifdef __APPLE__ // filter \016 symbol for F-keys on OS X
|
||||
|
@ -442,6 +450,9 @@ namespace MWInput
|
|||
|
||||
bool InputManager::keyReleased( const OIS::KeyEvent &arg )
|
||||
{
|
||||
if(arg.key == OIS::KC_RETURN)
|
||||
mEnterPressed = false;
|
||||
|
||||
mInputCtrl->keyReleased (arg);
|
||||
|
||||
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(arg.key));
|
||||
|
|
|
@ -151,6 +151,8 @@ namespace MWInput
|
|||
|
||||
std::map<std::string, bool> mControlSwitch;
|
||||
|
||||
bool mEnterPressed;
|
||||
|
||||
private:
|
||||
void adjustMouseRegion(int width, int height);
|
||||
|
||||
|
|
Loading…
Reference in a new issue