Initial handshake and network game start. Works with multiple clients. Not yet stable, because it is not thread-safe. GUI callbacks not complete yet (server dialog not updated).
This commit is contained in:
@@ -44,9 +44,9 @@ void connectToServerDialogImpl::refresh(int actionID) {
|
||||
default: { label_actionMessage->setText("Please wait..."); }
|
||||
}
|
||||
|
||||
progressBar->setValue(actionID*(100/MSG_SOCK_LAST));
|
||||
progressBar->setValue(actionID*(100/MSG_SOCK_LIMIT_CONNECT));
|
||||
|
||||
if (actionID == MSG_SOCK_LAST)
|
||||
if (actionID == MSG_SOCK_LIMIT_CONNECT)
|
||||
QTimer::singleShot(1000, this, SLOT(accept()));
|
||||
}
|
||||
|
||||
|
||||
@@ -88,5 +88,10 @@ void GuiWrapper::meInAction() const { myW->meInAction(); }
|
||||
void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->logPlayerActionMsg(playerName, action, setValue); }
|
||||
void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->logNewGameHandMsg(gameID, handID); }
|
||||
|
||||
void GuiWrapper::SignalNetSuccess(int actionID) { myW->SignalNetSuccess(actionID); }
|
||||
void GuiWrapper::SignalNetError(int errorID, int osErrorID) { myW->SignalNetError(errorID, osErrorID); }
|
||||
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::SignalNetServerSuccess(int actionID) { }
|
||||
void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { }
|
||||
|
||||
|
||||
@@ -88,8 +88,12 @@ public:
|
||||
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
|
||||
void logNewGameHandMsg(int gameID, int handID) ;
|
||||
|
||||
void SignalNetSuccess(int actionID);
|
||||
void SignalNetError(int errorID, int osErrorID);
|
||||
void SignalNetClientConnect(int actionID);
|
||||
void SignalNetClientGameInfo(int actionID);
|
||||
void SignalNetClientError(int errorID, int osErrorID);
|
||||
|
||||
void SignalNetServerSuccess(int actionID);
|
||||
void SignalNetServerError(int errorID, int osErrorID);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "connecttoserverdialogimpl.h"
|
||||
#include "createnetworkgamedialogimpl.h"
|
||||
#include "startnetworkgamedialogimpl.h"
|
||||
|
||||
#include "waitforservertostartgamedialogimpl.h"
|
||||
|
||||
#include "startsplash.h"
|
||||
#include "mycardspixmaplabel.h"
|
||||
@@ -427,6 +427,7 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent)
|
||||
myConnectToServerDialog = new connectToServerDialogImpl(this);
|
||||
myStartNetworkGameDialog = new startNetworkGameDialogImpl(this);
|
||||
myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this);
|
||||
myWaitingForServerGameDialog = new waitForServerToStartGameDialogImpl(this);
|
||||
|
||||
//Connects
|
||||
connect(dealFlopCards0Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards1() ));
|
||||
@@ -481,8 +482,10 @@ mainWindowImpl::mainWindowImpl(QMainWindow *parent)
|
||||
connect ( pushButton_break, SIGNAL( clicked()), this, SLOT ( breakButtonClicked() ) ); // auch wieder starten!!!!
|
||||
|
||||
//Nachrichten Thread-Save
|
||||
connect(this, SIGNAL(SignalNetSuccess(int)), myConnectToServerDialog, SLOT(refresh(int)));
|
||||
connect(this, SIGNAL(SignalNetError(int, int)), myConnectToServerDialog, SLOT(error(int, int)));
|
||||
connect(this, SIGNAL(SignalNetClientConnect(int)), myConnectToServerDialog, SLOT(refresh(int)));
|
||||
connect(this, SIGNAL(SignalNetClientGameInfo(int)), myWaitingForServerGameDialog, SLOT(refresh(int)));
|
||||
// TODO Fix, errors MUST be global, not within one dialog.
|
||||
connect(this, SIGNAL(SignalNetClientError(int, int)), myConnectToServerDialog, SLOT(error(int, int)));
|
||||
|
||||
// textBrowser_Log->append(QString::number(this->pos().x(),10)+" "+QString::number(this->pos().y(),10));
|
||||
// textBrowser_Log->append(QString::number(this->x(),10)+" "+QString::number(this->y(),10));
|
||||
@@ -586,29 +589,18 @@ void mainWindowImpl::callAboutPokerthDialog() {
|
||||
|
||||
void mainWindowImpl::callCreateNetworkGameDialog() {
|
||||
|
||||
myCreateNetworkGameDialog->showDialog();
|
||||
myCreateNetworkGameDialog->exec();
|
||||
//
|
||||
if (myCreateNetworkGameDialog->result() == QDialog::Accepted ) {
|
||||
|
||||
mySession->terminateNetworkServer();
|
||||
mySession->startNetworkServer();
|
||||
//
|
||||
// mySession->terminateNetworkClient();
|
||||
//
|
||||
// // Maybe use QUrl::toPunycode.
|
||||
// mySession->startNetworkClient(
|
||||
// myJoinNetworkGameDialog->lineEdit_ipAddress->text().toUtf8().constData(),
|
||||
// myJoinNetworkGameDialog->spinBox_port->value(),
|
||||
// myJoinNetworkGameDialog->checkBox_ipv6->isChecked(),
|
||||
// myJoinNetworkGameDialog->lineEdit_password->text().toUtf8().constData());
|
||||
//
|
||||
// //Dialog mit Statusbalken
|
||||
// myConnectToServerDialog->exec();
|
||||
//
|
||||
// if (myConnectToServerDialog->result() == QDialog::Rejected ) {
|
||||
// mySession->terminateNetworkClient();
|
||||
// actionJoin_network_Game->trigger(); // re-trigger
|
||||
// }
|
||||
//
|
||||
|
||||
myStartNetworkGameDialog->exec();
|
||||
|
||||
if (myStartNetworkGameDialog->result() == QDialog::Accepted ) {
|
||||
mySession->initiateNetworkServerGame();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -635,6 +627,9 @@ void mainWindowImpl::callJoinNetworkGameDialog() {
|
||||
mySession->terminateNetworkClient();
|
||||
actionJoin_network_Game->trigger(); // re-trigger
|
||||
}
|
||||
else {
|
||||
myWaitingForServerGameDialog->exec();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ class joinNetworkGameDialogImpl;
|
||||
class connectToServerDialogImpl;
|
||||
class createNetworkGameDialogImpl;
|
||||
class startNetworkGameDialogImpl;
|
||||
class waitForServerToStartGameDialogImpl;
|
||||
|
||||
class QColor;
|
||||
|
||||
@@ -88,8 +89,9 @@ public:
|
||||
void setSpeeds();
|
||||
|
||||
signals:
|
||||
void SignalNetSuccess(int actionID);
|
||||
void SignalNetError(int errorID, int osErrorID);
|
||||
void SignalNetClientConnect(int actionID);
|
||||
void SignalNetClientGameInfo(int actionID);
|
||||
void SignalNetClientError(int errorID, int osErrorID);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -258,6 +260,7 @@ private:
|
||||
connectToServerDialogImpl *myConnectToServerDialog;
|
||||
startNetworkGameDialogImpl *myStartNetworkGameDialog;
|
||||
createNetworkGameDialogImpl *myCreateNetworkGameDialog;
|
||||
waitForServerToStartGameDialogImpl *myWaitingForServerGameDialog;
|
||||
|
||||
int maxQuantityPlayers;
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@ waitForServerToStartGameDialogImpl::waitForServerToStartGameDialogImpl(QWidget *
|
||||
|
||||
}
|
||||
|
||||
void waitForServerToStartGameDialogImpl::refresh(int actionID) {
|
||||
QTimer::singleShot(1000, this, SLOT(accept()));
|
||||
}
|
||||
|
||||
void waitForServerToStartGameDialogImpl::cancel() {
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
|
||||
public slots:
|
||||
|
||||
void refresh(int actionID);
|
||||
void cancel();
|
||||
void keyPressEvent ( QKeyEvent * event );
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user