diff --git a/src/gui/qml/cpp/createlocalgameviewimpl.cpp b/src/gui/qml/cpp/createlocalgameviewimpl.cpp index 2cc125d9..f2c796fe 100644 --- a/src/gui/qml/cpp/createlocalgameviewimpl.cpp +++ b/src/gui/qml/cpp/createlocalgameviewimpl.cpp @@ -1,10 +1,12 @@ #include "createlocalgameviewimpl.h" +#include "startviewimpl.h" #include "configfile.h" #include "mylistviewitemdata.h" +#include "gamedata.h" #include -CreateLocalGameViewImpl::CreateLocalGameViewImpl(QObject *parent, QQmlApplicationEngine *e, boost::shared_ptr c) - : QObject(parent) ,myQmlEngine(e), myConfig(c) +CreateLocalGameViewImpl::CreateLocalGameViewImpl(QObject *parent, QQmlApplicationEngine *e, boost::shared_ptr c, StartViewImpl *s ) + : QObject(parent) ,myQmlEngine(e), myConfig(c), myStartView(s) { //Build the listView data structure MyListViewItemData *item = NULL; @@ -104,11 +106,51 @@ void CreateLocalGameViewImpl::readConfigValues() listItem("selector_BlindsRaiseMode")->setMyAfterMBAlwaysRaiseValue(QString::number(myConfig->readConfigInt("AfterMBAlwaysRaiseValue"))); listItem("selector_BlindsRaiseMode")->setMyAfterMBStayAtLastBlind(QString::number(myConfig->readConfigInt("AfterMBStayAtLastBlind"))); listItem("comboBox_GameSpeed")->setMyValue(QString::number(myConfig->readConfigInt("GameSpeed"))); - } void CreateLocalGameViewImpl::startGame() { qDebug() << "Start Game from CreateLocalGameViewImpl:"; 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 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); } diff --git a/src/gui/qml/cpp/createlocalgameviewimpl.h b/src/gui/qml/cpp/createlocalgameviewimpl.h index dd30ddd3..ea78c49b 100644 --- a/src/gui/qml/cpp/createlocalgameviewimpl.h +++ b/src/gui/qml/cpp/createlocalgameviewimpl.h @@ -7,6 +7,7 @@ class ConfigFile; class MyListViewItemData; +class StartViewImpl; class CreateLocalGameViewImpl : public QObject { @@ -15,7 +16,7 @@ public: Q_INVOKABLE void readConfigValues(); Q_INVOKABLE void startGame(); - CreateLocalGameViewImpl(QObject *parent, QQmlApplicationEngine *engine, boost::shared_ptr); + CreateLocalGameViewImpl(QObject *parent, QQmlApplicationEngine *engine, boost::shared_ptr, StartViewImpl*); ~CreateLocalGameViewImpl(); MyListViewItemData* listItem(QString id); @@ -27,6 +28,7 @@ private: QQmlApplicationEngine *myQmlEngine; QList myListData; boost::shared_ptr myConfig; + StartViewImpl *myStartView; }; #endif // CREATELOCALGAMEVIEWIMPL_H diff --git a/src/gui/qml/cpp/qmlwrapper.cpp b/src/gui/qml/cpp/qmlwrapper.cpp index cfcf2c18..5347e5dd 100644 --- a/src/gui/qml/cpp/qmlwrapper.cpp +++ b/src/gui/qml/cpp/qmlwrapper.cpp @@ -18,7 +18,7 @@ QmlWrapper::QmlWrapper(boost::shared_ptr c) //TODO create Session and Log here myStartViewImpl = new StartViewImpl(this); - myCreateLocalGameViewImpl = new CreateLocalGameViewImpl(this, myQmlEngine, myConfig); + myCreateLocalGameViewImpl = new CreateLocalGameViewImpl(this, myQmlEngine, myConfig, myStartViewImpl); //Add c++ content to QML here myQmlEngine->rootContext()->setContextProperty("Config", myQmlConfig); diff --git a/src/gui/qml/cpp/startviewimpl.cpp b/src/gui/qml/cpp/startviewimpl.cpp index fe0f02aa..e73db08e 100644 --- a/src/gui/qml/cpp/startviewimpl.cpp +++ b/src/gui/qml/cpp/startviewimpl.cpp @@ -1,5 +1,6 @@ #include "startviewimpl.h" #include "mylistviewitemdata.h" +#include "gamedata.h" 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(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); } diff --git a/src/gui/qml/cpp/startviewimpl.h b/src/gui/qml/cpp/startviewimpl.h index d92799ed..da57d602 100644 --- a/src/gui/qml/cpp/startviewimpl.h +++ b/src/gui/qml/cpp/startviewimpl.h @@ -3,6 +3,7 @@ #include class CreateLocalGameViewImpl; +class GameData; class StartViewImpl : public QObject { @@ -14,7 +15,7 @@ public: signals: public slots: - Q_INVOKABLE void startLocalGame(); + Q_INVOKABLE void startLocalGame(GameData &gd); private: diff --git a/src/gui/qml/main.qml b/src/gui/qml/main.qml index a1c737f6..1b89b4f6 100644 --- a/src/gui/qml/main.qml +++ b/src/gui/qml/main.qml @@ -34,7 +34,19 @@ ApplicationWindow { color: GlobalColors.accentColor width: appWindow.width 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 y: parent.height width: parent.width diff --git a/src/gui/qml/views/createlocalgameview/CreateLocalGameView.qml b/src/gui/qml/views/createlocalgameview/CreateLocalGameView.qml index 297f010f..a333c2af 100644 --- a/src/gui/qml/views/createlocalgameview/CreateLocalGameView.qml +++ b/src/gui/qml/views/createlocalgameview/CreateLocalGameView.qml @@ -41,7 +41,7 @@ Rectangle { } function setupToolBar() { - toolbar.visible = true; + toolbar.show() toolBarRightButton.myIconName = "accept"; toolBarLeftButton.myIconName = "back"; //send start signal to the session @@ -49,6 +49,7 @@ Rectangle { } function clearToolBar() { + //disconnect signals from the buttons toolBarRightButton.clicked.disconnect(CreateLocalGameViewImpl.startGame); } diff --git a/src/gui/qml/views/gametableview/GameTableView.qml b/src/gui/qml/views/gametableview/GameTableView.qml index c2c59373..81f5f705 100644 --- a/src/gui/qml/views/gametableview/GameTableView.qml +++ b/src/gui/qml/views/gametableview/GameTableView.qml @@ -10,7 +10,7 @@ Rectangle { height: parent.height function setupToolBar() { - toolbar.visible = false; + toolbar.hide(); } Component.onCompleted: { diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index aa12deec..153d4d5c 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -64,6 +64,7 @@ GuiWrapper::~GuiWrapper() void GuiWrapper::initGui(int speed) { myW->signalInitGui(speed); + qDebug("GuiWrapper::initGui"); } boost::shared_ptr GuiWrapper::getSession() @@ -78,47 +79,58 @@ void GuiWrapper::setSession(boost::shared_ptr /*session*/) void GuiWrapper::refreshSet() const { myW->signalRefreshSet(); + qDebug("GuiWrapper::refreshSet"); } void GuiWrapper::refreshCash() const { myW->signalRefreshCash(); + qDebug("GuiWrapper::refreshCash"); } void GuiWrapper::refreshAction(int playerID, int playerAction) const { myW->signalRefreshAction(playerID, playerAction); + qDebug("GuiWrapper::refreshAction"); } void GuiWrapper::refreshChangePlayer() const { myW->signalRefreshChangePlayer(); + qDebug("GuiWrapper::refreshChangePlayer"); } void GuiWrapper::refreshAll() const { myW->signalRefreshAll(); + qDebug("GuiWrapper::refreshAll"); } void GuiWrapper::refreshPot() const { myW->signalRefreshPot(); + qDebug("GuiWrapper::refreshPot"); } void GuiWrapper::refreshGroupbox(int playerID, int status) const { myW->signalRefreshGroupbox(playerID, status); + qDebug("GuiWrapper::refreshGroupbox"); } void GuiWrapper::refreshPlayerName() const { myW->signalRefreshPlayerName(); + qDebug("GuiWrapper::refreshPlayerName"); } void GuiWrapper::refreshButton() const { myW->signalRefreshButton(); + qDebug("GuiWrapper::refreshButton"); } void GuiWrapper::refreshGameLabels(GameState state) const { myW->signalRefreshGameLabels(state); + qDebug("GuiWrapper::refreshGameLabels"); } void GuiWrapper::setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const { myW->signalSetPlayerAvatar(myUniqueID, QString::fromUtf8(myAvatar.c_str())); + qDebug("GuiWrapper::setPlayerAvatar"); } @@ -126,47 +138,57 @@ void GuiWrapper::waitForGuiUpdateDone() const { myW->signalGuiUpdateDone(); myW->waitForGuiUpdateDone(); + qDebug("GuiWrapper::waitForGuiUpdateDone"); } void GuiWrapper::dealBeRoCards(int myBeRoID) { myW->signalDealBeRoCards(myBeRoID); + qDebug("GuiWrapper::dealBeRoCards"); } void GuiWrapper::dealHoleCards() { myW->signalDealHoleCards(); + qDebug("GuiWrapper::dealHoleCards"); } void GuiWrapper::dealFlopCards() { myW->signalDealFlopCards0(); + qDebug("GuiWrapper::dealFlopCard"); } void GuiWrapper::dealTurnCard() { myW->signalDealTurnCards0(); + qDebug("GuiWrapper::dealTurnCard"); } void GuiWrapper::dealRiverCard() { myW->signalDealRiverCards0(); + qDebug("GuiWrapper::dealRiverCard"); } void GuiWrapper::nextPlayerAnimation() { myW->signalNextPlayerAnimation(); + qDebug("GuiWrapper::nextPlayerAnimation"); } void GuiWrapper::beRoAnimation2(int myBeRoID) { myW->signalBeRoAnimation2(myBeRoID); + qDebug("GuiWrapper::beRoAnimantion2"); } void GuiWrapper::preflopAnimation1() { myW->signalPreflopAnimation1(); + qDebug("GuiWrapper::preflopAnimation1"); } void GuiWrapper::preflopAnimation2() { myW->signalPreflopAnimation2(); + qDebug("GuiWrapper::preFlopAnimation2"); } void GuiWrapper::flopAnimation1()