summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2007-12-10 02:50:15 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2007-12-10 02:50:15 +0000
commit2820f4d4329f29fc75c85d6b2195fd42b97fd457 (patch)
tree2e48985cf1fddad7b37afcc3eefaeb75ed1d1ee3
parente961be5bfd29ad3f44f948828981cb3ab07f25a7 (diff)
downloadmana-client-2820f4d4329f29fc75c85d6b2195fd42b97fd457.tar.gz
mana-client-2820f4d4329f29fc75c85d6b2195fd42b97fd457.tar.bz2
mana-client-2820f4d4329f29fc75c85d6b2195fd42b97fd457.tar.xz
mana-client-2820f4d4329f29fc75c85d6b2195fd42b97fd457.zip
Added an option to show log messages in the chat console.
-rw-r--r--ChangeLog2
-rw-r--r--src/game.cpp5
-rw-r--r--src/gui/chat.cpp3
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/log.cpp10
-rw-r--r--src/log.h8
6 files changed, 29 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 11591d6c..5b181966 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
src/player.cpp, src/player.h, data/items.xml: Simplified player
subsprite handling by treating equipment, hairstyle and base
sprites alike. This also enables gender-specific hairstyles.
+ * src/game.cpp, src/gui/chat.cpp, src/gui/chat.h, src/log.cpp,
+ src/log.h: Added an option to show log messages in the chat console.
2007-12-09 Philipp Sehmisch <tmw@crushnet.org>
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;
}
diff --git a/src/log.h b/src/log.h
index 36328527..dd1c0f91 100644
--- a/src/log.h
+++ b/src/log.h
@@ -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;