m_guitext2 = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0), false,
false, guiroot);
+ // Chat text
+ 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));
+ }
+
// At the middle of the screen
// Object infos are shown in this
+ u32 chat_font_height = m_guitext_chat->getActiveFont()->getDimension(L"Ay").Height;
m_guitext_info = gui::StaticText::add(guienv, L"",
- core::rect<s32>(0, 0, 400, g_fontengine->getTextHeight() * 5 + 5)
- + v2s32(100, 200), false, true, guiroot);
+ core::rect<s32>(0, 0, 400, g_fontengine->getTextHeight() * 5 + 5) +
+ v2s32(100, chat_font_height *
+ (g_settings->getU16("recent_chat_messages") + 3)),
+ false, true, guiroot);
// Status text (displays info when showing and hiding GUI stuff, etc.)
m_guitext_status = gui::StaticText::add(guienv, L"<Status>",
core::rect<s32>(0, 0, 0, 0), false, false, guiroot);
m_guitext_status->setVisible(false);
- // Chat text
- 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);
-
// Profiler text (size is updated when text is updated)
m_guitext_profiler = gui::StaticText::add(guienv, L"<Profiler>",
core::rect<s32>(0, 0, 0, 0), false, false, guiroot);
m_guitext_profiler->setOverrideFont(g_fontengine->getFont(
g_fontengine->getDefaultFontSize() * 0.9f, FM_Mono));
- m_guitext_profiler->setBackgroundColor(video::SColor(120, 0, 0, 0));
m_guitext_profiler->setVisible(false);
}
const CameraOrientation &cam, const PointedThing &pointed_old,
const GUIChatConsole *chat_console, float dtime)
{
- v2u32 screensize = RenderingEngine::get_instance()->getWindowSize();
+ v2u32 screensize = RenderingEngine::getWindowSize();
- if (m_flags.show_debug) {
+ // Minimal debug text must only contain info that can't give a gameplay advantage
+ if (m_flags.show_minimal_debug) {
static float drawtime_avg = 0;
drawtime_avg = drawtime_avg * 0.95 + stats.drawtime * 0.05;
u16 fps = 1.0 / stats.dtime_jitter.avg;
<< std::setprecision(1)
<< " | view range: "
<< (draw_control->range_all ? "All" : itos(draw_control->wanted_range))
- << std::setprecision(3)
- << " | RTT: " << client->getRTT() << "s";
+ << std::setprecision(2)
+ << " | RTT: " << (client->getRTT() * 1000.0f) << "ms";
setStaticText(m_guitext, utf8_to_wide(os.str()).c_str());
m_guitext->setRelativePosition(core::rect<s32>(5, 5, screensize.X,
}
// Finally set the guitext visible depending on the flag
- m_guitext->setVisible(m_flags.show_debug);
+ m_guitext->setVisible(m_flags.show_minimal_debug);
- if (m_flags.show_debug) {
+ // Basic debug text also shows info that might give a gameplay advantage
+ if (m_flags.show_basic_debug) {
LocalPlayer *player = client->getEnv().getLocalPlayer();
v3f player_position = player->getPosition();
));
}
- m_guitext2->setVisible(m_flags.show_debug);
+ m_guitext2->setVisible(m_flags.show_basic_debug);
- setStaticText(m_guitext_info, translate_string(m_infotext).c_str());
+ setStaticText(m_guitext_info, m_infotext.c_str());
m_guitext_info->setVisible(m_flags.show_hud && g_menumgr.menuCount() == 0);
static const float statustext_time_max = 1.5f;
}
}
- setStaticText(m_guitext_status, translate_string(m_statustext).c_str());
+ setStaticText(m_guitext_status, m_statustext.c_str());
m_guitext_status->setVisible(!m_statustext.empty());
if (!m_statustext.empty()) {
void GameUI::initFlags()
{
m_flags = GameUI::Flags();
- m_flags.show_debug = g_settings->getBool("show_debug");
+ m_flags.show_minimal_debug = g_settings->getBool("show_debug");
+ m_flags.show_basic_debug = false;
}
void GameUI::showMinimap(bool show)
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;
- if (m_flags.show_debug)
- chat_y += 2 * g_fontengine->getLineHeight();
+ if (m_flags.show_minimal_debug)
+ chat_y += g_fontengine->getLineHeight();
+ if (m_flags.show_basic_debug)
+ chat_y += g_fontengine->getLineHeight();
+
+ const v2u32 &window_size = RenderingEngine::getWindowSize();
- // 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));
+ 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);
- // 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()));
+ m_guitext_chat->setRelativePosition(chat_size);
+ setStaticText(m_guitext_chat, chat_text);
m_recent_chat_count = recent_chat_count;
}
int lines = g_profiler->print(os, m_profiler_current_page, m_profiler_max_page);
++lines;
- std::wstring text = utf8_to_wide(os.str());
- setStaticText(m_guitext_profiler, text.c_str());
+ EnrichedString str(utf8_to_wide(os.str()));
+ str.setBackground(video::SColor(120, 0, 0, 0));
+ setStaticText(m_guitext_profiler, str);
core::dimension2d<u32> size = m_guitext_profiler->getOverrideFont()->
- getDimension(text.c_str());
+ getDimension(str.c_str());
core::position2di upper_left(6, 50);
core::position2di lower_right = upper_left;
lower_right.X += size.Width + 10;
- lower_right.Y += size.Height;
+ lower_right.Y += size.Height;
m_guitext_profiler->setRelativePosition(core::rect<s32>(upper_left, lower_right));
}