aboutsummaryrefslogtreecommitdiff
path: root/src/client/gameui.cpp
diff options
context:
space:
mode:
authorAlex <24834740+GreenXenith@users.noreply.github.com>2023-02-20 12:00:37 -0800
committerGitHub <noreply@github.com>2023-02-20 21:00:37 +0100
commitaf4009d92493f43b43e83c799a694117316f2884 (patch)
tree1b0f6ea79ae2ee3f2b8540ad65abf633c09004da /src/client/gameui.cpp
parentcf19167e99d2212e6e8727ce1a277d1bb7cd719c (diff)
downloadminetest-af4009d92493f43b43e83c799a694117316f2884.tar.xz
Add chat HUD flag (#13189)
Diffstat (limited to 'src/client/gameui.cpp')
-rw-r--r--src/client/gameui.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp
index 9daecc355..8d346980c 100644
--- a/src/client/gameui.cpp
+++ b/src/client/gameui.cpp
@@ -102,6 +102,8 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
{
v2u32 screensize = RenderingEngine::getWindowSize();
+ LocalPlayer *player = client->getEnv().getLocalPlayer();
+
s32 minimal_debug_height = 0;
// Minimal debug text must only contain info that can't give a gameplay advantage
@@ -137,7 +139,6 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
// 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();
std::ostringstream os(std::ios_base::binary);
@@ -208,8 +209,8 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
m_guitext_status->enableOverrideColor(true);
}
- // Hide chat when console is visible
- m_guitext_chat->setVisible(isChatVisible() && !chat_console->isVisible());
+ // Hide chat when disabled by server or when console is visible
+ m_guitext_chat->setVisible(isChatVisible() && !chat_console->isVisible() && (player->hud_flags & HUD_FLAG_CHAT_VISIBLE));
}
void GameUI::initFlags()
@@ -287,13 +288,18 @@ void GameUI::updateProfiler()
m_guitext_profiler->setVisible(m_profiler_current_page != 0);
}
-void GameUI::toggleChat()
+void GameUI::toggleChat(Client *client)
{
- m_flags.show_chat = !m_flags.show_chat;
- if (m_flags.show_chat)
- showTranslatedStatusText("Chat shown");
- else
- showTranslatedStatusText("Chat hidden");
+ if (client->getEnv().getLocalPlayer()->hud_flags & HUD_FLAG_CHAT_VISIBLE) {
+ m_flags.show_chat = !m_flags.show_chat;
+ if (m_flags.show_chat)
+ showTranslatedStatusText("Chat shown");
+ else
+ showTranslatedStatusText("Chat hidden");
+ } else {
+ showTranslatedStatusText("Chat currently disabled by game or mod");
+ }
+
}
void GameUI::toggleHud()