1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-01 04:45:34 +00:00

Merge remote-tracking branch 'wheybags/master' into next

This commit is contained in:
Marc Zinnschlag 2013-02-10 17:29:28 +01:00
commit 64d9d9e2ce
7 changed files with 53 additions and 2 deletions

View file

@ -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)

View file

@ -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,28 @@ 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);
break;
}
}
}
void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed)
{
buttonActivated (pressed);
}
void InteractiveMessageBox::buttonActivated (MyGUI::Widget* pressed)
{
mMarkedToDelete = true;
int index = 0;

View file

@ -34,7 +34,8 @@ namespace MWGui
void removeMessageBox (float time, MessageBox *msgbox);
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;

View file

@ -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();

View file

@ -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);

View file

@ -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();
@ -251,7 +256,7 @@ namespace MWInput
// update values of channels (as a result of pressed keys)
if (!loading)
mInputCtrl->update(dt);
// Update windows/gui as a result of input events
// For instance this could mean opening a new window/dialog,
// by doing this after the input events are handled we
@ -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));

View file

@ -151,6 +151,8 @@ namespace MWInput
std::map<std::string, bool> mControlSwitch;
bool mEnterPressed;
private:
void adjustMouseRegion(int width, int height);