aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/game.cpp2
-rw-r--r--src/client/gameui.cpp24
-rw-r--r--src/client/gameui.h2
-rw-r--r--src/hud.cpp1
-rw-r--r--src/hud.h1
-rw-r--r--src/player.cpp3
6 files changed, 21 insertions, 12 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 94a09537a..833093673 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -2085,7 +2085,7 @@ void Game::processKeyInput()
} else if (wasKeyDown(KeyType::MINIMAP)) {
toggleMinimap(isKeyDown(KeyType::SNEAK));
} else if (wasKeyDown(KeyType::TOGGLE_CHAT)) {
- m_game_ui->toggleChat();
+ m_game_ui->toggleChat(client);
} else if (wasKeyDown(KeyType::TOGGLE_FOG)) {
toggleFog();
} else if (wasKeyDown(KeyType::TOGGLE_UPDATE_CAMERA)) {
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()
diff --git a/src/client/gameui.h b/src/client/gameui.h
index cc9377bdc..589328a28 100644
--- a/src/client/gameui.h
+++ b/src/client/gameui.h
@@ -93,7 +93,7 @@ public:
void updateProfiler();
- void toggleChat();
+ void toggleChat(Client *client);
void toggleHud();
void toggleProfiler();
diff --git a/src/hud.cpp b/src/hud.cpp
index 841c90758..9b336cdef 100644
--- a/src/hud.cpp
+++ b/src/hud.cpp
@@ -64,5 +64,6 @@ const struct EnumString es_HudBuiltinElement[] =
{HUD_FLAG_MINIMAP_VISIBLE, "minimap"},
{HUD_FLAG_MINIMAP_RADAR_VISIBLE, "minimap_radar"},
{HUD_FLAG_BASIC_DEBUG, "basic_debug"},
+ {HUD_FLAG_CHAT_VISIBLE, "chat"},
{0, NULL},
};
diff --git a/src/hud.h b/src/hud.h
index 173633fcc..922fdca19 100644
--- a/src/hud.h
+++ b/src/hud.h
@@ -48,6 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define HUD_FLAG_MINIMAP_VISIBLE (1 << 5)
#define HUD_FLAG_MINIMAP_RADAR_VISIBLE (1 << 6)
#define HUD_FLAG_BASIC_DEBUG (1 << 7)
+#define HUD_FLAG_CHAT_VISIBLE (1 << 8)
#define HUD_PARAM_HOTBAR_ITEMCOUNT 1
#define HUD_PARAM_HOTBAR_IMAGE 2
diff --git a/src/player.cpp b/src/player.cpp
index 1e064c1da..8742454d2 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -71,7 +71,8 @@ Player::Player(const char *name, IItemDefManager *idef):
HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
HUD_FLAG_BREATHBAR_VISIBLE | HUD_FLAG_MINIMAP_VISIBLE |
- HUD_FLAG_MINIMAP_RADAR_VISIBLE | HUD_FLAG_BASIC_DEBUG;
+ HUD_FLAG_MINIMAP_RADAR_VISIBLE | HUD_FLAG_BASIC_DEBUG |
+ HUD_FLAG_CHAT_VISIBLE;
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;