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.
This commit is contained in:
Matt Lowe 2015-03-31 23:07:24 +02:00
parent 11d1d22da5
commit a873a4efa4

View file

@ -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();
}