summaryrefslogtreecommitdiff
path: root/quacker/quacker.cpp
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-08-15 20:53:13 -0400
committerpommicket <pommicket@gmail.com>2025-08-15 20:53:13 -0400
commitbf75ca2b4ee5c00d53f7807d9feee23af281c9f6 (patch)
treeb8f6ac83da7c14ec2b5e625014e7709c48d9de92 /quacker/quacker.cpp
parent0c53cb08d8032687887802f1352c6409326e5d6a (diff)
Solving, but something's broken
Diffstat (limited to 'quacker/quacker.cpp')
-rw-r--r--quacker/quacker.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp
index b54e364..3d8d8d4 100644
--- a/quacker/quacker.cpp
+++ b/quacker/quacker.cpp
@@ -1052,15 +1052,19 @@ void TopLevel::ensureUpToDateSimulatorMoveList()
void TopLevel::simulate(bool startSimulation)
{
m_simulateAction->setChecked(startSimulation);
+
+ if (m_macondo->isRunning() && !startSimulation) {
+ // stop Macondo
+ m_macondo->stop();
+ m_simulationTimer->stop();
+ return;
+ }
// it's not so useful to have sim control show/hide
// like this
//m_simulatorWidget->setVisible(startSimulation);
if (m_macondo->useForSimulation()) {
- if (startSimulation)
- m_macondo->simulate();
- else
- m_macondo->stop();
+ m_macondo->simulate();
}
if (startSimulation)
{
@@ -1076,6 +1080,15 @@ void TopLevel::simulateToggled(bool startSimulation)
if (!m_game->hasPositions())
return;
+ if (startSimulation) {
+ // this function is called for the Macondo solver as well,
+ // so make sure user can stop solver through button in top bar.
+ m_simulateAction->setEnabled(true);
+ } else {
+ // restore previous enabledness* of Simulate action
+ m_simulateAction->setEnabled(!m_game->currentPosition().moves().empty());
+ }
+
simulate(startSimulation);
if (startSimulation)
@@ -1254,8 +1267,9 @@ void TopLevel::incrementSimulation()
if (!m_simulateAction->isChecked())
return;
- if (m_macondo->useForSimulation()) {
+ if (m_macondo->isRunning()) {
if (m_macondo->anyUpdates()) {
+ printf("aaa update\n");
updateMoveViews();
updateSimViews();
}
@@ -2026,6 +2040,8 @@ void TopLevel::createWidgets()
m_macondo = new Macondo(m_game);
plugIntoMatrix(m_macondo);
plugIntoPositionMatrix(m_macondo);
+ connect(m_macondo, SIGNAL(runningSolver()), this, SLOT(simulate()));
+ connect(m_macondo, SIGNAL(stoppedSolver()), this, SLOT(stopSimulation()));
m_tabWidget = new QTabWidget;
m_tabWidget->addTab(m_history, tr("Histor&y"));