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 *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(hoverCard(QString)), this, SIGNAL(hoverCard(QString)));
|
||||||
connect(newPlayer, SIGNAL(sigShowCardMenu(QPoint)), this, SLOT(showCardMenu(QPoint)));
|
connect(newPlayer, SIGNAL(sigShowCardMenu(QPoint)), this, SLOT(showCardMenu(QPoint)));
|
||||||
|
@ -346,7 +346,8 @@ void Game::actTap()
|
||||||
QListIterator<QGraphicsItem *> i(scene->selectedItems());
|
QListIterator<QGraphicsItem *> i(scene->selectedItems());
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
CardItem *temp = (CardItem *) i.next();
|
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());
|
QListIterator<QGraphicsItem *> i(scene->selectedItems());
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
CardItem *temp = (CardItem *) i.next();
|
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 actEditMessages();
|
||||||
|
|
||||||
void showCardMenu(QPoint p);
|
void showCardMenu(QPoint p);
|
||||||
void actTap();
|
|
||||||
void actUntap();
|
|
||||||
void actDoesntUntap();
|
void actDoesntUntap();
|
||||||
void actFlip();
|
void actFlip();
|
||||||
void actAddCounter();
|
void actAddCounter();
|
||||||
|
@ -54,6 +52,9 @@ private slots:
|
||||||
void gameEvent(const ServerEventData &msg);
|
void gameEvent(const ServerEventData &msg);
|
||||||
void playerListReceived(QList<ServerPlayer *> playerList);
|
void playerListReceived(QList<ServerPlayer *> playerList);
|
||||||
void readyStart();
|
void readyStart();
|
||||||
|
public slots:
|
||||||
|
void actTap();
|
||||||
|
void actUntap();
|
||||||
signals:
|
signals:
|
||||||
void submitDecklist();
|
void submitDecklist();
|
||||||
void hoverCard(QString name);
|
void hoverCard(QString name);
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
#include "playerarea.h"
|
#include "playerarea.h"
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
|
#include "game.h"
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene)
|
Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene, Game *_parent)
|
||||||
: QObject(), defaultNumberTopCards(3), name(_name), id(_id), base(_base), local(_local), db(_db), client(_client)
|
: QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), base(_base), local(_local), db(_db), client(_client)
|
||||||
{
|
{
|
||||||
area = new PlayerArea(this);
|
area = new PlayerArea(this);
|
||||||
area->setPos(_base);
|
area->setPos(_base);
|
||||||
|
|
|
@ -12,6 +12,7 @@ class QMenu;
|
||||||
class QAction;
|
class QAction;
|
||||||
class PlayerArea;
|
class PlayerArea;
|
||||||
class ZoneViewZone;
|
class ZoneViewZone;
|
||||||
|
class Game;
|
||||||
|
|
||||||
class Player : public QObject {
|
class Player : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -57,7 +58,7 @@ public:
|
||||||
PlayerArea *area;
|
PlayerArea *area;
|
||||||
Client *client;
|
Client *client;
|
||||||
void addZone(CardZone *z);
|
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();
|
~Player();
|
||||||
QMenu *getPlayerMenu() const { return playerMenu; }
|
QMenu *getPlayerMenu() const { return playerMenu; }
|
||||||
int getId() const { return id; }
|
int getId() const { return id; }
|
||||||
|
|
|
@ -55,9 +55,15 @@ void TableZone::reorganizeCards()
|
||||||
|
|
||||||
void TableZone::toggleTapped()
|
void TableZone::toggleTapped()
|
||||||
{
|
{
|
||||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
QList<QGraphicsItem *> selectedItems = scene()->selectedItems();
|
||||||
while (i.hasNext()) {
|
bool tapAll = false;
|
||||||
CardItem *temp = (CardItem *) i.next();
|
for (int i = 0; i < selectedItems.size(); i++)
|
||||||
setCardAttr(temp->getId(), "tapped", temp->getTapped() ? "0" : "1");
|
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