card menu re-added
This commit is contained in:
parent
bf92ef87da
commit
bda7ec2186
6 changed files with 178 additions and 318 deletions
|
@ -109,7 +109,7 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
|||
|
||||
void AbstractCardItem::setName(const QString &_name)
|
||||
{
|
||||
disconnect(info, 0, this, 0);
|
||||
disconnect(info, 0, this, 0);
|
||||
name = _name;
|
||||
info = db->getCard(name);
|
||||
connect(info, SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
|
||||
|
|
|
@ -1,204 +0,0 @@
|
|||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
#include <stdlib.h>
|
||||
#include "game.h"
|
||||
#include "client.h"
|
||||
#include "tablezone.h"
|
||||
#include "handzone.h"
|
||||
#include "carddatabase.h"
|
||||
#include "counter.h"
|
||||
#include "gamescene.h"
|
||||
#include "player.h"
|
||||
#include "arrowitem.h"
|
||||
#include "protocol_datastructures.h"
|
||||
|
||||
Game::Game(Client *_client, GameScene *_scene, QMenuBar *menuBar, QObject *parent)
|
||||
: QObject(parent), client(_client), scene(_scene), started(false), currentPhase(-1)
|
||||
{
|
||||
connect(client, SIGNAL(gameEvent(const ServerEventData &)), this, SLOT(gameEvent(const ServerEventData &)));
|
||||
|
||||
aTap = new QAction(this);
|
||||
aUntap = new QAction(this);
|
||||
aDoesntUntap = new QAction(this);
|
||||
aFlip = new QAction(this);
|
||||
aAddCounter = new QAction(this);
|
||||
aRemoveCounter = new QAction(this);
|
||||
aSetCounters = new QAction(this);
|
||||
connect(aSetCounters, SIGNAL(triggered()), this, SLOT(actSetCounters()));
|
||||
aMoveToTopLibrary = new QAction(this);
|
||||
aMoveToBottomLibrary = new QAction(this);
|
||||
aMoveToGraveyard = new QAction(this);
|
||||
aMoveToExile = new QAction(this);
|
||||
|
||||
cardMenu = menuBar->addMenu(QString());
|
||||
cardMenu->addAction(aTap);
|
||||
cardMenu->addAction(aUntap);
|
||||
cardMenu->addAction(aDoesntUntap);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aFlip);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aAddCounter);
|
||||
cardMenu->addAction(aRemoveCounter);
|
||||
cardMenu->addAction(aSetCounters);
|
||||
cardMenu->addSeparator();
|
||||
moveMenu = cardMenu->addMenu(QString());
|
||||
|
||||
moveMenu->addAction(aMoveToTopLibrary);
|
||||
moveMenu->addAction(aMoveToBottomLibrary);
|
||||
moveMenu->addAction(aMoveToGraveyard);
|
||||
moveMenu->addAction(aMoveToExile);
|
||||
|
||||
cardMenuHandlers.insert(aTap, &Game::actTap);
|
||||
cardMenuHandlers.insert(aUntap, &Game::actUntap);
|
||||
cardMenuHandlers.insert(aDoesntUntap, &Game::actDoesntUntap);
|
||||
cardMenuHandlers.insert(aFlip, &Game::actFlip);
|
||||
cardMenuHandlers.insert(aAddCounter, &Game::actAddCounter);
|
||||
cardMenuHandlers.insert(aRemoveCounter, &Game::actRemoveCounter);
|
||||
cardMenuHandlers.insert(aMoveToTopLibrary, &Game::actMoveToTopLibrary);
|
||||
cardMenuHandlers.insert(aMoveToBottomLibrary, &Game::actMoveToBottomLibrary);
|
||||
cardMenuHandlers.insert(aMoveToGraveyard, &Game::actMoveToGraveyard);
|
||||
cardMenuHandlers.insert(aMoveToExile, &Game::actMoveToExile);
|
||||
|
||||
QHashIterator<QAction *, CardMenuHandler> i(cardMenuHandlers);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
connect(i.key(), SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
}
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
qDebug("Game destructor");
|
||||
|
||||
QMapIterator<int, Player *> i(players);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
emit playerRemoved(i.value());
|
||||
delete i.value();
|
||||
}
|
||||
|
||||
delete gameMenu;
|
||||
delete cardMenu;
|
||||
}
|
||||
|
||||
void Game::retranslateUi()
|
||||
{
|
||||
cardMenu->setTitle(tr("C&ard"));
|
||||
aTap->setText(tr("&Tap"));
|
||||
aUntap->setText(tr("&Untap"));
|
||||
aDoesntUntap->setText(tr("Toggle &normal untapping"));
|
||||
aFlip->setText(tr("&Flip"));
|
||||
aAddCounter->setText(tr("&Add counter"));
|
||||
aRemoveCounter->setText(tr("&Remove counter"));
|
||||
aSetCounters->setText(tr("&Set counters..."));
|
||||
aMoveToTopLibrary->setText(tr("&top of library"));
|
||||
aMoveToBottomLibrary->setText(tr("&bottom of library"));
|
||||
aMoveToGraveyard->setText(tr("&graveyard"));
|
||||
aMoveToGraveyard->setShortcut(tr("Ctrl+Del"));
|
||||
aMoveToExile->setText(tr("&exile"));
|
||||
|
||||
moveMenu->setTitle(tr("&Move to"));
|
||||
|
||||
}
|
||||
|
||||
void Game::restartGameDialog()
|
||||
{
|
||||
// dlgStartGame->show();
|
||||
}
|
||||
|
||||
void Game::showCardMenu(QPoint p)
|
||||
{
|
||||
cardMenu->exec(p);
|
||||
}
|
||||
|
||||
void Game::cardMenuAction()
|
||||
{
|
||||
// Determine the appropriate handler function.
|
||||
CardMenuHandler handler = cardMenuHandlers.value(static_cast<QAction *>(sender()));
|
||||
|
||||
// The list of selected items is randomly shuffled.
|
||||
QList<QGraphicsItem *> sel = scene->selectedItems();
|
||||
while (!sel.isEmpty()) {
|
||||
unsigned int i = (unsigned int) (((double) sel.size()) * qrand() / (RAND_MAX + 1.0));
|
||||
CardItem *card = qgraphicsitem_cast<CardItem *>(sel.takeAt(i));
|
||||
// For each item, the handler function is called.
|
||||
(this->*handler)(card);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::actTap(CardItem *card)
|
||||
{
|
||||
// if (!card->getTapped())
|
||||
// client->setCardAttr(qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "tapped", "1");
|
||||
}
|
||||
|
||||
void Game::actUntap(CardItem *card)
|
||||
{
|
||||
// if (card->getTapped())
|
||||
// client->setCardAttr(qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "tapped", "0");
|
||||
}
|
||||
|
||||
void Game::actDoesntUntap(CardItem *card)
|
||||
{
|
||||
// client->setCardAttr(qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "doesnt_untap", QString::number(!card->getDoesntUntap()));
|
||||
}
|
||||
|
||||
void Game::actFlip(CardItem *card)
|
||||
{
|
||||
// QString zone = qgraphicsitem_cast<CardZone *>(card->parentItem())->getName();
|
||||
// client->moveCard(card->getId(), zone, zone, card->getGridPoint().x(), card->getGridPoint().y(), !card->getFaceDown());
|
||||
}
|
||||
|
||||
void Game::actAddCounter(CardItem *card)
|
||||
{
|
||||
// if (card->getCounters() < MAX_COUNTERS_ON_CARD)
|
||||
// client->setCardAttr(qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "counters", QString::number(card->getCounters() + 1));
|
||||
}
|
||||
|
||||
void Game::actRemoveCounter(CardItem *card)
|
||||
{
|
||||
// if (card->getCounters())
|
||||
// client->setCardAttr(qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "counters", QString::number(card->getCounters() - 1));
|
||||
}
|
||||
|
||||
void Game::actSetCounters()
|
||||
{
|
||||
bool ok;
|
||||
int number = QInputDialog::getInteger(0, tr("Set counters"), tr("Number:"), 0, 0, MAX_COUNTERS_ON_CARD, 1, &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
QListIterator<QGraphicsItem *> i(scene->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *temp = (CardItem *) i.next();
|
||||
// client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(number));
|
||||
}
|
||||
}
|
||||
|
||||
void Game::actMoveToTopLibrary(CardItem *card)
|
||||
{
|
||||
// CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||
// client->moveCard(card->getId(), startZone->getName(), "deck", 0, 0, false);
|
||||
}
|
||||
|
||||
void Game::actMoveToBottomLibrary(CardItem *card)
|
||||
{
|
||||
// CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||
// client->moveCard(card->getId(), startZone->getName(), "deck", -1, 0, false);
|
||||
}
|
||||
|
||||
void Game::actMoveToGraveyard(CardItem *card)
|
||||
{
|
||||
// CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||
// client->moveCard(card->getId(), startZone->getName(), "grave", 0, 0, false);
|
||||
}
|
||||
|
||||
void Game::actMoveToExile(CardItem *card)
|
||||
{
|
||||
// CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||
// client->moveCard(card->getId(), startZone->getName(), "rfg", 0, 0, false);
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include "client.h"
|
||||
|
||||
class GameScene;
|
||||
class Player;
|
||||
class CardDatabase;
|
||||
class CardItem;
|
||||
class QMenuBar;
|
||||
class CardZone;
|
||||
|
||||
class Game : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
static const int phaseCount = 11;
|
||||
|
||||
typedef void (Game::*CardMenuHandler)(CardItem *card);
|
||||
QHash<QAction *, CardMenuHandler> cardMenuHandlers;
|
||||
|
||||
QMenu *gameMenu, *cardMenu, *moveMenu;
|
||||
QAction *aTap, *aUntap, *aDoesntUntap, *aFlip, *aAddCounter, *aRemoveCounter, *aSetCounters,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile,
|
||||
*aNextPhase, *aNextTurn, *aRemoveLocalArrows;
|
||||
|
||||
Client *client;
|
||||
GameScene *scene;
|
||||
QStringList spectatorList;
|
||||
QMap<int, Player *> players;
|
||||
bool started;
|
||||
int currentPhase;
|
||||
|
||||
public slots:
|
||||
void activePlayerDrawCard();
|
||||
void activePlayerUntapAll();
|
||||
|
||||
void actNextPhase();
|
||||
void actNextTurn();
|
||||
void actRemoveLocalArrows();
|
||||
private slots:
|
||||
void cardMenuAction();
|
||||
|
||||
void showCardMenu(QPoint p);
|
||||
void actTap(CardItem *card);
|
||||
void actUntap(CardItem *card);
|
||||
void actDoesntUntap(CardItem *card);
|
||||
void actFlip(CardItem *card);
|
||||
void actAddCounter(CardItem *card);
|
||||
void actRemoveCounter(CardItem *card);
|
||||
void actSetCounters();
|
||||
void actMoveToTopLibrary(CardItem *card);
|
||||
void actMoveToBottomLibrary(CardItem *card);
|
||||
void actMoveToGraveyard(CardItem *card);
|
||||
void actMoveToExile(CardItem *card);
|
||||
|
||||
/* void gameEvent(const ServerEventData &msg);
|
||||
|
||||
void playerListReceived(QList<ServerPlayer> playerList);
|
||||
void cardListReceived(QList<ServerZoneCard> list);
|
||||
void zoneListReceived(QList<ServerZone> list);
|
||||
void counterListReceived(QList<ServerCounter> list);
|
||||
void arrowListReceived(QList<ServerArrow> list);
|
||||
*/
|
||||
signals:
|
||||
void submitDecklist();
|
||||
void hoverCard(QString name);
|
||||
void playerAdded(Player *player);
|
||||
void playerRemoved(Player *player);
|
||||
|
||||
// Log events
|
||||
void logPlayerListReceived(QStringList players);
|
||||
void logJoin(Player *player);
|
||||
void logLeave(Player *player);
|
||||
void logGameClosed();
|
||||
void logJoinSpectator(QString playerName);
|
||||
void logLeaveSpectator(QString playerName);
|
||||
void logReadyStart(Player *player);
|
||||
void logGameStart();
|
||||
void logSay(Player *player, QString text);
|
||||
void logShuffle(Player *player);
|
||||
void logRollDie(Player *player, int sides, int roll);
|
||||
void logDraw(Player *player, int number);
|
||||
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
||||
void logCreateToken(Player *player, QString cardName);
|
||||
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard);
|
||||
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
|
||||
void logSetTapped(Player *player, QString cardName, bool tapped);
|
||||
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
||||
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
|
||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
void logSetActivePlayer(Player *player);
|
||||
void setActivePhase(int phase);
|
||||
public:
|
||||
Game(Client *_client, GameScene *_scene, QMenuBar *menuBar, QObject *parent = 0);
|
||||
~Game();
|
||||
void retranslateUi();
|
||||
void restartGameDialog();
|
||||
void hoverCardEvent(CardItem *card);
|
||||
Player *getActiveLocalPlayer() const;
|
||||
const QMap<int, Player *> &getPlayers() const { return players; }
|
||||
void queryGameState();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -190,6 +190,55 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
|
|||
playerMenu->addSeparator();
|
||||
sayMenu = playerMenu->addMenu(QString());
|
||||
initSayMenu();
|
||||
|
||||
// Card menu
|
||||
aTap = new QAction(this);
|
||||
aUntap = new QAction(this);
|
||||
aDoesntUntap = new QAction(this);
|
||||
aFlip = new QAction(this);
|
||||
aAddCounter = new QAction(this);
|
||||
aRemoveCounter = new QAction(this);
|
||||
aSetCounters = new QAction(this);
|
||||
connect(aSetCounters, SIGNAL(triggered()), this, SLOT(actSetCounters()));
|
||||
aMoveToTopLibrary = new QAction(this);
|
||||
aMoveToBottomLibrary = new QAction(this);
|
||||
aMoveToGraveyard = new QAction(this);
|
||||
aMoveToExile = new QAction(this);
|
||||
|
||||
cardMenu = new QMenu;
|
||||
cardMenu->addAction(aTap);
|
||||
cardMenu->addAction(aUntap);
|
||||
cardMenu->addAction(aDoesntUntap);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aFlip);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aAddCounter);
|
||||
cardMenu->addAction(aRemoveCounter);
|
||||
cardMenu->addAction(aSetCounters);
|
||||
cardMenu->addSeparator();
|
||||
moveMenu = cardMenu->addMenu(QString());
|
||||
|
||||
moveMenu->addAction(aMoveToTopLibrary);
|
||||
moveMenu->addAction(aMoveToBottomLibrary);
|
||||
moveMenu->addAction(aMoveToGraveyard);
|
||||
moveMenu->addAction(aMoveToExile);
|
||||
|
||||
cardMenuHandlers.insert(aTap, &Player::actTap);
|
||||
cardMenuHandlers.insert(aUntap, &Player::actUntap);
|
||||
cardMenuHandlers.insert(aDoesntUntap, &Player::actDoesntUntap);
|
||||
cardMenuHandlers.insert(aFlip, &Player::actFlip);
|
||||
cardMenuHandlers.insert(aAddCounter, &Player::actAddCounter);
|
||||
cardMenuHandlers.insert(aRemoveCounter, &Player::actRemoveCounter);
|
||||
cardMenuHandlers.insert(aMoveToTopLibrary, &Player::actMoveToTopLibrary);
|
||||
cardMenuHandlers.insert(aMoveToBottomLibrary, &Player::actMoveToBottomLibrary);
|
||||
cardMenuHandlers.insert(aMoveToGraveyard, &Player::actMoveToGraveyard);
|
||||
cardMenuHandlers.insert(aMoveToExile, &Player::actMoveToExile);
|
||||
|
||||
QHashIterator<QAction *, CardMenuHandler> i(cardMenuHandlers);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
connect(i.key(), SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
}
|
||||
} else {
|
||||
countersMenu = 0;
|
||||
sbMenu = 0;
|
||||
|
@ -209,6 +258,7 @@ Player::~Player()
|
|||
clearCounters();
|
||||
clearArrows();
|
||||
delete playerMenu;
|
||||
delete cardMenu;
|
||||
}
|
||||
|
||||
void Player::updateBoundingRect()
|
||||
|
@ -269,6 +319,22 @@ void Player::retranslateUi()
|
|||
QMapIterator<int, Counter *> counterIterator(counters);
|
||||
while (counterIterator.hasNext())
|
||||
counterIterator.next().value()->retranslateUi();
|
||||
|
||||
cardMenu->setTitle(tr("C&ard"));
|
||||
aTap->setText(tr("&Tap"));
|
||||
aUntap->setText(tr("&Untap"));
|
||||
aDoesntUntap->setText(tr("Toggle &normal untapping"));
|
||||
aFlip->setText(tr("&Flip"));
|
||||
aAddCounter->setText(tr("&Add counter"));
|
||||
aRemoveCounter->setText(tr("&Remove counter"));
|
||||
aSetCounters->setText(tr("&Set counters..."));
|
||||
aMoveToTopLibrary->setText(tr("&top of library"));
|
||||
aMoveToBottomLibrary->setText(tr("&bottom of library"));
|
||||
aMoveToGraveyard->setText(tr("&graveyard"));
|
||||
aMoveToGraveyard->setShortcut(tr("Ctrl+Del"));
|
||||
aMoveToExile->setText(tr("&exile"));
|
||||
|
||||
moveMenu->setTitle(tr("&Move to"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -646,7 +712,7 @@ void Player::processGameEvent(GameEvent *event)
|
|||
|
||||
void Player::showCardMenu(const QPoint &p)
|
||||
{
|
||||
emit sigShowCardMenu(p);
|
||||
cardMenu->exec(p);
|
||||
}
|
||||
|
||||
void Player::setActive(bool _active)
|
||||
|
@ -854,3 +920,91 @@ void Player::sendGameCommand(GameCommand *command)
|
|||
{
|
||||
static_cast<TabGame *>(parent())->sendGameCommand(command);
|
||||
}
|
||||
|
||||
void Player::cardMenuAction()
|
||||
{
|
||||
// Determine the appropriate handler function.
|
||||
CardMenuHandler handler = cardMenuHandlers.value(static_cast<QAction *>(sender()));
|
||||
|
||||
// The list of selected items is randomly shuffled.
|
||||
QList<QGraphicsItem *> sel = scene()->selectedItems();
|
||||
while (!sel.isEmpty()) {
|
||||
unsigned int i = (unsigned int) (((double) sel.size()) * qrand() / (RAND_MAX + 1.0));
|
||||
CardItem *card = qgraphicsitem_cast<CardItem *>(sel.takeAt(i));
|
||||
// For each item, the handler function is called.
|
||||
(this->*handler)(card);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actTap(CardItem *card)
|
||||
{
|
||||
if (!card->getTapped())
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "tapped", "1"));
|
||||
}
|
||||
|
||||
void Player::actUntap(CardItem *card)
|
||||
{
|
||||
if (card->getTapped())
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "tapped", "0"));
|
||||
}
|
||||
|
||||
void Player::actDoesntUntap(CardItem *card)
|
||||
{
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "doesnt_untap", QString::number(!card->getDoesntUntap())));
|
||||
}
|
||||
|
||||
void Player::actFlip(CardItem *card)
|
||||
{
|
||||
QString zone = qgraphicsitem_cast<CardZone *>(card->parentItem())->getName();
|
||||
sendGameCommand(new Command_MoveCard(-1, zone, card->getId(), zone, card->getGridPoint().x(), card->getGridPoint().y(), !card->getFaceDown()));
|
||||
}
|
||||
|
||||
void Player::actAddCounter(CardItem *card)
|
||||
{
|
||||
if (card->getCounters() < MAX_COUNTERS_ON_CARD)
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "counters", QString::number(card->getCounters() + 1)));
|
||||
}
|
||||
|
||||
void Player::actRemoveCounter(CardItem *card)
|
||||
{
|
||||
if (card->getCounters())
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(card->parentItem())->getName(), card->getId(), "counters", QString::number(card->getCounters() - 1)));
|
||||
}
|
||||
|
||||
void Player::actSetCounters()
|
||||
{
|
||||
bool ok;
|
||||
int number = QInputDialog::getInteger(0, tr("Set counters"), tr("Number:"), 0, 0, MAX_COUNTERS_ON_CARD, 1, &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *temp = (CardItem *) i.next();
|
||||
sendGameCommand(new Command_SetCardAttr(-1, qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(number)));
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actMoveToTopLibrary(CardItem *card)
|
||||
{
|
||||
CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||
sendGameCommand(new Command_MoveCard(-1, startZone->getName(), card->getId(), "deck", 0, 0, false));
|
||||
}
|
||||
|
||||
void Player::actMoveToBottomLibrary(CardItem *card)
|
||||
{
|
||||
CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||
sendGameCommand(new Command_MoveCard(-1, startZone->getName(), card->getId(), "deck", -1, 0, false));
|
||||
}
|
||||
|
||||
void Player::actMoveToGraveyard(CardItem *card)
|
||||
{
|
||||
CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||
sendGameCommand(new Command_MoveCard(-1, startZone->getName(), card->getId(), "grave", 0, 0, false));
|
||||
}
|
||||
|
||||
void Player::actMoveToExile(CardItem *card)
|
||||
{
|
||||
CardZone *startZone = qgraphicsitem_cast<CardZone *>(card->parentItem());
|
||||
sendGameCommand(new Command_MoveCard(-1, startZone->getName(), card->getId(), "rfg", 0, 0, false));
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ class Player : public QObject, public QGraphicsItem {
|
|||
signals:
|
||||
void closeZoneView(ZoneViewZone *zone);
|
||||
void toggleZoneView(Player *player, QString zoneName, int number);
|
||||
void sigShowCardMenu(QPoint p); // XXX
|
||||
void newCardAdded(CardItem *card);
|
||||
// Log events
|
||||
void logDeckSelect(Player *player, int deckId);
|
||||
|
@ -84,6 +83,8 @@ public slots:
|
|||
void actSayMessage();
|
||||
private slots:
|
||||
void updateBoundingRect();
|
||||
void cardMenuAction();
|
||||
void actSetCounters();
|
||||
private:
|
||||
QMenu *playerMenu, *handMenu, *graveMenu, *rfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu;
|
||||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg,
|
||||
|
@ -93,6 +94,25 @@ private:
|
|||
*aDrawCard, *aDrawCards, *aMulligan, *aShuffle,
|
||||
*aUntapAll, *aRollDie, *aCreateToken;
|
||||
|
||||
typedef void (Player::*CardMenuHandler)(CardItem *card);
|
||||
QHash<QAction *, CardMenuHandler> cardMenuHandlers;
|
||||
|
||||
QMenu *cardMenu, *moveMenu;
|
||||
QAction *aTap, *aUntap, *aDoesntUntap, *aFlip, *aAddCounter, *aRemoveCounter, *aSetCounters,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile;
|
||||
|
||||
|
||||
void actTap(CardItem *card);
|
||||
void actUntap(CardItem *card);
|
||||
void actDoesntUntap(CardItem *card);
|
||||
void actFlip(CardItem *card);
|
||||
void actAddCounter(CardItem *card);
|
||||
void actRemoveCounter(CardItem *card);
|
||||
void actMoveToTopLibrary(CardItem *card);
|
||||
void actMoveToBottomLibrary(CardItem *card);
|
||||
void actMoveToGraveyard(CardItem *card);
|
||||
void actMoveToExile(CardItem *card);
|
||||
|
||||
int defaultNumberTopCards;
|
||||
int mulliganCards;
|
||||
QString name;
|
||||
|
|
|
@ -128,7 +128,7 @@ void TabGame::retranslateUi()
|
|||
aLeaveGame->setText(tr("&Leave game"));
|
||||
|
||||
loadLocalButton->setText(tr("Load &local deck"));
|
||||
loadRemoteButton->setText(tr("Load deck from &server"));
|
||||
loadRemoteButton->setText(tr("Load d&eck from server"));
|
||||
readyStartButton->setText(tr("&Start game"));
|
||||
sayLabel->setText(tr("&Say:"));
|
||||
cardInfo->retranslateUi();
|
||||
|
|
Loading…
Reference in a new issue