+
+void GameUI::showTranslatedStatusText(const char *str)
+{
+ const wchar_t *wmsg = wgettext(str);
+ showStatusText(wmsg);
+ delete[] wmsg;
+}
+
+void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count)
+{
+
+ // Update gui element size and position
+ s32 chat_y = 5;
+
+ 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();
+
+ 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;
+}
+
+void GameUI::updateProfiler()
+{
+ if (m_profiler_current_page != 0) {
+ std::ostringstream os(std::ios_base::binary);
+ os << " Profiler page " << (int)m_profiler_current_page <<
+ ", elapsed: " << g_profiler->getElapsedMs() << " ms)" << std::endl;
+
+ int lines = g_profiler->print(os, m_profiler_current_page, m_profiler_max_page);
+ ++lines;
+
+ 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(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;
+
+ m_guitext_profiler->setRelativePosition(core::rect<s32>(upper_left, lower_right));
+ }
+
+ m_guitext_profiler->setVisible(m_profiler_current_page != 0);
+}
+
+void GameUI::toggleChat()
+{
+ m_flags.show_chat = !m_flags.show_chat;
+ if (m_flags.show_chat)
+ showTranslatedStatusText("Chat shown");
+ else
+ showTranslatedStatusText("Chat hidden");
+}
+
+void GameUI::toggleHud()
+{
+ m_flags.show_hud = !m_flags.show_hud;
+ if (m_flags.show_hud)
+ showTranslatedStatusText("HUD shown");
+ else
+ showTranslatedStatusText("HUD hidden");
+}
+
+void GameUI::toggleProfiler()
+{
+ m_profiler_current_page = (m_profiler_current_page + 1) % (m_profiler_max_page + 1);
+
+ // FIXME: This updates the profiler with incomplete values
+ updateProfiler();
+
+ if (m_profiler_current_page != 0) {
+ wchar_t buf[255];
+ const wchar_t* str = wgettext("Profiler shown (page %d of %d)");
+ swprintf(buf, sizeof(buf) / sizeof(wchar_t), str,
+ m_profiler_current_page, m_profiler_max_page);
+ delete[] str;
+ showStatusText(buf);
+ } else {
+ showTranslatedStatusText("Profiler hidden");
+ }
+}
+
+
+void GameUI::deleteFormspec()
+{
+ if (m_formspec) {
+ m_formspec->drop();
+ m_formspec = nullptr;
+ }
+
+ m_formname.clear();
+}