small changes and initial commit for phases toolbar

This commit is contained in:
Max-Wilhelm Bruker 2009-08-12 19:27:41 +02:00
parent 938825f27b
commit cd6c5108af
13 changed files with 274 additions and 172 deletions

View file

@ -177,8 +177,10 @@ void Client::readLine()
void Client::setStatus(const ProtocolStatus _status)
{
ProtocolStatus oldStatus = status;
status = _status;
emit statusChanged(_status);
if (oldStatus != _status)
emit statusChanged(_status);
}
void Client::msg(const QString &s)

View file

@ -137,7 +137,7 @@ Player *Game::addPlayer(int playerId, const QString &playerName, QPointF base, b
Player *newPlayer = new Player(playerName, playerId, base, local, db, client, scene, this);
connect(newPlayer, SIGNAL(sigShowCardMenu(QPoint)), this, SLOT(showCardMenu(QPoint)));
connect(newPlayer, SIGNAL(logMoveCard(Player *, QString, QString, int, QString, int)), this, SIGNAL(logMoveCard(Player *, QString, QString, int, QString, int)));
connect(newPlayer, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)), this, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)));
connect(newPlayer, SIGNAL(logCreateToken(Player *, QString)), this, SIGNAL(logCreateToken(Player *, QString)));
connect(newPlayer, SIGNAL(logSetCardCounters(Player *, QString, int, int)), this, SIGNAL(logSetCardCounters(Player *, QString, int, int)));
connect(newPlayer, SIGNAL(logSetTapped(Player *, QString, bool)), this, SIGNAL(logSetTapped(Player *, QString, bool)));

View file

@ -70,7 +70,7 @@ signals:
void logShuffle(Player *player);
void logRollDice(Player *player, int sides, int roll);
void logDraw(Player *player, int number);
void logMoveCard(Player *player, QString cardName, QString startZone, int oldX, QString targetZone, int newX);
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
void logCreateToken(Player *player, QString cardName);
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
void logSetTapped(Player *player, QString cardName, bool tapped);

View file

@ -1,6 +1,7 @@
#include "messagelogwidget.h"
#include "game.h"
#include "player.h"
#include "cardzone.h"
QString MessageLogWidget::sanitizeHtml(QString dirty)
{
@ -94,38 +95,53 @@ void MessageLogWidget::logDraw(Player *player, int number)
append(tr("%1 draws %2 cards").arg(sanitizeHtml(player->getName())).arg(number));
}
void MessageLogWidget::logMoveCard(Player *player, QString cardName, QString startZone, int oldX, QString targetZone, int newX)
void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX)
{
if ((startZone == "table") && (targetZone == "table"))
QString startName = startZone->getName();
QString targetName = targetZone->getName();
if (((startName == "table") && (targetName == "table")) || ((startName == "hand") && (targetName == "hand")))
return;
QString fromStr;
if (startZone == "table")
if (startName == "table")
fromStr = tr("from table");
else if (startZone == "grave")
else if (startName == "grave")
fromStr = tr("from graveyard");
else if (startZone == "rfg")
else if (startName == "rfg")
fromStr = tr("from exile");
else if (startZone == "hand")
else if (startName == "hand")
fromStr = tr("from hand");
else if (startZone == "deck")
fromStr = tr("from library");
else if (startName == "deck") {
if (oldX == startZone->getCards().size() - 1)
fromStr = tr("from the bottom of his library");
else if (oldX == 0)
fromStr = tr("from the top of his library");
else
fromStr = tr("from library");
} else if (startName == "sb")
fromStr = tr("from sideboard");
QString finalStr;
if (targetZone == "table")
if (targetName == "table")
finalStr = tr("%1 puts %2 into play %3");
else {
if (targetZone == "grave")
finalStr = tr("%1 puts %2 %3 into graveyard");
else if (targetZone == "rfg")
finalStr = tr("%1 exiles %2 %3");
else if (targetZone == "hand")
finalStr = tr("%1 moves %2 %3 to hand");
else if (targetZone == "deck")
else if (targetName == "grave")
finalStr = tr("%1 puts %2 %3 into graveyard");
else if (targetName == "rfg")
finalStr = tr("%1 exiles %2 %3");
else if (targetName == "hand")
finalStr = tr("%1 moves %2 %3 to hand");
else if (targetName == "deck") {
if (newX == -1)
finalStr = tr("%1 puts %2 %3 into his library");
else if (newX == targetZone->getCards().size())
finalStr = tr("%1 puts %2 %3 on bottom of his library");
else if (newX == 0)
finalStr = tr("%1 puts %2 %3 on top of his library");
else
finalStr = tr("%1 moves %2 %3 to %4");
}
append(finalStr.arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(fromStr).arg(targetZone));
finalStr = tr("%1 puts %2 %3 into his library at position %4");
} else if (targetName == "sb")
finalStr = tr("%1 moves %2 %3 to sideboard");
append(finalStr.arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(fromStr).arg(newX));
}
void MessageLogWidget::logCreateToken(Player *player, QString cardName)
@ -192,7 +208,7 @@ void MessageLogWidget::connectToGame(Game *game)
connect(game, SIGNAL(logShuffle(Player *)), this, SLOT(logShuffle(Player *)));
connect(game, SIGNAL(logRollDice(Player *, int, int)), this, SLOT(logRollDice(Player *, int, int)));
connect(game, SIGNAL(logDraw(Player *, int)), this, SLOT(logDraw(Player *, int)));
connect(game, SIGNAL(logMoveCard(Player *, QString, QString, int, QString, int)), this, SLOT(logMoveCard(Player *, QString, QString, int, QString, int)));
connect(game, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)), this, SLOT(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)));
connect(game, SIGNAL(logCreateToken(Player *, QString)), this, SLOT(logCreateToken(Player *, QString)));
connect(game, SIGNAL(logSetCardCounters(Player *, QString, int, int)), this, SLOT(logSetCardCounters(Player *, QString, int, int)));
connect(game, SIGNAL(logSetTapped(Player *, QString, bool)), this, SLOT(logSetTapped(Player *, QString, bool)));

