This commit is contained in:
Max-Wilhelm Bruker 2010-03-09 14:43:06 +01:00
parent 15aa6a600a
commit 929f4f9b4d
10 changed files with 14 additions and 30 deletions

View file

@ -5,7 +5,6 @@
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QCursor> #include <QCursor>
#include <QDebug>
CardDragItem::CardDragItem(AbstractCardItem *_item, int _id, const QPointF &_hotSpot, bool _faceDown, AbstractCardDragItem *parentDrag) CardDragItem::CardDragItem(AbstractCardItem *_item, int _id, const QPointF &_hotSpot, bool _faceDown, AbstractCardDragItem *parentDrag)
: AbstractCardDragItem(_item, _hotSpot, parentDrag), id(_id), faceDown(_faceDown), currentZone(0) : AbstractCardDragItem(_item, _hotSpot, parentDrag), id(_id), faceDown(_faceDown), currentZone(0)
@ -20,21 +19,16 @@ void CardDragItem::updatePosition(const QPointF &cursorScenePos)
ZoneViewZone *zoneViewZone = 0; ZoneViewZone *zoneViewZone = 0;
for (int i = colliding.size() - 1; i >= 0; i--) { for (int i = colliding.size() - 1; i >= 0; i--) {
CardZone *temp = qgraphicsitem_cast<CardZone *>(colliding.at(i)); CardZone *temp = qgraphicsitem_cast<CardZone *>(colliding.at(i));
if (temp)
qDebug() << "zone name:" << temp->getName();
if (!cardZone) if (!cardZone)
cardZone = temp; cardZone = temp;
if (!zoneViewZone) if (!zoneViewZone)
zoneViewZone = qobject_cast<ZoneViewZone *>(temp); zoneViewZone = qobject_cast<ZoneViewZone *>(temp);
} }
CardZone *cursorZone = 0; CardZone *cursorZone = 0;
if (zoneViewZone) { if (zoneViewZone)
qDebug() << "zv found";
cursorZone = zoneViewZone; cursorZone = zoneViewZone;
} else if (cardZone) { else if (cardZone)
qDebug() << "normal found";
cursorZone = cardZone; cursorZone = cardZone;
}
if (!cursorZone) if (!cursorZone)
return; return;
currentZone = cursorZone; currentZone = cursorZone;

View file

@ -82,18 +82,14 @@ void CardZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
void CardZone::addCard(CardItem *card, bool reorganize, int x, int y) void CardZone::addCard(CardItem *card, bool reorganize, int x, int y)
{ {
dumpObjectInfo();
if (view) if (view)
if ((x <= view->getCards().size()) || (view->getNumberCards() == -1)) if ((x <= view->getCards().size()) || (view->getNumberCards() == -1))
view->addCard(new CardItem(player, card->getName(), card->getId()), reorganize, x, y); view->addCard(new CardItem(player, card->getName(), card->getId()), reorganize, x, y);
addCardImpl(card, x, y); addCardImpl(card, x, y);
if (reorganize) { if (reorganize)
qDebug("------------ emitting");
emit contentsChanged();
reorganizeCards(); reorganizeCards();
}
} }
CardItem *CardZone::getCard(int cardId, const QString &cardName) CardItem *CardZone::getCard(int cardId, const QString &cardName)
@ -137,7 +133,6 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName,
c->setId(cardId); c->setId(cardId);
c->setName(cardName); c->setName(cardName);
emit contentsChanged();
reorganizeCards(); reorganizeCards();
return c; return c;
} }

View file

@ -27,8 +27,6 @@ protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void addCardImpl(CardItem *card, int x, int y) = 0; virtual void addCardImpl(CardItem *card, int x, int y) = 0;
signals:
void contentsChanged();
public slots: public slots:
void moveAllToZone(); void moveAllToZone();
public: public:

View file

@ -3,7 +3,6 @@
#include "decklist.h" #include "decklist.h"
#include "carddatabase.h" #include "carddatabase.h"
#include "main.h" #include "main.h"
#include <QDebug>
DeckViewCardDragItem::DeckViewCardDragItem(DeckViewCard *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag) DeckViewCardDragItem::DeckViewCardDragItem(DeckViewCard *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag)
: AbstractCardDragItem(_item, _hotSpot, parentDrag) : AbstractCardDragItem(_item, _hotSpot, parentDrag)

View file

@ -83,6 +83,7 @@ void GameScene::toggleZoneView(Player *player, const QString &zoneName, int numb
views.append(item); views.append(item);
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeZoneView(ZoneViewWidget *))); connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeZoneView(ZoneViewWidget *)));
addItem(item); addItem(item);
item->setPos(100, 100);
} }
void GameScene::removeZoneView(ZoneViewWidget *item) void GameScene::removeZoneView(ZoneViewWidget *item)

View file

@ -601,12 +601,6 @@ void Player::eventMoveCard(Event_MoveCard *event)
if (!startZone || !targetZone) if (!startZone || !targetZone)
return; return;
qDebug("Player::eventMoveCard --- startZone");
startZone->dumpObjectInfo();
qDebug("Player::eventMoveCard --- targetZone");
targetZone->dumpObjectInfo();
qDebug("---");
int position = event->getPosition(); int position = event->getPosition();
int x = event->getX(); int x = event->getX();
int y = event->getY(); int y = event->getY();
@ -747,13 +741,16 @@ void Player::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/
void Player::processPlayerInfo(ServerInfo_Player *info) void Player::processPlayerInfo(ServerInfo_Player *info)
{ {
QMapIterator<QString, CardZone *> zoneIt(zones);
while (zoneIt.hasNext())
zoneIt.next().value()->clearContents();
for (int i = 0; i < info->getZoneList().size(); ++i) { for (int i = 0; i < info->getZoneList().size(); ++i) {
ServerInfo_Zone *zoneInfo = info->getZoneList()[i]; ServerInfo_Zone *zoneInfo = info->getZoneList()[i];
CardZone *zone = zones.value(zoneInfo->getName(), 0); CardZone *zone = zones.value(zoneInfo->getName(), 0);
if (!zone) if (!zone)
continue; continue;
zone->clearContents();
const QList<ServerInfo_Card *> &cardList = zoneInfo->getCardList(); const QList<ServerInfo_Card *> &cardList = zoneInfo->getCardList();
if (cardList.isEmpty()) { if (cardList.isEmpty()) {
for (int j = 0; j < zoneInfo->getCardCount(); ++j) for (int j = 0; j < zoneInfo->getCardCount(); ++j)

View file

@ -39,7 +39,6 @@ void ZoneViewZone::initializeCards()
CardItem *card = c.at(i); CardItem *card = c.at(i);
addCard(new CardItem(player, card->getName(), card->getId(), this), false, i); addCard(new CardItem(player, card->getName(), card->getId(), this), false, i);
} }
emit contentsChanged();
reorganizeCards(); reorganizeCards();
} }
} }
@ -56,7 +55,6 @@ void ZoneViewZone::zoneDumpReceived(ProtocolResponse *r)
addCard(card, false, i); addCard(card, false, i);
} }
emit contentsChanged();
reorganizeCards(); reorganizeCards();
} }

View file

@ -154,6 +154,11 @@ void Server_Game::stopGameIfFinished()
return; return;
gameStarted = false; gameStarted = false;
playerIterator.toFront();
while (playerIterator.hasNext())
playerIterator.next().value()->clearZones();
playerIterator.toFront(); playerIterator.toFront();
while (playerIterator.hasNext()) { while (playerIterator.hasNext()) {
Server_Player *player = playerIterator.next().value(); Server_Player *player = playerIterator.next().value();

View file

@ -53,9 +53,6 @@ int Server_Player::newArrowId() const
void Server_Player::setupZones() void Server_Player::setupZones()
{ {
// Delete existing zones and counters
clearZones();
// This may need to be customized according to the game rules. // This may need to be customized according to the game rules.
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View file

@ -29,7 +29,6 @@ private:
bool spectator; bool spectator;
int initialCards; int initialCards;
int nextCardId; int nextCardId;
void clearZones();
bool readyStart; bool readyStart;
bool conceded; bool conceded;
int deckId; int deckId;
@ -68,6 +67,7 @@ public:
void addCounter(Server_Counter *counter); void addCounter(Server_Counter *counter);
bool deleteCounter(int counterId); bool deleteCounter(int counterId);
void clearZones();
void setupZones(); void setupZones();
void sendProtocolItem(ProtocolItem *item, bool deleteItem = true); void sendProtocolItem(ProtocolItem *item, bool deleteItem = true);