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
|
||||
|
||||
# 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
|
||||
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
|
||||
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/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 "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
#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)
|
||||
{
|
||||
if ((hotSpot.x() < 0) || (hotSpot.y() < 0)) {
|
||||
|
@ -46,9 +46,9 @@ void CardDragItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
QPointF sp = event->scenePos();
|
||||
QList<QGraphicsItem *> colliding = scene()->items(sp);
|
||||
|
||||
PlayerZone *cursorZone = 0;
|
||||
CardZone *cursorZone = 0;
|
||||
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") {
|
||||
QPointF cp = cursorZone->scenePos();
|
||||
QPointF localpos = sp - hotSpot - cp;
|
||||
|
@ -70,12 +70,12 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
QList<QGraphicsItem *> colliding = sc->items(event->scenePos());
|
||||
|
||||
qDebug(QString("drop: %1 collisions").arg(colliding.size()).toLatin1());
|
||||
PlayerZone *dropZone = 0;
|
||||
CardZone *dropZone = 0;
|
||||
for (int i = colliding.size() - 1; i >= 0; i--) {
|
||||
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());
|
||||
|
||||
if ((dropZone = qgraphicsitem_cast<PlayerZone *>(colliding.at(i)))) {
|
||||
if ((dropZone = qgraphicsitem_cast<CardZone *>(colliding.at(i)))) {
|
||||
qDebug("zone found");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
#include "carditem.h"
|
||||
|
||||
class QGraphicsScene;
|
||||
class PlayerZone;
|
||||
class CardZone;
|
||||
|
||||
class CardDragItem : public QGraphicsItem {
|
||||
private:
|
||||
QPixmap *image;
|
||||
int id;
|
||||
QPointF hotSpot;
|
||||
PlayerZone *startZone;
|
||||
CardZone *startZone;
|
||||
public:
|
||||
enum { Type = typeCardDrag };
|
||||
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();
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "carditem.h"
|
||||
#include "carddragitem.h"
|
||||
#include "carddatabase.h"
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
#include "tablezone.h"
|
||||
#include "player.h"
|
||||
|
||||
|
@ -105,7 +105,7 @@ void CardItem::resetState()
|
|||
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->setPos(_scenePos - dragItem->getHotSpot());
|
||||
|
@ -128,7 +128,7 @@ void CardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (event->button() == Qt::LeftButton) {
|
||||
setCursor(Qt::ClosedHandCursor);
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
qgraphicsitem_cast<PlayerZone *>(parentItem())->getPlayer()->showCardMenu(event->screenPos());
|
||||
qgraphicsitem_cast<CardZone *>(parentItem())->getPlayer()->showCardMenu(event->screenPos());
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() < QApplication::startDragDistance())
|
||||
return;
|
||||
|
||||
createDragItem((PlayerZone *) parentItem(), id, event->pos(), event->scenePos());
|
||||
createDragItem((CardZone *) parentItem(), id, event->pos(), event->scenePos());
|
||||
dragItem->grabMouse();
|
||||
|
||||
QList<QGraphicsItem *> sel = scene()->selectedItems();
|
||||
|
@ -146,7 +146,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
CardItem *c = (CardItem *) sel.at(i);
|
||||
if (c == this)
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
event->accept();
|
||||
|
||||
PlayerZone *zone = (PlayerZone *) parentItem();
|
||||
CardZone *zone = (CardZone *) parentItem();
|
||||
// Do nothing if the card belongs to another player
|
||||
if (!zone->getPlayer()->getLocal())
|
||||
return;
|
||||
|
@ -180,7 +180,7 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
void CardItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
((PlayerZone *) parentItem())->hoverCardEvent(this);
|
||||
((CardZone *) parentItem())->hoverCardEvent(this);
|
||||
QGraphicsItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class CardDatabase;
|
||||
class CardDragItem;
|
||||
class PlayerZone;
|
||||
class CardZone;
|
||||
|
||||
|
||||
const int CARD_WIDTH = 72;
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
void setAnnotation(const QString &_annotation);
|
||||
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();
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#include <QtGui>
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
#include "carditem.h"
|
||||
#include "player.h"
|
||||
#include "client.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)
|
||||
{
|
||||
if (!isView)
|
||||
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())
|
||||
delete views.at(0);
|
||||
|
||||
|
@ -22,14 +22,14 @@ PlayerZone::~PlayerZone()
|
|||
delete cards;
|
||||
}
|
||||
|
||||
void PlayerZone::clearContents()
|
||||
void CardZone::clearContents()
|
||||
{
|
||||
for (int i = 0; i < cards->size(); i++)
|
||||
delete cards->at(i);
|
||||
cards->clear();
|
||||
}
|
||||
|
||||
void PlayerZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
void CardZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) {
|
||||
if (menu) {
|
||||
|
@ -41,7 +41,7 @@ void PlayerZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
event->ignore();
|
||||
}
|
||||
|
||||
CardItem *PlayerZone::getCard(int cardId, const QString &cardName)
|
||||
CardItem *CardZone::getCard(int cardId, const QString &cardName)
|
||||
{
|
||||
CardItem *c = cards->findCard(cardId, false);
|
||||
// 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;
|
||||
}
|
||||
|
||||
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);
|
||||
for (int i = 0; i < views.size(); i++)
|
||||
|
@ -68,28 +68,28 @@ CardItem *PlayerZone::takeCard(int position, int cardId, const QString &cardName
|
|||
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)
|
||||
player->client->setCardAttr(name, cardId, aname, avalue);
|
||||
}
|
||||
|
||||
void PlayerZone::hoverCardEvent(CardItem *card)
|
||||
void CardZone::hoverCardEvent(CardItem *card)
|
||||
{
|
||||
player->hoverCardEvent(card);
|
||||
}
|
||||
|
||||
void PlayerZone::addView(ZoneViewZone *view)
|
||||
void CardZone::addView(ZoneViewZone *view)
|
||||
{
|
||||
views.append(view);
|
||||
}
|
||||
|
||||
void PlayerZone::removeView(ZoneViewZone *view)
|
||||
void CardZone::removeView(ZoneViewZone *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' list index doesn't change
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef PLAYERZONE_H
|
||||
#define PLAYERZONE_H
|
||||
#ifndef CARDZONE_H
|
||||
#define CARDZONE_H
|
||||
|
||||
#include <QString>
|
||||
#include "cardlist.h"
|
||||
|
@ -8,7 +8,7 @@ class Player;
|
|||
class ZoneViewZone;
|
||||
class QMenu;
|
||||
|
||||
class PlayerZone : public QGraphicsItem {
|
||||
class CardZone : public QGraphicsItem {
|
||||
protected:
|
||||
Player *player;
|
||||
QString name;
|
||||
|
@ -20,9 +20,9 @@ protected:
|
|||
public:
|
||||
enum { Type = typeZone };
|
||||
int type() const { return Type; }
|
||||
virtual void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint) = 0;
|
||||
PlayerZone(Player *_player, const QString &_name, QGraphicsItem *parent = 0, bool isView = false);
|
||||
~PlayerZone();
|
||||
virtual void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint) = 0;
|
||||
CardZone(Player *_player, const QString &_name, QGraphicsItem *parent = 0, bool isView = false);
|
||||
~CardZone();
|
||||
void clearContents();
|
||||
bool getHasCardAttr() const { return hasCardAttr; }
|
||||
QMenu *getMenu() const { return menu; }
|
|
@ -305,7 +305,7 @@ void Game::actTap()
|
|||
QListIterator<QGraphicsItem *> i(scene->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
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());
|
||||
while (i.hasNext()) {
|
||||
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()) {
|
||||
CardItem *temp = (CardItem *) i.next();
|
||||
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()) {
|
||||
CardItem *temp = (CardItem *) i.next();
|
||||
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());
|
||||
while (i.hasNext()) {
|
||||
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++) {
|
||||
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;
|
||||
y = y_initial + (i % 3) * RASTER_HEIGHT;
|
||||
client->moveCard(temp->getId(), zoneName, zoneName, x, y);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "zoneviewzone.h"
|
||||
|
||||
GraveZone::GraveZone(Player *_p)
|
||||
: PlayerZone(_p, "grave")
|
||||
: CardZone(_p, "grave")
|
||||
{
|
||||
cards = new CardList(true);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void GraveZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef GRAVEZONE_H
|
||||
#define GRAVEZONE_H
|
||||
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
|
||||
class GraveZone : public PlayerZone {
|
||||
class GraveZone : public CardZone {
|
||||
private:
|
||||
public:
|
||||
GraveZone(Player *_p);
|
||||
|
@ -11,7 +11,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||
void reorganizeCards();
|
||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "client.h"
|
||||
|
||||
HandZone::HandZone(Player *_p)
|
||||
: PlayerZone(_p, "hand")
|
||||
: CardZone(_p, "hand")
|
||||
{
|
||||
cards = new CardList(player->getLocal());
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ void HandZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
reorganizeCards();
|
||||
}
|
||||
|
||||
void HandZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
||||
void HandZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||
{
|
||||
Q_UNUSED(dropPoint);
|
||||
player->client->moveCard(cardId, startZone->getName(), getName(), cards->size(), 0);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef HANDZONE_H
|
||||
#define HANDZONE_H
|
||||
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
|
||||
class HandZone : public PlayerZone {
|
||||
class HandZone : public CardZone {
|
||||
private:
|
||||
public:
|
||||
HandZone(Player *_p);
|
||||
|
@ -11,7 +11,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void addCard(CardItem *card, bool reorganize = true, int x = -1, int y = -1);
|
||||
void reorganizeCards();
|
||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "zoneviewzone.h"
|
||||
|
||||
LibraryZone::LibraryZone(Player *_p)
|
||||
: PlayerZone(_p, "deck")
|
||||
: CardZone(_p, "deck")
|
||||
{
|
||||
cards = new CardList(false);
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
|
@ -47,7 +47,7 @@ void LibraryZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
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);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void LibraryZone::reorganizeCards()
|
|||
|
||||
void LibraryZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
PlayerZone::mousePressEvent(event);
|
||||
CardZone::mousePressEvent(event);
|
||||
if (event->isAccepted())
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef LIBRARYZONE_H
|
||||
#define LIBRARYZONE_H
|
||||
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
|
||||
class LibraryZone : public PlayerZone {
|
||||
class LibraryZone : public CardZone {
|
||||
private:
|
||||
public:
|
||||
LibraryZone(Player *_p);
|
||||
|
@ -11,7 +11,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||
void reorganizeCards();
|
||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
protected:
|
||||
void mousePressEvent(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);
|
||||
|
||||
PlayerZone *hand = new HandZone(this);
|
||||
CardZone *hand = new HandZone(this);
|
||||
hand->setPos(_base);
|
||||
_base += QPointF(hand->boundingRect().width(), 0);
|
||||
|
||||
PlayerZone *table = new TableZone(this);
|
||||
CardZone *table = new TableZone(this);
|
||||
table->setPos(_base);
|
||||
|
||||
aMoveHandToTopLibrary = new QAction(tr("Move to &top of library"), this);
|
||||
|
@ -99,13 +99,13 @@ Player::~Player()
|
|||
|
||||
void Player::actMoveHandToTopLibrary()
|
||||
{
|
||||
PlayerZone *library = zones.findZone("deck");
|
||||
CardZone *library = zones.findZone("deck");
|
||||
zones.findZone("hand")->moveAllToZone(library->getName(), 0);
|
||||
}
|
||||
|
||||
void Player::actMoveHandToBottomLibrary()
|
||||
{
|
||||
PlayerZone *library = zones.findZone("deck");
|
||||
CardZone *library = zones.findZone("deck");
|
||||
zones.findZone("hand")->moveAllToZone(library->getName(), library->getCards()->size());
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ void Player::actViewSideboard()
|
|||
emit addZoneView(this, "sb", 0);
|
||||
}
|
||||
|
||||
void Player::addZone(PlayerZone *z)
|
||||
void Player::addZone(CardZone *z)
|
||||
{
|
||||
zones << z;
|
||||
}
|
||||
|
@ -167,12 +167,12 @@ void Player::gameEvent(ServerEventData *event)
|
|||
Counter *lifeCounter = counters.findCounter("life");
|
||||
lifeCounter->setValue(life);
|
||||
|
||||
PlayerZone *deck = zones.findZone("deck");
|
||||
CardZone *deck = zones.findZone("deck");
|
||||
for (; deck_cards; deck_cards--)
|
||||
deck->addCard(new CardItem(db, QString(), -1));
|
||||
deck->reorganizeCards();
|
||||
|
||||
PlayerZone *sb = zones.findZone("sb");
|
||||
CardZone *sb = zones.findZone("sb");
|
||||
for (; sb_cards; sb_cards--)
|
||||
sb->addCard(new CardItem(db, QString(), -1));
|
||||
sb->reorganizeCards();
|
||||
|
@ -180,8 +180,8 @@ void Player::gameEvent(ServerEventData *event)
|
|||
break;
|
||||
}
|
||||
case eventDraw: {
|
||||
PlayerZone *deck = zones.findZone("deck");
|
||||
PlayerZone *hand = zones.findZone("hand");
|
||||
CardZone *deck = zones.findZone("deck");
|
||||
CardZone *hand = zones.findZone("hand");
|
||||
if (!event->getPublic()) {
|
||||
hand->addCard(deck->takeCard(0, data[0].toInt(), data[1]));
|
||||
} else {
|
||||
|
@ -198,11 +198,11 @@ void Player::gameEvent(ServerEventData *event)
|
|||
}
|
||||
int cardId = data[0].toInt();
|
||||
QString cardName = data[1];
|
||||
PlayerZone *startZone = zones.findZone(data[2]);
|
||||
CardZone *startZone = zones.findZone(data[2]);
|
||||
if (!startZone)
|
||||
qDebug(QString("start zone invalid: %1").arg(data[2]).toLatin1());
|
||||
int position = data[3].toInt();
|
||||
PlayerZone *targetZone = zones.findZone(data[4]);
|
||||
CardZone *targetZone = zones.findZone(data[4]);
|
||||
if (!targetZone)
|
||||
qDebug(QString("target zone invalid: %1").arg(data[4]).toLatin1());
|
||||
int x = data[5].toInt();
|
||||
|
@ -228,7 +228,7 @@ void Player::gameEvent(ServerEventData *event)
|
|||
if (data.size() != 6) {
|
||||
qDebug("error");
|
||||
}
|
||||
PlayerZone *zone = zones.findZone(data[0]);
|
||||
CardZone *zone = zones.findZone(data[0]);
|
||||
int cardid = data[1].toInt();
|
||||
QString cardname = data[2];
|
||||
QString powtough = data[3];
|
||||
|
@ -246,7 +246,7 @@ void Player::gameEvent(ServerEventData *event)
|
|||
if (data.size() != 4) {
|
||||
// XXX
|
||||
}
|
||||
PlayerZone *zone = zones.findZone(data[0]);
|
||||
CardZone *zone = zones.findZone(data[0]);
|
||||
int cardId = data[1].toInt();
|
||||
CardItem *card = zone->getCard(cardId, "");
|
||||
QString aname = data[2];
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
CardDatabase *db;
|
||||
public:
|
||||
Client *client;
|
||||
void addZone(PlayerZone *z);
|
||||
void addZone(CardZone *z);
|
||||
void addCounter(Counter *c);
|
||||
Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client);
|
||||
~Player();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "zoneviewzone.h"
|
||||
|
||||
RfgZone::RfgZone(Player *_p)
|
||||
: PlayerZone(_p, "rfg")
|
||||
: CardZone(_p, "rfg")
|
||||
{
|
||||
cards = new CardList(true);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void RfgZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef RFGZONE_H
|
||||
#define RFGZONE_H
|
||||
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
|
||||
class RfgZone : public PlayerZone {
|
||||
class RfgZone : public CardZone {
|
||||
private:
|
||||
public:
|
||||
RfgZone(Player *_p);
|
||||
|
@ -11,7 +11,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||
void reorganizeCards();
|
||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "zoneviewzone.h"
|
||||
|
||||
SideboardZone::SideboardZone(Player *_p)
|
||||
: PlayerZone(_p, "sb")
|
||||
: CardZone(_p, "sb")
|
||||
{
|
||||
cards = new CardList(false);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void SideboardZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef SIDEBOARDZONE_H
|
||||
#define SIDEBOARDZONE_H
|
||||
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
|
||||
class SideboardZone : public PlayerZone {
|
||||
class SideboardZone : public CardZone {
|
||||
private:
|
||||
public:
|
||||
SideboardZone(Player *_p);
|
||||
|
@ -11,7 +11,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void addCard(CardItem *card, bool reorganize = true, int x = 0, int y = -1);
|
||||
void reorganizeCards();
|
||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "client.h"
|
||||
|
||||
TableZone::TableZone(Player *_p)
|
||||
: PlayerZone(_p, "table"), width(700), height(500)
|
||||
: CardZone(_p, "table"), width(700), height(500)
|
||||
{
|
||||
cards = new CardList(true);
|
||||
hasCardAttr = true;
|
||||
|
@ -37,7 +37,7 @@ void TableZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
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());
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef TABLEZONE_H
|
||||
#define TABLEZONE_H
|
||||
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
|
||||
const int GRID_WIDTH = 30;
|
||||
const int GRID_HEIGHT = 30;
|
||||
|
||||
class TableZone : public PlayerZone {
|
||||
class TableZone : public CardZone {
|
||||
private:
|
||||
int width, height;
|
||||
public:
|
||||
|
@ -16,7 +16,7 @@ public:
|
|||
void addCard(CardItem *card, bool reorganize = true, int x = -1, int y = -1);
|
||||
void reorganizeCards();
|
||||
void toggleTapped();
|
||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "zonelist.h"
|
||||
|
||||
PlayerZone *ZoneList::findZone(const QString &name) const
|
||||
CardZone *ZoneList::findZone(const QString &name) const
|
||||
{
|
||||
for (int i = 0; i < size(); i++) {
|
||||
PlayerZone *temp = at(i);
|
||||
CardZone *temp = at(i);
|
||||
if (!temp->getName().compare(name))
|
||||
return temp;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef ZONELIST_H
|
||||
#define ZONELIST_H
|
||||
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
#include <QList>
|
||||
|
||||
class ZoneList : public QList<PlayerZone *> {
|
||||
class ZoneList : public QList<CardZone *> {
|
||||
public:
|
||||
PlayerZone *findZone(const QString &name) const;
|
||||
CardZone *findZone(const QString &name) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "client.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)
|
||||
{
|
||||
ZoneCloseButton *closeButton = new ZoneCloseButton(this);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <QGraphicsWidget>
|
||||
#include "serverzonecard.h"
|
||||
|
||||
class PlayerZone;
|
||||
class CardZone;
|
||||
class ZoneViewZone;
|
||||
class Player;
|
||||
class CardDatabase;
|
||||
|
@ -25,7 +25,7 @@ private slots:
|
|||
void zoneDumpReceived(int commandId, QList<ServerZoneCard *> cards);
|
||||
void slotClosePressed();
|
||||
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
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include "player.h"
|
||||
#include "client.h"
|
||||
|
||||
ZoneViewZone::ZoneViewZone(Player *_p, PlayerZone *_origZone, int _numberCards, QGraphicsItem *parent)
|
||||
: PlayerZone(_p, _origZone->getName(), parent, true), numberCards(_numberCards), origZone(_origZone)
|
||||
ZoneViewZone::ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards, QGraphicsItem *parent)
|
||||
: CardZone(_p, _origZone->getName(), parent, true), numberCards(_numberCards), origZone(_origZone)
|
||||
{
|
||||
cards = new CardList(true);
|
||||
origZone->addView(this);
|
||||
|
@ -85,7 +85,7 @@ void ZoneViewZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
reorganizeCards();
|
||||
}
|
||||
|
||||
void ZoneViewZone::handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint)
|
||||
void ZoneViewZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint)
|
||||
{
|
||||
Q_UNUSED(dropPoint);
|
||||
qDebug(QString("handleDropEvent id=%1").arg(cardId).toLatin1());
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#ifndef ZONEVIEWERZONE_H
|
||||
#define ZONEVIEWERZONE_H
|
||||
|
||||
#include "playerzone.h"
|
||||
#include "cardzone.h"
|
||||
#include "serverzonecard.h"
|
||||
|
||||
class ZoneViewWidget;
|
||||
|
||||
class ZoneViewZone : public PlayerZone {
|
||||
class ZoneViewZone : public CardZone {
|
||||
private:
|
||||
int numberCards;
|
||||
void handleDropEvent(int cardId, PlayerZone *startZone, const QPoint &dropPoint);
|
||||
PlayerZone *origZone;
|
||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint);
|
||||
CardZone *origZone;
|
||||
signals:
|
||||
void removeZoneViewWidget(ZoneViewWidget *zv);
|
||||
public:
|
||||
ZoneViewZone(Player *_p, PlayerZone *_origZone, int _numberCards = 0, QGraphicsItem *parent = 0);
|
||||
ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards = 0, QGraphicsItem *parent = 0);
|
||||
~ZoneViewZone();
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
|
Loading…
Reference in a new issue