Remember pressed message box button longer

Remember which button was pressed until a new interactive message box is
displayed or until the pressed button number is read.

Before that, it was not possible to get the pressed button after the
message box was hidden/destroyed.
This commit is contained in:
Emanuel Guevel 2013-10-14 11:15:23 +02:00
parent db7ea30483
commit ba4b8a37e2
2 changed files with 8 additions and 8 deletions

View file

@ -14,6 +14,7 @@ namespace MWGui
mMessageBoxSpeed = 0.1; mMessageBoxSpeed = 0.1;
mInterMessageBoxe = NULL; mInterMessageBoxe = NULL;
mStaticMessageBox = NULL; mStaticMessageBox = NULL;
mLastButtonPressed = -1;
} }
void MessageBoxManager::onFrame (float frameDuration) void MessageBoxManager::onFrame (float frameDuration)
@ -62,6 +63,7 @@ namespace MWGui
} }
if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) { if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) {
mLastButtonPressed = mInterMessageBoxe->readPressedButton();
delete mInterMessageBoxe; delete mInterMessageBoxe;
mInterMessageBoxe = NULL; mInterMessageBoxe = NULL;
MWBase::Environment::get().getInputManager()->changeInputMode( MWBase::Environment::get().getInputManager()->changeInputMode(
@ -107,6 +109,7 @@ namespace MWGui
} }
mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons); mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons);
mLastButtonPressed = -1;
return true; return true;
} }
@ -154,11 +157,9 @@ namespace MWGui
int MessageBoxManager::readPressedButton () int MessageBoxManager::readPressedButton ()
{ {
if(mInterMessageBoxe != NULL) int pressed = mLastButtonPressed;
{ mLastButtonPressed = -1;
return mInterMessageBoxe->readPressedButton(); return pressed;
}
return -1;
} }
@ -421,9 +422,7 @@ namespace MWGui
int InteractiveMessageBox::readPressedButton () int InteractiveMessageBox::readPressedButton ()
{ {
int pressed = mButtonPressed; return mButtonPressed;
mButtonPressed = -1;
return pressed;
} }
} }

View file

@ -56,6 +56,7 @@ namespace MWGui
MessageBox* mStaticMessageBox; MessageBox* mStaticMessageBox;
std::vector<MessageBoxManagerTimer> mTimers; std::vector<MessageBoxManagerTimer> mTimers;
float mMessageBoxSpeed; float mMessageBoxSpeed;
int mLastButtonPressed;
}; };
class MessageBox : public OEngine::GUI::Layout class MessageBox : public OEngine::GUI::Layout