game is almost playable again

This commit is contained in:
Max-Wilhelm Bruker 2009-11-26 18:52:53 +01:00
parent 0d4717f40b
commit e796af2b89
34 changed files with 309 additions and 320 deletions

View file

@ -1,6 +1,7 @@
#include "counter.h"
#include "player.h"
#include "client.h"
#include "protocol_items.h"
#include <QtGui>
Counter::Counter(Player *_player, int _id, const QString &_name, QColor _color, int _radius, int _value, QGraphicsItem *parent)
@ -77,10 +78,10 @@ void Counter::setValue(int _value)
void Counter::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
player->client->incCounter(id, 1);
player->sendGameCommand(new Command_IncCounter(-1, id, 1));
event->accept();
} else if (event->button() == Qt::RightButton) {
player->client->incCounter(id, -1);
player->sendGameCommand(new Command_IncCounter(-1, id, -1));
event->accept();
} else if (event->button() == Qt::MidButton) {
if (menu)
@ -93,7 +94,7 @@ void Counter::mousePressEvent(QGraphicsSceneMouseEvent *event)
void Counter::incrementCounter()
{
int delta = static_cast<QAction *>(sender())->data().toInt();
player->client->incCounter(id, delta);
player->sendGameCommand(new Command_IncCounter(-1, id, delta));
}
void Counter::setCounter()
@ -101,5 +102,5 @@ void Counter::setCounter()
bool ok;
int newValue = QInputDialog::getInteger(0, tr("Set counter"), tr("New value for counter '%1':").arg(name), value, 0, 2000000000, 1, &ok);
if (ok)
player->client->setCounter(id, newValue);
player->sendGameCommand(new Command_SetCounter(-1, id, newValue));
}