diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 148a7f98c..a96906d25 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -17,8 +17,8 @@ void MessageBoxManager::createMessageBox (const std::string& message) std::vector::const_iterator it; int i = 0; - for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) { - if(i == 3) { + for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it) { + if(i == 2) { (*it)->del(); break; } @@ -39,35 +39,50 @@ void MessageBoxManager::createInteractiveMessageBox (const std::string& message, MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) : Layout("openmw_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) + , cMessage(message) { - setText("message", message); + mFixedWidth = 300; + mBottomPadding = 20; + + getWidget(mMessageWidget, "message"); + + mMessageWidget->setOverflowToTheLeft(true); + mMessageWidget->addText(cMessage); + + MyGUI::IntSize size; + size.width = mFixedWidth; // fiexd width + size.height = 100; // dummy + + MyGUI::IntCoord coord; + coord.left = 10; // dummy + coord.top = 10; // dummy + + mMessageWidget->setSize(size); + + MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); + size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box + + mMainWidget->setSize(size); + size.width -= 5; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") + mMessageWidget->setSize(size); + update(0); } void MessageBox::update (int height) { - MyGUI::WidgetPtr messageWidget; - getWidget(messageWidget, "message"); - - MyGUI::IntSize size = messageWidget->_getTextSize(); - messageWidget->setSize(size); - size.width += 20; // padding between text and border of the box - size.height += 20; // same here - MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); MyGUI::IntCoord coord; - coord.left = (gameWindowSize.width - size.width)/2; - coord.top = (gameWindowSize.height - size.height - height); - + coord.left = (gameWindowSize.width - mFixedWidth)/2; + coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding); - std::cout << "Setting MainWidget to position (" << coord.left << "|" << coord.top - << ") and size to (" << size.width << "|" << size.height << ")" - << " while height is " << height << std::endl; + MyGUI::IntSize size; + size.width = mFixedWidth; + size.height = mHeight; mMainWidget->setCoord(coord); mMainWidget->setSize(size); - - mHeight = size.height; + mMainWidget->setVisible(true); } void MessageBox::del () diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 717ec5ab3..e5593473a 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -38,6 +38,10 @@ namespace MWGui protected: MessageBoxManager& mMessageBoxManager; int mHeight; + const std::string& cMessage; + MyGUI::EditPtr mMessageWidget; + int mFixedWidth; + int mBottomPadding; }; } diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml index e2caf1e31..aa1e00258 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml @@ -1,7 +1,17 @@ - - + + + + + + + + + +