Merge pull request #7 from skoh-fley/play-to-stack-option

Added a UI option to play all nonlands to the stack instead of the battlefield
This commit is contained in:
Daenyth 2013-07-11 10:58:55 -07:00
commit 92ff503832
5 changed files with 22 additions and 2 deletions

View file

@ -435,8 +435,13 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
doubleClickToPlayCheckBox->setChecked(settingsCache->getDoubleClickToPlay());
connect(doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
playToStackCheckBox = new QCheckBox;
playToStackCheckBox->setChecked(settingsCache->getPlayToStack());
connect(playToStackCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPlayToStack(int)));
QGridLayout *generalGrid = new QGridLayout;
generalGrid->addWidget(doubleClickToPlayCheckBox, 0, 0);
generalGrid->addWidget(playToStackCheckBox, 1, 0);
generalGroupBox = new QGroupBox;
generalGroupBox->setLayout(generalGrid);
@ -485,6 +490,7 @@ void UserInterfaceSettingsPage::retranslateUi()
{
generalGroupBox->setTitle(tr("General interface settings"));
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
playToStackCheckBox->setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
animationGroupBox->setTitle(tr("Animation settings"));
tapAnimationCheckBox->setText(tr("&Tap/untap animation"));
soundEnabledCheckBox->setText(tr("Enable &sounds"));

View file

@ -82,6 +82,7 @@ signals:
void soundPathChanged();
private:
QCheckBox *doubleClickToPlayCheckBox;
QCheckBox *playToStackCheckBox;
QCheckBox *tapAnimationCheckBox;
QCheckBox *soundEnabledCheckBox;
QLabel *soundPathLabel;

View file

@ -1513,7 +1513,9 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
cardToMove->set_card_id(c->getId());
CardInfo *ci = c->getInfo();
if (ci->getTableRow() == 3) {
if ((!settingsCache->getPlayToStack() && ci->getTableRow() == 3) ||
(settingsCache->getPlayToStack() && ci->getTableRow() != 0) &&
c->getZone()->getName().toStdString() != "stack") {
cmd.set_target_zone("stack");
cmd.set_x(0);
cmd.set_y(0);
@ -1522,7 +1524,8 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
cardToMove->set_face_down(faceDown);
cardToMove->set_pt(ci->getPowTough().toStdString());
cardToMove->set_tapped(tapped);
cmd.set_target_zone("table");
if(ci->getTableRow() != 3)
cmd.set_target_zone("table");
cmd.set_x(gridPoint.x());
cmd.set_y(gridPoint.y());
}

View file

@ -22,6 +22,7 @@ SettingsCache::SettingsCache()
mainWindowGeometry = settings->value("interface/main_window_geometry").toByteArray();
picDownload = settings->value("personal/picturedownload", true).toBool();
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
playToStack = settings->value("interface/playtostack", false).toBool();
cardInfoMinimized = settings->value("interface/cardinfominimized", 0).toInt();
tabGameSplitterSizes = settings->value("interface/tabgame_splittersizes").toByteArray();
displayCardNames = settings->value("cards/displaycardnames", true).toBool();
@ -129,6 +130,12 @@ void SettingsCache::setDoubleClickToPlay(int _doubleClickToPlay)
settings->setValue("interface/doubleclicktoplay", doubleClickToPlay);
}
void SettingsCache::setPlayToStack(int _playToStack)
{
playToStack = _playToStack;
settings->setValue("interface/playtostack", playToStack);
}
void SettingsCache::setCardInfoMinimized(int _cardInfoMinimized)
{
cardInfoMinimized = _cardInfoMinimized;

View file

@ -34,6 +34,7 @@ private:
QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
bool picDownload;
bool doubleClickToPlay;
bool playToStack;
int cardInfoMinimized;
QByteArray tabGameSplitterSizes;
bool displayCardNames;
@ -62,6 +63,7 @@ public:
QString getCardBackPicturePath() const { return cardBackPicturePath; }
bool getPicDownload() const { return picDownload; }
bool getDoubleClickToPlay() const { return doubleClickToPlay; }
bool getPlayToStack() const { return playToStack; }
int getCardInfoMinimized() const { return cardInfoMinimized; }
QByteArray getTabGameSplitterSizes() const { return tabGameSplitterSizes; }
bool getDisplayCardNames() const { return displayCardNames; }
@ -90,6 +92,7 @@ public slots:
void setCardBackPicturePath(const QString &_cardBackPicturePath);
void setPicDownload(int _picDownload);
void setDoubleClickToPlay(int _doubleClickToPlay);
void setPlayToStack(int _playToStack);
void setCardInfoMinimized(int _cardInfoMinimized);
void setTabGameSplitterSizes(const QByteArray &_tabGameSplitterSizes);
void setDisplayCardNames(int _displayCardNames);