serverlist gui added

This commit is contained in:
doitux
2009-04-05 12:32:16 +00:00
parent 534b6066a8
commit f54e03d179
10 changed files with 226 additions and 71 deletions
+4 -59
View File
@@ -123,8 +123,11 @@ void GuiWrapper::logPlayerWinGame(std::string playerName, int gameID) { myLog->s
void GuiWrapper::flushLogAtGame(int gameID) { myLog->signalFlushLogAtGame(gameID); }
void GuiWrapper::flushLogAtHand() { myLog->signalFlushLogAtHand(); }
////////// this is for startwindow ////////////////////
void GuiWrapper::SignalNetClientConnect(int actionID) { myStartWindow->signalNetClientConnect(actionID); }
void GuiWrapper::SignalNetClientServerListAdd(unsigned serverId) { myStartWindow->signalNetClientServerListAdd(serverId); }
void GuiWrapper::SignalNetClientServerListShow() { myStartWindow->signalNetClientServerListShow(); }
void GuiWrapper::SignalNetClientServerListClear() { myStartWindow->signalNetClientServerListClear(); }
void GuiWrapper::SignalNetClientGameInfo(int actionID) { myStartWindow->signalNetClientGameInfo(actionID); }
void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myStartWindow->signalNetClientError(errorID, osErrorID); }
void GuiWrapper::SignalNetClientNotification(int notificationId) { myStartWindow->signalNetClientNotification(notificationId); }
@@ -176,61 +179,3 @@ void GuiWrapper::SignalIrcPlayerLeft(const std::string &nickName) { myStartWindo
void GuiWrapper::SignalIrcChatMsg(const std::string &nickName, const std::string &msg) { myStartWindow->signalIrcChatMessage(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(msg.c_str())); }
void GuiWrapper::SignalIrcError(int errorCode) { myStartWindow->signalIrcError(errorCode); }
void GuiWrapper::SignalIrcServerError(int errorCode) {myStartWindow->signalIrcServerError(errorCode); }
////////// this is for startwindow ////////////////////
//TEMPORARELY UNTIL STARTWINDOW REFACTORING IS OVER TODO
// void GuiWrapper::SignalNetClientConnect(int actionID) { myW->signalNetClientConnect(actionID); }
// void GuiWrapper::SignalNetClientGameInfo(int actionID) { myW->signalNetClientGameInfo(actionID); }
// void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->signalNetClientError(errorID, osErrorID); }
// void GuiWrapper::SignalNetClientNotification(int notificationId) { myW->signalNetClientNotification(notificationId); }
// void GuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) { myW->signalNetClientStatsUpdate(stats); }
// void GuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) { myW->signalNetClientShowTimeoutDialog(reason, remainingSec); }
// void GuiWrapper::SignalNetClientRemovedFromGame(int notificationId) { myW->signalNetClientRemovedFromGame(notificationId); }
// void GuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, PlayerRights rights) { myW->signalNetClientSelfJoined(playerId, QString::fromUtf8(playerName.c_str()), rights); }
// void GuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, PlayerRights rights) { myW->signalNetClientPlayerJoined(playerId, QString::fromUtf8(playerName.c_str()), rights); }
// void GuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName)
// {
// myW->signalNetClientPlayerChanged(playerId, QString::fromUtf8(newPlayerName.c_str()));
// }
// void GuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName)
// {
// QString tmpName(QString::fromUtf8(playerName.c_str()));
// myW->signalNetClientPlayerLeft(playerId, tmpName);
// if (!playerName.empty() && playerName[0] != '#')
// myLog->signalLogPlayerLeftMsg(tmpName);
// }
// void GuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName) {
//
// myW->signalNetClientNewGameAdmin(playerId, QString::fromUtf8(playerName.c_str()));
// if (!playerName.empty() && playerName[0] != '#')
// myLog->signalLogNewGameAdminMsg(QString::fromUtf8(playerName.c_str()));
//
// }
//
// void GuiWrapper::SignalNetClientGameListNew(unsigned gameId) { myW->signalNetClientGameListNew(gameId); }
// void GuiWrapper::SignalNetClientGameListRemove(unsigned gameId) { myW->signalNetClientGameListRemove(gameId); }
// void GuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode) { myW->signalNetClientGameListUpdateMode(gameId, mode); }
// void GuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId) {myW->signalNetClientGameListUpdateAdmin(gameId, adminPlayerId); }
// void GuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) { myW->signalNetClientGameListPlayerJoined(gameId, playerId); }
// void GuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) { myW->signalNetClientGameListPlayerLeft(gameId, playerId); }
//
// void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr<Game> game) { myW->signalNetClientGameStart(game); }
// void GuiWrapper::SignalNetClientWaitDialog() { myW->signalShowClientDialog(); }
// void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myW->signalNetClientChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); }
// void GuiWrapper::SignalNetServerSuccess(int /*actionID*/) { }
// void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { myW->signalNetServerError(errorID, osErrorID); }
//
// void GuiWrapper::SignalIrcConnect(const string &server) { myW->signalIrcConnect(QString::fromUtf8(server.c_str())); }
// void GuiWrapper::SignalIrcSelfJoined(const string &nickName, const string &channel) { myW->signalIrcSelfJoined(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(channel.c_str())); }
// void GuiWrapper::SignalIrcPlayerJoined(const string &nickName) { myW->signalIrcPlayerJoined(QString::fromUtf8(nickName.c_str())); }
// void GuiWrapper::SignalIrcPlayerChanged(const string &oldNick, const string &newNick) { myW->signalIrcPlayerChanged(QString::fromUtf8(oldNick.c_str()), QString::fromUtf8(newNick.c_str())); }
// void GuiWrapper::SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) { myW->signalIrcPlayerKicked(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(byWhom.c_str()), QString::fromUtf8(reason.c_str())); }
// void GuiWrapper::SignalIrcPlayerLeft(const std::string &nickName) { myW->signalIrcPlayerLeft(QString::fromUtf8(nickName.c_str())); }
// void GuiWrapper::SignalIrcChatMsg(const std::string &nickName, const std::string &msg) { myW->signalIrcChatMessage(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(msg.c_str())); }
// void GuiWrapper::SignalIrcError(int errorCode) { myW->signalIrcError(errorCode); }
// void GuiWrapper::SignalIrcServerError(int errorCode) {myW->signalIrcServerError(errorCode); }
//TEMPORARELY UNTIL STARTWINDOW REFACTORING IS OVER TODO
+3
View File
@@ -113,6 +113,9 @@ public:
void flushLogAtHand();
void SignalNetClientConnect(int actionID);
void SignalNetClientServerListAdd(unsigned serverId);
void SignalNetClientServerListShow();
void SignalNetClientServerListClear();
void SignalNetClientGameInfo(int actionID);
void SignalNetClientError(int errorID, int osErrorID);
void SignalNetClientNotification(int notificationId);
+80
View File
@@ -0,0 +1,80 @@
<ui version="4.0" >
<class>ServerListDialog</class>
<widget class="QDialog" name="ServerListDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QTreeWidget" name="treeWidget_serverList" >
<column>
<property name="text" >
<string>Servername</string>
</property>
</column>
<column>
<property name="text" >
<string>Country</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ServerListDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ServerListDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "serverlistdialogimpl.h"
#include "configfile.h"
#include "startwindowimpl.h"
#include "serverdata.h"
#include "session.h"
serverListDialogImpl::serverListDialogImpl(startWindowImpl *sw, QMainWindow *parent, ConfigFile *c)
: QDialog(parent), myConfig(c), mySw(sw)
{
#ifdef __APPLE__
setWindowModality(Qt::ApplicationModal);
setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog);
#endif
setupUi(this);
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( connectToServer() ));
}
void serverListDialogImpl::exec() {
QDialog::exec();
}
void serverListDialogImpl::clearList()
{
treeWidget_serverList->clear();
}
void serverListDialogImpl::addServerItem(unsigned serverId)
{
ServerInfo info = mySw->getSession()->getClientServerInfo(serverId);
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_serverList);
item->setData(0, Qt::DisplayRole, QString::fromUtf8(info.name.c_str()));
item->setData(0, Qt::UserRole, serverId);
item->setData(1, Qt::DisplayRole, QString::fromUtf8(info.country.c_str()));
}
void serverListDialogImpl::connectToServer()
{
QTreeWidgetItem *item = treeWidget_serverList->currentItem();
if (item) {
// mySw->getSession()->connect(item->data(0, Qt::UserRole)) TODO
}
}
@@ -0,0 +1,52 @@
/***************************************************************************
* Copyright (C) 2006 by FThauer FHammer *
* f.thauer@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef SERVERLISTDIALOGIMPL_H
#define SERVERLISTDIALOGIMPL_H
#include "ui_serverlistdialog.h"
#include <QtGui>
#include <QtCore>
class ConfigFile;
class startWindowImpl;
class serverListDialogImpl: public QDialog, public Ui::ServerListDialog {
Q_OBJECT
public:
serverListDialogImpl(startWindowImpl *sw, QMainWindow *parent = 0, ConfigFile* = 0 );
public slots:
void exec();
void clearList();
void addServerItem(unsigned);
void connectToServer();
private:
ConfigFile *myConfig;
startWindowImpl *mySw;
};
#endif
void exec();
@@ -47,6 +47,7 @@
#include "timeoutmsgboximpl.h"
#include "lobbychat.h"
#include "chat.h"
#include "serverlistdialogimpl.h"
using namespace std;
@@ -98,6 +99,7 @@ startWindowImpl::startWindowImpl(ConfigFile *c)
myGameLobbyDialog->setMyW(myGuiInterface->getMyW());
myTimeoutDialog = new timeoutMsgBoxImpl(this);
myServerListDialog = new serverListDialogImpl(this, this, myConfig);
connect( actionStart_Local_Game, SIGNAL( triggered() ), this, SLOT( callNewGameDialog() ) );
connect( pushButtonStart_Local_Game, SIGNAL( clicked() ), this, SLOT( callNewGameDialog() ) );
@@ -118,6 +120,10 @@ startWindowImpl::startWindowImpl(ConfigFile *c)
connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog, SLOT(refresh(int)));
connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog, SLOT(refresh(int)));
connect(this, SIGNAL(signalNetClientServerListShow()), myServerListDialog, SLOT(exec()));
connect(this, SIGNAL(signalNetClientServerListClear()), myServerListDialog, SLOT(clearList()));
connect(this, SIGNAL(signalNetClientServerListAdd(unsigned serverId)), myServerListDialog, SLOT(addServerItem(serverId)));
connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(unsigned, QString, int)));
connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(unsigned, QString, int)));
connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog, SLOT(updatePlayer(unsigned, QString)));
+5 -1
View File
@@ -42,7 +42,7 @@ class startNetworkGameDialogImpl;
class changeHumanPlayerNameDialogImpl;
class gameLobbyDialogImpl;
class timeoutMsgBoxImpl;
class serverListDialogImpl;
class startWindowImpl: public QMainWindow, public Ui::startWindow {
Q_OBJECT
@@ -57,6 +57,9 @@ signals:
void signalShowClientDialog();
void signalNetClientConnect(int actionID);
void signalNetClientServerListShow();
void signalNetClientServerListClear();
void signalNetClientServerListAdd(unsigned serverId);
void signalNetClientGameInfo(int actionID);
void signalNetClientError(int errorID, int osErrorID);
void signalNetClientNotification(int notificationId);
@@ -135,6 +138,7 @@ private:
gameLobbyDialogImpl *myGameLobbyDialog;
timeoutMsgBoxImpl *myTimeoutDialog;
startWindowImpl *myStartWindow;
serverListDialogImpl *myServerListDialog;
friend class GuiWrapper;