Create GameData from createLocalGameView and move to startviewimpl. Ready to start the Network session ...

This commit is contained in:
Felix Hammer
2015-10-31 23:17:29 +01:00
parent e053cdcaf6
commit 055f87019c
9 changed files with 126 additions and 11 deletions
+45 -3
View File
@@ -1,10 +1,12 @@
#include "createlocalgameviewimpl.h" #include "createlocalgameviewimpl.h"
#include "startviewimpl.h"
#include "configfile.h" #include "configfile.h"
#include "mylistviewitemdata.h" #include "mylistviewitemdata.h"
#include "gamedata.h"
#include <QtQml> #include <QtQml>
CreateLocalGameViewImpl::CreateLocalGameViewImpl(QObject *parent, QQmlApplicationEngine *e, boost::shared_ptr<ConfigFile> c) CreateLocalGameViewImpl::CreateLocalGameViewImpl(QObject *parent, QQmlApplicationEngine *e, boost::shared_ptr<ConfigFile> c, StartViewImpl *s )
: QObject(parent) ,myQmlEngine(e), myConfig(c) : QObject(parent) ,myQmlEngine(e), myConfig(c), myStartView(s)
{ {
//Build the listView data structure //Build the listView data structure
MyListViewItemData *item = NULL; MyListViewItemData *item = NULL;
@@ -104,11 +106,51 @@ void CreateLocalGameViewImpl::readConfigValues()
listItem("selector_BlindsRaiseMode")->setMyAfterMBAlwaysRaiseValue(QString::number(myConfig->readConfigInt("AfterMBAlwaysRaiseValue"))); listItem("selector_BlindsRaiseMode")->setMyAfterMBAlwaysRaiseValue(QString::number(myConfig->readConfigInt("AfterMBAlwaysRaiseValue")));
listItem("selector_BlindsRaiseMode")->setMyAfterMBStayAtLastBlind(QString::number(myConfig->readConfigInt("AfterMBStayAtLastBlind"))); listItem("selector_BlindsRaiseMode")->setMyAfterMBStayAtLastBlind(QString::number(myConfig->readConfigInt("AfterMBStayAtLastBlind")));
listItem("comboBox_GameSpeed")->setMyValue(QString::number(myConfig->readConfigInt("GameSpeed"))); listItem("comboBox_GameSpeed")->setMyValue(QString::number(myConfig->readConfigInt("GameSpeed")));
} }
void CreateLocalGameViewImpl::startGame() void CreateLocalGameViewImpl::startGame()
{ {
qDebug() << "Start Game from CreateLocalGameViewImpl:"; qDebug() << "Start Game from CreateLocalGameViewImpl:";
qDebug() << "Number of players: " << listItem("comboBox_NumberOfPlayers")->myValue(); qDebug() << "Number of players: " << listItem("comboBox_NumberOfPlayers")->myValue();
GameData gameData;
gameData.maxNumberOfPlayers = listItem("comboBox_NumberOfPlayers")->myValue().toInt();
gameData.startMoney = listItem("spinBox_StartCash")->myValue().toInt();
gameData.firstSmallBlind = listItem("spinBox_FirstSmallBlind")->myValue().toInt();
if(listItem("selector_BlindsRaiseInterval")->myRaiseOnHandsType() == "1") {
gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER;
gameData.raiseSmallBlindEveryHandsValue = listItem("selector_BlindsRaiseInterval")->myRaiseOnHandsInterval().toInt();
} else {
gameData.raiseIntervalMode = RAISE_ON_MINUTES;
gameData.raiseSmallBlindEveryMinutesValue = listItem("selector_BlindsRaiseInterval")->myRaiseOnMinutesInterval().toInt();
}
if(listItem("selector_BlindsRaiseMode")->myAlwaysDoubleBlinds() == "1") {
gameData.raiseMode = DOUBLE_BLINDS;
} else {
gameData.raiseMode = MANUAL_BLINDS_ORDER;
std::list<int> tempBlindList;
int i;
bool ok = true;
for(i = 0; i < listItem("selector_BlindsRaiseMode")->myManualBlindsList().count(); i++) {
tempBlindList.push_back(listItem("selector_BlindsRaiseMode")->myManualBlindsList().at(i).toInt());
}
gameData.manualBlindsList = tempBlindList;
if(listItem("selector_BlindsRaiseMode")->myAfterMBAlwaysDoubleBlinds() == "1") {
gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS;
} else {
if(listItem("selector_BlindsRaiseMode")->myAfterMBAlwaysRaiseAbout() == "1") {
gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT;
gameData.afterMBAlwaysRaiseValue = listItem("selector_BlindsRaiseMode")->myAfterMBAlwaysRaiseValue().toInt();
} else {
gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND;
}
}
}
gameData.guiSpeed = listItem("comboBox_GameSpeed")->myValue().toInt();
gameData.delayBetweenHandsSec = 7;
gameData.playerActionTimeoutSec = 20;
myStartView->startLocalGame(gameData);
} }
+3 -1
View File
@@ -7,6 +7,7 @@
class ConfigFile; class ConfigFile;
class MyListViewItemData; class MyListViewItemData;
class StartViewImpl;
class CreateLocalGameViewImpl : public QObject class CreateLocalGameViewImpl : public QObject
{ {
@@ -15,7 +16,7 @@ public:
Q_INVOKABLE void readConfigValues(); Q_INVOKABLE void readConfigValues();
Q_INVOKABLE void startGame(); Q_INVOKABLE void startGame();
CreateLocalGameViewImpl(QObject *parent, QQmlApplicationEngine *engine, boost::shared_ptr<ConfigFile>); CreateLocalGameViewImpl(QObject *parent, QQmlApplicationEngine *engine, boost::shared_ptr<ConfigFile>, StartViewImpl*);
~CreateLocalGameViewImpl(); ~CreateLocalGameViewImpl();
MyListViewItemData* listItem(QString id); MyListViewItemData* listItem(QString id);
@@ -27,6 +28,7 @@ private:
QQmlApplicationEngine *myQmlEngine; QQmlApplicationEngine *myQmlEngine;
QList<QObject*> myListData; QList<QObject*> myListData;
boost::shared_ptr<ConfigFile> myConfig; boost::shared_ptr<ConfigFile> myConfig;
StartViewImpl *myStartView;
}; };
#endif // CREATELOCALGAMEVIEWIMPL_H #endif // CREATELOCALGAMEVIEWIMPL_H
+1 -1
View File
@@ -18,7 +18,7 @@ QmlWrapper::QmlWrapper(boost::shared_ptr<ConfigFile> c)
//TODO create Session and Log here //TODO create Session and Log here
myStartViewImpl = new StartViewImpl(this); myStartViewImpl = new StartViewImpl(this);
myCreateLocalGameViewImpl = new CreateLocalGameViewImpl(this, myQmlEngine, myConfig); myCreateLocalGameViewImpl = new CreateLocalGameViewImpl(this, myQmlEngine, myConfig, myStartViewImpl);
//Add c++ content to QML here //Add c++ content to QML here
myQmlEngine->rootContext()->setContextProperty("Config", myQmlConfig); myQmlEngine->rootContext()->setContextProperty("Config", myQmlConfig);
+37 -2
View File
@@ -1,5 +1,6 @@
#include "startviewimpl.h" #include "startviewimpl.h"
#include "mylistviewitemdata.h" #include "mylistviewitemdata.h"
#include "gamedata.h"
StartViewImpl::StartViewImpl(QObject *parent) : QObject(parent) StartViewImpl::StartViewImpl(QObject *parent) : QObject(parent)
{ {
@@ -12,8 +13,42 @@ StartViewImpl::~StartViewImpl()
} }
void StartViewImpl::startLocalGame() void StartViewImpl::startLocalGame(GameData &gd)
{ {
qDebug("startLocalGame im c++"); // // Stop local game.
// myGuiInterface->getMyW()->stopTimer();
// Frage 1. Was ist nochmal ServerGuiInterface? Wofür? Was macht es?
// if (!myServerGuiInterface) {
// // Create pseudo Gui Wrapper for the server.
// myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui(), mySession->getGui()));
// {
// boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig, 0));
// session->init(mySession->getAvatarManager());
// myServerGuiInterface->setSession(session);
// }
// }
// // Terminate existing network games.
// mySession->terminateNetworkClient();
// myServerGuiInterface->getSession()->terminateNetworkServer();
// Frage 2. Warum an dieser Stelle die StartView-Session an Lobby und StartNetworkDialog?
// myGameLobbyDialog->setSession(getSession());
// myStartNetworkGameDialog->setSession(getSession());
// myServerGuiInterface->getSession()->startNetworkServer(false,true);
// mySession->startNetworkClientForLocalServer(gd);
// myGuiInterface->getMyW()->show();
// myGuiInterface->getMyW()->networkGameModification();
// assert(getSession());
// getSession()->sendStartEvent(true);
} }
+2 -1
View File
@@ -3,6 +3,7 @@
#include <QtCore> #include <QtCore>
class CreateLocalGameViewImpl; class CreateLocalGameViewImpl;
class GameData;
class StartViewImpl : public QObject class StartViewImpl : public QObject
{ {
@@ -14,7 +15,7 @@ public:
signals: signals:
public slots: public slots:
Q_INVOKABLE void startLocalGame(); Q_INVOKABLE void startLocalGame(GameData &gd);
private: private:
+13 -1
View File
@@ -34,7 +34,19 @@ ApplicationWindow {
color: GlobalColors.accentColor color: GlobalColors.accentColor
width: appWindow.width width: appWindow.width
height: appWindow.height*0.13 height: appWindow.height*0.13
Behavior on height { NumberAnimation{} } Behavior on y { NumberAnimation{} }
function show() {
visible = true;
y = 0;
}
function hide() {
y = -height;
visible = false;
}
Rectangle { //Shadow Rectangle { //Shadow
y: parent.height y: parent.height
width: parent.width width: parent.width
@@ -41,7 +41,7 @@ Rectangle {
} }
function setupToolBar() { function setupToolBar() {
toolbar.visible = true; toolbar.show()
toolBarRightButton.myIconName = "accept"; toolBarRightButton.myIconName = "accept";
toolBarLeftButton.myIconName = "back"; toolBarLeftButton.myIconName = "back";
//send start signal to the session //send start signal to the session
@@ -49,6 +49,7 @@ Rectangle {
} }
function clearToolBar() { function clearToolBar() {
//disconnect signals from the buttons
toolBarRightButton.clicked.disconnect(CreateLocalGameViewImpl.startGame); toolBarRightButton.clicked.disconnect(CreateLocalGameViewImpl.startGame);
} }
@@ -10,7 +10,7 @@ Rectangle {
height: parent.height height: parent.height
function setupToolBar() { function setupToolBar() {
toolbar.visible = false; toolbar.hide();
} }
Component.onCompleted: { Component.onCompleted: {
+22
View File
@@ -64,6 +64,7 @@ GuiWrapper::~GuiWrapper()
void GuiWrapper::initGui(int speed) void GuiWrapper::initGui(int speed)
{ {
myW->signalInitGui(speed); myW->signalInitGui(speed);
qDebug("GuiWrapper::initGui");
} }
boost::shared_ptr<Session> GuiWrapper::getSession() boost::shared_ptr<Session> GuiWrapper::getSession()
@@ -78,47 +79,58 @@ void GuiWrapper::setSession(boost::shared_ptr<Session> /*session*/)
void GuiWrapper::refreshSet() const void GuiWrapper::refreshSet() const
{ {
myW->signalRefreshSet(); myW->signalRefreshSet();
qDebug("GuiWrapper::refreshSet");
} }
void GuiWrapper::refreshCash() const void GuiWrapper::refreshCash() const
{ {
myW->signalRefreshCash(); myW->signalRefreshCash();
qDebug("GuiWrapper::refreshCash");
} }
void GuiWrapper::refreshAction(int playerID, int playerAction) const void GuiWrapper::refreshAction(int playerID, int playerAction) const
{ {
myW->signalRefreshAction(playerID, playerAction); myW->signalRefreshAction(playerID, playerAction);
qDebug("GuiWrapper::refreshAction");
} }
void GuiWrapper::refreshChangePlayer() const void GuiWrapper::refreshChangePlayer() const
{ {
myW->signalRefreshChangePlayer(); myW->signalRefreshChangePlayer();
qDebug("GuiWrapper::refreshChangePlayer");
} }
void GuiWrapper::refreshAll() const void GuiWrapper::refreshAll() const
{ {
myW->signalRefreshAll(); myW->signalRefreshAll();
qDebug("GuiWrapper::refreshAll");
} }
void GuiWrapper::refreshPot() const void GuiWrapper::refreshPot() const
{ {
myW->signalRefreshPot(); myW->signalRefreshPot();
qDebug("GuiWrapper::refreshPot");
} }
void GuiWrapper::refreshGroupbox(int playerID, int status) const void GuiWrapper::refreshGroupbox(int playerID, int status) const
{ {
myW->signalRefreshGroupbox(playerID, status); myW->signalRefreshGroupbox(playerID, status);
qDebug("GuiWrapper::refreshGroupbox");
} }
void GuiWrapper::refreshPlayerName() const void GuiWrapper::refreshPlayerName() const
{ {
myW->signalRefreshPlayerName(); myW->signalRefreshPlayerName();
qDebug("GuiWrapper::refreshPlayerName");
} }
void GuiWrapper::refreshButton() const void GuiWrapper::refreshButton() const
{ {
myW->signalRefreshButton(); myW->signalRefreshButton();
qDebug("GuiWrapper::refreshButton");
} }
void GuiWrapper::refreshGameLabels(GameState state) const void GuiWrapper::refreshGameLabels(GameState state) const
{ {
myW->signalRefreshGameLabels(state); myW->signalRefreshGameLabels(state);
qDebug("GuiWrapper::refreshGameLabels");
} }
void GuiWrapper::setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const void GuiWrapper::setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const
{ {
myW->signalSetPlayerAvatar(myUniqueID, QString::fromUtf8(myAvatar.c_str())); myW->signalSetPlayerAvatar(myUniqueID, QString::fromUtf8(myAvatar.c_str()));
qDebug("GuiWrapper::setPlayerAvatar");
} }
@@ -126,47 +138,57 @@ void GuiWrapper::waitForGuiUpdateDone() const
{ {
myW->signalGuiUpdateDone(); myW->signalGuiUpdateDone();
myW->waitForGuiUpdateDone(); myW->waitForGuiUpdateDone();
qDebug("GuiWrapper::waitForGuiUpdateDone");
} }
void GuiWrapper::dealBeRoCards(int myBeRoID) void GuiWrapper::dealBeRoCards(int myBeRoID)
{ {
myW->signalDealBeRoCards(myBeRoID); myW->signalDealBeRoCards(myBeRoID);
qDebug("GuiWrapper::dealBeRoCards");
} }
void GuiWrapper::dealHoleCards() void GuiWrapper::dealHoleCards()
{ {
myW->signalDealHoleCards(); myW->signalDealHoleCards();
qDebug("GuiWrapper::dealHoleCards");
} }
void GuiWrapper::dealFlopCards() void GuiWrapper::dealFlopCards()
{ {
myW->signalDealFlopCards0(); myW->signalDealFlopCards0();
qDebug("GuiWrapper::dealFlopCard");
} }
void GuiWrapper::dealTurnCard() void GuiWrapper::dealTurnCard()
{ {
myW->signalDealTurnCards0(); myW->signalDealTurnCards0();
qDebug("GuiWrapper::dealTurnCard");
} }
void GuiWrapper::dealRiverCard() void GuiWrapper::dealRiverCard()
{ {
myW->signalDealRiverCards0(); myW->signalDealRiverCards0();
qDebug("GuiWrapper::dealRiverCard");
} }
void GuiWrapper::nextPlayerAnimation() void GuiWrapper::nextPlayerAnimation()
{ {
myW->signalNextPlayerAnimation(); myW->signalNextPlayerAnimation();
qDebug("GuiWrapper::nextPlayerAnimation");
} }
void GuiWrapper::beRoAnimation2(int myBeRoID) void GuiWrapper::beRoAnimation2(int myBeRoID)
{ {
myW->signalBeRoAnimation2(myBeRoID); myW->signalBeRoAnimation2(myBeRoID);
qDebug("GuiWrapper::beRoAnimantion2");
} }
void GuiWrapper::preflopAnimation1() void GuiWrapper::preflopAnimation1()
{ {
myW->signalPreflopAnimation1(); myW->signalPreflopAnimation1();
qDebug("GuiWrapper::preflopAnimation1");
} }
void GuiWrapper::preflopAnimation2() void GuiWrapper::preflopAnimation2()
{ {
myW->signalPreflopAnimation2(); myW->signalPreflopAnimation2();
qDebug("GuiWrapper::preFlopAnimation2");
} }
void GuiWrapper::flopAnimation1() void GuiWrapper::flopAnimation1()