From 967f25461bbde28dbc0247fa1c491e9d9938a5b2 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Sat, 3 Dec 2011 09:01:14 +0100 Subject: Chat console, including a number of rebases and modifications. Defaults modified from original: alpha=200, key=F10 --- src/client.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 72cd28b18..14f93a1a1 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2036,7 +2036,21 @@ void Client::printDebugInfo(std::ostream &os) //<<", m_opt_not_found_history.size()="< Client::getConnectedPlayerNames() +{ + core::list players = m_env.getPlayers(true); + core::list playerNames; + for(core::list::Iterator + i = players.begin(); + i != players.end(); i++) + { + Player *player = *i; + playerNames.push_back(narrow_to_wide(player->getName())); + } + return playerNames; +} + u32 Client::getDayNightRatio() { //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out @@ -2084,6 +2098,39 @@ void Client::clearTempMod(v3s16 p) } } +bool Client::getChatMessage(std::wstring &message) +{ + if(m_chat_queue.size() == 0) + return false; + message = m_chat_queue.pop_front(); + return true; +} + +void Client::typeChatMessage(const std::wstring &message) +{ + // Discard empty line + if(message == L"") + return; + + // Send to others + sendChatMessage(message); + + // Show locally + if (message[0] == L'/') + { + m_chat_queue.push_back( + (std::wstring)L"issued command: "+message); + } + else + { + LocalPlayer *player = m_env.getLocalPlayer(); + assert(player != NULL); + std::wstring name = narrow_to_wide(player->getName()); + m_chat_queue.push_back( + (std::wstring)L"<"+name+L"> "+message); + } +} + void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server) { /*infostream<<"Client::addUpdateMeshTask(): " -- cgit v1.2.3