From 938825f27b81b16c66bc1b245b8ccc909cc78aae Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Wed, 12 Aug 2009 16:50:18 +0200 Subject: [PATCH 1/2] small client bug fix --- cockatrice/src/client.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cockatrice/src/client.cpp b/cockatrice/src/client.cpp index e4f6d95b..d143dabc 100644 --- a/cockatrice/src/client.cpp +++ b/cockatrice/src/client.cpp @@ -204,6 +204,8 @@ PendingCommand *Client::cmd(const QString &s) void Client::connectToServer(const QString &hostname, unsigned int port, const QString &_playerName, const QString &_password) { + disconnectFromServer(); + playerName = _playerName; password = _password; socket->connectToHost(hostname, port); From cd6c5108afa9f49888fd72fbf5c36f7d003681dd Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Wed, 12 Aug 2009 19:27:41 +0200 Subject: [PATCH 2/2] small changes and initial commit for phases toolbar --- cockatrice/cockatrice.pro | 4 +- cockatrice/cockatrice.qrc | 6 + cockatrice/src/client.cpp | 4 +- cockatrice/src/game.cpp | 2 +- cockatrice/src/game.h | 2 +- cockatrice/src/messagelogwidget.cpp | 58 ++++--- cockatrice/src/messagelogwidget.h | 3 +- cockatrice/src/player.cpp | 2 +- cockatrice/src/player.h | 2 +- cockatrice/src/window_main.cpp | 5 +- cockatrice/translations/cockatrice_de.ts | 147 ++++++++++------ cockatrice/translations/cockatrice_en.ts | 209 +++++++++++++---------- servatrice/src/playerzone.h | 2 +- 13 files changed, 274 insertions(+), 172 deletions(-) diff --git a/cockatrice/cockatrice.pro b/cockatrice/cockatrice.pro index 87e28872..9e96ca1a 100644 --- a/cockatrice/cockatrice.pro +++ b/cockatrice/cockatrice.pro @@ -16,8 +16,8 @@ QT += network svg #QTPLUGIN += qjpeg # Input -HEADERS += src/counter.h src/gameselector.h src/dlg_creategame.h src/dlg_connect.h src/gamesmodel.h src/client.h src/window_main.h src/servergame.h src/servereventdata.h src/zonelist.h src/cardzone.h src/player.h src/cardlist.h src/carditem.h src/tablezone.h src/handzone.h src/playerlist.h src/game.h src/carddatabase.h src/gameview.h src/decklistmodel.h src/dlg_startgame.h src/cardinfowidget.h src/messagelogwidget.h src/serverzonecard.h src/zoneviewzone.h src/zoneviewwidget.h src/pilezone.h src/carddragitem.h src/zoneviewlayout.h src/playerarea.h src/carddatabasemodel.h src/window_deckeditor.h src/decklist.h setsmodel.h src/window_sets.h src/abstractgraphicsitem.h src/dlg_settings.h -SOURCES += src/counter.cpp src/gameselector.cpp src/dlg_creategame.cpp src/dlg_connect.cpp src/client.cpp src/main.cpp src/window_main.cpp src/servereventdata.cpp src/gamesmodel.cpp src/player.cpp src/cardzone.cpp src/zonelist.cpp src/cardlist.cpp src/carditem.cpp src/tablezone.cpp src/handzone.cpp src/playerlist.cpp src/game.cpp src/carddatabase.cpp src/gameview.cpp src/decklistmodel.cpp src/dlg_startgame.cpp src/cardinfowidget.cpp src/messagelogwidget.cpp src/zoneviewzone.cpp src/zoneviewwidget.cpp src/pilezone.cpp src/carddragitem.cpp src/zoneviewlayout.cpp src/playerarea.cpp src/carddatabasemodel.cpp src/window_deckeditor.cpp src/decklist.cpp src/setsmodel.cpp src/window_sets.cpp src/abstractgraphicsitem.cpp src/dlg_settings.cpp +HEADERS += src/counter.h src/gameselector.h src/dlg_creategame.h src/dlg_connect.h src/gamesmodel.h src/client.h src/window_main.h src/servergame.h src/servereventdata.h src/zonelist.h src/cardzone.h src/player.h src/cardlist.h src/carditem.h src/tablezone.h src/handzone.h src/playerlist.h src/game.h src/carddatabase.h src/gameview.h src/decklistmodel.h src/dlg_startgame.h src/cardinfowidget.h src/messagelogwidget.h src/serverzonecard.h src/zoneviewzone.h src/zoneviewwidget.h src/pilezone.h src/carddragitem.h src/zoneviewlayout.h src/playerarea.h src/carddatabasemodel.h src/window_deckeditor.h src/decklist.h setsmodel.h src/window_sets.h src/abstractgraphicsitem.h src/dlg_settings.h src/phasestoolbar.h +SOURCES += src/counter.cpp src/gameselector.cpp src/dlg_creategame.cpp src/dlg_connect.cpp src/client.cpp src/main.cpp src/window_main.cpp src/servereventdata.cpp src/gamesmodel.cpp src/player.cpp src/cardzone.cpp src/zonelist.cpp src/cardlist.cpp src/carditem.cpp src/tablezone.cpp src/handzone.cpp src/playerlist.cpp src/game.cpp src/carddatabase.cpp src/gameview.cpp src/decklistmodel.cpp src/dlg_startgame.cpp src/cardinfowidget.cpp src/messagelogwidget.cpp src/zoneviewzone.cpp src/zoneviewwidget.cpp src/pilezone.cpp src/carddragitem.cpp src/zoneviewlayout.cpp src/playerarea.cpp src/carddatabasemodel.cpp src/window_deckeditor.cpp src/decklist.cpp src/setsmodel.cpp src/window_sets.cpp src/abstractgraphicsitem.cpp src/dlg_settings.cpp src/phasestoolbar.cpp TRANSLATIONS += \ translations/cockatrice_de.ts \ translations/cockatrice_en.ts diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 0e1283b8..2df39109 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -3,6 +3,12 @@ resources/back.svg resources/icon_config_general.svg resources/icon_config_messages.svg + + resources/icon_phase_untap.svg + resources/icon_phase_upkeep.svg + resources/icon_phase_draw.svg + resources/icon_phase_combat.svg + resources/icon_phase_cleanup.svg translations/cockatrice_de.qm translations/cockatrice_en.qm diff --git a/cockatrice/src/client.cpp b/cockatrice/src/client.cpp index d143dabc..7b0136a0 100644 --- a/cockatrice/src/client.cpp +++ b/cockatrice/src/client.cpp @@ -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) diff --git a/cockatrice/src/game.cpp b/cockatrice/src/game.cpp index 1edc79fa..b991d902 100644 --- a/cockatrice/src/game.cpp +++ b/cockatrice/src/game.cpp @@ -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))); diff --git a/cockatrice/src/game.h b/cockatrice/src/game.h index da9c8ccf..2b48cf83 100644 --- a/cockatrice/src/game.h +++ b/cockatrice/src/game.h @@ -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); diff --git a/cockatrice/src/messagelogwidget.cpp b/cockatrice/src/messagelogwidget.cpp index 8a0b8786..29e09304 100644 --- a/cockatrice/src/messagelogwidget.cpp +++ b/cockatrice/src/messagelogwidget.cpp @@ -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("%1").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("%1").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))); diff --git a/cockatrice/src/messagelogwidget.h b/cockatrice/src/messagelogwidget.h index e1b411cd..51f6270e 100644 --- a/cockatrice/src/messagelogwidget.h +++ b/cockatrice/src/messagelogwidget.h @@ -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); diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index d6726ecd..de650c59 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -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); diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index 380dcb41..6c21399f 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -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); diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index 59e12369..b31adf25 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -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); diff --git a/cockatrice/translations/cockatrice_de.ts b/cockatrice/translations/cockatrice_de.ts index 1869a15e..c7ab7470 100644 --- a/cockatrice/translations/cockatrice_de.ts +++ b/cockatrice/translations/cockatrice_de.ts @@ -232,27 +232,27 @@ DlgSettings - + Settings Einstellungen - + General Allgemeines - + Appearance Erscheinungsbild - + Messages Nachrichten - + &Close S&chließen @@ -446,48 +446,48 @@ F10 - + Set life Setze Leben - + New life total: Neues Leben insgesammt: - + Roll dice Würfeln - + Number of sides: Anzahl der Seiten: - + Draw cards Karten ziehen - - + + Number: Anzahl: - + Create token Token erstellen - + Name: Name: - + Set counters Setze Zählmarke @@ -706,132 +706,171 @@ MessageLogWidget - + Connecting to %1... Verbinde zu %1... - + Connected. Verbunden. - + Disconnected from server. - Verbindung zum Server trennen. + Verbindung zum Server getrennt. - + Invalid password. Ungültiges Passwort. - + You have joined the game. Player list: Du bist dem Spiel beigetreten. Spielerliste: - + %1 has joined the game %1 ist dem Spiel beigetreten - + %1 has left the game %1 hat das Spiel verlassen - + %1 is ready to start a new game. %1 ist bereit ein neues Spiel zu starten. - + Game has started. Spiel hat begonnen. - + %1 shuffles his/her library %1 mischt seine/ihre Bibliothek - + %1 rolled a %2 with a %3-sided dice %1 würfelte eine %2 mit einem %3-seitigen Würfel - + %1 draws a card %1 zieht eine Karte - + %1 draws %2 cards %1 zieht %2 Karten - + from table vom Spielfeld - + from graveyard aus dem Friedhof - + from exile aus dem Exil - + from hand von der Hand - + + from the bottom of his library + von der Unterseite seiner Bibliothek + + + + from the top of his library + oben von seiner Bibliothek + + + from library von der Bibliothek - + + from sideboard + aus seinem Sideboard + + + %1 puts %2 into play %3 %1 bringt %2 %3 ins Spiel - + %1 puts %2 %3 into graveyard %1 legt %2 %3 in den Friedhof - + %1 exiles %2 %3 %1 schickt %2 %3 ins Exil - + %1 moves %2 %3 to hand %1 nimmt %2 %3 auf die Hand - + + %1 puts %2 %3 into his library + %1 legt %2 %3 in seine Bibliothek + + + + %1 puts %2 %3 on bottom of his library + %1 legt %2 %3 unter seine Bibliothek + + + %1 puts %2 %3 on top of his library %1 legt %2 %3 auf die Bibliothek - - %1 moves %2 %3 to %4 - %1 bewegt %2 %3 nach %4 + + %1 puts %2 %3 into his library at position %4 + %1 legt %2 %3 in seine Bibliothek an Stelle %4 - + + %1 moves %2 %3 to sideboard + %1 legt %2 %3 in sein Sideboard + + + + %1 stops looking at %2's %3 + %1 sieht sich %2s %3 nicht mehr an + + + %1 moves %2 %3 to %4 + %1 bewegt %2 %3 nach %4 + + + taps tappt - + untaps enttappt @@ -844,52 +883,52 @@ %1 bewegt %2 von %3 nach %4 - + %1 creates token: %2 %1 erstellt Token: %2 - + %1 places %2 counters on %3 (now %4) %1 legt %2 Zählmarken auf %3 (jetzt %4) - + %1 removes %2 counters from %3 (now %4) %1 entfernt %2 Zählmarken von %3 (jetzt %4) - + his permanents seine bleibenden Karten - + %1 %2 %3 %1 %2 %3 - + %1 sets counter "%2" to %3 (%4%5) %1 setzt Zähler "%2" auf %3 (%4%5) - + %1 sets %2 to not untap normally. %1 setzt %2 auf explizites Enttappen. - + %1 sets %2 to untap normally. %1 setzt %2 auf normales Enttappen. - + %1 is looking at the top %2 cards of %3's %4 %1 sieht sich die obersten %2 Karten von %3s %4 an - + %1 is looking at %2's %3 %1 sieht sich %2s %3 an diff --git a/cockatrice/translations/cockatrice_en.ts b/cockatrice/translations/cockatrice_en.ts index 78f1ed1b..537f6d21 100644 --- a/cockatrice/translations/cockatrice_en.ts +++ b/cockatrice/translations/cockatrice_en.ts @@ -173,27 +173,27 @@ DlgSettings - + Settings - + General - + Appearance - + Messages - + &Close @@ -379,48 +379,48 @@ - + Set life - + New life total: - + Roll dice - + Number of sides: - + Draw cards - - + + Number: - + Create token - + Name: - + Set counters @@ -639,182 +639,217 @@ MessageLogWidget - + Connecting to %1... - + Connected. - + Disconnected from server. - + Invalid password. - + You have joined the game. Player list: - + %1 has joined the game - + %1 has left the game - + %1 is ready to start a new game. - + Game has started. - + %1 shuffles his/her library - + %1 rolled a %2 with a %3-sided dice - + %1 draws a card - + %1 draws %2 cards - + from table - + from graveyard - + from exile - + from hand - + + from the bottom of his library + + + + + from the top of his library + + + + from library - + + from sideboard + + + + %1 puts %2 into play %3 - + %1 puts %2 %3 into graveyard - + %1 exiles %2 %3 - + %1 moves %2 %3 to hand - + + %1 puts %2 %3 into his library + + + + + %1 puts %2 %3 on bottom of his library + + + + %1 puts %2 %3 on top of his library - - - %1 moves %2 %3 to %4 - - - - - %1 creates token: %2 - - - %1 places %2 counters on %3 (now %4) + %1 puts %2 %3 into his library at position %4 - %1 removes %2 counters from %3 (now %4) + %1 moves %2 %3 to sideboard - - %1 %2 %3 - - - - - taps - - - - - untaps - - - - - %1 sets counter "%2" to %3 (%4%5) - - - - - %1 sets %2 to not untap normally. - - - - - %1 sets %2 to untap normally. - - - - - %1 is looking at the top %2 cards of %3's %4 - - - - - %1 is looking at %2's %3 + + %1 stops looking at %2's %3 + %1 creates token: %2 + + + + + %1 places %2 counters on %3 (now %4) + + + + + %1 removes %2 counters from %3 (now %4) + + + + + %1 %2 %3 + + + + + taps + + + + + untaps + + + + + %1 sets counter "%2" to %3 (%4%5) + + + + + %1 sets %2 to not untap normally. + + + + + %1 sets %2 to untap normally. + + + + + %1 is looking at the top %2 cards of %3's %4 + + + + + %1 is looking at %2's %3 + + + + his permanents diff --git a/servatrice/src/playerzone.h b/servatrice/src/playerzone.h index a7782e1a..6f8b6a67 100644 --- a/servatrice/src/playerzone.h +++ b/servatrice/src/playerzone.h @@ -49,7 +49,7 @@ public: Card *getCard(int id, bool remove, int *position = NULL); int getCardsBeingLookedAt() const { return cardsBeingLookedAt; } - void setCardsBeingLookedAt(bool _cardsBeingLookedAt) { cardsBeingLookedAt = _cardsBeingLookedAt; } + void setCardsBeingLookedAt(int _cardsBeingLookedAt) { cardsBeingLookedAt = _cardsBeingLookedAt; } bool hasCoords() const { return has_coords; } ZoneType getType() const { return type; } QString getName() const { return name; }