forked from mirror/openmw-tes3mp
Merge remote branch 'swick/MessageBox' into MessageBox
This commit is contained in:
commit
beeaa2cf7f
4 changed files with 38 additions and 19 deletions
|
@ -50,6 +50,7 @@ set(GAMEGUI_HEADER
|
||||||
mwgui/dialogue_history.hpp
|
mwgui/dialogue_history.hpp
|
||||||
mwgui/window_base.hpp
|
mwgui/window_base.hpp
|
||||||
mwgui/stats_window.hpp
|
mwgui/stats_window.hpp
|
||||||
|
mwgui/messagebox.hpp
|
||||||
)
|
)
|
||||||
set(GAMEGUI
|
set(GAMEGUI
|
||||||
mwgui/window_manager.cpp
|
mwgui/window_manager.cpp
|
||||||
|
|
|
@ -17,7 +17,28 @@ void MessageBoxManager::onFrame (float frameDuration)
|
||||||
it->current += frameDuration;
|
it->current += frameDuration;
|
||||||
if(it->current >= it->max)
|
if(it->current >= it->max)
|
||||||
{
|
{
|
||||||
removeMessageBox(it->messageBox);
|
it->messageBox->mMarkedToDelete = true;
|
||||||
|
|
||||||
|
if(*mMessageBoxes.begin() == it->messageBox) // if this box is the last one
|
||||||
|
{
|
||||||
|
// collect all with mMarkedToDelete and delete them.
|
||||||
|
// and place the other messageboxes on the right position
|
||||||
|
int height = 0;
|
||||||
|
std::vector<MessageBox*>::iterator it2 = mMessageBoxes.begin();
|
||||||
|
while(it2 != mMessageBoxes.end())
|
||||||
|
{
|
||||||
|
if((*it2)->mMarkedToDelete)
|
||||||
|
{
|
||||||
|
delete (*it2);
|
||||||
|
it2 = mMessageBoxes.erase(it2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
(*it2)->update(height);
|
||||||
|
height += (*it2)->getHeight();
|
||||||
|
it2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
it = mTimers.erase(it);
|
it = mTimers.erase(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -35,23 +56,19 @@ void MessageBoxManager::createMessageBox (const std::string& message)
|
||||||
|
|
||||||
removeMessageBox(message.length()*mMessageBoxSpeed, box);
|
removeMessageBox(message.length()*mMessageBoxSpeed, box);
|
||||||
|
|
||||||
mMessageBoxes.insert(mMessageBoxes.begin(), box);
|
mMessageBoxes.push_back(box);
|
||||||
int height = box->getHeight();
|
|
||||||
std::vector<MessageBox*>::iterator it;
|
std::vector<MessageBox*>::iterator it;
|
||||||
|
|
||||||
int i = 0;
|
if(mMessageBoxes.size() > 3) {
|
||||||
for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it)
|
delete *mMessageBoxes.begin();
|
||||||
|
mMessageBoxes.erase(mMessageBoxes.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
int height = 0;
|
||||||
|
for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it)
|
||||||
{
|
{
|
||||||
if(i == 2) {
|
(*it)->update(height);
|
||||||
delete (*it);
|
height += (*it)->getHeight();
|
||||||
mMessageBoxes.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
(*it)->update(height);
|
|
||||||
height += (*it)->getHeight();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +129,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin
|
||||||
mFixedWidth = 300;
|
mFixedWidth = 300;
|
||||||
mBottomPadding = 20;
|
mBottomPadding = 20;
|
||||||
mNextBoxPadding = 20;
|
mNextBoxPadding = 20;
|
||||||
|
mMarkedToDelete = false;
|
||||||
|
|
||||||
getWidget(mMessageWidget, "message");
|
getWidget(mMessageWidget, "message");
|
||||||
|
|
||||||
|
@ -132,10 +150,8 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin
|
||||||
size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box
|
size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box
|
||||||
|
|
||||||
mMainWidget->setSize(size);
|
mMainWidget->setSize(size);
|
||||||
size.width -= 5; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0")
|
size.width -= 15; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0")
|
||||||
mMessageWidget->setSize(size);
|
mMessageWidget->setSize(size);
|
||||||
|
|
||||||
update(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBox::update (int height)
|
void MessageBox::update (int height)
|
||||||
|
|
|
@ -48,6 +48,8 @@ namespace MWGui
|
||||||
int getHeight ();
|
int getHeight ();
|
||||||
void update (int height);
|
void update (int height);
|
||||||
|
|
||||||
|
bool mMarkedToDelete;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MessageBoxManager& mMessageBoxManager;
|
MessageBoxManager& mMessageBoxManager;
|
||||||
int mHeight;
|
int mHeight;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<Widget type="StaticText" skin="StaticText" position="4 4 4 4" name="message" />
|
<Widget type="StaticText" skin="StaticText" position="4 4 4 4" name="message" />
|
||||||
</Widget-->
|
</Widget-->
|
||||||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 0 0" name="_Main">
|
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 0 0" name="_Main">
|
||||||
<Widget type="Edit" skin="MW_TextEditClient" position="-2 -3 0 0" name="message" align="ALIGN_LEFT ALIGN_TOP STRETCH">
|
<Widget type="Edit" skin="MW_TextEditClient" position="5 -5 0 0" name="message" align="ALIGN_LEFT ALIGN_TOP STRETCH">
|
||||||
<Property key="Edit_Static" value="true"/>
|
<Property key="Edit_Static" value="true"/>
|
||||||
<Property key="Edit_WordWrap" value="true"/>
|
<Property key="Edit_WordWrap" value="true"/>
|
||||||
<Property key="Text_FontHeight" value="18"/>
|
<Property key="Text_FontHeight" value="18"/>
|
||||||
|
|
Loading…
Reference in a new issue