zone background textures
This commit is contained in:
parent
af605ab1f8
commit
7c06d6d84f
8 changed files with 124 additions and 3 deletions
|
@ -191,12 +191,93 @@ void GeneralSettingsPage::retranslateUi()
|
|||
|
||||
AppearanceSettingsPage::AppearanceSettingsPage()
|
||||
{
|
||||
zoneBgGroupBox = new QGroupBox;
|
||||
QSettings settings;
|
||||
settings.beginGroup("zonebg");
|
||||
|
||||
handBgLabel = new QLabel;
|
||||
handBgEdit = new QLineEdit(settings.value("hand").toString());
|
||||
handBgEdit->setReadOnly(true);
|
||||
QPushButton *handBgButton = new QPushButton("...");
|
||||
connect(handBgButton, SIGNAL(clicked()), this, SLOT(handBgButtonClicked()));
|
||||
|
||||
tableBgLabel = new QLabel;
|
||||
tableBgEdit = new QLineEdit(settings.value("table").toString());
|
||||
tableBgEdit->setReadOnly(true);
|
||||
QPushButton *tableBgButton = new QPushButton("...");
|
||||
connect(tableBgButton, SIGNAL(clicked()), this, SLOT(tableBgButtonClicked()));
|
||||
|
||||
playerAreaBgLabel = new QLabel;
|
||||
playerAreaBgEdit = new QLineEdit(settings.value("carddatabase").toString());
|
||||
playerAreaBgEdit->setReadOnly(true);
|
||||
QPushButton *playerAreaBgButton = new QPushButton("...");
|
||||
connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked()));
|
||||
|
||||
QGridLayout *zoneBgGrid = new QGridLayout;
|
||||
zoneBgGrid->addWidget(handBgLabel, 0, 0);
|
||||
zoneBgGrid->addWidget(handBgEdit, 0, 1);
|
||||
zoneBgGrid->addWidget(handBgButton, 0, 2);
|
||||
zoneBgGrid->addWidget(tableBgLabel, 1, 0);
|
||||
zoneBgGrid->addWidget(tableBgEdit, 1, 1);
|
||||
zoneBgGrid->addWidget(tableBgButton, 1, 2);
|
||||
zoneBgGrid->addWidget(playerAreaBgLabel, 2, 0);
|
||||
zoneBgGrid->addWidget(playerAreaBgEdit, 2, 1);
|
||||
zoneBgGrid->addWidget(playerAreaBgButton, 2, 2);
|
||||
|
||||
zoneBgGroupBox->setLayout(zoneBgGrid);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(zoneBgGroupBox);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::retranslateUi()
|
||||
{
|
||||
zoneBgGroupBox->setTitle(tr("Zone background pictures"));
|
||||
handBgLabel->setText(tr("Path to hand background:"));
|
||||
tableBgLabel->setText(tr("Path to table background:"));
|
||||
playerAreaBgLabel->setText(tr("Path to player info background:"));
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::handBgButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
QSettings settings;
|
||||
settings.beginGroup("zonebg");
|
||||
settings.setValue("hand", path);
|
||||
handBgEdit->setText(path);
|
||||
|
||||
emit handBgChanged(path);
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::tableBgButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
QSettings settings;
|
||||
settings.beginGroup("zonebg");
|
||||
settings.setValue("table", path);
|
||||
tableBgEdit->setText(path);
|
||||
|
||||
emit tableBgChanged(path);
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::playerAreaBgButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
QSettings settings;
|
||||
settings.beginGroup("zonebg");
|
||||
settings.setValue("playerarea", path);
|
||||
playerAreaBgEdit->setText(path);
|
||||
|
||||
emit playerAreaBgChanged(path);
|
||||
}
|
||||
|
||||
MessagesSettingsPage::MessagesSettingsPage()
|
||||
|
|
|
@ -50,6 +50,18 @@ private:
|
|||
|
||||
class AppearanceSettingsPage : public AbstractSettingsPage {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void handBgButtonClicked();
|
||||
void tableBgButtonClicked();
|
||||
void playerAreaBgButtonClicked();
|
||||
signals:
|
||||
void handBgChanged(const QString &path);
|
||||
void tableBgChanged(const QString &path);
|
||||
void playerAreaBgChanged(const QString &path);
|
||||
private:
|
||||
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel;
|
||||
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit;
|
||||
QGroupBox *zoneBgGroupBox;
|
||||
public:
|
||||
AppearanceSettingsPage();
|
||||
void retranslateUi();
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
HandZone::HandZone(Player *_p, QGraphicsItem *parent)
|
||||
: CardZone(_p, "hand", false, false, _p->getLocal(), parent)
|
||||
{
|
||||
QSettings settings;
|
||||
QString bgPath = settings.value("zonebg/hand").toString();
|
||||
if (!bgPath.isEmpty())
|
||||
bgPixmap.load(bgPath);
|
||||
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
setAcceptsHoverEvents(true); // Awkwardly, this is needed to repaint the cached item after it has been corrupted by buggy rubberband drag.
|
||||
}
|
||||
|
@ -17,7 +22,10 @@ QRectF HandZone::boundingRect() const
|
|||
|
||||
void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||
{
|
||||
painter->fillRect(boundingRect(), Qt::darkGreen);
|
||||
if (bgPixmap.isNull())
|
||||
painter->fillRect(boundingRect(), Qt::darkGreen);
|
||||
else
|
||||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||
}
|
||||
|
||||
void HandZone::reorganizeCards()
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
class HandZone : public CardZone {
|
||||
private:
|
||||
QPixmap bgPixmap;
|
||||
public:
|
||||
HandZone(Player *_p, QGraphicsItem *parent = 0);
|
||||
QRectF boundingRect() const;
|
||||
|
|
|
@ -5,10 +5,15 @@
|
|||
#include "pilezone.h"
|
||||
#include "counter.h"
|
||||
#include <QPainter>
|
||||
#include <QSettings>
|
||||
|
||||
PlayerArea::PlayerArea(Player *_player, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent), player(_player)
|
||||
{
|
||||
QSettings settings;
|
||||
QString bgPath = settings.value("zonebg/playerarea").toString();
|
||||
if (!bgPath.isEmpty())
|
||||
bgPixmap.load(bgPath);
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
|
||||
QPointF base = QPointF(55, 50);
|
||||
|
@ -51,7 +56,10 @@ QRectF PlayerArea::boundingRect() const
|
|||
|
||||
void PlayerArea::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||
{
|
||||
painter->fillRect(boundingRect(), QColor(200, 200, 200));
|
||||
if (bgPixmap.isNull())
|
||||
painter->fillRect(boundingRect(), QColor(200, 200, 200));
|
||||
else
|
||||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||
|
||||
QString nameStr = player->getName();
|
||||
QFont font("Times");
|
||||
|
|
|
@ -9,6 +9,7 @@ class Counter;
|
|||
|
||||
class PlayerArea : public QGraphicsItem {
|
||||
private:
|
||||
QPixmap bgPixmap;
|
||||
QRectF bRect;
|
||||
Player *player;
|
||||
QList<Counter *> counterList;
|
||||
|
|
|
@ -48,6 +48,12 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
|||
<< QPoint(19, 0)
|
||||
<< QPoint(1, 0)
|
||||
<< QPoint(22, 0));
|
||||
QSettings settings;
|
||||
QString bgPath = settings.value("zonebg/table").toString();
|
||||
if (!bgPath.isEmpty())
|
||||
bgPixmap.load(bgPath);
|
||||
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
}
|
||||
|
||||
QRectF TableZone::boundingRect() const
|
||||
|
@ -57,7 +63,10 @@ QRectF TableZone::boundingRect() const
|
|||
|
||||
void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||
{
|
||||
painter->fillRect(boundingRect(), QColor(0, 0, 100));
|
||||
if (bgPixmap.isNull())
|
||||
painter->fillRect(boundingRect(), QColor(0, 0, 100));
|
||||
else
|
||||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||
}
|
||||
|
||||
void TableZone::addCardImpl(CardItem *card, int _x, int _y)
|
||||
|
|
|
@ -7,6 +7,7 @@ class TableZone : public CardZone {
|
|||
private:
|
||||
int width, height;
|
||||
QList<QList<QPoint> > gridPoints;
|
||||
QPixmap bgPixmap;
|
||||
public:
|
||||
static const int gridPointsPerCardX = 2;
|
||||
static const int gridPointsPerCardY = 3;
|
||||
|
|
Loading…
Reference in a new issue