summaryrefslogtreecommitdiff
path: root/src/client/gameui.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2018-01-04 23:58:46 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-01-05 20:59:30 +0100
commitf40f4143dfbbaadaabcdbd5243412d389a9d29fb (patch)
tree40008c66ba49779cfddabc3c7a16e58c0e801f09 /src/client/gameui.cpp
parent02f82eca0b20a4e998e1541413e64766db5d12b0 (diff)
downloadminetest-f40f4143dfbbaadaabcdbd5243412d389a9d29fb.tar.gz
minetest-f40f4143dfbbaadaabcdbd5243412d389a9d29fb.tar.bz2
minetest-f40f4143dfbbaadaabcdbd5243412d389a9d29fb.zip
GameUI refactor (part 7/7): Finish to include profiler things to GameUI
Other changes: * Add GameUI clarification comment * Move force_fog_off & disable_camera_update flags from GameUI to Game, it's not UI related * Properly init GameUI::Flags * Move toggleChat toggleHud & toggleProfiler to GameUI * Add gameui.cpp to LINT whitelist
Diffstat (limited to 'src/client/gameui.cpp')
-rw-r--r--src/client/gameui.cpp44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp
index 924336165..6f6d2c2a8 100644
--- a/src/client/gameui.cpp
+++ b/src/client/gameui.cpp
@@ -204,8 +204,7 @@ void GameUI::showTranslatedStatusText(const char *str)
delete[] wmsg;
}
-void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count,
- u32 profiler_current_page)
+void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count)
{
setStaticText(m_guitext_chat, chat_text);
@@ -228,15 +227,14 @@ void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count,
// Don't show chat if disabled or empty or profiler is enabled
m_guitext_chat->setVisible(m_flags.show_chat &&
- recent_chat_count != 0 && profiler_current_page == 0);
+ recent_chat_count != 0 && m_profiler_current_page == 0);
}
-void GameUI::updateProfiler(u32 profiler_current_page, u32 profiler_max_page)
+void GameUI::updateProfiler()
{
- if (profiler_current_page != 0) {
+ if (m_profiler_current_page != 0) {
std::ostringstream os(std::ios_base::binary);
- g_profiler->printPage(os, profiler_current_page,
- profiler_max_page);
+ g_profiler->printPage(os, m_profiler_current_page, m_profiler_max_page);
std::wstring text = translate_string(utf8_to_wide(os.str()));
setStaticText(m_guitext_profiler, text.c_str());
@@ -263,13 +261,39 @@ void GameUI::updateProfiler(u32 profiler_current_page, u32 profiler_max_page)
m_guitext_profiler->setRelativePosition(core::rect<s32>(upper_left, lower_right));
}
- m_guitext_profiler->setVisible(profiler_current_page != 0);
+ 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 (profiler_current_page != 0) {
+ 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,
- profiler_current_page, profiler_max_page);
+ m_profiler_current_page, m_profiler_max_page);
delete[] str;
showStatusText(buf);
} else {