1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-23 08:08:47 -05:00

Improve GUIMessageMenu (move and resize elements based on size of text)

This commit is contained in:
Perttu Ahola 2012-06-04 22:33:47 +03:00
parent 816b9c8d71
commit 1cd2076d42

View File

@ -81,19 +81,29 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize)
v2s32 size = rect.getSize(); 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 Add stuff
*/ */
{ {
core::rect<s32> rect(0, 0, 400, 70); core::rect<s32> rect(0, 0, msg_w, msg_h);
rect = rect + v2s32(size.X/2-400/2, size.Y/2-50/2-25); 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, Environment->addStaticText(m_message_text.c_str(),
true, this, 256); rect, false, true, this, -1);
} }
changeCtype(""); changeCtype("");
int bw = 140;
{ {
core::rect<s32> rect(0, 0, 140, 30); core::rect<s32> rect(0, 0, bw, 30);
rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+45); rect = rect + v2s32(size.X/2-bw/2, size.Y/2-30/2+5 + msg_h/2);
gui::IGUIElement *e = gui::IGUIElement *e =
Environment->addButton(rect, this, 257, Environment->addButton(rect, this, 257,
wgettext("Proceed")); wgettext("Proceed"));