hand counter

This commit is contained in:
Max-Wilhelm Bruker 2010-05-29 16:37:41 +02:00
parent 0d63bb7316
commit aaf236d0b4
5 changed files with 14 additions and 0 deletions

View file

@ -20,6 +20,7 @@ HEADERS += src/counter.h \
src/carditem.h \ src/carditem.h \
src/tablezone.h \ src/tablezone.h \
src/handzone.h \ src/handzone.h \
src/handcounter.h \
src/carddatabase.h \ src/carddatabase.h \
src/gameview.h \ src/gameview.h \
src/deck_picturecacher.h \ src/deck_picturecacher.h \
@ -73,6 +74,7 @@ SOURCES += src/counter.cpp \
src/carditem.cpp \ src/carditem.cpp \
src/tablezone.cpp \ src/tablezone.cpp \
src/handzone.cpp \ src/handzone.cpp \
src/handcounter.cpp \
src/carddatabase.cpp \ src/carddatabase.cpp \
src/gameview.cpp \ src/gameview.cpp \
src/deck_picturecacher.cpp \ src/deck_picturecacher.cpp \

View file

@ -18,6 +18,7 @@
<file>resources/icon_phase_main2.svg</file> <file>resources/icon_phase_main2.svg</file>
<file>resources/icon_phase_cleanup.svg</file> <file>resources/icon_phase_cleanup.svg</file>
<file>resources/icon_nextturn.svg</file> <file>resources/icon_nextturn.svg</file>
<file>resources/hand.svg</file>
<file>resources/pencil.svg</file> <file>resources/pencil.svg</file>
<file>resources/icon_search.svg</file> <file>resources/icon_search.svg</file>
<file>resources/icon_clearsearch.svg</file> <file>resources/icon_clearsearch.svg</file>

View file

@ -24,6 +24,7 @@ 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();
emit cardCountChanged();
} }
QString CardZone::getTranslatedName(bool hisOwn, GrammaticalCase gc) const QString CardZone::getTranslatedName(bool hisOwn, GrammaticalCase gc) const
@ -90,6 +91,8 @@ void CardZone::addCard(CardItem *card, bool reorganize, int x, int y)
if (reorganize) if (reorganize)
reorganizeCards(); reorganizeCards();
emit cardCountChanged();
} }
CardItem *CardZone::getCard(int cardId, const QString &cardName) CardItem *CardZone::getCard(int cardId, const QString &cardName)
@ -134,6 +137,7 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName,
c->setName(cardName); c->setName(cardName);
reorganizeCards(); reorganizeCards();
emit cardCountChanged();
return c; return c;
} }

View file

@ -27,6 +27,8 @@ 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 cardCountChanged();
public slots: public slots:
void moveAllToZone(); void moveAllToZone();
public: public:

View file

@ -8,6 +8,7 @@
#include "pilezone.h" #include "pilezone.h"
#include "tablezone.h" #include "tablezone.h"
#include "handzone.h" #include "handzone.h"
#include "handcounter.h"
#include "cardlist.h" #include "cardlist.h"
#include "tab_game.h" #include "tab_game.h"
#include "protocol_items.h" #include "protocol_items.h"
@ -41,9 +42,13 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
PileZone *sb = new PileZone(this, "sb", false, false, this); PileZone *sb = new PileZone(this, "sb", false, false, this);
sb->setVisible(false); sb->setVisible(false);
HandCounter *handCounter = new HandCounter(this);
handCounter->setPos(base + QPointF(0, 3 * h));
table = new TableZone(this, this); table = new TableZone(this, this);
connect(table, SIGNAL(sizeChanged()), this, SLOT(updateBoundingRect())); connect(table, SIGNAL(sizeChanged()), this, SLOT(updateBoundingRect()));
hand = new HandZone(this, (int) table->boundingRect().height(), this); hand = new HandZone(this, (int) table->boundingRect().height(), this);
connect(hand, SIGNAL(cardCountChanged()), handCounter, SLOT(updateNumber()));
base = QPointF(deck->boundingRect().width() + counterAreaWidth + 5, 0); base = QPointF(deck->boundingRect().width() + counterAreaWidth + 5, 0);
hand->setPos(base); hand->setPos(base);