phases toolbar improvement
This commit is contained in:
parent
a5280946c2
commit
0dbc580b8a
6 changed files with 33 additions and 18 deletions
|
@ -107,6 +107,7 @@ public slots:
|
||||||
PendingCommand *say(const QString &s);
|
PendingCommand *say(const QString &s);
|
||||||
PendingCommand *shuffle();
|
PendingCommand *shuffle();
|
||||||
PendingCommand *rollDie(unsigned int sides);
|
PendingCommand *rollDie(unsigned int sides);
|
||||||
|
PendingCommand *drawCard() { return drawCards(1); }
|
||||||
PendingCommand *drawCards(unsigned int number);
|
PendingCommand *drawCards(unsigned int number);
|
||||||
PendingCommand *moveCard(int cardid, const QString &startzone, const QString &targetzone, int x, int y = 0, bool faceDown = false);
|
PendingCommand *moveCard(int cardid, const QString &startzone, const QString &targetzone, int x, int y = 0, bool faceDown = false);
|
||||||
PendingCommand *createToken(const QString &zone, const QString &name, const QString &powtough, int x, int y);
|
PendingCommand *createToken(const QString &zone, const QString &name, const QString &powtough, int x, int y);
|
||||||
|
|
|
@ -294,8 +294,10 @@ void Game::gameEvent(const ServerEventData &msg)
|
||||||
case eventSetActivePhase: {
|
case eventSetActivePhase: {
|
||||||
QStringList data = msg.getEventData();
|
QStringList data = msg.getEventData();
|
||||||
int phase = data[0].toInt();
|
int phase = data[0].toInt();
|
||||||
currentPhase = phase;
|
if (currentPhase != phase) {
|
||||||
emit setActivePhase(phase);
|
currentPhase = phase;
|
||||||
|
emit setActivePhase(phase);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,7 @@ private:
|
||||||
int currentPhase;
|
int currentPhase;
|
||||||
Player *addPlayer(int playerId, const QString &playerName, QPointF base, bool local);
|
Player *addPlayer(int playerId, const QString &playerName, QPointF base, bool local);
|
||||||
void initSayMenu();
|
void initSayMenu();
|
||||||
private slots:
|
public slots:
|
||||||
void cardMenuAction();
|
|
||||||
|
|
||||||
void actNextPhase();
|
void actNextPhase();
|
||||||
void actNextTurn();
|
void actNextTurn();
|
||||||
void actUntapAll();
|
void actUntapAll();
|
||||||
|
@ -47,6 +45,8 @@ private slots:
|
||||||
void actSetLife();
|
void actSetLife();
|
||||||
void actRollDie();
|
void actRollDie();
|
||||||
void actCreateToken();
|
void actCreateToken();
|
||||||
|
private slots:
|
||||||
|
void cardMenuAction();
|
||||||
|
|
||||||
void showCardMenu(QPoint p);
|
void showCardMenu(QPoint p);
|
||||||
void actTap(CardItem *card);
|
void actTap(CardItem *card);
|
||||||
|
|
|
@ -4,17 +4,12 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
PhaseButton::PhaseButton(QIcon icon)
|
PhaseButton::PhaseButton(const QIcon &icon, QAction *_doubleClickAction)
|
||||||
: QPushButton(icon, QString()), active(false)
|
: QPushButton(icon, QString()), active(false), doubleClickAction(_doubleClickAction)
|
||||||
{
|
{
|
||||||
setFixedSize(50, 50);
|
setFixedSize(50, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhaseButton::update()
|
|
||||||
{
|
|
||||||
QPushButton::update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhaseButton::paintEvent(QPaintEvent *event)
|
void PhaseButton::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPushButton::paintEvent(event);
|
QPushButton::paintEvent(event);
|
||||||
|
@ -42,12 +37,23 @@ void PhaseButton::setPhaseText(const QString &_phaseText)
|
||||||
setToolTip(phaseText);
|
setToolTip(phaseText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhaseButton::mouseDoubleClickEvent(QMouseEvent */*event*/)
|
||||||
|
{
|
||||||
|
if (doubleClickAction)
|
||||||
|
doubleClickAction->trigger();
|
||||||
|
}
|
||||||
|
|
||||||
PhasesToolbar::PhasesToolbar(QWidget *parent)
|
PhasesToolbar::PhasesToolbar(QWidget *parent)
|
||||||
: QFrame(parent)
|
: QFrame(parent)
|
||||||
{
|
{
|
||||||
PhaseButton *untapButton = new PhaseButton(QIcon(":/resources/icon_phase_untap.svg"));
|
QAction *aUntapAll = new QAction(this);
|
||||||
|
connect(aUntapAll, SIGNAL(triggered()), this, SIGNAL(signalUntapAll()));
|
||||||
|
QAction *aDrawCard = new QAction(this);
|
||||||
|
connect(aDrawCard, SIGNAL(triggered()), this, SIGNAL(signalDrawCard()));
|
||||||
|
|
||||||
|
PhaseButton *untapButton = new PhaseButton(QIcon(":/resources/icon_phase_untap.svg"), aUntapAll);
|
||||||
PhaseButton *upkeepButton = new PhaseButton(QIcon(":/resources/icon_phase_upkeep.svg"));
|
PhaseButton *upkeepButton = new PhaseButton(QIcon(":/resources/icon_phase_upkeep.svg"));
|
||||||
PhaseButton *drawButton = new PhaseButton(QIcon(":/resources/icon_phase_draw.svg"));
|
PhaseButton *drawButton = new PhaseButton(QIcon(":/resources/icon_phase_draw.svg"), aDrawCard);
|
||||||
PhaseButton *main1Button = new PhaseButton(QIcon(":/resources/icon_phase_main1.svg"));
|
PhaseButton *main1Button = new PhaseButton(QIcon(":/resources/icon_phase_main1.svg"));
|
||||||
PhaseButton *combatStartButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_start.svg"));
|
PhaseButton *combatStartButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_start.svg"));
|
||||||
PhaseButton *combatAttackersButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_attackers.svg"));
|
PhaseButton *combatAttackersButton = new PhaseButton(QIcon(":/resources/icon_phase_combat_attackers.svg"));
|
||||||
|
@ -125,5 +131,7 @@ void PhasesToolbar::setActivePhase(int phase)
|
||||||
void PhasesToolbar::phaseButtonClicked()
|
void PhasesToolbar::phaseButtonClicked()
|
||||||
{
|
{
|
||||||
PhaseButton *button = qobject_cast<PhaseButton *>(sender());
|
PhaseButton *button = qobject_cast<PhaseButton *>(sender());
|
||||||
|
if (button->getActive())
|
||||||
|
return;
|
||||||
emit signalSetPhase(buttonList.indexOf(button));
|
emit signalSetPhase(buttonList.indexOf(button));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,16 @@ class PhaseButton : public QPushButton {
|
||||||
private:
|
private:
|
||||||
QString phaseText;
|
QString phaseText;
|
||||||
bool active;
|
bool active;
|
||||||
|
QAction *doubleClickAction;
|
||||||
public:
|
public:
|
||||||
PhaseButton();
|
PhaseButton(const QIcon &icon, QAction *_doubleClickAction = 0);
|
||||||
PhaseButton(QIcon);
|
|
||||||
void setPhaseText(const QString &_phaseText);
|
void setPhaseText(const QString &_phaseText);
|
||||||
QString getPhaseText() const { return phaseText; }
|
QString getPhaseText() const { return phaseText; }
|
||||||
void setActive(bool _active) { active = _active; update(); }
|
void setActive(bool _active) { active = _active; update(); }
|
||||||
public slots:
|
bool getActive() const { return active; }
|
||||||
void update();
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PhasesToolbar : public QFrame {
|
class PhasesToolbar : public QFrame {
|
||||||
|
@ -38,6 +38,8 @@ private slots:
|
||||||
signals:
|
signals:
|
||||||
void signalSetPhase(int phase);
|
void signalSetPhase(int phase);
|
||||||
void signalNextTurn();
|
void signalNextTurn();
|
||||||
|
void signalUntapAll();
|
||||||
|
void signalDrawCard();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -179,6 +179,7 @@ void MainWindow::playerIdReceived(int id, QString name)
|
||||||
connect(game, SIGNAL(playerAdded(Player *)), this, SLOT(playerAdded(Player *)));
|
connect(game, SIGNAL(playerAdded(Player *)), this, SLOT(playerAdded(Player *)));
|
||||||
connect(game, SIGNAL(playerRemoved(Player *)), this, SLOT(playerRemoved(Player *)));
|
connect(game, SIGNAL(playerRemoved(Player *)), this, SLOT(playerRemoved(Player *)));
|
||||||
connect(game, SIGNAL(setActivePhase(int)), phasesToolbar, SLOT(setActivePhase(int)));
|
connect(game, SIGNAL(setActivePhase(int)), phasesToolbar, SLOT(setActivePhase(int)));
|
||||||
|
connect(phasesToolbar, SIGNAL(signalUntapAll()), game, SLOT(actUntapAll()));
|
||||||
playerAdded(game->getLocalPlayer());
|
playerAdded(game->getLocalPlayer());
|
||||||
|
|
||||||
messageLog->connectToGame(game);
|
messageLog->connectToGame(game);
|
||||||
|
@ -342,6 +343,7 @@ MainWindow::MainWindow(QTranslator *_translator, QWidget *parent)
|
||||||
connect(client, SIGNAL(serverError(ServerResponse)), messageLog, SLOT(logServerError(ServerResponse)));
|
connect(client, SIGNAL(serverError(ServerResponse)), messageLog, SLOT(logServerError(ServerResponse)));
|
||||||
connect(phasesToolbar, SIGNAL(signalSetPhase(int)), client, SLOT(setActivePhase(int)));
|
connect(phasesToolbar, SIGNAL(signalSetPhase(int)), client, SLOT(setActivePhase(int)));
|
||||||
connect(phasesToolbar, SIGNAL(signalNextTurn()), client, SLOT(nextTurn()));
|
connect(phasesToolbar, SIGNAL(signalNextTurn()), client, SLOT(nextTurn()));
|
||||||
|
connect(phasesToolbar, SIGNAL(signalDrawCard()), client, SLOT(drawCard()));
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
createMenus();
|
createMenus();
|
||||||
|
|
Loading…
Reference in a new issue