Commit 0d84de23 authored by Max-Wilhelm Bruker's avatar Max-Wilhelm Bruker
Browse files

moved carddraw from game to player; qt 4.4 compilation fix; minor behaviour change

parent 557aed2e
...@@ -37,15 +37,6 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a ...@@ -37,15 +37,6 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
aSetLife->setShortcut(tr("Ctrl+L")); aSetLife->setShortcut(tr("Ctrl+L"));
connect(aSetLife, SIGNAL(triggered()), this, SLOT(actSetLife())); connect(aSetLife, SIGNAL(triggered()), this, SLOT(actSetLife()));
aShuffle = new QAction(tr("&Shuffle"), this);
aShuffle->setShortcut(tr("Ctrl+S"));
connect(aShuffle, SIGNAL(triggered()), this, SLOT(actShuffle()));
aDraw = new QAction(tr("&Draw a card"), this);
aDraw->setShortcut(tr("Ctrl+D"));
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+E"));
aRollDice = new QAction(tr("R&oll dice..."), this); aRollDice = new QAction(tr("R&oll dice..."), this);
aRollDice->setShortcut(tr("Ctrl+I")); aRollDice->setShortcut(tr("Ctrl+I"));
connect(aRollDice, SIGNAL(triggered()), this, SLOT(actRollDice())); connect(aRollDice, SIGNAL(triggered()), this, SLOT(actRollDice()));
...@@ -70,9 +61,6 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a ...@@ -70,9 +61,6 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
actionsMenu->addAction(aIncLife); actionsMenu->addAction(aIncLife);
actionsMenu->addAction(aSetLife); actionsMenu->addAction(aSetLife);
actionsMenu->addSeparator(); actionsMenu->addSeparator();
actionsMenu->addAction(aShuffle);
actionsMenu->addAction(aDraw);
actionsMenu->addAction(aDrawCards);
actionsMenu->addAction(aRollDice); actionsMenu->addAction(aRollDice);
actionsMenu->addSeparator(); actionsMenu->addSeparator();
actionsMenu->addAction(aCreateToken); actionsMenu->addAction(aCreateToken);
...@@ -354,11 +342,6 @@ void Game::actSetLife() ...@@ -354,11 +342,6 @@ void Game::actSetLife()
client->setCounter("life", life); client->setCounter("life", life);
} }
void Game::actShuffle()
{
client->shuffle();
}
void Game::actRollDice() void Game::actRollDice()
{ {
bool ok; bool ok;
...@@ -367,18 +350,6 @@ void Game::actRollDice() ...@@ -367,18 +350,6 @@ void Game::actRollDice()
client->rollDice(sides); client->rollDice(sides);
} }
void Game::actDrawCard()
{
client->drawCards(1);
}
void Game::actDrawCards()
{
int number = QInputDialog::getInteger(0, tr("Draw cards"), tr("Number:"));
if (number)
client->drawCards(number);
}
void Game::actCreateToken() void Game::actCreateToken()
{ {
QString cardname = QInputDialog::getText(0, tr("Create token"), tr("Name:")); QString cardname = QInputDialog::getText(0, tr("Create token"), tr("Name:"));
......
#ifndef GAME_H #ifndef GAME_H
#define GAME_H #define GAME_H
#include <QHash>
#include "playerlist.h" #include "playerlist.h"
class ServerPlayer; class ServerPlayer;
...@@ -23,7 +24,7 @@ private: ...@@ -23,7 +24,7 @@ private:
QMenu *actionsMenu, *sayMenu, *cardMenu, *moveMenu; QMenu *actionsMenu, *sayMenu, *cardMenu, *moveMenu;
QAction *aTap, *aUntap, *aDoesntUntap, *aFlip, *aAddCounter, *aRemoveCounter, *aSetCounters, QAction *aTap, *aUntap, *aDoesntUntap, *aFlip, *aAddCounter, *aRemoveCounter, *aSetCounters,
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile, *aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile,
*aNextPhase, *aNextTurn, *aUntapAll, *aDecLife, *aIncLife, *aSetLife, *aShuffle, *aDraw, *aDrawCards, *aRollDice, *aCreateToken; *aNextPhase, *aNextTurn, *aUntapAll, *aDecLife, *aIncLife, *aSetLife, *aRollDice, *aCreateToken;
DlgStartGame *dlgStartGame; DlgStartGame *dlgStartGame;
CardDatabase *db; CardDatabase *db;
...@@ -44,9 +45,6 @@ private slots: ...@@ -44,9 +45,6 @@ private slots:
void actIncLife(); void actIncLife();
void actDecLife(); void actDecLife();
void actSetLife(); void actSetLife();
void actShuffle();
void actDrawCard();
void actDrawCards();
void actRollDice(); void actRollDice();
void actCreateToken(); void actCreateToken();
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QDateTime> #include <QDateTime>
#include <QSettings> #include <QSettings>
#include <QIcon>
#include <stdio.h> #include <stdio.h>
#include "window_main.h" #include "window_main.h"
......
...@@ -16,17 +16,18 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa ...@@ -16,17 +16,18 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa
area->setPos(_base); area->setPos(_base);
_scene->addItem(area); _scene->addItem(area);
aMoveHandToTopLibrary = new QAction(tr("Move to &top of library"), this); if (local) {
connect(aMoveHandToTopLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToTopLibrary())); aMoveHandToTopLibrary = new QAction(tr("Move to &top of library"), this);
aMoveHandToBottomLibrary = new QAction(tr("Move to &bottom of library"), this); connect(aMoveHandToTopLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToTopLibrary()));
connect(aMoveHandToBottomLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToBottomLibrary())); aMoveHandToBottomLibrary = new QAction(tr("Move to &bottom of library"), this);
connect(aMoveHandToBottomLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToBottomLibrary()));
aViewLibrary = new QAction(tr("&View library"), this); aViewLibrary = new QAction(tr("&View library"), this);
if (local)
aViewLibrary->setShortcut(tr("F3")); aViewLibrary->setShortcut(tr("F3"));
connect(aViewLibrary, SIGNAL(triggered()), this, SLOT(actViewLibrary())); connect(aViewLibrary, SIGNAL(triggered()), this, SLOT(actViewLibrary()));
aViewTopCards = new QAction(tr("View &top cards of library..."), this); aViewTopCards = new QAction(tr("View &top cards of library..."), this);
connect(aViewTopCards, SIGNAL(triggered()), this, SLOT(actViewTopCards())); connect(aViewTopCards, SIGNAL(triggered()), this, SLOT(actViewTopCards()));
}
aViewGraveyard = new QAction(tr("&View graveyard"), this); aViewGraveyard = new QAction(tr("&View graveyard"), this);
if (local) if (local)
...@@ -36,20 +37,37 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa ...@@ -36,20 +37,37 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa
aViewRfg = new QAction(tr("&View removed cards"), this); aViewRfg = new QAction(tr("&View removed cards"), this);
connect(aViewRfg, SIGNAL(triggered()), this, SLOT(actViewRfg())); connect(aViewRfg, SIGNAL(triggered()), this, SLOT(actViewRfg()));
aViewSideboard = new QAction(tr("&View sideboard"), this); if (local) {
connect(aViewSideboard, SIGNAL(triggered()), this, SLOT(actViewSideboard())); aViewSideboard = new QAction(tr("&View sideboard"), this);
connect(aViewSideboard, SIGNAL(triggered()), this, SLOT(actViewSideboard()));
aDrawCard = new QAction(tr("&Draw card"), this);
connect(aDrawCard, SIGNAL(triggered()), this, SLOT(actDrawCard()));
aDrawCard->setShortcut(tr("Ctrl+D"));
aDrawCards = new QAction(tr("D&raw cards..."), this);
connect(aDrawCards, SIGNAL(triggered()), this, SLOT(actDrawCards()));
aDrawCards->setShortcut(tr("Ctrl+E"));
aShuffle = new QAction(tr("&Shuffle"), this);
connect(aShuffle, SIGNAL(triggered()), this, SLOT(actShuffle()));
aShuffle->setShortcut(tr("Ctrl+S"));
}
playerMenu = new QMenu(tr("Player \"%1\"").arg(name)); playerMenu = new QMenu(tr("Player \"%1\"").arg(name));
QMenu *handMenu = playerMenu->addMenu(tr("&Hand")); if (local) {
handMenu->addAction(aMoveHandToTopLibrary); QMenu *handMenu = playerMenu->addMenu(tr("&Hand"));
handMenu->addAction(aMoveHandToBottomLibrary); handMenu->addAction(aMoveHandToTopLibrary);
zones.findZone("hand")->setMenu(handMenu); handMenu->addAction(aMoveHandToBottomLibrary);
zones.findZone("hand")->setMenu(handMenu);
QMenu *libraryMenu = playerMenu->addMenu(tr("&Library"));
libraryMenu->addAction(aViewLibrary); QMenu *libraryMenu = playerMenu->addMenu(tr("&Library"));
libraryMenu->addAction(aViewTopCards); libraryMenu->addAction(aDrawCard);
zones.findZone("deck")->setMenu(libraryMenu, aViewLibrary); libraryMenu->addAction(aDrawCards);
libraryMenu->addSeparator();
libraryMenu->addAction(aViewLibrary);
libraryMenu->addAction(aViewTopCards);
zones.findZone("deck")->setMenu(libraryMenu, aDrawCard);
}
QMenu *graveMenu = playerMenu->addMenu(tr("&Graveyard")); QMenu *graveMenu = playerMenu->addMenu(tr("&Graveyard"));
graveMenu->addAction(aViewGraveyard); graveMenu->addAction(aViewGraveyard);
...@@ -59,9 +77,11 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa ...@@ -59,9 +77,11 @@ Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDa
rfgMenu->addAction(aViewRfg); rfgMenu->addAction(aViewRfg);
zones.findZone("rfg")->setMenu(rfgMenu, aViewRfg); zones.findZone("rfg")->setMenu(rfgMenu, aViewRfg);
QMenu *sbMenu = playerMenu->addMenu(tr("&Sideboard")); if (local) {
sbMenu->addAction(aViewSideboard); QMenu *sbMenu = playerMenu->addMenu(tr("&Sideboard"));
zones.findZone("sb")->setMenu(sbMenu, aViewSideboard); sbMenu->addAction(aViewSideboard);
zones.findZone("sb")->setMenu(sbMenu, aViewSideboard);
}
} }
Player::~Player() Player::~Player()
...@@ -114,6 +134,23 @@ void Player::actViewSideboard() ...@@ -114,6 +134,23 @@ void Player::actViewSideboard()
emit toggleZoneView(this, "sb", -1); emit toggleZoneView(this, "sb", -1);
} }
void Player::actShuffle()
{
client->shuffle();
}
void Player::actDrawCard()
{
client->drawCards(1);
}
void Player::actDrawCards()
{
int number = QInputDialog::getInteger(0, tr("Draw cards"), tr("Number:"));
if (number)
client->drawCards(number);
}
void Player::addZone(CardZone *z) void Player::addZone(CardZone *z)
{ {
zones << z; zones << z;
......
...@@ -33,18 +33,20 @@ private slots: ...@@ -33,18 +33,20 @@ private slots:
void actMoveHandToTopLibrary(); void actMoveHandToTopLibrary();
void actMoveHandToBottomLibrary(); void actMoveHandToBottomLibrary();
void actShuffle();
void actDrawCard();
void actDrawCards();
void actViewLibrary(); void actViewLibrary();
void actViewTopCards(); void actViewTopCards();
void actViewGraveyard(); void actViewGraveyard();
void actViewRfg(); void actViewRfg();
void actViewSideboard(); void actViewSideboard();
private: private:
QMenu *playerMenu; QMenu *playerMenu;
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary,
*aViewLibrary, *aViewTopCards, *aViewGraveyard, *aViewRfg, *aViewSideboard; *aViewLibrary, *aViewTopCards, *aViewGraveyard, *aViewRfg, *aViewSideboard,
*aDrawCard, *aDrawCards, *aShuffle;
int defaultNumberTopCards; int defaultNumberTopCards;
QString name; QString name;
......
...@@ -68,6 +68,7 @@ void MainWindow::statusChanged(ProtocolStatus _status) ...@@ -68,6 +68,7 @@ void MainWindow::statusChanged(ProtocolStatus _status)
aDisconnect->setEnabled(false); aDisconnect->setEnabled(false);
aRestartGame->setEnabled(false); aRestartGame->setEnabled(false);
aLeaveGame->setEnabled(false); aLeaveGame->setEnabled(false);
phasesToolbar->setActivePhase(-1);
phasesToolbar->setEnabled(false); phasesToolbar->setEnabled(false);
emit logDisconnected(); emit logDisconnected();
break; break;
...@@ -82,10 +83,12 @@ void MainWindow::statusChanged(ProtocolStatus _status) ...@@ -82,10 +83,12 @@ void MainWindow::statusChanged(ProtocolStatus _status)
} }
aRestartGame->setEnabled(false); aRestartGame->setEnabled(false);
aLeaveGame->setEnabled(false); aLeaveGame->setEnabled(false);
phasesToolbar->setActivePhase(-1);
phasesToolbar->setEnabled(false); phasesToolbar->setEnabled(false);
GameSelector *gameSelector = new GameSelector(client); GameSelector *gameSelector = new GameSelector(client);
viewLayout->insertWidget(0, gameSelector); viewLayout->insertWidget(0, gameSelector);
break;
} }
case StatusPlaying: case StatusPlaying:
phasesToolbar->setEnabled(true); phasesToolbar->setEnabled(true);
...@@ -186,6 +189,8 @@ void MainWindow::serverTimeout() ...@@ -186,6 +189,8 @@ void MainWindow::serverTimeout()
void MainWindow::retranslateUi() void MainWindow::retranslateUi()
{ {
setWindowTitle(tr("Cockatrice"));
aConnect->setText(tr("&Connect...")); aConnect->setText(tr("&Connect..."));
aDisconnect->setText(tr("&Disconnect")); aDisconnect->setText(tr("&Disconnect"));
aRestartGame->setText(tr("&Restart game...")); aRestartGame->setText(tr("&Restart game..."));
......
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment