- Customize QTextBrowser look
- Add a place for server messages on rooms list page
--- 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 <QSpinBox>
#include <QCloseEvent>
#include <QCheckBox>
+#include <QTextBrowser>
#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&)));
--- 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;"
--- 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;
--- 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);
--- 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 <QMessageBox>
#include <QHeaderView>
#include <QTabWidget>
+#include <QTextBrowser>
#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();
--- 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);
--- 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", "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"])]
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