diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index d85c28fe2..e4a0c209e 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -215,6 +215,7 @@ namespace MWBase virtual void removeStaticMessageBox() = 0; virtual void enterPressed () = 0; + virtual void activateKeyPressed () = 0; virtual int readPressedButton() = 0; ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox) diff --git a/apps/openmw/mwgui/countdialog.cpp b/apps/openmw/mwgui/countdialog.cpp index c429b0ccf..02ccbbc05 100644 --- a/apps/openmw/mwgui/countdialog.cpp +++ b/apps/openmw/mwgui/countdialog.cpp @@ -49,11 +49,16 @@ namespace MWGui mItemEdit->setCaption(boost::lexical_cast(maxCount)); } - void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender) + void CountDialog::cancel() { setVisible(false); } + void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender) + { + cancel(); + } + void CountDialog::onOkButtonClicked(MyGUI::Widget* _sender) { eventOkClicked(NULL, mSlider->getScrollPosition()+1); diff --git a/apps/openmw/mwgui/countdialog.hpp b/apps/openmw/mwgui/countdialog.hpp index 82a833bb7..06de3eb88 100644 --- a/apps/openmw/mwgui/countdialog.hpp +++ b/apps/openmw/mwgui/countdialog.hpp @@ -10,6 +10,7 @@ namespace MWGui public: CountDialog(); void open(const std::string& item, const std::string& message, const int maxCount); + void cancel(); typedef MyGUI::delegates::CMultiDelegate2 EventHandle_WidgetInt; @@ -25,7 +26,7 @@ namespace MWGui MyGUI::TextBox* mLabelText; MyGUI::Button* mOkButton; MyGUI::Button* mCancelButton; - + void onCancelButtonClicked(MyGUI::Widget* _sender); void onOkButtonClicked(MyGUI::Widget* _sender); void onEditTextChange(MyGUI::EditBox* _sender); diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 2fc50f257..3a969c7ca 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -146,10 +146,10 @@ namespace MWGui mMessageBoxSpeed = speed; } - void MessageBoxManager::enterPressed () + void MessageBoxManager::okayPressed () { if(mInterMessageBoxe != NULL) - mInterMessageBoxe->enterPressed(); + mInterMessageBoxe->okayPressed(); } int MessageBoxManager::readPressedButton () @@ -379,7 +379,7 @@ namespace MWGui } } - void InteractiveMessageBox::enterPressed() + void InteractiveMessageBox::okayPressed() { std::string ok = Misc::StringUtils::lowerCase(MyGUI::LanguageManager::getInstance().replaceTags("#{sOK}")); diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 0e47b0323..4ef645f5e 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -40,7 +40,7 @@ namespace MWGui bool removeMessageBox (MessageBox *msgbox); void setMessageBoxSpeed (int speed); - void enterPressed(); + void okayPressed(); int readPressedButton (); typedef MyGUI::delegates::CMultiDelegate1 EventHandle_Int; @@ -82,7 +82,7 @@ namespace MWGui { public: InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons); - void enterPressed (); + void okayPressed (); void mousePressed (MyGUI::Widget* _widget); int readPressedButton (); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 6fcc19a47..03fd7c796 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -663,7 +663,13 @@ namespace MWGui void WindowManager::enterPressed () { - mMessageBoxManager->enterPressed(); + mMessageBoxManager->okayPressed(); + } + + void WindowManager::activateKeyPressed () + { + mMessageBoxManager->okayPressed(); + mCountDialog->cancel(); } int WindowManager::readPressedButton () diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 6395b1bb5..82efd006a 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -204,6 +204,7 @@ namespace MWGui virtual void staticMessageBox(const std::string& message); virtual void removeStaticMessageBox(); virtual void enterPressed (); + virtual void activateKeyPressed (); virtual int readPressedButton (); ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox) virtual void onFrame (float frameDuration); diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index eae5d7d19..973089d75 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -204,13 +204,15 @@ namespace MWInput case A_Activate: resetIdleTime(); - if (mWindows.getMode() == MWGui::GM_Container) { - toggleContainer (); - } else if (MWBase::Environment::get().getWindowManager()->isGuiMode()) { - MWBase::Environment::get().getWindowManager()->enterPressed(); - } else { - activate(); + if (mWindows.isGuiMode()) + { + if (mWindows.getMode() == MWGui::GM_Container) + toggleContainer (); + else + MWBase::Environment::get().getWindowManager()->activateKeyPressed(); } + else + activate(); break; case A_Journal: toggleJournal (); @@ -681,10 +683,8 @@ namespace MWInput if (MyGUI::InputManager::getInstance ().isModalAny()) return; - bool gameMode = !mWindows.isGuiMode(); - // Toggle between game mode and inventory mode - if(gameMode) + if(!mWindows.isGuiMode()) mWindows.pushGuiMode(MWGui::GM_Inventory); else { @@ -701,9 +701,7 @@ namespace MWInput if (MyGUI::InputManager::getInstance ().isModalAny()) return; - bool gameMode = !mWindows.isGuiMode(); - - if(!gameMode) + if(mWindows.isGuiMode()) { if (mWindows.getMode() == MWGui::GM_Container) mWindows.popGuiMode(); @@ -713,17 +711,14 @@ namespace MWInput } - void InputManager::toggleConsole() { if (MyGUI::InputManager::getInstance ().isModalAny()) return; - bool gameMode = !mWindows.isGuiMode(); - // Switch to console mode no matter what mode we are currently // in, except of course if we are already in console mode - if (!gameMode) + if (mWindows.isGuiMode()) { if (mWindows.getMode() == MWGui::GM_Console) mWindows.popGuiMode(); @@ -740,9 +735,7 @@ namespace MWInput return; // Toggle between game mode and journal mode - bool gameMode = !mWindows.isGuiMode(); - - if(gameMode && MWBase::Environment::get().getWindowManager ()->getJournalAllowed()) + if(!mWindows.isGuiMode() && MWBase::Environment::get().getWindowManager ()->getJournalAllowed()) { MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0); mWindows.pushGuiMode(MWGui::GM_Journal);