renamed playerzone to cardzone
This commit is contained in:
parent
141b116528
commit
8782438fcc
28 changed files with 106 additions and 106 deletions
|
@ -12,5 +12,5 @@ QT += network
|
||||||
#QTPLUGIN += qjpeg
|
#QTPLUGIN += qjpeg
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
HEADERS += src/counter.h src/dlg_games.h src/dlg_creategame.h src/dlg_connect.h src/gamesmodel.h src/client.h src/window.h src/servergame.h src/servereventdata.h src/serverresponse.h src/pendingcommand.h src/zonelist.h src/counterlist.h src/playerzone.h src/player.h src/cardlist.h src/carditem.h src/tablezone.h src/handzone.h src/playerlist.h src/game.h src/carddatabase.h src/gameview.h src/decklistmodel.h src/dlg_startgame.h src/cardinfowidget.h src/messagelogwidget.h src/serverzonecard.h src/zoneviewzone.h src/zoneviewwidget.h src/libraryzone.h src/gravezone.h src/rfgzone.h src/sideboardzone.h src/carddragitem.h src/zoneclosebutton.h src/zoneviewlayout.h
|
HEADERS += src/counter.h src/dlg_games.h src/dlg_creategame.h src/dlg_connect.h src/gamesmodel.h src/client.h src/window.h src/servergame.h src/servereventdata.h src/serverresponse.h src/pendingcommand.h src/zonelist.h src/counterlist.h src/cardzone.h src/player.h src/cardlist.h src/carditem.h src/tablezone.h src/handzone.h src/playerlist.h src/game.h src/carddatabase.h src/gameview.h src/decklistmodel.h src/dlg_startgame.h src/cardinfowidget.h src/messagelogwidget.h src/serverzonecard.h src/zoneviewzone.h src/zoneviewwidget.h src/libraryzone.h src/gravezone.h src/rfgzone.h src/sideboardzone.h src/carddragitem.h src/zoneclosebutton.h src/zoneviewlayout.h
|
||||||
SOURCES += src/counter.cpp src/dlg_games.cpp src/dlg_creategame.cpp src/dlg_connect.cpp src/client.cpp src/main.cpp src/window.cpp src/servereventdata.cpp src/gamesmodel.cpp src/player.cpp src/playerzone.cpp src/zonelist.cpp src/counterlist.cpp src/cardlist.cpp src/carditem.cpp src/tablezone.cpp src/handzone.cpp src/playerlist.cpp src/game.cpp src/carddatabase.cpp src/gameview.cpp src/decklistmodel.cpp src/dlg_startgame.cpp src/cardinfowidget.cpp src/messagelogwidget.cpp src/zoneviewzone.cpp src/zoneviewwidget.cpp src/libraryzone.cpp src/gravezone.cpp src/rfgzone.cpp src/sideboardzone.cpp src/carddragitem.cpp src/zoneclosebutton.cpp src/zoneviewlayout.cpp
|
SOURCES += src/counter.cpp src/dlg_games.cpp src/dlg_creategame.cpp src/dlg_connect.cpp src/client.cpp src/main.cpp src/window.cpp src/servereventdata.cpp src/gamesmodel.cpp src/player.cpp src/cardzone.cpp src/zonelist.cpp src/counterlist.cpp src/cardlist.cpp src/carditem.cpp src/tablezone.cpp src/handzone.cpp src/playerlist.cpp src/game.cpp src/carddatabase.cpp src/gameview.cpp src/decklistmodel.cpp src/dlg_startgame.cpp src/cardinfowidget.cpp src/messagelogwidget.cpp src/zoneviewzone.cpp src/zoneviewwidget.cpp src/libraryzone.cpp src/gravezone.cpp src/rfgzone.cpp src/sideboardzone.cpp src/carddragitem.cpp src/zoneclosebutton.cpp src/zoneviewlayout.cpp
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "carddragitem.h"
|
#include "carddragitem.h"
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
CardDragItem::CardDragItem(QGraphicsScene *scene, PlayerZone *_startZone, QPixmap *_image, int _id, const QPointF &_hotSpot, QGraphicsItem *parent)
|
CardDragItem::CardDragItem(QGraphicsScene *scene, CardZone *_startZone, QPixmap *_image, int _id, const QPointF &_hotSpot, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent), image(_image), id(_id), hotSpot(_hotSpot), startZone(_startZone)
|
: QGraphicsItem(parent), image(_image), id(_id), hotSpot(_hotSpot), startZone(_startZone)
|
||||||
{
|
{
|
||||||
if ((hotSpot.x() < 0) || (hotSpot.y() < 0)) {
|
if ((hotSpot.x() < 0) || (hotSpot.y() < 0)) {
|
||||||
|
@ -46,9 +46,9 @@ void CardDragItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
QPointF sp = event->scenePos();
|
QPointF sp = event->scenePos();
|
||||||
QList<QGraphicsItem *> colliding = scene()->items(sp);
|
QList<QGraphicsItem *> colliding = scene()->items(sp);
|
||||||
|
|
||||||
PlayerZone *cursorZone = 0;
|
CardZone *cursorZone = 0;
|
||||||
for (int i = colliding.size() - 1; i >= 0; i--) {
|
for (int i = colliding.size() - 1; i >= 0; i--) {
|
||||||
if ((cursorZone = qgraphicsitem_cast<PlayerZone *>(colliding.at(i)))) {
|
if ((cursorZone = qgraphicsitem_cast<CardZone *>(colliding.at(i)))) {
|
||||||
if (cursorZone->getName() == "table") {
|
if (cursorZone->getName() == "table") {
|
||||||
QPointF cp = cursorZone->scenePos();
|
QPointF cp = cursorZone->scenePos();
|
||||||
QPointF localpos = sp - hotSpot - cp;
|
QPointF localpos = sp - hotSpot - cp;
|
||||||
|
@ -70,12 +70,12 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
QList<QGraphicsItem *> colliding = sc->items(event->scenePos());
|
QList<QGraphicsItem *> colliding = sc->items(event->scenePos());
|
||||||
|
|
||||||
qDebug(QString("drop: %1 collisions").arg(colliding.size()).toLatin1());
|
qDebug(QString("drop: %1 collisions").arg(colliding.size()).toLatin1());
|
||||||
PlayerZone *dropZone = 0;
|
CardZone *dropZone = 0;
|
||||||
for (int i = colliding.size() - 1; i >= 0; i--) {
|
for (int i = colliding.size() - 1; i >= 0; i--) {
|
||||||
QRectF bbox = colliding.at(i)->boundingRect();
|
QRectF bbox = colliding.at(i)->boundingRect();
|
||||||
qDebug(QString("bbox x %1 y %2 w %3 h %4").arg(bbox.x()).arg(bbox.y()).arg(bbox.width()).arg(bbox.height()).toLatin1());
|
qDebug(QString("bbox x %1 y %2 w %3 h %4").arg(bbox.x()).arg(bbox.y()).arg(bbox.width()).arg(bbox.height()).toLatin1());
|
||||||
|
|
||||||
if ((dropZone = qgraphicsitem_cast<PlayerZone *>(colliding.at(i)))) {
|
if ((dropZone = qgraphicsitem_cast<CardZone *>(colliding.at(i)))) {
|
||||||
qDebug("zone found");
|
qDebug("zone found");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,18 @@
|
||||||
#include "carditem.h"
|
#include "carditem.h"
|
||||||
|
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
class PlayerZone;
|
class CardZone;
|
||||||
|
|
||||||
class CardDragItem : public QGraphicsItem {
|
class CardDragItem : public QGraphicsItem {
|
||||||
private:
|
private:
|
||||||
QPixmap *image;
|
QPixmap *image;
|
||||||
int id;
|
int id;
|
||||||
QPointF hotSpot;
|
QPointF hotSpot;
|
||||||
PlayerZone *startZone;
|
CardZone *startZone;
|
||||||
public:
|
public:
|
||||||
enum { Type = typeCardDrag };
|
enum { Type = typeCardDrag };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
CardDragItem(QGraphicsScene *scene, PlayerZone *_startZone, QPixmap *_image, int _id, const QPointF &_hotSpot, QGraphicsItem *parent = 0);
|
CardDragItem(QGraphicsScene *scene, CardZone *_startZone, QPixmap *_image, int _id, const QPointF &_hotSpot, QGraphicsItem *parent = 0);
|
||||||
~CardDragItem();
|
~CardDragItem();
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "carditem.h"
|
#include "carditem.h"
|
||||||
#include "carddragitem.h"
|
#include "carddragitem.h"
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
#include "tablezone.h"
|
#include "tablezone.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void CardItem::resetState()
|
||||||
update(boundingRect());
|
update(boundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
CardDragItem *CardItem::createDragItem(PlayerZone *startZone, int _id, const QPointF &_pos, const QPointF &_scenePos)
|
CardDragItem *CardItem::createDragItem(CardZone *startZone, int _id, const QPointF &_pos, const QPointF &_scenePos)
|
||||||
{
|
{
|
||||||
dragItem = new CardDragItem(scene(), startZone, image, _id, _pos);
|
dragItem = new CardDragItem(scene(), startZone, image, _id, _pos);
|
||||||
dragItem->setPos(_scenePos - dragItem->getHotSpot());
|
dragItem->setPos(_scenePos - dragItem->getHotSpot());
|
||||||
|
@ -128,7 +128,7 @@ void CardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
setCursor(Qt::ClosedHandCursor);
|
setCursor(Qt::ClosedHandCursor);
|
||||||
} else if (event->button() == Qt::RightButton) {
|
} else if (event->button() == Qt::RightButton) {
|
||||||
qgraphicsitem_cast<PlayerZone *>(parentItem())->getPlayer()->showCardMenu(event->screenPos());
|
qgraphicsitem_cast<CardZone *>(parentItem())->getPlayer()->showCardMenu(event->screenPos());
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() < QApplication::startDragDistance())
|
if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() < QApplication::startDragDistance())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
createDragItem((PlayerZone *) parentItem(), id, event->pos(), event->scenePos());
|
createDragItem((CardZone *) parentItem(), id, event->pos(), event->scenePos());
|
||||||
dragItem->grabMouse();
|
dragItem->grabMouse();
|
||||||
|
|
||||||
QList<QGraphicsItem *> sel = scene()->selectedItems();
|
QList<QGraphicsItem *> sel = scene()->selectedItems();
|
||||||
|
@ -146,7 +146,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
CardItem *c = (CardItem *) sel.at(i);
|
CardItem *c = (CardItem *) sel.at(i);
|
||||||
if (c == this)
|
if (c == this)
|
||||||
continue;
|
continue;
|
||||||
CardDragItem *drag = new CardDragItem(scene(), (PlayerZone *) parentItem(), c->getImage(), c->getId(), QPointF(), dragItem);
|
CardDragItem *drag = new CardDragItem(scene(), (CardZone *) parentItem(), c->getImage(), c->getId(), QPointF(), dragItem);
|
||||||
drag->setPos(c->pos() - pos());
|
drag->setPos(c->pos() - pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
PlayerZone *zone = (PlayerZone *) parentItem();
|
CardZone *zone = (CardZone *) parentItem();
|
||||||
// Do nothing if the card belongs to another player
|
// Do nothing if the card belongs to another player
|
||||||
if (!zone->getPlayer()->getLocal())
|
if (!zone->getPlayer()->getLocal())
|
||||||
return;
|
return;
|
||||||
|
@ -180,7 +180,7 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
void CardItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void CardItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
((PlayerZone *) parentItem())->hoverCardEvent(this);
|
((CardZone *) parentItem())->hoverCardEvent(this);
|
||||||
QGraphicsItem::hoverEnterEvent(event);
|
QGraphicsItem::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
class CardDragItem;
|
class CardDragItem;
|
||||||
class PlayerZone;
|
class CardZone;
|
||||||
|
|
||||||
|
|
||||||
const int CARD_WIDTH = 72;
|
const int CARD_WIDTH = 72;
|
||||||
|
@ -66,7 +66,7 @@ public:
|
||||||
void setAnnotation(const QString &_annotation);
|
void setAnnotation(const QString &_annotation);
|
||||||
void resetState();
|
void resetState();
|
||||||
|
|
||||||
CardDragItem *createDragItem(PlayerZone *startZone, int _id, const QPointF &_pos, const QPointF &_scenePos);
|
CardDragItem *createDragItem(CardZone *startZone, int _id, const QPointF &_pos, const QPointF &_scenePos);
|
||||||
void deleteDragItem();
|
void deleteDragItem();
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
#include "carditem.h"
|
#include "carditem.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
|
|
||||||
PlayerZone::PlayerZone(Player *_p, const QString &_name, QGraphicsItem *parent, bool isView)
|
CardZone::CardZone(Player *_p, const QString &_name, QGraphicsItem *parent, bool isView)
|
||||||
: QGraphicsItem(parent), player(_p), name(_name), cards(NULL), menu(NULL), hasCardAttr(false)
|
: QGraphicsItem(parent), player(_p), name(_name), cards(NULL), menu(NULL), hasCardAttr(false)
|
||||||
{
|
{
|
||||||
if (!isView)
|
if (!isView)
|
||||||
player->addZone(this);
|
player->addZone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerZone::~PlayerZone()
|
CardZone::~CardZone()
|
||||||
{
|
{
|
||||||
qDebug(QString("PlayerZone destructor: %1").arg(name).toLatin1());
|
qDebug(QString("CardZone destructor: %1").arg(name).toLatin1());
|
||||||
while (!views.empty())
|
while (!views.empty())
|
||||||
delete views.at(0);
|
delete views.at(0);
|
||||||
|
|
||||||
|
@ -22,14 +22,14 @@ PlayerZone::~PlayerZone()
|
||||||
delete cards;
|
delete cards;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerZone::clearContents()
|
void CardZone::clearContents()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < cards->size(); i++)
|
for (int i = 0; i < cards->size(); i++)
|
||||||
delete cards->at(i);
|
delete cards->at(i);
|
||||||
cards->clear();
|
cards->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void CardZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::RightButton) {
|
if (event->button() == Qt::RightButton) {
|
||||||
if (menu) {
|
if (menu) {
|
||||||
|
@ -41,7 +41,7 @@ void PlayerZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
CardItem *PlayerZone::getCard(int cardId, const QString &cardName)
|
CardItem *CardZone::getCard(int cardId, const QString &cardName)
|
||||||
{
|
{
|
||||||
CardItem *c = cards->findCard(cardId, false);
|
CardItem *c = cards->findCard(cardId, false);
|
||||||
// If the card's id is -1, this zone is invisible,
|
// If the card's id is -1, this zone is invisible,
|
||||||
|
@ -54,7 +54,7 @@ CardItem *PlayerZone::getCard(int cardId, const QString &cardName)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
CardItem *PlayerZone::takeCard(int position, int cardId, const QString &cardName)
|
CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName)
|
||||||
{
|
{
|
||||||
CardItem *c = cards->takeAt(position);
|
CardItem *c = cards->takeAt(position);
|
||||||
for (int i = 0; i < views.size(); i++)
|
for (int i = 0; i < views.size(); i++)
|
||||||
|
@ -68,28 +68,28 @@ CardItem *PlayerZone::takeCard(int position, int cardId, const QString &cardName
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerZone::setCardAttr(int cardId, const QString &aname, const QString &avalue)
|
void CardZone::setCardAttr(int cardId, const QString &aname, const QString &avalue)
|
||||||
{
|
{
|
||||||
if (hasCardAttr)
|
if (hasCardAttr)
|
||||||
player->client->setCardAttr(name, cardId, aname, avalue);
|
player->client->setCardAttr(name, cardId, aname, avalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerZone::hoverCardEvent(CardItem *card)
|
void CardZone::hoverCardEvent(CardItem *card)
|
||||||
{
|
{
|
||||||
player->hoverCardEvent(card);
|
player->hoverCardEvent(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerZone::addView(ZoneViewZone *view)
|
void CardZone::addView(ZoneViewZone *view)
|
||||||
{
|
{
|
||||||
views.append(view);
|
views.append(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerZone::removeView(ZoneViewZone *view)
|
void CardZone::removeView(ZoneViewZone *view)
|
||||||
{
|
{
|
||||||
views.removeAt(views.indexOf(view));
|
views.removeAt(views.indexOf(view));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerZone::moveAllToZone(const QString &targetZone, int targetX)
|
void CardZone::moveAllToZone(const QString &targetZone, int targetX)
|
||||||
{
|
{
|
||||||
// Cards need to be moved in reverse order so that the other
|
// Cards need to be moved in reverse order so that the other
|
||||||
// cards' list index doesn't change
|
// cards' list index doesn't change
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef PLAYERZONE_H
|
#ifndef CARDZONE_H
|
||||||
#define PLAYERZONE_H
|
#define CARDZONE_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "cardlist.h"
|
#include "cardlist.h"
|
||||||
|
@ -8,7 +8,7 @@ class Player;
|
||||||
class ZoneViewZone;
|
class ZoneViewZone;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
|
|
||||||
class PlayerZone : public QGraphicsItem {
|
class CardZone : public QGraphicsItem {
|
||||||
protected:
|
protected:
|
||||||
Player *player;
|
Player *player;
|
||||||
QString name;
|
QString name;
|
||||||
|
@ -20,9 +20,9 @@ protected:
|
||||||
public:
|
public:
|
||||||
enum { Type = typeZone };
|
enum { Type = typeZone };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
virtual void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint) = 0;
|
virtual void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint) = 0;
|
||||||
PlayerZone(Player *_player, const QString &_name, QGraphicsItem *parent = 0, bool isView = false);
|
CardZone(Player *_player, const QString &_name, QGraphicsItem *parent = 0, bool isView = false);
|
||||||
~PlayerZone();
|
~CardZone();
|
||||||
void clearContents();
|
void clearContents();
|
||||||
bool getHasCardAttr() const { return hasCardAttr; }
|
bool getHasCardAttr() const { return hasCardAttr; }
|
||||||
QMenu *getMenu() const { return menu; }
|
QMenu *getMenu() const { return menu; }
|
|
@ -305,7 +305,7 @@ 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<PlayerZone *>(temp->parentItem())->getName(), temp->getId(), "tapped", "1");
|
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "tapped", "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ 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<PlayerZone *>(temp->parentItem())->getName(), temp->getId(), "tapped", "0");
|
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "tapped", "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ void Game::actAddCounter()
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
CardItem *temp = (CardItem *) i.next();
|
CardItem *temp = (CardItem *) i.next();
|
||||||
if (temp->getCounters() < MAX_COUNTERS_ON_CARD)
|
if (temp->getCounters() < MAX_COUNTERS_ON_CARD)
|
||||||
client->setCardAttr(qgraphicsitem_cast<PlayerZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(temp->getCounters() + 1));
|
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(temp->getCounters() + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ void Game::actRemoveCounter()
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
CardItem *temp = (CardItem *) i.next();
|
CardItem *temp = (CardItem *) i.next();
|
||||||
if (temp->getCounters())
|
if (temp->getCounters())
|
||||||
client->setCardAttr(qgraphicsitem_cast<PlayerZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(temp->getCounters() - 1));
|
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(temp->getCounters() - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ void Game::actSetCounters()
|
||||||
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<PlayerZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(number));
|
client->setCardAttr(qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName(), temp->getId(), "counters", QString::number(number));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ void Game::actRearrange()
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
CardItem *temp = (CardItem *) list.at(i);
|
CardItem *temp = (CardItem *) list.at(i);
|
||||||
QString zoneName = qgraphicsitem_cast<PlayerZone *>(temp->parentItem())->getName();
|
QString zoneName = qgraphicsitem_cast<CardZone *>(temp->parentItem())->getName();
|
||||||
x = x_initial + i * RASTER_WIDTH;
|
x = x_initial + i * RASTER_WIDTH;
|
||||||
y = y_initial + (i % 3) * RASTER_HEIGHT;
|
y = y_initial + (i % 3) * RASTER_HEIGHT;
|
||||||
client->moveCard(temp->getId(), zoneName, zoneName, x, y);
|
client->moveCard(temp->getId(), zoneName, zoneName, x, y);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
|
|
||||||
GraveZone::GraveZone(Player *_p)
|
GraveZone::GraveZone(Player *_p)
|
||||||
: PlayerZone(_p, "grave")
|
: CardZone(_p, "grave")
|
||||||
{
|
{
|
||||||
cards = new CardList(true);
|
cards = new CardList(true);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ void GraveZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraveZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
void GraveZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
player->client->moveCard(cardId, startZone->getName(), getName(), 0, 0);
|
player->client->moveCard(cardId, startZone->getName(), getName(), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef GRAVEZONE_H
|
#ifndef GRAVEZONE_H
|
||||||
#define GRAVEZONE_H
|
#define GRAVEZONE_H
|
||||||
|
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
|
|
||||||
class GraveZone : public PlayerZone {
|
class GraveZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
GraveZone(Player *_p);
|
GraveZone(Player *_p);
|
||||||
|
@ -11,7 +11,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
HandZone::HandZone(Player *_p)
|
HandZone::HandZone(Player *_p)
|
||||||
: PlayerZone(_p, "hand")
|
: CardZone(_p, "hand")
|
||||||
{
|
{
|
||||||
cards = new CardList(player->getLocal());
|
cards = new CardList(player->getLocal());
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ void HandZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
void HandZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
Q_UNUSED(dropPoint);
|
Q_UNUSED(dropPoint);
|
||||||
player->client->moveCard(cardId, startZone->getName(), getName(), cards->size(), 0);
|
player->client->moveCard(cardId, startZone->getName(), getName(), cards->size(), 0);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef HANDZONE_H
|
#ifndef HANDZONE_H
|
||||||
#define HANDZONE_H
|
#define HANDZONE_H
|
||||||
|
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
|
|
||||||
class HandZone : public PlayerZone {
|
class HandZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
HandZone(Player *_p);
|
HandZone(Player *_p);
|
||||||
|
@ -11,7 +11,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void addCard(CardItem *card, bool reorganize = true, int x = -1, int y = -1);
|
void addCard(CardItem *card, bool reorganize = true, int x = -1, int y = -1);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
|
|
||||||
LibraryZone::LibraryZone(Player *_p)
|
LibraryZone::LibraryZone(Player *_p)
|
||||||
: PlayerZone(_p, "deck")
|
: CardZone(_p, "deck")
|
||||||
{
|
{
|
||||||
cards = new CardList(false);
|
cards = new CardList(false);
|
||||||
setCursor(Qt::OpenHandCursor);
|
setCursor(Qt::OpenHandCursor);
|
||||||
|
@ -47,7 +47,7 @@ void LibraryZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
void LibraryZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
player->client->moveCard(cardId, startZone->getName(), getName(), 0, 0);
|
player->client->moveCard(cardId, startZone->getName(), getName(), 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void LibraryZone::reorganizeCards()
|
||||||
|
|
||||||
void LibraryZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void LibraryZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
PlayerZone::mousePressEvent(event);
|
CardZone::mousePressEvent(event);
|
||||||
if (event->isAccepted())
|
if (event->isAccepted())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef LIBRARYZONE_H
|
#ifndef LIBRARYZONE_H
|
||||||
#define LIBRARYZONE_H
|
#define LIBRARYZONE_H
|
||||||
|
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
|
|
||||||
class LibraryZone : public PlayerZone {
|
class LibraryZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
LibraryZone(Player *_p);
|
LibraryZone(Player *_p);
|
||||||
|
@ -11,7 +11,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
|
@ -31,11 +31,11 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa
|
||||||
|
|
||||||
_base += QPointF(deck->boundingRect().width(), 0);
|
_base += QPointF(deck->boundingRect().width(), 0);
|
||||||
|
|
||||||
PlayerZone *hand = new HandZone(this);
|
CardZone *hand = new HandZone(this);
|
||||||
hand->setPos(_base);
|
hand->setPos(_base);
|
||||||
_base += QPointF(hand->boundingRect().width(), 0);
|
_base += QPointF(hand->boundingRect().width(), 0);
|
||||||
|
|
||||||
PlayerZone *table = new TableZone(this);
|
CardZone *table = new TableZone(this);
|
||||||
table->setPos(_base);
|
table->setPos(_base);
|
||||||
|
|
||||||
aMoveHandToTopLibrary = new QAction(tr("Move to &top of library"), this);
|
aMoveHandToTopLibrary = new QAction(tr("Move to &top of library"), this);
|
||||||
|
@ -99,13 +99,13 @@ Player::~Player()
|
||||||
|
|
||||||
void Player::actMoveHandToTopLibrary()
|
void Player::actMoveHandToTopLibrary()
|
||||||
{
|
{
|
||||||
PlayerZone *library = zones.findZone("deck");
|
CardZone *library = zones.findZone("deck");
|
||||||
zones.findZone("hand")->moveAllToZone(library->getName(), 0);
|
zones.findZone("hand")->moveAllToZone(library->getName(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actMoveHandToBottomLibrary()
|
void Player::actMoveHandToBottomLibrary()
|
||||||
{
|
{
|
||||||
PlayerZone *library = zones.findZone("deck");
|
CardZone *library = zones.findZone("deck");
|
||||||
zones.findZone("hand")->moveAllToZone(library->getName(), library->getCards()->size());
|
zones.findZone("hand")->moveAllToZone(library->getName(), library->getCards()->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void Player::actViewSideboard()
|
||||||
emit addZoneView(this, "sb", 0);
|
emit addZoneView(this, "sb", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::addZone(PlayerZone *z)
|
void Player::addZone(CardZone *z)
|
||||||
{
|
{
|
||||||
zones << z;
|
zones << z;
|
||||||
}
|
}
|
||||||
|
@ -167,12 +167,12 @@ void Player::gameEvent(ServerEventData *event)
|
||||||
Counter *lifeCounter = counters.findCounter("life");
|
Counter *lifeCounter = counters.findCounter("life");
|
||||||
lifeCounter->setValue(life);
|
lifeCounter->setValue(life);
|
||||||
|
|
||||||
PlayerZone *deck = zones.findZone("deck");
|
CardZone *deck = zones.findZone("deck");
|
||||||
for (; deck_cards; deck_cards--)
|
for (; deck_cards; deck_cards--)
|
||||||
deck->addCard(new CardItem(db, QString(), -1));
|
deck->addCard(new CardItem(db, QString(), -1));
|
||||||
deck->reorganizeCards();
|
deck->reorganizeCards();
|
||||||
|
|
||||||
PlayerZone *sb = zones.findZone("sb");
|
CardZone *sb = zones.findZone("sb");
|
||||||
for (; sb_cards; sb_cards--)
|
for (; sb_cards; sb_cards--)
|
||||||
sb->addCard(new CardItem(db, QString(), -1));
|
sb->addCard(new CardItem(db, QString(), -1));
|
||||||
sb->reorganizeCards();
|
sb->reorganizeCards();
|
||||||
|
@ -180,8 +180,8 @@ void Player::gameEvent(ServerEventData *event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eventDraw: {
|
case eventDraw: {
|
||||||
PlayerZone *deck = zones.findZone("deck");
|
CardZone *deck = zones.findZone("deck");
|
||||||
PlayerZone *hand = zones.findZone("hand");
|
CardZone *hand = zones.findZone("hand");
|
||||||
if (!event->getPublic()) {
|
if (!event->getPublic()) {
|
||||||
hand->addCard(deck->takeCard(0, data[0].toInt(), data[1]));
|
hand->addCard(deck->takeCard(0, data[0].toInt(), data[1]));
|
||||||
} else {
|
} else {
|
||||||
|
@ -198,11 +198,11 @@ void Player::gameEvent(ServerEventData *event)
|
||||||
}
|
}
|
||||||
int cardId = data[0].toInt();
|
int cardId = data[0].toInt();
|
||||||
QString cardName = data[1];
|
QString cardName = data[1];
|
||||||
PlayerZone *startZone = zones.findZone(data[2]);
|
CardZone *startZone = zones.findZone(data[2]);
|
||||||
if (!startZone)
|
if (!startZone)
|
||||||
qDebug(QString("start zone invalid: %1").arg(data[2]).toLatin1());
|
qDebug(QString("start zone invalid: %1").arg(data[2]).toLatin1());
|
||||||
int position = data[3].toInt();
|
int position = data[3].toInt();
|
||||||
PlayerZone *targetZone = zones.findZone(data[4]);
|
CardZone *targetZone = zones.findZone(data[4]);
|
||||||
if (!targetZone)
|
if (!targetZone)
|
||||||
qDebug(QString("target zone invalid: %1").arg(data[4]).toLatin1());
|
qDebug(QString("target zone invalid: %1").arg(data[4]).toLatin1());
|
||||||
int x = data[5].toInt();
|
int x = data[5].toInt();
|
||||||
|
@ -228,7 +228,7 @@ void Player::gameEvent(ServerEventData *event)
|
||||||
if (data.size() != 6) {
|
if (data.size() != 6) {
|
||||||
qDebug("error");
|
qDebug("error");
|
||||||
}
|
}
|
||||||
PlayerZone *zone = zones.findZone(data[0]);
|
CardZone *zone = zones.findZone(data[0]);
|
||||||
int cardid = data[1].toInt();
|
int cardid = data[1].toInt();
|
||||||
QString cardname = data[2];
|
QString cardname = data[2];
|
||||||
QString powtough = data[3];
|
QString powtough = data[3];
|
||||||
|
@ -246,7 +246,7 @@ void Player::gameEvent(ServerEventData *event)
|
||||||
if (data.size() != 4) {
|
if (data.size() != 4) {
|
||||||
// XXX
|
// XXX
|
||||||
}
|
}
|
||||||
PlayerZone *zone = zones.findZone(data[0]);
|
CardZone *zone = zones.findZone(data[0]);
|
||||||
int cardId = data[1].toInt();
|
int cardId = data[1].toInt();
|
||||||
CardItem *card = zone->getCard(cardId, "");
|
CardItem *card = zone->getCard(cardId, "");
|
||||||
QString aname = data[2];
|
QString aname = data[2];
|
||||||
|
|
|
@ -52,7 +52,7 @@ private:
|
||||||
CardDatabase *db;
|
CardDatabase *db;
|
||||||
public:
|
public:
|
||||||
Client *client;
|
Client *client;
|
||||||
void addZone(PlayerZone *z);
|
void addZone(CardZone *z);
|
||||||
void addCounter(Counter *c);
|
void addCounter(Counter *c);
|
||||||
Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client);
|
Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client);
|
||||||
~Player();
|
~Player();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
|
|
||||||
RfgZone::RfgZone(Player *_p)
|
RfgZone::RfgZone(Player *_p)
|
||||||
: PlayerZone(_p, "rfg")
|
: CardZone(_p, "rfg")
|
||||||
{
|
{
|
||||||
cards = new CardList(true);
|
cards = new CardList(true);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ void RfgZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RfgZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
void RfgZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
player->client->moveCard(cardId, startZone->getName(), getName(), 0, 0);
|
player->client->moveCard(cardId, startZone->getName(), getName(), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef RFGZONE_H
|
#ifndef RFGZONE_H
|
||||||
#define RFGZONE_H
|
#define RFGZONE_H
|
||||||
|
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
|
|
||||||
class RfgZone : public PlayerZone {
|
class RfgZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
RfgZone(Player *_p);
|
RfgZone(Player *_p);
|
||||||
|
@ -11,7 +11,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
|
|
||||||
SideboardZone::SideboardZone(Player *_p)
|
SideboardZone::SideboardZone(Player *_p)
|
||||||
: PlayerZone(_p, "sb")
|
: CardZone(_p, "sb")
|
||||||
{
|
{
|
||||||
cards = new CardList(false);
|
cards = new CardList(false);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ void SideboardZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SideboardZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
void SideboardZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
player->client->moveCard(cardId, startZone->getName(), getName(), 0, 0);
|
player->client->moveCard(cardId, startZone->getName(), getName(), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SIDEBOARDZONE_H
|
#ifndef SIDEBOARDZONE_H
|
||||||
#define SIDEBOARDZONE_H
|
#define SIDEBOARDZONE_H
|
||||||
|
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
|
|
||||||
class SideboardZone : public PlayerZone {
|
class SideboardZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
SideboardZone(Player *_p);
|
SideboardZone(Player *_p);
|
||||||
|
@ -11,7 +11,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
TableZone::TableZone(Player *_p)
|
TableZone::TableZone(Player *_p)
|
||||||
: PlayerZone(_p, "table"), width(700), height(500)
|
: CardZone(_p, "table"), width(700), height(500)
|
||||||
{
|
{
|
||||||
cards = new CardList(true);
|
cards = new CardList(true);
|
||||||
hasCardAttr = true;
|
hasCardAttr = true;
|
||||||
|
@ -37,7 +37,7 @@ void TableZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
||||||
card->update(card->boundingRect());
|
card->update(card->boundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
void TableZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
player->client->moveCard(cardId, startZone->getName(), getName(), dropPoint.x(), dropPoint.y());
|
player->client->moveCard(cardId, startZone->getName(), getName(), dropPoint.x(), dropPoint.y());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#ifndef TABLEZONE_H
|
#ifndef TABLEZONE_H
|
||||||
#define TABLEZONE_H
|
#define TABLEZONE_H
|
||||||
|
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
|
|
||||||
const int GRID_WIDTH = 30;
|
const int GRID_WIDTH = 30;
|
||||||
const int GRID_HEIGHT = 30;
|
const int GRID_HEIGHT = 30;
|
||||||
|
|
||||||
class TableZone : public PlayerZone {
|
class TableZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
int width, height;
|
int width, height;
|
||||||
public:
|
public:
|
||||||
|
@ -16,7 +16,7 @@ public:
|
||||||
void addCard(CardItem *card, bool reorganize = true, int x = -1, int y = -1);
|
void addCard(CardItem *card, bool reorganize = true, int x = -1, int y = -1);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void toggleTapped();
|
void toggleTapped();
|
||||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "zonelist.h"
|
#include "zonelist.h"
|
||||||
|
|
||||||
PlayerZone *ZoneList::findZone(const QString &name) const
|
CardZone *ZoneList::findZone(const QString &name) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size(); i++) {
|
for (int i = 0; i < size(); i++) {
|
||||||
PlayerZone *temp = at(i);
|
CardZone *temp = at(i);
|
||||||
if (!temp->getName().compare(name))
|
if (!temp->getName().compare(name))
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#ifndef ZONELIST_H
|
#ifndef ZONELIST_H
|
||||||
#define ZONELIST_H
|
#define ZONELIST_H
|
||||||
|
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
class ZoneList : public QList<PlayerZone *> {
|
class ZoneList : public QList<CardZone *> {
|
||||||
public:
|
public:
|
||||||
PlayerZone *findZone(const QString &name) const;
|
CardZone *findZone(const QString &name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "zoneclosebutton.h"
|
#include "zoneclosebutton.h"
|
||||||
|
|
||||||
ZoneViewWidget::ZoneViewWidget(CardDatabase *_db, Player *_player, PlayerZone *_origZone, int numberCards, QGraphicsItem *parent)
|
ZoneViewWidget::ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_origZone, int numberCards, QGraphicsItem *parent)
|
||||||
: QGraphicsWidget(parent), db(_db), player(_player)
|
: QGraphicsWidget(parent), db(_db), player(_player)
|
||||||
{
|
{
|
||||||
ZoneCloseButton *closeButton = new ZoneCloseButton(this);
|
ZoneCloseButton *closeButton = new ZoneCloseButton(this);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <QGraphicsWidget>
|
#include <QGraphicsWidget>
|
||||||
#include "serverzonecard.h"
|
#include "serverzonecard.h"
|
||||||
|
|
||||||
class PlayerZone;
|
class CardZone;
|
||||||
class ZoneViewZone;
|
class ZoneViewZone;
|
||||||
class Player;
|
class Player;
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
|
@ -25,7 +25,7 @@ private slots:
|
||||||
void zoneDumpReceived(int commandId, QList<ServerZoneCard *> cards);
|
void zoneDumpReceived(int commandId, QList<ServerZoneCard *> cards);
|
||||||
void slotClosePressed();
|
void slotClosePressed();
|
||||||
public:
|
public:
|
||||||
ZoneViewWidget(CardDatabase *_db, Player *_player, PlayerZone *_origZone, int numberCards = 0, QGraphicsItem *parent = 0);
|
ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_origZone, int numberCards = 0, QGraphicsItem *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
ZoneViewZone::ZoneViewZone(Player *_p, PlayerZone *_origZone, int _numberCards, QGraphicsItem *parent)
|
ZoneViewZone::ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards, QGraphicsItem *parent)
|
||||||
: PlayerZone(_p, _origZone->getName(), parent, true), numberCards(_numberCards), origZone(_origZone)
|
: CardZone(_p, _origZone->getName(), parent, true), numberCards(_numberCards), origZone(_origZone)
|
||||||
{
|
{
|
||||||
cards = new CardList(true);
|
cards = new CardList(true);
|
||||||
origZone->addView(this);
|
origZone->addView(this);
|
||||||
|
@ -85,7 +85,7 @@ void ZoneViewZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
void ZoneViewZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
Q_UNUSED(dropPoint);
|
Q_UNUSED(dropPoint);
|
||||||
qDebug(QString("handleDropEvent id=%1").arg(cardId).toLatin1());
|
qDebug(QString("handleDropEvent id=%1").arg(cardId).toLatin1());
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
#ifndef ZONEVIEWERZONE_H
|
#ifndef ZONEVIEWERZONE_H
|
||||||
#define ZONEVIEWERZONE_H
|
#define ZONEVIEWERZONE_H
|
||||||
|
|
||||||
#include "playerzone.h"
|
#include "cardzone.h"
|
||||||
#include "serverzonecard.h"
|
#include "serverzonecard.h"
|
||||||
|
|
||||||
class ZoneViewWidget;
|
class ZoneViewWidget;
|
||||||
|
|
||||||
class ZoneViewZone : public PlayerZone {
|
class ZoneViewZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
int numberCards;
|
int numberCards;
|
||||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||||
PlayerZone *origZone;
|
CardZone *origZone;
|
||||||
signals:
|
signals:
|
||||||
void removeZoneViewWidget(ZoneViewWidget *zv);
|
void removeZoneViewWidget(ZoneViewWidget *zv);
|
||||||
public:
|
public:
|
||||||
ZoneViewZone(Player *_p, PlayerZone *_origZone, int _numberCards = 0, QGraphicsItem *parent = 0);
|
ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards = 0, QGraphicsItem *parent = 0);
|
||||||
~ZoneViewZone();
|
~ZoneViewZone();
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
Loading…
Reference in a new issue