View file

@ -7,6 +7,7 @@
class Game;
class Player;
class CardZone;
class MessageLogWidget : public QTextEdit {
Q_OBJECT
@ -28,7 +29,7 @@ private slots:
void logShuffle(Player *player);
void logRollDice(Player *player, int sides, int roll);
void logDraw(Player *player, int number);
void logMoveCard(Player *player, QString cardName, QString startZone, int oldX, QString targetZone, int newX);
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
void logCreateToken(Player *player, QString cardName);
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
void logSetTapped(Player *player, QString cardName, bool tapped);

View file

@ -236,7 +236,7 @@ void Player::gameEvent(const ServerEventData &event)
// The log event has to be sent before the card is added to the target zone
// because the addCard function can modify the card object.
emit logMoveCard(this, card->getName(), startZone->getName(), logPosition, targetZone->getName(), logX);
emit logMoveCard(this, card->getName(), startZone, logPosition, targetZone, logX);
targetZone->addCard(card, true, x, y);

View file

@ -23,7 +23,7 @@ signals:
void toggleZoneView(Player *player, QString zoneName, int number);
void sigShowCardMenu(QPoint p);
// Log events
void logMoveCard(Player *player, QString cardName, QString startZone, int oldX, QString targetZone, int newX);
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
void logCreateToken(Player *player, QString cardName);
void logSetCardCounters(Player *player, QString cardName, int value, int oldValue);
void logSetTapped(Player *player, QString cardName, bool tapped);

View file

@ -27,7 +27,7 @@
#include "window_deckeditor.h"
#include "cardinfowidget.h"
#include "messagelogwidget.h"
#include "phasestoolbar.h"
#include "gameview.h"
#include "player.h"
#include "game.h"
@ -289,7 +289,10 @@ MainWindow::MainWindow(QTranslator *_translator, QWidget *parent)
viewLayout = new QVBoxLayout;
viewLayout->addWidget(view);
PhasesToolbar *phasesToolbar = new PhasesToolbar;
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(phasesToolbar);
mainLayout->addLayout(viewLayout, 10);
mainLayout->addLayout(verticalLayout);