summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Sehmisch <tmw@crushnet.org>2008-03-09 15:35:00 +0000
committerPhilipp Sehmisch <tmw@crushnet.org>2008-03-09 15:35:00 +0000
commit91176f564ae9462d50819f033756cb6e32b113ac (patch)
treeb6b4579ab02e37a570c8209510e85283563310fd /src
parent9085123bab570e32ddec9dda6ecfae40a3ac25f1 (diff)
downloadmana-91176f564ae9462d50819f033756cb6e32b113ac.tar.gz
mana-91176f564ae9462d50819f033756cb6e32b113ac.tar.bz2
mana-91176f564ae9462d50819f033756cb6e32b113ac.tar.xz
mana-91176f564ae9462d50819f033756cb6e32b113ac.zip
Applied some patches by peavey related to chatlog and the quit dialog.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp6
-rw-r--r--src/gui/chat.cpp20
-rw-r--r--src/gui/chat.h2
3 files changed, 21 insertions, 7 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 52d70bc0..553f80c3 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -525,8 +525,12 @@ void Game::handleInput()
exitConfirm = new ConfirmDialog(
"Quit", "Are you sure you want to quit?");
exitConfirm->addActionListener(&exitListener);
+ exitConfirm->requestMoveToTop();
+ }
+ else
+ {
+ exitConfirm->action(gcn::ActionEvent(NULL, "no"));
}
- exitConfirm->requestMoveToTop();
break;
default:
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 2e7e109b..effb58d2 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -97,10 +97,13 @@ ChatWindow::logic()
void
ChatWindow::chatLog(std::string line, int own)
{
+ // Trim whitespace
+ trim(line);
CHATLOG tmp;
tmp.own = own;
tmp.nick = "";
+ tmp.text = line;
// Fix the owner of welcome message.
if (line.substr(0, 7) == "Welcome")
@@ -111,12 +114,9 @@ ChatWindow::chatLog(std::string line, int own)
std::string::size_type pos = line.find(" : ");
if (pos != std::string::npos) {
tmp.nick = line.substr(0, pos);
- line.erase(0, pos + 3);
+ tmp.text = line.substr(pos + 3);
}
- // Trim whitespace
- trim(line);
-
std::string lineColor = "##0"; // Equiv. to BrowserBox::BLACK
switch (own) {
case BY_GM:
@@ -132,7 +132,8 @@ ChatWindow::chatLog(std::string line, int own)
lineColor = "##0"; // Equiv. to BrowserBox::BLACK
break;
case BY_SERVER:
- tmp.nick += std::string("Server: ");
+ tmp.nick = "Server: ";
+ tmp.text = line;
lineColor = "##7"; // Equiv. to BrowserBox::PINK
break;
case ACT_WHISPER:
@@ -144,6 +145,8 @@ ChatWindow::chatLog(std::string line, int own)
lineColor = "##5"; // Equiv. to BrowserBox::YELLOW
break;
case BY_LOGGER:
+ tmp.nick = "";
+ tmp.text = line;
lineColor = "##8"; // Equiv. to BrowserBox::GREY
break;
}
@@ -162,7 +165,7 @@ ChatWindow::chatLog(std::string line, int own)
<< (int)((t / 60) % 60)
<< "] ";
- line = lineColor + timeStr.str() + tmp.nick + line;
+ line = lineColor + timeStr.str() + tmp.nick + tmp.text;
// We look if the Vertical Scroll Bar is set at the max before
// adding a row, otherwise the max will always be a row higher
@@ -277,6 +280,7 @@ ChatWindow::chatSend(const std::string &nick, std::string msg)
chatLog("/announce : Global announcement (GM only)", BY_SERVER);
chatLog("/where : Display map name", BY_SERVER);
chatLog("/who : Display number of online users", BY_SERVER);
+ chatLog("/clear : Clears this window", BY_SERVER);
}
else if (msg.substr(0, IS_WHERE_LENGTH) == IS_WHERE)
{
@@ -287,6 +291,10 @@ ChatWindow::chatSend(const std::string &nick, std::string msg)
MessageOut outMsg(mNetwork);
outMsg.writeInt16(0x00c1);
}
+ else if (msg.substr(0, IS_CLEAR_LENGTH) == IS_CLEAR)
+ {
+ mTextOutput->clearRows();
+ }
else
{
chatLog("Unknown command", BY_SERVER);
diff --git a/src/gui/chat.h b/src/gui/chat.h
index b857f4b4..cbfc8a63 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -56,6 +56,8 @@ class ScrollArea;
#define IS_WHERE_LENGTH 6
#define IS_WHO "/who"
#define IS_WHO_LENGTH 4
+#define IS_CLEAR "/clear"
+#define IS_CLEAR_LENGTH 6
/**
* gets in between usernick and message text depending on