mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
non-interactive MessageBox is finished. Didn't find any bugs.
This commit is contained in:
parent
4d1db13c8f
commit
b72e9d3b2b
2 changed files with 32 additions and 10 deletions
|
@ -12,33 +12,39 @@ MessageBoxManager::MessageBoxManager (WindowManager *windowManager)
|
||||||
void MessageBoxManager::onFrame (float frameDuration)
|
void MessageBoxManager::onFrame (float frameDuration)
|
||||||
{
|
{
|
||||||
std::vector<MessageBoxManagerTimer>::iterator it;
|
std::vector<MessageBoxManagerTimer>::iterator it;
|
||||||
for(it = mTimers.begin(); it != mTimers.end(); it++)
|
for(it = mTimers.begin(); it != mTimers.end();)
|
||||||
{
|
{
|
||||||
it->current += frameDuration;
|
it->current += frameDuration;
|
||||||
if(it->current >= it->max)
|
if(it->current >= it->max)
|
||||||
{
|
{
|
||||||
// FIXME: delete the messagebox and erase it from the vector
|
removeMessageBox(it->messageBox);
|
||||||
|
it = mTimers.erase(it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBoxManager::createMessageBox (const std::string& message)
|
void MessageBoxManager::createMessageBox (const std::string& message)
|
||||||
{
|
{
|
||||||
std::cout << "create non-interactive message box" << std::endl;
|
std::cout << "MessageBox: " << message << std::endl;
|
||||||
|
|
||||||
MessageBox *box = new MessageBox(*this, message);
|
MessageBox *box = new MessageBox(*this, message);
|
||||||
|
|
||||||
removeMessageBox(message.length()*mMessageBoxSpeed, box);
|
removeMessageBox(message.length()*mMessageBoxSpeed, box);
|
||||||
|
|
||||||
mMessageBoxes.insert(mMessageBoxes.begin(), box);
|
mMessageBoxes.insert(mMessageBoxes.begin(), box);
|
||||||
int height = box->getHeight();
|
int height = box->getHeight();
|
||||||
std::vector<MessageBox*>::const_iterator it;
|
std::vector<MessageBox*>::iterator it;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it)
|
for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it)
|
||||||
{
|
{
|
||||||
if(i == 2) {
|
if(i == 2) {
|
||||||
delete (*it);
|
delete (*it);
|
||||||
// FIXME: erase it from the vector without segfault :/
|
mMessageBoxes.erase(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -47,19 +53,19 @@ void MessageBoxManager::createMessageBox (const std::string& message)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "mMessageBoxes.size() is " << mMessageBoxes.size() << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons)
|
void MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons)
|
||||||
{
|
{
|
||||||
std::cout << "create interactive message box" << std::endl;
|
std::cout << "interactive MessageBox: " << message << " - ";
|
||||||
std::copy (buttons.begin(), buttons.end(), std::ostream_iterator<std::string> (std::cout, ", "));
|
std::copy (buttons.begin(), buttons.end(), std::ostream_iterator<std::string> (std::cout, ", "));
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
// FIXME: erase it from the vector without segfault :/
|
std::vector<MessageBox*>::iterator it = mMessageBoxes.begin();
|
||||||
std::vector<MessageBox*>::const_iterator it;
|
while(it != mMessageBoxes.end())
|
||||||
for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); it++)
|
|
||||||
{
|
{
|
||||||
delete (*it);
|
delete (*it);
|
||||||
|
it = mMessageBoxes.erase(it);
|
||||||
}
|
}
|
||||||
mMessageBoxes.clear();
|
mMessageBoxes.clear();
|
||||||
}
|
}
|
||||||
|
@ -74,6 +80,21 @@ void MessageBoxManager::removeMessageBox (float time, MessageBox *msgbox)
|
||||||
mTimers.insert(mTimers.end(), timer);
|
mTimers.insert(mTimers.end(), timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessageBoxManager::removeMessageBox (MessageBox *msgbox)
|
||||||
|
{
|
||||||
|
std::vector<MessageBox*>::iterator it;
|
||||||
|
for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it)
|
||||||
|
{
|
||||||
|
if((*it) == msgbox)
|
||||||
|
{
|
||||||
|
delete (*it);
|
||||||
|
mMessageBoxes.erase(it);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void MessageBoxManager::setMessageBoxSpeed (int speed)
|
void MessageBoxManager::setMessageBoxSpeed (int speed)
|
||||||
{
|
{
|
||||||
mMessageBoxSpeed = speed;
|
mMessageBoxSpeed = speed;
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace MWGui
|
||||||
void createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons);
|
void createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons);
|
||||||
|
|
||||||
void removeMessageBox (float time, MessageBox *msgbox);
|
void removeMessageBox (float time, MessageBox *msgbox);
|
||||||
|
bool removeMessageBox (MessageBox *msgbox);
|
||||||
void setMessageBoxSpeed (int speed);
|
void setMessageBoxSpeed (int speed);
|
||||||
|
|
||||||
WindowManager *mWindowManager;
|
WindowManager *mWindowManager;
|
||||||
|
|
Loading…
Reference in a new issue