diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 5 | ||||
-rw-r--r-- | src/gui/chat.cpp | 3 | ||||
-rw-r--r-- | src/gui/chat.h | 2 | ||||
-rw-r--r-- | src/log.cpp | 10 | ||||
-rw-r--r-- | src/log.h | 8 |
5 files changed, 27 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp index 2794b2e6..9a669661 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -212,6 +212,11 @@ void createGuiWindows(Network *network) miniStatusWindow->setVisible(true); menuWindow->setVisible(true); itemShortcutWindow->setVisible(true); + + if (config.getValue("logToChat", 0)) + { + logger->setChatWindow(chatWindow); + } } /** diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 877866df..2e7e109b 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -143,6 +143,9 @@ ChatWindow::chatLog(std::string line, int own) tmp.nick += CAT_IS; lineColor = "##5"; // Equiv. to BrowserBox::YELLOW break; + case BY_LOGGER: + lineColor = "##8"; // Equiv. to BrowserBox::GREY + break; } // Get the current system time diff --git a/src/gui/chat.h b/src/gui/chat.h index 9c57f227..b857f4b4 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -46,6 +46,8 @@ class ScrollArea; #define ACT_WHISPER 4 // getting whispered at #define ACT_IS 5 // equivalent to "/me" in irc +#define BY_LOGGER 6 + #define IS_ANNOUNCE "/announce " #define IS_ANNOUNCE_LENGTH 10 #define IS_HELP "/help" diff --git a/src/log.cpp b/src/log.cpp index 63a34776..96630a96 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -34,8 +34,11 @@ #include "log.h" +#include "gui/chat.h" + Logger::Logger(): - mLogToStandardOut(false) + mLogToStandardOut(false), + mChatWindow(NULL) { } @@ -100,6 +103,11 @@ void Logger::log(const char *log_text, ...) std::cout << timeStr.str() << buf << std::endl; } + if (mChatWindow) + { + mChatWindow->chatLog(buf, BY_LOGGER); + } + // Delete temporary buffer delete[] buf; } @@ -25,6 +25,8 @@ #include <iosfwd> #include <fstream> +class ChatWindow; + /** * The Log Class : Useful to write debug or info messages */ @@ -52,6 +54,11 @@ class Logger void setLogToStandardOut(bool value) { mLogToStandardOut = value; } /** + * Enables logging to chat window + */ + void setChatWindow(ChatWindow *window) { mChatWindow = window; } + + /** * Enters a message in the log. The message will be timestamped. */ void log(const char *log_text, ...); @@ -65,6 +72,7 @@ class Logger private: std::ofstream mLogFile; bool mLogToStandardOut; + ChatWindow *mChatWindow; }; extern Logger *logger; |