diff options
Diffstat (limited to 'quacker/macondo.cpp')
-rw-r--r-- | quacker/macondo.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/quacker/macondo.cpp b/quacker/macondo.cpp index 8c53beb..c089b42 100644 --- a/quacker/macondo.cpp +++ b/quacker/macondo.cpp @@ -1,33 +1,49 @@ #include "macondo.h" #include "macondobackend.h" +#include "movebox.h" #include "quacker.h" #include <QGridLayout> #include <QPushButton> Macondo::Macondo(Quackle::Game *game) : QWidget() { + m_game = game; QGridLayout *layout = new QGridLayout(this); + m_moveBox = new MoveBox; m_simulateButton = new QPushButton(tr("Simulate")); - layout->addWidget(m_simulateButton, 0, 0); layout->setAlignment(Qt::AlignTop); + layout->addWidget(m_simulateButton, 0, 0); + layout->addWidget(m_moveBox, 1, 0); const char *home = getenv("HOME"); // TODO: configurable path std::string execPath = home ? home : "/"; execPath += "/apps/macondo/macondo"; - MacondoBackend::InitOptions initOptions(execPath); - m_backend = new MacondoBackend(game, initOptions); + initOptions = std::make_unique<MacondoInitOptions>(execPath); + m_backend = new MacondoBackend(game, *initOptions); connect(m_simulateButton, SIGNAL(clicked()), this, SLOT(simulate())); - connect(m_backend, SIGNAL(gotSimMoves(const std::vector<Quackle::Move> &)), this, SLOT(gotSimMoves(const std::vector<Quackle::Move> &))); + connect(m_backend, SIGNAL(gotSimMoves(const Quackle::MoveList &)), this, SLOT(gotSimMoves(const Quackle::MoveList &))); } +Macondo::~Macondo() {} + void Macondo::simulate() { - MacondoBackend::SimulateOptions options; + MacondoSimulateOptions options; m_backend->simulate(options); + m_moveBox->positionChanged(&m_game->currentPosition()); +} + + +void Macondo::setGame(Quackle::Game *game) { + delete m_backend; + m_backend = new MacondoBackend(game, *initOptions); + m_game = game; } -void Macondo::gotSimMoves(const std::vector<Quackle::Move> &moves) { - printf("got %zu moves\n",moves.size()); +void Macondo::gotSimMoves(const Quackle::MoveList &moves) { + m_moveBox->movesChanged(&moves); + /*printf("got %zu moves\n",moves.size()); for (const Quackle::Move &move: moves) { std::cout << move << std::endl; } + */ } |