mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-05 04:53:54 -07:00
Added option to customize the card back picture
This commit is contained in:
parent
5ee6bdd338
commit
11e1202dcc
8 changed files with 146 additions and 130 deletions
|
|
@ -124,21 +124,22 @@ QPixmap *CardInfo::loadPixmap()
|
|||
return pixmap;
|
||||
|
||||
if (getName().isEmpty()) {
|
||||
pixmap->load(QString("%1/back.jpg").arg(picsPath));
|
||||
pixmap->load(settingsCache->getCardBackPicturePath());
|
||||
return pixmap;
|
||||
}
|
||||
sets.sortByKey();
|
||||
SetList sortedSets = sets;
|
||||
sortedSets.sortByKey();
|
||||
|
||||
QString debugOutput = QString("CardDatabase: loading pixmap for '%1' from ").arg(getName());
|
||||
for (int i = 0; i < sets.size(); i++)
|
||||
debugOutput.append(QString("%1, ").arg(sets[i]->getShortName()));
|
||||
for (int i = 0; i < sortedSets.size(); i++)
|
||||
debugOutput.append(QString("%1, ").arg(sortedSets[i]->getShortName()));
|
||||
qDebug(debugOutput.toLatin1());
|
||||
|
||||
QString correctedName = getCorrectedName();
|
||||
for (int i = 0; i < sets.size(); i++) {
|
||||
if (pixmap->load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(sets[i]->getShortName()).arg(correctedName)))
|
||||
for (int i = 0; i < sortedSets.size(); i++) {
|
||||
if (pixmap->load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(sortedSets[i]->getShortName()).arg(correctedName)))
|
||||
return pixmap;
|
||||
if (pixmap->load(QString("%1/%2/%3%4.full.jpg").arg(picsPath).arg(sets[i]->getShortName()).arg(correctedName).arg(1)))
|
||||
if (pixmap->load(QString("%1/%2/%3%4.full.jpg").arg(picsPath).arg(sortedSets[i]->getShortName()).arg(correctedName).arg(1)))
|
||||
return pixmap;
|
||||
}
|
||||
if (pixmap->load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg("downloadedPics").arg(correctedName)))
|
||||
|
|
@ -245,6 +246,7 @@ CardDatabase::CardDatabase(QObject *parent)
|
|||
|
||||
noCard = new CardInfo(this);
|
||||
noCard->loadPixmap(); // cache pixmap for card back
|
||||
connect(settingsCache, SIGNAL(cardBackPicturePathChanged()), noCard, SLOT(updatePixmapCache()));
|
||||
}
|
||||
|
||||
CardDatabase::~CardDatabase()
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ public:
|
|||
QPixmap *getPixmap(QSize size);
|
||||
void clearPixmapCache();
|
||||
void clearPixmapCacheMiss();
|
||||
public slots:
|
||||
void updatePixmapCache();
|
||||
signals:
|
||||
void pixmapUpdated();
|
||||
|
|
|
|||
|
|
@ -67,14 +67,6 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
QPushButton *cardDatabasePathButton = new QPushButton("...");
|
||||
connect(cardDatabasePathButton, SIGNAL(clicked()), this, SLOT(cardDatabasePathButtonClicked()));
|
||||
|
||||
/*
|
||||
cardBackgroundPathLabel = new QLabel;
|
||||
cardBackgroundPathEdit = new QLineEdit(settings.value("cardbackground").toString());
|
||||
cardBackgroundPathEdit->setReadOnly(true);
|
||||
QPushButton *cardBackgroundPathButton = new QPushButton("...");
|
||||
connect(cardBackgroundPathButton, SIGNAL(clicked()), this, SLOT(cardBackgroundPathButtonClicked()));
|
||||
*/
|
||||
|
||||
QGridLayout *pathsGrid = new QGridLayout;
|
||||
pathsGrid->addWidget(deckPathLabel, 0, 0);
|
||||
pathsGrid->addWidget(deckPathEdit, 0, 1);
|
||||
|
|
@ -85,11 +77,6 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
pathsGrid->addWidget(cardDatabasePathLabel, 2, 0);
|
||||
pathsGrid->addWidget(cardDatabasePathEdit, 2, 1);
|
||||
pathsGrid->addWidget(cardDatabasePathButton, 2, 2);
|
||||
/*
|
||||
pathsGrid->addWidget(cardBackgroundPathLabel, 3, 0);
|
||||
pathsGrid->addWidget(cardBackgroundPathEdit, 3, 1);
|
||||
pathsGrid->addWidget(cardBackgroundPathButton, 3, 2);
|
||||
*/
|
||||
pathsGroupBox = new QGroupBox;
|
||||
pathsGroupBox->setLayout(pathsGrid);
|
||||
|
||||
|
|
@ -146,19 +133,6 @@ void GeneralSettingsPage::cardDatabasePathButtonClicked()
|
|||
settingsCache->setCardDatabasePath(path);
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::cardBackgroundPathButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
QSettings settings;
|
||||
settings.beginGroup("paths");
|
||||
settings.setValue("cardbackground", path);
|
||||
cardBackgroundPathEdit->setText(path);
|
||||
|
||||
emit cardBackgroundPathChanged(path);
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::languageBoxChanged(int index)
|
||||
{
|
||||
settingsCache->setLang(languageBox->itemData(index).toString());
|
||||
|
|
@ -173,7 +147,6 @@ void GeneralSettingsPage::retranslateUi()
|
|||
deckPathLabel->setText(tr("Decks directory:"));
|
||||
picsPathLabel->setText(tr("Pictures directory:"));
|
||||
cardDatabasePathLabel->setText(tr("Path to card database:"));
|
||||
//cardBackgroundPathLabel->setText(tr("Path to card background:"));
|
||||
}
|
||||
|
||||
AppearanceSettingsPage::AppearanceSettingsPage()
|
||||
|
|
@ -196,6 +169,12 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
QPushButton *playerAreaBgButton = new QPushButton("...");
|
||||
connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked()));
|
||||
|
||||
cardBackPicturePathLabel = new QLabel;
|
||||
cardBackPicturePathEdit = new QLineEdit(settingsCache->getCardBackPicturePath());
|
||||
cardBackPicturePathEdit->setReadOnly(true);
|
||||
QPushButton *cardBackPicturePathButton = new QPushButton("...");
|
||||
connect(cardBackPicturePathButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathButtonClicked()));
|
||||
|
||||
QGridLayout *zoneBgGrid = new QGridLayout;
|
||||
zoneBgGrid->addWidget(handBgLabel, 0, 0);
|
||||
zoneBgGrid->addWidget(handBgEdit, 0, 1);
|
||||
|
|
@ -206,6 +185,9 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
zoneBgGrid->addWidget(playerAreaBgLabel, 2, 0);
|
||||
zoneBgGrid->addWidget(playerAreaBgEdit, 2, 1);
|
||||
zoneBgGrid->addWidget(playerAreaBgButton, 2, 2);
|
||||
zoneBgGrid->addWidget(cardBackPicturePathLabel, 3, 0);
|
||||
zoneBgGrid->addWidget(cardBackPicturePathEdit, 3, 1);
|
||||
zoneBgGrid->addWidget(cardBackPicturePathButton, 3, 2);
|
||||
|
||||
zoneBgGroupBox = new QGroupBox;
|
||||
zoneBgGroupBox->setLayout(zoneBgGrid);
|
||||
|
|
@ -260,6 +242,7 @@ void AppearanceSettingsPage::retranslateUi()
|
|||
handBgLabel->setText(tr("Path to hand background:"));
|
||||
tableBgLabel->setText(tr("Path to table background:"));
|
||||
playerAreaBgLabel->setText(tr("Path to player info background:"));
|
||||
cardBackPicturePathLabel->setText(tr("Path to picture of card back:"));
|
||||
|
||||
handGroupBox->setTitle(tr("Hand layout"));
|
||||
horizontalHandCheckBox->setText(tr("Display hand horizontally (wastes space)"));
|
||||
|
|
@ -302,6 +285,16 @@ void AppearanceSettingsPage::playerAreaBgButtonClicked()
|
|||
settingsCache->setPlayerBgPath(path);
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::cardBackPicturePathButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
cardBackPicturePathEdit->setText(path);
|
||||
settingsCache->setCardBackPicturePath(path);
|
||||
}
|
||||
|
||||
UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||
{
|
||||
doubleClickToPlayCheckBox = new QCheckBox;
|
||||
|
|
@ -422,7 +415,6 @@ DlgSettings::DlgSettings(QWidget *parent)
|
|||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(hboxLayout);
|
||||
//mainLayout->addStretch(1);
|
||||
mainLayout->addSpacing(12);
|
||||
mainLayout->addLayout(buttonsLayout);
|
||||
setLayout(mainLayout);
|
||||
|
|
|
|||
|
|
@ -29,22 +29,20 @@ private slots:
|
|||
void deckPathButtonClicked();
|
||||
void picsPathButtonClicked();
|
||||
void cardDatabasePathButtonClicked();
|
||||
void cardBackgroundPathButtonClicked();
|
||||
void languageBoxChanged(int index);
|
||||
signals:
|
||||
void picsPathChanged(const QString &path);
|
||||
void cardDatabasePathChanged(const QString &path);
|
||||
void cardBackgroundPathChanged(const QString &path);
|
||||
void changeLanguage(const QString &qmFile);
|
||||
void picDownloadChanged(int state);
|
||||
private:
|
||||
QStringList findQmFiles();
|
||||
QString languageName(const QString &qmFile);
|
||||
QLineEdit *deckPathEdit, *picsPathEdit, *cardDatabasePathEdit, *cardBackgroundPathEdit;
|
||||
QLineEdit *deckPathEdit, *picsPathEdit, *cardDatabasePathEdit;
|
||||
QGroupBox *personalGroupBox, *pathsGroupBox;
|
||||
QComboBox *languageBox;
|
||||
QCheckBox *picDownloadCheckBox;
|
||||
QLabel *languageLabel, *deckPathLabel, *picsPathLabel, *cardDatabasePathLabel, *cardBackgroundPathLabel;
|
||||
QLabel *languageLabel, *deckPathLabel, *picsPathLabel, *cardDatabasePathLabel;
|
||||
};
|
||||
|
||||
class AppearanceSettingsPage : public AbstractSettingsPage {
|
||||
|
|
@ -53,13 +51,15 @@ private slots:
|
|||
void handBgButtonClicked();
|
||||
void tableBgButtonClicked();
|
||||
void playerAreaBgButtonClicked();
|
||||
void cardBackPicturePathButtonClicked();
|
||||
signals:
|
||||
void handBgChanged(const QString &path);
|
||||
void tableBgChanged(const QString &path);
|
||||
void playerAreaBgChanged(const QString &path);
|
||||
void cardBackPicturePathChanged(const QString &path);
|
||||
private:
|
||||
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel;
|
||||
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit;
|
||||
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel, *cardBackPicturePathLabel;
|
||||
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit, *cardBackPicturePathEdit;
|
||||
QCheckBox *horizontalHandCheckBox, *economicGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
||||
QGroupBox *zoneBgGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox;
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ SettingsCache::SettingsCache()
|
|||
handBgPath = settings->value("zonebg/hand").toString();
|
||||
tableBgPath = settings->value("zonebg/table").toString();
|
||||
playerBgPath = settings->value("zonebg/playerarea").toString();
|
||||
cardBackPicturePath = settings->value("paths/cardbackpicture").toString();
|
||||
|
||||
picDownload = settings->value("personal/picturedownload", false).toBool();
|
||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||
|
|
@ -72,6 +73,13 @@ void SettingsCache::setPlayerBgPath(const QString &_playerBgPath)
|
|||
emit playerBgPathChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setCardBackPicturePath(const QString &_cardBackPicturePath)
|
||||
{
|
||||
cardBackPicturePath = _cardBackPicturePath;
|
||||
settings->setValue("paths/cardbackpicture", cardBackPicturePath);
|
||||
emit cardBackPicturePathChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setPicDownload(int _picDownload)
|
||||
{
|
||||
picDownload = _picDownload;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ signals:
|
|||
void handBgPathChanged();
|
||||
void tableBgPathChanged();
|
||||
void playerBgPathChanged();
|
||||
void cardBackPicturePathChanged();
|
||||
void picDownloadChanged();
|
||||
void horizontalHandChanged();
|
||||
void economicGridChanged();
|
||||
|
|
@ -22,7 +23,7 @@ private:
|
|||
|
||||
QString lang;
|
||||
QString deckPath, picsPath, cardDatabasePath;
|
||||
QString handBgPath, tableBgPath, playerBgPath;
|
||||
QString handBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
|
||||
bool picDownload;
|
||||
bool doubleClickToPlay;
|
||||
bool horizontalHand;
|
||||
|
|
@ -37,6 +38,7 @@ public:
|
|||
QString getHandBgPath() const { return handBgPath; }
|
||||
QString getTableBgPath() const { return tableBgPath; }
|
||||
QString getPlayerBgPath() const { return playerBgPath; }
|
||||
QString getCardBackPicturePath() const { return cardBackPicturePath; }
|
||||
bool getPicDownload() const { return picDownload; }
|
||||
bool getDoubleClickToPlay() const { return doubleClickToPlay; }
|
||||
bool getHorizontalHand() const { return horizontalHand; }
|
||||
|
|
@ -51,6 +53,7 @@ public slots:
|
|||
void setHandBgPath(const QString &_handBgPath);
|
||||
void setTableBgPath(const QString &_tableBgPath);
|
||||
void setPlayerBgPath(const QString &_playerBgPath);
|
||||
void setCardBackPicturePath(const QString &_cardBackPicturePath);
|
||||
void setPicDownload(int _picDownload);
|
||||
void setDoubleClickToPlay(int _doubleClickToPlay);
|
||||
void setHorizontalHand(int _horizontalHand);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue