diff --git a/CHANGELOG.md b/CHANGELOG.md index 2101b6994..d8bf7bf9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,6 +94,7 @@ Engine * Liquids drop torches and plants #### Client + * Clearing on-screen chat by invoking the /clear command * Fixed some input issues: not working numpad and some keys in azerty layout * Chat forms were replaced with console (opens up to 10% height of the screen) * Default keymap for console changed to tilde (~) diff --git a/src/client.cpp b/src/client.cpp index 6561f6fab..8a23bc978 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -67,6 +67,7 @@ along with Freeminer. If not, see . #if !MINETEST_PROTO #include "network/fm_clientpacketsender.cpp" #endif +#include "chat.h" extern gui::IGUIEnvironment* guienv; @@ -1632,15 +1633,18 @@ void Client::typeChatMessage(const std::string &message) if(message.empty()) return; - // Send to others - sendChatMessage(message); - - // Show locally - if (message[0] == '/') - { - m_chat_queue.push("issued command: " + message); + if (message[0] == '/') { + // TODO register client commands in help + std::string command = message.substr(1,-1); + // Clears on-screen chat messages + if (command.compare("clear") == 0) { + chat_backend->clearRecentChat(); + return; + // it's kinda self-evident when you run a local command + } else { + m_chat_queue.push("issued command: " + message); + } } - //freeminer display self message after recieving from server #if MINETEST_PROTO else @@ -1651,6 +1655,9 @@ void Client::typeChatMessage(const std::string &message) m_chat_queue.push(std::string() + "<" + name + "> " + message); } #endif + + // Send to others + sendChatMessage(message); } void Client::addUpdateMeshTask(v3s16 p, bool urgent, int step) diff --git a/src/client.h b/src/client.h index 5396dc8d6..601011a13 100644 --- a/src/client.h +++ b/src/client.h @@ -59,6 +59,7 @@ class Database; class Server; class Mapper; struct MinimapMapblock; +class ChatBackend; /* struct QueuedMeshUpdate @@ -545,6 +546,8 @@ public: LocalClientState getState() { return m_state; } void makeScreenshot(const std::string & name = "screenshot_", IrrlichtDevice *device = nullptr); + + ChatBackend *chat_backend; private: diff --git a/src/game.cpp b/src/game.cpp index e32316c70..98ba55f40 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2373,6 +2373,7 @@ bool Game::connectToServer(const std::string &playername, if (!client) return false; + client->chat_backend = chat_backend; gamedef = client; // Client acts as our GameDef infostream << "Connecting to server at ";