diff --git a/cockatrice/cockatrice.pro b/cockatrice/cockatrice.pro
index 1233dc2f..e24a899d 100644
--- a/cockatrice/cockatrice.pro
+++ b/cockatrice/cockatrice.pro
@@ -40,12 +40,11 @@ HEADERS += src/counter.h \
src/carddatabasemodel.h \
src/window_deckeditor.h \
src/decklist.h \
- setsmodel.h \
+ src/setsmodel.h \
src/window_sets.h \
src/abstractgraphicsitem.h \
src/dlg_settings.h \
- src/phasestoolbar.h \
- src/phasebutton.h
+ src/phasestoolbar.h
SOURCES += src/counter.cpp \
src/gameselector.cpp \
src/dlg_creategame.cpp \
@@ -83,6 +82,5 @@ SOURCES += src/counter.cpp \
src/window_sets.cpp \
src/abstractgraphicsitem.cpp \
src/dlg_settings.cpp \
- src/phasestoolbar.cpp \
- src/phasebutton.cpp
+ src/phasestoolbar.cpp
TRANSLATIONS += translations/cockatrice_de.ts translations/cockatrice_en.ts
diff --git a/cockatrice/src/game.cpp b/cockatrice/src/game.cpp
index b991d902..cd61eeb6 100644
--- a/cockatrice/src/game.cpp
+++ b/cockatrice/src/game.cpp
@@ -224,10 +224,25 @@ void Game::gameEvent(const ServerEventData &msg)
emit logRollDice(p, sides, roll);
break;
}
- case eventSetActivePlayer:
+ case eventSetActivePlayer: {
+ QStringList data = msg.getEventData();
+ int playerId = data[0].toInt();
+ Player *player = players.findPlayer(playerId);
+ if (!player) {
+ qDebug(QString("setActivePlayer: invalid player: %1").arg(playerId).toLatin1());
+ break;
+ }
+ for (int i = 0; i < players.size(); ++i)
+ players[i]->setActive(players[i] == player);
+ emit logSetActivePlayer(player);
break;
- case eventSetActivePhase:
+ }
+ case eventSetActivePhase: {
+ QStringList data = msg.getEventData();
+ int phase = data[0].toInt();
+ emit setActivePhase(p, phase);
break;
+ }
case eventName:
case eventCreateToken:
diff --git a/cockatrice/src/game.h b/cockatrice/src/game.h
index 2b48cf83..ca58545f 100644
--- a/cockatrice/src/game.h
+++ b/cockatrice/src/game.h
@@ -78,6 +78,8 @@ signals:
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
void logDumpZone(Player *player, QString zoneName, QString zoneOwner, int numberCards);
void logStopDumpZone(Player *player, QString zoneName, QString zoneOwner);
+ void logSetActivePlayer(Player *player);
+ void setActivePhase(Player *player, int phase);
public:
Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_actionsMenu, QMenu *_cardMenu, int playerId, const QString &playerName, QObject *parent = 0);
~Game();
diff --git a/cockatrice/src/messagelogwidget.cpp b/cockatrice/src/messagelogwidget.cpp
index 29e09304..b2d07898 100644
--- a/cockatrice/src/messagelogwidget.cpp
+++ b/cockatrice/src/messagelogwidget.cpp
@@ -97,6 +97,9 @@ void MessageLogWidget::logDraw(Player *player, int number)
void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX)
{
+ if (cardName.isEmpty())
+ cardName = tr("a card");
+
QString startName = startZone->getName();
QString targetName = targetZone->getName();
if (((startName == "table") && (targetName == "table")) || ((startName == "hand") && (targetName == "hand")))
@@ -197,6 +200,18 @@ void MessageLogWidget::logStopDumpZone(Player *player, QString zoneName, QString
append(tr("%1 stops looking at %2's %3").arg(sanitizeHtml(player->getName())).arg(zoneOwner).arg(zoneName));
}
+void MessageLogWidget::logSetActivePlayer(Player *player)
+{
+ append("---");
+ append("" + tr("It is now %1's turn.").arg(player->getName()) + "");
+ append("---");
+}
+
+void MessageLogWidget::logSetActivePhase(Player *player, int phase)
+{
+ append("" + tr("It is now the %1 phase.").arg(phase) + "");
+}
+
void MessageLogWidget::connectToGame(Game *game)
{
connect(game, SIGNAL(logPlayerListReceived(QStringList)), this, SLOT(logPlayerListReceived(QStringList)));
@@ -216,6 +231,8 @@ void MessageLogWidget::connectToGame(Game *game)
connect(game, SIGNAL(logSetDoesntUntap(Player *, QString, bool)), this, SLOT(logSetDoesntUntap(Player *, QString, bool)));
connect(game, SIGNAL(logDumpZone(Player *, QString, QString, int)), this, SLOT(logDumpZone(Player *, QString, QString, int)));
connect(game, SIGNAL(logStopDumpZone(Player *, QString, QString)), this, SLOT(logStopDumpZone(Player *, QString, QString)));
+ connect(game, SIGNAL(logSetActivePlayer(Player *)), this, SLOT(logSetActivePlayer(Player *)));
+ connect(game, SIGNAL(setActivePhase(Player *, int)), this, SLOT(logSetActivePhase(Player *, int)));
}
MessageLogWidget::MessageLogWidget(QWidget *parent)
diff --git a/cockatrice/src/messagelogwidget.h b/cockatrice/src/messagelogwidget.h
index 51f6270e..5e42f9e0 100644
--- a/cockatrice/src/messagelogwidget.h
+++ b/cockatrice/src/messagelogwidget.h
@@ -37,6 +37,8 @@ private slots:
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
void logDumpZone(Player *player, QString zoneName, QString zoneOwner, int numberCards);
void logStopDumpZone(Player *player, QString zoneName, QString zoneOwner);
+ void logSetActivePlayer(Player *player);
+ void logSetActivePhase(Player *player, int phase);
public:
void connectToGame(Game *game);
MessageLogWidget(QWidget *parent = 0);
diff --git a/cockatrice/src/phasebutton.cpp b/cockatrice/src/phasebutton.cpp
deleted file mode 100644
index fcd347ed..00000000
--- a/cockatrice/src/phasebutton.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "phasebutton.h"
-#include
-#include
-//
-PhaseButton::PhaseButton(QIcon icon, QString name )
- : QPushButton(icon,name)
-{
-
-}
-
-//PhaseButton::PhaseButton( )
- //: QPushButton()
-//{
- //
-//}
-
-void PhaseButton::update()
-{
- QPushButton::update();
-}
-
-void PhaseButton::paintEvent(QPaintEvent *event)
-{
- QPushButton::paintEvent(event);
- if(isChecked())
- {
- QPainter painter(this);
- int height = size().height();
- int width = size().width();
- QPen pen;
- pen.setWidth(3);
- pen.setColor(QColor::fromRgb(180,0,0));
- painter.setPen(pen);
- painter.drawRect(3,3, width-7, height-7);
- }
-
-
-}
-//
diff --git a/cockatrice/src/phasebutton.h b/cockatrice/src/phasebutton.h
deleted file mode 100644
index fc7e586a..00000000
--- a/cockatrice/src/phasebutton.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef PHASEBUTTON_H
-#define PHASEBUTTON_H
-//
-#include
-//
-class PhaseButton : public QPushButton
-{
-Q_OBJECT
-public:
- PhaseButton();
- PhaseButton(QIcon, QString);
- void update();
- void paintEvent(QPaintEvent *event);
-
-};
-#endif
diff --git a/cockatrice/src/phasestoolbar.cpp b/cockatrice/src/phasestoolbar.cpp
index 668aea5b..5bd1b785 100644
--- a/cockatrice/src/phasestoolbar.cpp
+++ b/cockatrice/src/phasestoolbar.cpp
@@ -1,35 +1,79 @@
#include "phasestoolbar.h"
#include
-//#include
-#include "phasebutton.h"
#include
#include
+#include
+#include
+
+PhaseButton::PhaseButton(QIcon icon)
+ : QPushButton(icon, QString())
+{
+
+}
+
+void PhaseButton::update()
+{
+ QPushButton::update();
+}
+
+void PhaseButton::paintEvent(QPaintEvent *event)
+{
+ QPushButton::paintEvent(event);
+ if (isChecked()) {
+ QPainter painter(this);
+ int height = size().height();
+ int width = size().width();
+
+ QPen pen;
+ pen.setWidth(3);
+ pen.setColor(QColor::fromRgb(180, 0, 0));
+ painter.setPen(pen);
+
+// painter.setPen(QColor(0, 0, 0, 0));
+ QRadialGradient grad(QPointF(0.5, 0.5), 0.5);
+ grad.setCoordinateMode(QGradient::ObjectBoundingMode);
+ grad.setColorAt(0, QColor(180, 0, 0, 0));
+ grad.setColorAt(0.8, QColor(180, 0, 0, 0));
+ grad.setColorAt(1, QColor(180, 0, 0, 255));
+ painter.setBrush(QBrush(grad));
+// painter.drawEllipse(QRect(0, 0, width, height));
+
+ painter.drawRect(3, 3, width - 7, height - 7);
+
+ }
+}
+
+void PhaseButton::setPhaseText(const QString &_phaseText)
+{
+ phaseText = _phaseText;
+ setToolTip(phaseText);
+}
PhasesToolbar::PhasesToolbar(QWidget *parent)
: QFrame(parent)
{
- PhaseButton *untapButton = new PhaseButton(QIcon(":/resources/icon_phase_untap.svg"), QString());
- PhaseButton *upkeepButton = new PhaseButton(QIcon(":/resources/icon_phase_upkeep.svg"), QString());
- PhaseButton *drawButton = new PhaseButton(QIcon(":/resources/icon_phase_draw.svg"), QString());
- PhaseButton *main1Button = new PhaseButton(QIcon(":/resources/icon_phase_main1.svg"), QString());
- PhaseButton *combatStartButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_start.svg"), QString());
- PhaseButton *combatAttackersButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_attackers.svg"), QString());
- PhaseButton *combatBlockersButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_blockers.svg"), QString());
- PhaseButton *combatDamageButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_damage.svg"), QString());
- PhaseButton *combatEndButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_end.svg"), QString());
- PhaseButton *main2Button = new PhaseButton(QIcon(":/resources/icon_phase_main2.svg"), QString());
- PhaseButton *cleanupButton = new PhaseButton(QIcon(":/resources/icon_phase_cleanup.svg"), QString());
+ PhaseButton *untapButton = new PhaseButton(QIcon(":/resources/icon_phase_untap.svg"));
+ PhaseButton *upkeepButton = new PhaseButton(QIcon(":/resources/icon_phase_upkeep.svg"));
+ PhaseButton *drawButton = new PhaseButton(QIcon(":/resources/icon_phase_draw.svg"));
+ PhaseButton *main1Button = new PhaseButton(QIcon(":/resources/icon_phase_main1.svg"));
+ PhaseButton *combatStartButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_start.svg"));
+ PhaseButton *combatAttackersButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_attackers.svg"));
+ PhaseButton *combatBlockersButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_blockers.svg"));
+ PhaseButton *combatDamageButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_damage.svg"));
+ PhaseButton *combatEndButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_end.svg"));
+ PhaseButton *main2Button = new PhaseButton(QIcon(":/resources/icon_phase_main2.svg"));
+ PhaseButton *cleanupButton = new PhaseButton(QIcon(":/resources/icon_phase_cleanup.svg"));
buttonList << untapButton << upkeepButton << drawButton << main1Button << combatStartButton
<< combatAttackersButton << combatBlockersButton << combatDamageButton << combatEndButton
<< main2Button << cleanupButton;
-
+
for (int i = 0; i < buttonList.size(); ++i) {
buttonList[i]->setCheckable(true);
buttonList[i]->setIconSize(QSize(40, 40));
}
- PhaseButton *nextTurnButton = new PhaseButton(QIcon(":/resources/icon_nextturn.svg"), QString());
+ QPushButton *nextTurnButton = new QPushButton(QIcon(":/resources/icon_nextturn.svg"), QString());
nextTurnButton->setIconSize(QSize(40, 40));
QVBoxLayout *layout = new QVBoxLayout;
@@ -40,7 +84,6 @@ PhasesToolbar::PhasesToolbar(QWidget *parent)
bg->addButton(buttonList[i]);
}
-
layout->addStretch(1);
layout->addWidget(untapButton);
layout->addWidget(upkeepButton);
@@ -61,5 +104,21 @@ PhasesToolbar::PhasesToolbar(QWidget *parent)
layout->addWidget(nextTurnButton);
layout->addStretch(1);
+ retranslateUi();
setLayout(layout);
}
+
+void PhasesToolbar::retranslateUi()
+{
+ buttonList[0]->setPhaseText(tr("Untap step"));
+ buttonList[1]->setPhaseText(tr("Upkeep step"));
+ buttonList[2]->setPhaseText(tr("Draw step"));
+ buttonList[3]->setPhaseText(tr("First main phase"));
+ buttonList[4]->setPhaseText(tr("Beginning of combat step"));
+ buttonList[5]->setPhaseText(tr("Declare attackers step"));
+ buttonList[6]->setPhaseText(tr("Declare blockers step"));
+ buttonList[7]->setPhaseText(tr("Combat damage step"));
+ buttonList[8]->setPhaseText(tr("End of combat step"));
+ buttonList[9]->setPhaseText(tr("Second main phase"));
+ buttonList[10]->setPhaseText(tr("End of turn step"));
+}
diff --git a/cockatrice/src/phasestoolbar.h b/cockatrice/src/phasestoolbar.h
index d9a2e4c5..60cd0a7d 100644
--- a/cockatrice/src/phasestoolbar.h
+++ b/cockatrice/src/phasestoolbar.h
@@ -3,15 +3,30 @@
#include
#include
+#include
-class QPushButton;
+class PhaseButton : public QPushButton {
+ Q_OBJECT
+private:
+ QString phaseText;
+public:
+ PhaseButton();
+ PhaseButton(QIcon);
+ void setPhaseText(const QString &_phaseText);
+ QString getPhaseText() const { return phaseText; }
+public slots:
+ void update();
+protected:
+ void paintEvent(QPaintEvent *event);
+};
class PhasesToolbar : public QFrame {
Q_OBJECT
public:
PhasesToolbar(QWidget *parent = 0);
+ void retranslateUi();
private:
- QList buttonList;
+ QList buttonList;
};
#endif
diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp
index de650c59..3eba6703 100644
--- a/cockatrice/src/player.cpp
+++ b/cockatrice/src/player.cpp
@@ -10,7 +10,7 @@
#include
Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene, Game *_parent)
- : QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), base(_base), local(_local), db(_db), client(_client)
+ : QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), active(false), base(_base), local(_local), db(_db), client(_client)
{
area = new PlayerArea(this);
area->setPos(_base);
@@ -315,3 +315,8 @@ void Player::showCardMenu(const QPoint &p)
{
emit sigShowCardMenu(p);
}
+
+void Player::setActive(bool _active)
+{
+ active = _active;
+}
diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h
index 6c21399f..b5d68dea 100644
--- a/cockatrice/src/player.h
+++ b/cockatrice/src/player.h
@@ -49,6 +49,7 @@ private:
int defaultNumberTopCards;
QString name;
int id;
+ bool active;
QPointF base;
bool local;
ZoneList zones;
@@ -68,6 +69,8 @@ public:
void gameEvent(const ServerEventData &event);
CardDatabase *getDb() const { return db; }
void showCardMenu(const QPoint &p);
+ bool getActive() const { return active; }
+ void setActive(bool _active);
};
#endif
diff --git a/servatrice/src/serversocket.cpp b/servatrice/src/serversocket.cpp
index 4f626f3e..307ab363 100644
--- a/servatrice/src/serversocket.cpp
+++ b/servatrice/src/serversocket.cpp
@@ -609,6 +609,7 @@ ReturnMessage::ReturnCode ServerSocket::cmdSetActivePlayer(const QList
if (!game->getPlayer(active_player))
return ReturnMessage::ReturnContextError;
game->setActivePlayer(active_player);
+ emit broadcastEvent(QString("set_active_player|%1").arg(active_player), this);
return ReturnMessage::ReturnOk;
}
@@ -616,7 +617,10 @@ ReturnMessage::ReturnCode ServerSocket::cmdSetActivePhase(const QList
{
int active_phase = params[0].toInt();
// XXX Überprüfung, ob die Phase existiert...
+ if (game->getActivePlayer() != playerId)
+ return ReturnMessage::ReturnContextError;
game->setActivePhase(active_phase);
+ emit broadcastEvent(QString("set_active_phase|%1").arg(active_phase), this);
return ReturnMessage::ReturnOk;
}