aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-06-04 22:33:47 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-06-04 22:33:47 +0300
commit1cd2076d42d9f97c10984cce17645b2ee4905713 (patch)
tree30aa0dd1e5e7810a18dd99e7501a19c1a1b7cfa9 /src
parent816b9c8d711818aaa3baec212216e47ac863814e (diff)
downloadminetest-1cd2076d42d9f97c10984cce17645b2ee4905713.tar.gz
minetest-1cd2076d42d9f97c10984cce17645b2ee4905713.tar.bz2
minetest-1cd2076d42d9f97c10984cce17645b2ee4905713.zip
Improve GUIMessageMenu (move and resize elements based on size of text)
Diffstat (limited to 'src')
-rw-r--r--src/guiMessageMenu.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/guiMessageMenu.cpp b/src/guiMessageMenu.cpp
index ff9316b89..7ea743257 100644
--- a/src/guiMessageMenu.cpp
+++ b/src/guiMessageMenu.cpp
@@ -81,19 +81,29 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize)
v2s32 size = rect.getSize();
+ gui::IGUISkin *skin = Environment->getSkin();
+ gui::IGUIFont *font = skin->getFont();
+ s32 msg_h = font->getDimension(m_message_text.c_str()).Height;
+ s32 msg_w = font->getDimension(m_message_text.c_str()).Width;
+ if(msg_h > 200)
+ msg_h = 200;
+ if(msg_w > 540)
+ msg_w = 540;
+
/*
Add stuff
*/
{
- core::rect<s32> rect(0, 0, 400, 70);
- rect = rect + v2s32(size.X/2-400/2, size.Y/2-50/2-25);
- Environment->addStaticText(m_message_text.c_str(), rect, false,
- true, this, 256);
+ core::rect<s32> rect(0, 0, msg_w, msg_h);
+ rect += v2s32(size.X/2-msg_w/2, size.Y/2-30/2 - msg_h/2);
+ Environment->addStaticText(m_message_text.c_str(),
+ rect, false, true, this, -1);
}
changeCtype("");
+ int bw = 140;
{
- core::rect<s32> rect(0, 0, 140, 30);
- rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+45);
+ core::rect<s32> rect(0, 0, bw, 30);
+ rect = rect + v2s32(size.X/2-bw/2, size.Y/2-30/2+5 + msg_h/2);
gui::IGUIElement *e =
Environment->addButton(rect, this, 257,
wgettext("Proceed"));