summaryrefslogtreecommitdiff
path: root/src/client/gameui.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2020-05-24 14:24:13 +0200
committerGitHub <noreply@github.com>2020-05-24 14:24:13 +0200
commita9b74f4c3966ad38c2f9a97364d3fdda0e514c93 (patch)
treef761d90d6ca00a349252c9e3ad096ff16c62215f /src/client/gameui.cpp
parentf51cf7c68af16d0068b91d00ab2cc9abdf2b31d0 (diff)
downloadminetest-a9b74f4c3966ad38c2f9a97364d3fdda0e514c93.tar.gz
minetest-a9b74f4c3966ad38c2f9a97364d3fdda0e514c93.tar.bz2
minetest-a9b74f4c3966ad38c2f9a97364d3fdda0e514c93.zip
Add chat_font_size setting (#9736)
Default font sizes are used when the setting value is 0 or below (clamped by Settings).
Diffstat (limited to 'src/client/gameui.cpp')
-rw-r--r--src/client/gameui.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp
index bbe7caeb1..c216f405d 100644
--- a/src/client/gameui.cpp
+++ b/src/client/gameui.cpp
@@ -76,6 +76,11 @@ void GameUI::init()
m_guitext_chat = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0),
//false, false); // Disable word wrap as of now
false, true, guiroot);
+ u16 chat_font_size = g_settings->getU16("chat_font_size");
+ if (chat_font_size != 0) {
+ m_guitext_chat->setOverrideFont(g_fontengine->getFont(
+ chat_font_size, FM_Unspecified));
+ }
// Profiler text (size is updated when text is updated)
m_guitext_profiler = gui::StaticText::add(guienv, L"<Profiler>",
@@ -213,7 +218,6 @@ void GameUI::showTranslatedStatusText(const char *str)
void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count)
{
- setStaticText(m_guitext_chat, chat_text);
// Update gui element size and position
s32 chat_y = 5;
@@ -221,16 +225,15 @@ void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count)
if (m_flags.show_debug)
chat_y += 2 * g_fontengine->getLineHeight();
- // first pass to calculate height of text to be set
const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize();
- s32 width = std::min(g_fontengine->getTextWidth(chat_text.c_str()) + 10,
- window_size.X - 20);
- m_guitext_chat->setRelativePosition(core::rect<s32>(10, chat_y, width,
- chat_y + window_size.Y));
-
- // now use real height of text and adjust rect according to this size
- m_guitext_chat->setRelativePosition(core::rect<s32>(10, chat_y, width,
- chat_y + m_guitext_chat->getTextHeight()));
+
+ core::rect<s32> chat_size(10, chat_y,
+ window_size.X - 20, 0);
+ chat_size.LowerRightCorner.Y = std::min((s32)window_size.Y,
+ m_guitext_chat->getTextHeight() + chat_y);
+
+ m_guitext_chat->setRelativePosition(chat_size);
+ setStaticText(m_guitext_chat, chat_text);
m_recent_chat_count = recent_chat_count;
}