unimportant changes

This commit is contained in:
Max-Wilhelm Bruker 2009-06-10 21:17:24 +02:00
parent 4054afc759
commit 7f659573bc
21 changed files with 89 additions and 51 deletions

View file

@ -43,6 +43,7 @@ public:
CardItem *takeCard(int position, int cardId, const QString &cardName);
void setCardAttr(int cardId, const QString &aname, const QString &avalue);
void hoverCardEvent(CardItem *card);
ZoneViewZone *getView() const { return view; }
void setView(ZoneViewZone *_view);
virtual void reorganizeCards() = 0;
void moveAllToZone(const QString &targetZone, int targetX);

View file

@ -43,6 +43,7 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
connect(aDraw, SIGNAL(triggered()), this, SLOT(actDrawCard()));
aDrawCards = new QAction(tr("D&raw cards..."), this);
connect(aDrawCards, SIGNAL(triggered()), this, SLOT(actDrawCards()));
aDrawCards->setShortcut(tr("Ctrl+C"));
aRollDice = new QAction(tr("R&oll dice..."), this);
aRollDice->setShortcut(tr("Ctrl+I"));
connect(aRollDice, SIGNAL(triggered()), this, SLOT(actRollDice()));
@ -182,10 +183,8 @@ void Game::gameEvent(const ServerEventData &msg)
if (started) {
started = false;
emit logReadyStart(p->getName());
if (!p->getLocal()) {
// XXX Zoneviews schließen
if (!p->getLocal())
restartGameDialog();
}
}
break;
case eventGameStart:

View file

@ -3,6 +3,7 @@
#include "cardzone.h"
#include "playerarea.h"
#include "counter.h"
#include "zoneviewzone.h"
#include <QGraphicsScene>
#include <QMenu>
@ -85,7 +86,7 @@ void Player::actMoveHandToBottomLibrary()
void Player::actViewLibrary()
{
emit addZoneView(this, "deck", 0);
emit toggleZoneView(this, "deck", 0);
}
void Player::actViewTopCards()
@ -94,23 +95,23 @@ void Player::actViewTopCards()
int number = QInputDialog::getInteger(0, tr("View top cards of library"), tr("Number of cards:"), defaultNumberTopCards, 1, 2000000000, 1, &ok);
if (ok) {
defaultNumberTopCards = number;
emit addZoneView(this, "deck", number);
emit toggleZoneView(this, "deck", number);
}
}
void Player::actViewGraveyard()
{
emit addZoneView(this, "grave", 0);
emit toggleZoneView(this, "grave", 0);
}
void Player::actViewRfg()
{
emit addZoneView(this, "rfg", 0);
emit toggleZoneView(this, "rfg", 0);
}
void Player::actViewSideboard()
{
emit addZoneView(this, "sb", 0);
emit toggleZoneView(this, "sb", 0);
}
void Player::addZone(CardZone *z)
@ -155,8 +156,11 @@ void Player::gameEvent(const ServerEventData &event)
// XXX Fehlerbehandlung
// Clean up existing zones first
for (int i = 0; i < zones.size(); i++)
for (int i = 0; i < zones.size(); i++) {
if (ZoneViewZone *view = zones.at(i)->getView())
emit closeZoneView(view);
zones.at(i)->clearContents();
}
area->clearCounters();

View file

@ -11,13 +11,15 @@ class CardDatabase;
class QMenu;
class QAction;
class PlayerArea;
class ZoneViewZone;
class Player : public QObject {
Q_OBJECT
signals:
void moveCard(int cardId, QString startZone, QString targetZone, int x, int y);
void hoverCard(QString name);
void addZoneView(Player *player, QString zoneName, int number);
void closeZoneView(ZoneViewZone *zone);
void toggleZoneView(Player *player, QString zoneName, int number);
void sigShowCardMenu(QPoint p);
// Log events
void logMoveCard(QString playerName, QString cardName, QString startZone, QString targetZone);

View file

@ -43,7 +43,8 @@ void MainWindow::hoverCard(QString name)
void MainWindow::playerAdded(Player *player)
{
menuBar()->addMenu(player->getPlayerMenu());
connect(player, SIGNAL(addZoneView(Player *, QString, int)), zoneLayout, SLOT(addItem(Player *, QString, int)));
connect(player, SIGNAL(toggleZoneView(Player *, QString, int)), zoneLayout, SLOT(toggleZoneView(Player *, QString, int)));
connect(player, SIGNAL(closeZoneView(ZoneViewZone *)), zoneLayout, SLOT(removeItem(ZoneViewZone *)));
}
void MainWindow::playerRemoved(Player *player)

View file

@ -1,5 +1,6 @@
#include "zoneviewlayout.h"
#include "zoneviewwidget.h"
#include "zoneviewzone.h"
#include "player.h"
ZoneViewLayout::ZoneViewLayout(CardDatabase *_db, QGraphicsItem *parent)
@ -30,8 +31,17 @@ void ZoneViewLayout::reorganize()
emit sizeChanged();
}
void ZoneViewLayout::addItem(Player *player, const QString &zoneName, int numberCards)
void ZoneViewLayout::toggleZoneView(Player *player, const QString &zoneName, int numberCards)
{
for (int i = 0; i < views.size(); i++) {
ZoneViewZone *temp = views[i]->getZone();
if ((temp->getName() == zoneName) && (temp->getPlayer() == player)) { // view is already open
removeItem(views[i]);
if (temp->getNumberCards() == numberCards)
return;
}
}
ZoneViewWidget *item = new ZoneViewWidget(db, player, player->getZones()->findZone(zoneName), numberCards, this);
views.append(item);
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeItem(ZoneViewWidget *)));
@ -46,6 +56,11 @@ void ZoneViewLayout::removeItem(ZoneViewWidget *item)
reorganize();
}
void ZoneViewLayout::removeItem(ZoneViewZone *item)
{
removeItem(dynamic_cast<ZoneViewWidget *>(item->parentItem()));
}
void ZoneViewLayout::closeMostRecentZoneView()
{
if (views.isEmpty())

View file

@ -5,6 +5,7 @@
class CardDatabase;
class ZoneViewWidget;
class ZoneViewZone;
class Player;
class ZoneViewLayout : public QGraphicsWidget {
@ -18,8 +19,9 @@ public:
ZoneViewLayout(CardDatabase *_db, QGraphicsItem *parent = 0);
void reorganize();
public slots:
void addItem(Player *player, const QString &zoneName, int numberCards = 0);
void toggleZoneView(Player *player, const QString &zoneName, int numberCards = 0);
void removeItem(ZoneViewWidget *item);
void removeItem(ZoneViewZone *item);
void closeMostRecentZoneView();
void clear();
};

View file

@ -30,6 +30,7 @@ private slots:
void zoneDumpReceived(int commandId, QList<ServerZoneCard *> cards);
public:
ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_origZone, int numberCards = 0, QGraphicsItem *parent = 0);
ZoneViewZone *getZone() const { return zone; }
protected:
void closeEvent(QCloseEvent *event);
};

View file

@ -23,6 +23,7 @@ public:
bool initializeCards();
void removeCard(int position);
void setHeight(int _height) { height = _height; }
int getNumberCards() const { return numberCards; }
protected:
void addCardImpl(CardItem *card, int x, int y);
};