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) void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) { if (isUnderMouse()) {
if (event->button() == Qt::LeftButton && isUnderMouse()) {
Command_IncCounter cmd; Command_IncCounter cmd;
cmd.set_counter_id(id); cmd.set_counter_id(id);
cmd.set_delta(1); cmd.set_delta(1);
player->sendGameCommand(cmd); player->sendGameCommand(cmd);
event->accept(); event->accept();
} else if (event->button() == Qt::RightButton) { } else if (event->button() == Qt::RightButton && isUnderMouse()) {
Command_IncCounter cmd; Command_IncCounter cmd;
cmd.set_counter_id(id); cmd.set_counter_id(id);
cmd.set_delta(-1); cmd.set_delta(-1);
player->sendGameCommand(cmd); player->sendGameCommand(cmd);
event->accept(); event->accept();
} else if (event->button() == Qt::MidButton) { } else if (event->button() == Qt::MidButton && isUnderMouse()) {
if (menu) if (menu)
menu->exec(event->screenPos()); menu->exec(event->screenPos());
event->accept(); event->accept();
} else }
}else
event->ignore(); event->ignore();
} }