From a873a4efa4e795bedf5f116369f7b725f2f93378 Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Tue, 31 Mar 2015 23:07:24 +0200 Subject: [PATCH 1/2] Fixed accidental +/- of counters Previously if you middle click on a counter (life/mana) and then click away, depending on the button clicked, the counter would +/-. I have added a fix to make sure the mouse is over the counter to change it. --- cockatrice/src/abstractcounter.cpp | 36 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/cockatrice/src/abstractcounter.cpp b/cockatrice/src/abstractcounter.cpp index b9debae4..1d05aaba 100644 --- a/cockatrice/src/abstractcounter.cpp +++ b/cockatrice/src/abstractcounter.cpp @@ -88,23 +88,25 @@ void AbstractCounter::setValue(int _value) void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if (event->button() == Qt::LeftButton) { - Command_IncCounter cmd; - cmd.set_counter_id(id); - cmd.set_delta(1); - player->sendGameCommand(cmd); - event->accept(); - } else if (event->button() == Qt::RightButton) { - Command_IncCounter cmd; - cmd.set_counter_id(id); - cmd.set_delta(-1); - player->sendGameCommand(cmd); - event->accept(); - } else if (event->button() == Qt::MidButton) { - if (menu) - menu->exec(event->screenPos()); - event->accept(); - } else + if (isUnderMouse()) { + if (event->button() == Qt::LeftButton && isUnderMouse()) { + Command_IncCounter cmd; + cmd.set_counter_id(id); + cmd.set_delta(1); + player->sendGameCommand(cmd); + event->accept(); + } else if (event->button() == Qt::RightButton && isUnderMouse()) { + Command_IncCounter cmd; + cmd.set_counter_id(id); + cmd.set_delta(-1); + player->sendGameCommand(cmd); + event->accept(); + } else if (event->button() == Qt::MidButton && isUnderMouse()) { + if (menu) + menu->exec(event->screenPos()); + event->accept(); + } + }else event->ignore(); } From a0be18ca09cf3acee6ef1d1a85c730f1edc495be Mon Sep 17 00:00:00 2001 From: Matt Lowe Date: Wed, 1 Apr 2015 18:33:02 +0200 Subject: [PATCH 2/2] Removed dev code --- cockatrice/src/abstractcounter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/abstractcounter.cpp b/cockatrice/src/abstractcounter.cpp index 1d05aaba..1e24ca4e 100644 --- a/cockatrice/src/abstractcounter.cpp +++ b/cockatrice/src/abstractcounter.cpp @@ -89,19 +89,19 @@ void AbstractCounter::setValue(int _value) void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (isUnderMouse()) { - if (event->button() == Qt::LeftButton && isUnderMouse()) { + if (event->button() == Qt::LeftButton) { Command_IncCounter cmd; cmd.set_counter_id(id); cmd.set_delta(1); player->sendGameCommand(cmd); event->accept(); - } else if (event->button() == Qt::RightButton && isUnderMouse()) { + } else if (event->button() == Qt::RightButton) { Command_IncCounter cmd; cmd.set_counter_id(id); cmd.set_delta(-1); player->sendGameCommand(cmd); event->accept(); - } else if (event->button() == Qt::MidButton && isUnderMouse()) { + } else if (event->button() == Qt::MidButton) { if (menu) menu->exec(event->screenPos()); event->accept();