# HG changeset patch # User unc0rr # Date 1224338038 0 # Node ID a9e768739345a2d9fe1a4dc39c93fd3e8b9de1fe # Parent 6c82ad758a806340e0f5218fdfd7850c36503239 - Customize QTextBrowser look - Add a place for server messages on rooms list page diff -r 6c82ad758a80 -r a9e768739345 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sat Oct 18 13:45:42 2008 +0000 +++ b/QTfrontend/hwform.cpp Sat Oct 18 13:53:58 2008 +0000 @@ -28,6 +28,7 @@ #include #include #include +#include #include "hwform.h" #include "game.h" @@ -422,6 +423,8 @@ connect(hwnet, SIGNAL(roomsList(const QStringList&)), ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); + connect(hwnet, SIGNAL(serverMessage(const QString&)), + ui.pageRoomsList->serverMessage, SLOT(setText(const QString&))); connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), hwnet, SLOT(CreateRoom(const QString&))); diff -r 6c82ad758a80 -r a9e768739345 QTfrontend/main.cpp --- a/QTfrontend/main.cpp Sat Oct 18 13:45:42 2008 +0000 +++ b/QTfrontend/main.cpp Sat Oct 18 13:53:58 2008 +0000 @@ -115,6 +115,16 @@ // "background: #2f213a;" // "}" + "QTextBrowser{" + "border: solid;" + "border-width: 3px;" + "border-radius: 12px;" + "border-color: #ffcc00;" + "background-color: #0d0544;" + "color: #ffcc00;" + "font: bold 14px;" + "}" + "QSpinBox{" "border: solid;" "border-width: 3px;" @@ -195,7 +205,6 @@ "font: bold 14px;" "}" - "IconedGroupBox{" "border: solid;" "border-width: 3px;" diff -r 6c82ad758a80 -r a9e768739345 QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Sat Oct 18 13:45:42 2008 +0000 +++ b/QTfrontend/newnetclient.cpp Sat Oct 18 13:53:58 2008 +0000 @@ -233,11 +233,21 @@ return; } + if (lst[0] == "SERVER_MESSAGE") { + if(lst.size() < 2) + { + qWarning("Net: Empty SERVERMESSAGE message"); + return; + } + emit serverMessage(lst[1]); + return; + } + if (lst[0] == "CHAT_STRING") { if(lst.size() < 3) { - qWarning("Net: Empty CHAT_STRING message"); - return; + qWarning("Net: Empty CHAT_STRING message"); + return; } emit chatStringFromNet(QString("%1: %2").arg(lst[1]).arg(lst[2])); return; diff -r 6c82ad758a80 -r a9e768739345 QTfrontend/newnetclient.h --- a/QTfrontend/newnetclient.h Sat Oct 18 13:45:42 2008 +0000 +++ b/QTfrontend/newnetclient.h Sat Oct 18 13:53:58 2008 +0000 @@ -107,7 +107,9 @@ void chatStringFromNet(const QString&); void chatStringFromMe(const QString&); void ammoChanged(const QString& name, const QString& ammo); + void roomsList(const QStringList&); + void serverMessage(const QString &); public slots: void chatLineToNet(const QString& str); diff -r 6c82ad758a80 -r a9e768739345 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Sat Oct 18 13:45:42 2008 +0000 +++ b/QTfrontend/pages.cpp Sat Oct 18 13:53:58 2008 +0000 @@ -33,6 +33,7 @@ #include #include #include +#include #include "pages.h" #include "sdlkeys.h" @@ -629,8 +630,11 @@ pageLayout->addWidget(roomName, 0, 0); roomsList = new QListWidget(this); pageLayout->addWidget(roomsList, 1, 0, 3, 1); + serverMessage = new QTextBrowser(this); + serverMessage->setOpenExternalLinks(true); + pageLayout->addWidget(serverMessage, 4, 0, 1, 2); - BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true); BtnCreate = addButton(tr("Create"), pageLayout, 0, 1); BtnJoin = addButton(tr("Join"), pageLayout, 1, 1); BtnRefresh = addButton(tr("Refresh"), pageLayout, 2, 1); @@ -641,6 +645,7 @@ connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick())); } + void PageRoomsList::setRoomsList(const QStringList & list) { roomsList->clear(); diff -r 6c82ad758a80 -r a9e768739345 QTfrontend/pages.h --- a/QTfrontend/pages.h Sat Oct 18 13:45:42 2008 +0000 +++ b/QTfrontend/pages.h Sat Oct 18 13:53:58 2008 +0000 @@ -39,6 +39,7 @@ class QTextEdit; class QRadioButton; class QTableView; +class QTextBrowser; class GameCFGWidget; class TeamSelWidget; @@ -349,6 +350,7 @@ QPushButton * BtnCreate; QPushButton * BtnJoin; QPushButton * BtnRefresh; + QTextBrowser * serverMessage; public slots: void setRoomsList(const QStringList & list); diff -r 6c82ad758a80 -r a9e768739345 netserver/HWProto.hs --- a/netserver/HWProto.hs Sat Oct 18 13:45:42 2008 +0000 +++ b/netserver/HWProto.hs Sat Oct 18 13:53:58 2008 +0000 @@ -11,6 +11,7 @@ where hhsInfo = concatMap (\(HedgehogInfo name hat) -> [name, hat]) $ hedgehogs team +answerServerMessage = [(clientOnly, ["SERVER_MESSAGE", "

http://www.hedgewars.org/

"])] answerBadCmd = [(clientOnly, ["ERROR", "Bad command, state or incorrect parameter"])] answerNotMaster = [(clientOnly, ["ERROR", "You cannot configure room parameters"])] answerBadParam = [(clientOnly, ["ERROR", "Bad parameter"])] @@ -103,7 +104,7 @@ -- 'noRoom' clients state command handlers handleCmd_noRoom :: CmdHandler handleCmd_noRoom client _ rooms ["LIST"] = - (noChangeClients, noChangeRooms, answerRoomsList $ map name rooms) + (noChangeClients, noChangeRooms, answerServerMessage ++ (answerRoomsList $ map name rooms)) handleCmd_noRoom client _ rooms ["CREATE", newRoom, roomPassword] = if haveSameRoom then