diff options
Diffstat (limited to 'quacker/macondo.cpp')
-rw-r--r-- | quacker/macondo.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/quacker/macondo.cpp b/quacker/macondo.cpp index 55d5deb..3b941e1 100644 --- a/quacker/macondo.cpp +++ b/quacker/macondo.cpp @@ -1,26 +1,28 @@ +/* +TODO: +- configurable execPath +- set Macondo lexicon based on game +*/ + #include "macondo.h" #include "macondobackend.h" -#include "movebox.h" -#include "quacker.h" #include <QGridLayout> #include <QPushButton> #include <QCheckBox> -Macondo::Macondo(Quackle::Game *game, MoveBox *moveBox) : View() { +Macondo::Macondo(Quackle::Game *game) : View() { m_game = game; - m_moveBox = moveBox; QGridLayout *layout = new QGridLayout(this); m_useMacondo = new QCheckBox(tr("Use Macondo for 'Simulate'")); layout->setAlignment(Qt::AlignTop); layout->addWidget(m_useMacondo, 0, 0); const char *home = getenv("HOME"); - // TODO: configurable path std::string execPath = home ? home : "/"; execPath += "/apps/macondo/macondo"; initOptions = std::make_unique<MacondoInitOptions>(execPath); m_backend = new MacondoBackend(game, *initOptions); - connect(m_backend, SIGNAL(gotSimMoves(const Quackle::MoveList *)), this, SIGNAL(newMoves(const Quackle::MoveList *))); + connect(m_backend, SIGNAL(gotSimMoves(const Quackle::MoveList &)), this, SLOT(gotSimMoves(const Quackle::MoveList &))); } Macondo::~Macondo() { @@ -28,16 +30,14 @@ Macondo::~Macondo() { } void Macondo::simulate() { - if (m_backend->isRunning()) { - // stop analysis + if (m_backend->isRunning()) stop(); - return; - } + clearMoves(); MacondoSimulateOptions options; m_backend->simulate(options); } -void Macondo::setGame(Quackle::Game *game) { +void Macondo::gameChanged(Quackle::Game *game) { delete m_backend; m_backend = new MacondoBackend(game, *initOptions); m_game = game; @@ -45,8 +45,14 @@ void Macondo::setGame(Quackle::Game *game) { void Macondo::stop() { m_backend->stop(); + m_anyUpdates = false; } bool Macondo::useForSimulation() const { return m_useMacondo->isChecked(); } + +void Macondo::gotSimMoves(const Quackle::MoveList &moves) { + m_moves = moves; + m_anyUpdates = true; +} |