mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
phase toolbar
This commit is contained in:
parent
0e4517bf63
commit
cb90463530
12 changed files with 146 additions and 81 deletions
|
|
@ -1,35 +1,79 @@
|
|||
#include "phasestoolbar.h"
|
||||
#include <QAction>
|
||||
//#include <QPushButton>
|
||||
#include "phasebutton.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QButtonGroup>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
|
||||
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"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue