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

View file

@ -82,19 +82,15 @@ void CardZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
void CardZone::addCard(CardItem *card, bool reorganize, int x, int y)
{
dumpObjectInfo();
if (view)
if ((x <= view->getCards().size()) || (view->getNumberCards() == -1))
view->addCard(new CardItem(player, card->getName(), card->getId()), reorganize, x, y);
addCardImpl(card, x, y);
if (reorganize) {
qDebug("------------ emitting");
emit contentsChanged();
if (reorganize)
reorganizeCards();
}
}
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->setName(cardName);
emit contentsChanged();
reorganizeCards();
return c;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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