Add an option to annotate tokens from card text (default off); fix #241

This commit is contained in:
Fabio Bas 2015-07-07 19:19:58 +02:00
parent 685aa99ad6
commit 68e176cc00
6 changed files with 23 additions and 3 deletions

View file

@ -10,10 +10,12 @@
#include <QTreeView>
#include <QRadioButton>
#include <QHeaderView>
#include "decklist.h"
#include "dlg_create_token.h"
#include "carddatabasemodel.h"
#include "main.h"
#include "settingscache.h"
DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent)
: QDialog(parent), predefinedTokens(_predefinedTokens)
@ -136,7 +138,8 @@ void DlgCreateToken::tokenSelectionChanged(const QModelIndex &current, const QMo
const QString cardColor = cardInfo->getColors().isEmpty() ? QString() : (cardInfo->getColors().size() > 1 ? QString("m") : cardInfo->getColors().first());
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
ptEdit->setText(cardInfo->getPowTough());
annotationEdit->setText(cardInfo->getText());
if(settingsCache->getAnnotateTokens())
annotationEdit->setText(cardInfo->getText());
}
void DlgCreateToken::actChooseTokenFromAll(bool checked)

View file

@ -482,12 +482,16 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
playToStackCheckBox.setChecked(settingsCache->getPlayToStack());
connect(&playToStackCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPlayToStack(int)));
annotateTokensCheckBox.setChecked(settingsCache->getAnnotateTokens());
connect(&annotateTokensCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setAnnotateTokens(int)));
QGridLayout *generalGrid = new QGridLayout;
generalGrid->addWidget(&notificationsEnabledCheckBox, 0, 0);
generalGrid->addWidget(&specNotificationsEnabledCheckBox, 1, 0);
generalGrid->addWidget(&doubleClickToPlayCheckBox, 2, 0);
generalGrid->addWidget(&playToStackCheckBox, 3, 0);
generalGrid->addWidget(&annotateTokensCheckBox, 4, 0);
generalGroupBox = new QGroupBox;
generalGroupBox->setLayout(generalGrid);
@ -519,6 +523,7 @@ void UserInterfaceSettingsPage::retranslateUi()
specNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar for game events while you are spectating"));
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"));
annotateTokensCheckBox.setText(tr("Annotate card text on tokens"));
animationGroupBox->setTitle(tr("Animation settings"));
tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
}

View file

@ -127,6 +127,7 @@ private:
QCheckBox specNotificationsEnabledCheckBox;
QCheckBox doubleClickToPlayCheckBox;
QCheckBox playToStackCheckBox;
QCheckBox annotateTokensCheckBox;
QCheckBox tapAnimationCheckBox;
QGroupBox *generalGroupBox;
QGroupBox *animationGroupBox;

View file

@ -1075,7 +1075,7 @@ void Player::actCreatePredefinedToken()
lastTokenName = cardInfo->getName();
lastTokenColor = cardInfo->getColors().isEmpty() ? QString() : cardInfo->getColors().first().toLower();
lastTokenPT = cardInfo->getPowTough();
lastTokenAnnotation = cardInfo->getText();
lastTokenAnnotation = settingsCache->getAnnotateTokens() ? cardInfo->getText() : "";
lastTokenTableRow = table->clampValidTableRow(2 - cardInfo->getTableRow());
lastTokenDestroy = true;
aCreateAnotherToken->setEnabled(true);
@ -1100,6 +1100,7 @@ void Player::actCreateRelatedCard()
cmd.set_card_name(cardInfo->getName().toStdString());
cmd.set_color(cardInfo->getColors().isEmpty() ? QString().toStdString() : cardInfo->getColors().first().toLower().toStdString());
cmd.set_pt(cardInfo->getPowTough().toStdString());
cmd.set_annotation(settingsCache->getAnnotateTokens() ? cardInfo->getText().toStdString() : QString().toStdString());
cmd.set_destroy_on_zone_change(true);
cmd.set_target_zone(sourceCard->getZone()->getName().toStdString());
cmd.set_target_card_id(sourceCard->getId());

View file

@ -46,6 +46,7 @@ SettingsCache::SettingsCache()
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
playToStack = settings->value("interface/playtostack", false).toBool();
annotateTokens = settings->value("interface/annotatetokens", false).toBool();
cardInfoMinimized = settings->value("interface/cardinfominimized", 0).toInt();
tabGameSplitterSizes = settings->value("interface/tabgame_splittersizes").toByteArray();
displayCardNames = settings->value("cards/displaycardnames", true).toBool();
@ -251,6 +252,12 @@ void SettingsCache::setPlayToStack(int _playToStack)
settings->setValue("interface/playtostack", playToStack);
}
void SettingsCache::setAnnotateTokens(int _annotateTokens)
{
annotateTokens = _annotateTokens;
settings->setValue("interface/annotatetokens", annotateTokens);
}
void SettingsCache::setCardInfoMinimized(int _cardInfoMinimized)
{
cardInfoMinimized = _cardInfoMinimized;

View file

@ -55,6 +55,7 @@ private:
bool spectatorNotificationsEnabled;
bool doubleClickToPlay;
bool playToStack;
bool annotateTokens;
int cardInfoMinimized;
QByteArray tabGameSplitterSizes;
bool displayCardNames;
@ -106,6 +107,7 @@ public:
bool getDoubleClickToPlay() const { return doubleClickToPlay; }
bool getPlayToStack() const { return playToStack; }
bool getAnnotateTokens() const { return annotateTokens; }
int getCardInfoMinimized() const { return cardInfoMinimized; }
QByteArray getTabGameSplitterSizes() const { return tabGameSplitterSizes; }
bool getDisplayCardNames() const { return displayCardNames; }
@ -161,6 +163,7 @@ public slots:
void setSpectatorNotificationsEnabled(int _spectatorNotificationsEnabled);
void setDoubleClickToPlay(int _doubleClickToPlay);
void setPlayToStack(int _playToStack);
void setAnnotateTokens(int _annotateTokens);
void setCardInfoMinimized(int _cardInfoMinimized);
void setTabGameSplitterSizes(const QByteArray &_tabGameSplitterSizes);
void setDisplayCardNames(int _displayCardNames);