more intuitive tapping behaviour
This commit is contained in:
parent
ae82996c0e
commit
9e044ffad0
5 changed files with 23 additions and 12 deletions
|
@ -144,7 +144,7 @@ void Game::initSayMenu()
|
|||
|
||||
Player *Game::addPlayer(int playerId, const QString &playerName, QPointF base, bool local)
|
||||
{
|
||||
Player *newPlayer = new Player(playerName, playerId, base, local, db, client, scene);
|
||||
Player *newPlayer = new Player(playerName, playerId, base, local, db, client, scene, this);
|
||||
|
||||
connect(newPlayer, SIGNAL(hoverCard(QString)), this, SIGNAL(hoverCard(QString)));
|
||||
connect(newPlayer, SIGNAL(sigShowCardMenu(QPoint)), this, SLOT(showCardMenu(QPoint)));
|
||||
|
@ -346,7 +346,8 @@ void Game::actTap()
|
|||
QListIterator<QGraphicsItem *> i(scene->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *temp = (CardItem *) i.next();
|
||||
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "tapped", "1");
|
||||
if (!temp->getTapped())
|
||||
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "tapped", "1");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,7 +356,8 @@ void Game::actUntap()
|
|||
QListIterator<QGraphicsItem *> i(scene->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *temp = (CardItem *) i.next();
|
||||
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "tapped", "0");
|
||||
if (temp->getTapped())
|
||||
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "tapped", "0");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ private slots:
|
|||
void actEditMessages();
|
||||
|
||||
void showCardMenu(QPoint p);
|
||||
void actTap();
|
||||
void actUntap();
|
||||
void actDoesntUntap();
|
||||
void actFlip();
|
||||
void actAddCounter();
|
||||
|
@ -54,6 +52,9 @@ private slots:
|
|||
void gameEvent(const ServerEventData &msg);
|
||||
void playerListReceived(QList<ServerPlayer *> playerList);
|
||||
void readyStart();
|
||||
public slots:
|
||||
void actTap();
|
||||
void actUntap();
|
||||
signals:
|
||||
void submitDecklist();
|
||||
void hoverCard(QString name);
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
#include "playerarea.h"
|
||||
#include "counter.h"
|
||||
#include "zoneviewzone.h"
|
||||
#include "game.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QMenu>
|
||||
|
||||
Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene)
|
||||
: QObject(), defaultNumberTopCards(3), name(_name), id(_id), base(_base), local(_local), db(_db), client(_client)
|
||||
Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene, Game *_parent)
|
||||
: QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), base(_base), local(_local), db(_db), client(_client)
|
||||
{
|
||||
area = new PlayerArea(this);
|
||||
area->setPos(_base);
|
||||
|
|
|
@ -12,6 +12,7 @@ class QMenu;
|
|||
class QAction;
|
||||
class PlayerArea;
|
||||
class ZoneViewZone;
|
||||
class Game;
|
||||
|
||||
class Player : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -57,7 +58,7 @@ public:
|
|||
PlayerArea *area;
|
||||
Client *client;
|
||||
void addZone(CardZone *z);
|
||||
Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene);
|
||||
Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene, Game *_parent);
|
||||
~Player();
|
||||
QMenu *getPlayerMenu() const { return playerMenu; }
|
||||
int getId() const { return id; }
|
||||
|
|
|
@ -55,9 +55,15 @@ void TableZone::reorganizeCards()
|
|||
|
||||
void TableZone::toggleTapped()
|
||||
{
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *temp = (CardItem *) i.next();
|
||||
setCardAttr(temp->getId(), "tapped", temp->getTapped() ? "0" : "1");
|
||||
QList<QGraphicsItem *> selectedItems = scene()->selectedItems();
|
||||
bool tapAll = false;
|
||||
for (int i = 0; i < selectedItems.size(); i++)
|
||||
if (!qgraphicsitem_cast<CardItem *>(selectedItems[i])->getTapped()) {
|
||||
tapAll = true;
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < selectedItems.size(); i++) {
|
||||
CardItem *temp = qgraphicsitem_cast<CardItem *>(selectedItems[i]);
|
||||
setCardAttr(temp->getId(), "tapped", (!temp->getTapped() || tapAll) ? "1" : "0");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue