# HG changeset patch # User sheepluva # Date 1319273527 -7200 # Node ID d56d188024818aaba99ec7259202931c7b32c37c # Parent c739b503ae3165310aa69d9889aa0848be86b791 some more chat fixes and changes, I think. hum. what was that? um. aaah, I better go catch some sheep ... er sleep.. um.. diff -r c739b503ae31 -r d56d18802481 QTfrontend/net/newnetclient.cpp --- a/QTfrontend/net/newnetclient.cpp Sat Oct 22 08:51:02 2011 +0200 +++ b/QTfrontend/net/newnetclient.cpp Sat Oct 22 10:52:07 2011 +0200 @@ -643,7 +643,7 @@ { if(str != "") { RawSendNet(QString("CHAT") + delimeter + str); - emit(chatStringFromMeLobby(HWProto::formatChatMsg(mynick, str))); + emit chatStringLobby(mynick, HWProto::formatChatMsgForFrontend(str)); } } diff -r c739b503ae31 -r d56d18802481 QTfrontend/res/css/chat.css --- a/QTfrontend/res/css/chat.css Sat Oct 22 08:51:02 2011 +0200 +++ b/QTfrontend/res/css/chat.css Sat Oct 22 10:52:07 2011 +0200 @@ -2,21 +2,22 @@ * see http://doc.qt.nokia.com/4.5/richtext-html-subset.html#css-properties * * In the QTfrontend of hedgewars also display:none; will work for class names - * that start with msg_ - as long as they are referenced directly and not + * that start with msg_ - as long as they are referenced directly and not * within any hierachy. */ /* links */ a { color:#c8c8ff; } + /* nick names (they are also sometimes linked) */ .nick { text-decoration: none; } /* various chat messages */ -.msg_UserChat { } +.msg_UserChat { color:#ffcc00; } /* chat of people who aren't your friends */ .msg_UserChat .nick { color:#ffec20; } -.msg_FriendChat { color: #08e008; } -.msg_FriendChat .nick { color: #20ff20; } +.msg_FriendChat { color: #b0ff08; } +.msg_FriendChat .nick { color: #30ff30; } .msg_UserJoin { color: #c0c0c0; } .msg_UserJoin .nick { color: #d0d0d0; } .msg_FriendJoin { font-weight: bold; color: #c0f0c0; } @@ -25,10 +26,16 @@ .msg_UserAction .nick { color: #ffa0ff;} .msg_FriendAction { color: #ff00ff; } .msg_FriendAction .nick { color: #ff30ff; } + +/* messages that contain your nickname */ +.highlight { } +.highlight .nick { color: red; } /* nicknames in highlighted messages */ + /* uncomment next line to disable join and leave messages of non-friends */ /* .msg_UserJoin { display:none; } */ -/* frontend messages */ +/* system messages */ .msg_Error { color: #ff0000; } .msg_Warning { color: #ff8000; } .msg_Notice { color: #fefefe; } + diff -r c739b503ae31 -r d56d18802481 QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Sat Oct 22 08:51:02 2011 +0200 +++ b/QTfrontend/ui/widget/chatwidget.cpp Sat Oct 22 10:52:07 2011 +0200 @@ -182,12 +182,16 @@ void HWChatWidget::displayNotice(const QString & message) { addLine("msg_Notice", " *** " + message); + // scroll to the end + chatText->moveCursor(QTextCursor::End); } void HWChatWidget::displayWarning(const QString & message) { addLine("msg_Warning", " *!* " + message); + // scroll to the end + chatText->moveCursor(QTextCursor::End); } @@ -197,9 +201,14 @@ { this->gameSettings = gameSettings; this->notify = notify; - if(notify && gameSettings->value("frontend/sound", true).toBool()) - helloSound = HWDataManager::instance().findFileForRead( - "Sounds/voices/Classic/Hello.ogg"); + if(gameSettings->value("frontend/sound", true).toBool()) + { + if (notify) + m_helloSound = HWDataManager::instance().findFileForRead( + "Sounds/voices/Classic/Hello.ogg"); + m_hilightSound = HWDataManager::instance().findFileForRead( + "Sounds/1C.ogg"); + } mainLayout.setSpacing(1); mainLayout.setMargin(1); @@ -264,6 +273,8 @@ showReady = false; setShowFollow(true); + + clear(); } @@ -442,7 +453,8 @@ QString cssClass("msg_UserChat"); // check first character for color code and set color properly - switch (str[0].toAscii()) { + char c = str[0].toAscii(); + switch (c) { case 3: cssClass = (isFriend ? "msg_FriendJoin" : "msg_UserJoin"); break; @@ -454,10 +466,10 @@ cssClass = "msg_FriendChat"; } - addLine(cssClass,formattedStr); + addLine(cssClass, formattedStr, (!nick.isEmpty()) && str.contains(m_userNick)); } -void HWChatWidget::addLine(const QString & cssClass, QString line) +void HWChatWidget::addLine(const QString & cssClass, QString line, bool isHighlight) { if (s_displayNone->contains(cssClass)) return; // the css forbids us to display this line @@ -465,7 +477,13 @@ if (chatStrings.size() > 250) chatStrings.removeFirst(); - line = QString("%1").arg(line).arg(cssClass); + line = QString("%2").arg(cssClass).arg(line); + + if (isHighlight) + { + line = QString("%1").arg(line); + SDLInteraction::instance().playSoundFile(m_hilightSound); + } chatStrings.append(line); @@ -486,20 +504,20 @@ chatText->moveCursor(QTextCursor::End); } -void HWChatWidget::nickAdded(const QString& nick, bool notifyNick) +void HWChatWidget::nickAdded(const QString & nick, bool notifyNick) { bool isIgnored = ignoreList.contains(nick, Qt::CaseInsensitive); QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), isIgnored); updateNickItem(item); chatNicks->addItem(item); - if (!isIgnored) + if ((!isIgnored) && (nick != m_userNick)) // don't auto-complete own name chatEditLine->addNickname(nick); emit nickCountUpdate(chatNicks->count()); if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) { - SDLInteraction::instance().playSoundFile(helloSound); + SDLInteraction::instance().playSoundFile(m_helloSound); } } @@ -519,6 +537,7 @@ chatText->clear(); chatStrings.clear(); chatNicks->clear(); + m_userNick = gameSettings->value("net/nick","").toString(); } void HWChatWidget::onKick() diff -r c739b503ae31 -r d56d18802481 QTfrontend/ui/widget/chatwidget.h --- a/QTfrontend/ui/widget/chatwidget.h Sat Oct 22 08:51:02 2011 +0200 +++ b/QTfrontend/ui/widget/chatwidget.h Sat Oct 22 10:52:07 2011 +0200 @@ -76,7 +76,7 @@ void saveList(QStringList & list, const QString & file); void updateNickItem(QListWidgetItem *item); void updateNickItems(); - void addLine(const QString & cssClass, QString line); + void addLine(const QString & cssClass, QString line, bool isHighlight = false); static const QRegExp URLREGEXP; public slots: @@ -110,7 +110,9 @@ QAction * acIgnore; QAction * acFriend; QSettings * gameSettings; - QString helloSound; + QString m_helloSound; + QString m_hilightSound; + QString m_userNick; bool notify; bool showReady;