Remove more cruft in MessageBox. Fixes inconsistent sizing when close to a newline.

actorid
scrawl 11 years ago
parent bb70deabb1
commit 742e0e014d

@ -141,7 +141,6 @@ namespace MWGui
, mMaxTime(0) , mMaxTime(0)
{ {
// defines // defines
mFixedWidth = 300;
mBottomPadding = 20; mBottomPadding = 20;
mNextBoxPadding = 20; mNextBoxPadding = 20;
@ -149,41 +148,21 @@ namespace MWGui
mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->setOverflowToTheLeft(true);
mMessageWidget->setCaptionWithReplacing(mMessage); mMessageWidget->setCaptionWithReplacing(mMessage);
MyGUI::IntSize size;
size.width = mFixedWidth;
size.height = 100; // 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 -= 15; // this is to center the text (see messagebox.layout, Widget type="Edit" position="-2 -3 0 0")
mMessageWidget->setSize(size);
} }
void MessageBox::update (int height) void MessageBox::update (int height)
{ {
MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize();
MyGUI::IntCoord coord; MyGUI::IntPoint pos;
coord.left = (gameWindowSize.width - mFixedWidth)/2; pos.left = (gameWindowSize.width - mMainWidget->getWidth())/2;
coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding); pos.top = (gameWindowSize.height - mMainWidget->getHeight() - height - mBottomPadding);
MyGUI::IntSize size;
size.width = mFixedWidth;
size.height = mHeight;
mMainWidget->setCoord(coord); mMainWidget->setPosition(pos);
mMainWidget->setSize(size);
mMainWidget->setVisible(true);
} }
int MessageBox::getHeight () int MessageBox::getHeight ()
{ {
return mHeight+mNextBoxPadding; // 20 is the padding between this and the next MessageBox return mMainWidget->getHeight()+mNextBoxPadding; // 20 is the padding between this and the next MessageBox
} }

@ -63,10 +63,8 @@ namespace MWGui
protected: protected:
MessageBoxManager& mMessageBoxManager; MessageBoxManager& mMessageBoxManager;
int mHeight;
const std::string& mMessage; const std::string& mMessage;
MyGUI::EditBox* mMessageWidget; MyGUI::EditBox* mMessageWidget;
int mFixedWidth;
int mBottomPadding; int mBottomPadding;
int mNextBoxPadding; int mNextBoxPadding;
}; };

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout"> <MyGUI type="Layout">
<!--Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 0 0" name="_Main"> <Widget type="VBox" skin="MW_Dialog" layer="Notification" position="0 0 0 0" name="_Main">
<Widget type="TextBox" skin="TextBox" position="4 4 4 4" name="message"/> <Property key="Padding" value="10"/>
</Widget--> <Property key="AutoResize" value="true"/>
<Widget type="Window" skin="MW_Dialog" layer="Notification" position="0 0 0 0" name="_Main">
<Widget type="EditBox" skin="MW_TextEditClient" position="5 -5 0 0" name="message" align="Left Top Stretch"> <Widget type="AutoSizedEditBox" skin="MW_TextEditClient" position="0 0 300 0" name="message" align="Left Top">
<Property key="FontName" value="Default"/> <Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Center"/> <Property key="TextAlign" value="Center"/>
<Property key="TextColour" value="0.75 0.6 0.35"/> <Property key="TextColour" value="0.75 0.6 0.35"/>

Loading…
Cancel
Save