diff options
author | sapier <Sapier at GMX dot net> | 2014-09-25 19:54:02 +0200 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-09-25 19:54:02 +0200 |
commit | 15c7460edaa279b96c235ec8bc4ae9bad5739e66 (patch) | |
tree | 519f97e6ba31218554a2ba0b5f6d49e900229953 | |
parent | 5ca5630a116458910fdffa097417bb211b89ba4e (diff) | |
download | minetest-15c7460edaa279b96c235ec8bc4ae9bad5739e66.tar.gz minetest-15c7460edaa279b96c235ec8bc4ae9bad5739e66.tar.bz2 minetest-15c7460edaa279b96c235ec8bc4ae9bad5739e66.zip |
Fix chat lines not word wrapped correct
-rw-r--r-- | src/game.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp index 45b879ff2..a8f6bc992 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1102,8 +1102,16 @@ static void updateChat(Client& client, f32 dtime, bool show_debug, if (show_debug) chat_y += line_height; - core::rect<s32> rect(10, chat_y, font->getDimension(recent_chat.c_str()).Width +10, - chat_y + (recent_chat_count * line_height)); + // first pass to calculate height of text to be set + s32 width = std::min(font->getDimension(recent_chat.c_str()).Width + 10, + porting::getWindowSize().X - 20); + core::rect<s32> rect(10, chat_y, width, chat_y + porting::getWindowSize().Y); + guitext_chat->setRelativePosition(rect); + + //now use real height of text and adjust rect according to this size + rect = core::rect<s32>(10, chat_y, width, + chat_y + guitext_chat->getTextHeight()); + guitext_chat->setRelativePosition(rect); // Don't show chat if disabled or empty or profiler is enabled |