mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-14 19:18:55 -07:00
Merge branch 'master' of ssh://cockatrice.de/home/cockgit/cockatrice
This commit is contained in:
commit
fbcb34db61
39 changed files with 1125 additions and 379 deletions
|
|
@ -3,13 +3,16 @@
|
|||
#include <QCursor>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <math.h>
|
||||
#include "carddatabase.h"
|
||||
#include "abstractcarditem.h"
|
||||
#include "settingscache.h"
|
||||
#include "main.h"
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
|
||||
AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphicsItem *parent)
|
||||
: ArrowTarget(_owner, parent), info(db->getCard(_name)), name(_name), tapped(false)
|
||||
: ArrowTarget(_owner, parent), info(db->getCard(_name)), name(_name), tapped(false), tapAngle(0)
|
||||
{
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
setFlag(ItemIsSelectable);
|
||||
|
|
@ -17,6 +20,10 @@ AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphi
|
|||
setCacheMode(DeviceCoordinateCache);
|
||||
|
||||
connect(info, SIGNAL(pixmapUpdated()), this, SLOT(pixmapUpdated()));
|
||||
|
||||
animationTimer = new QTimer(this);
|
||||
animationTimer->setSingleShot(false);
|
||||
connect(animationTimer, SIGNAL(timeout()), this, SLOT(animationEvent()));
|
||||
}
|
||||
|
||||
AbstractCardItem::~AbstractCardItem()
|
||||
|
|
@ -37,19 +44,22 @@ void AbstractCardItem::pixmapUpdated()
|
|||
void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||
{
|
||||
painter->save();
|
||||
QSizeF translatedSize = painter->combinedTransform().mapRect(boundingRect()).size();
|
||||
if (tapped)
|
||||
translatedSize.transpose();
|
||||
qreal w = painter->combinedTransform().map(QLineF(0, 0, boundingRect().width(), 0)).length();
|
||||
qreal h = painter->combinedTransform().map(QLineF(0, 0, 0, boundingRect().height())).length();
|
||||
QSizeF translatedSize(w, h);
|
||||
QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect());
|
||||
QPixmap *translatedPixmap = info->getPixmap(translatedSize.toSize());
|
||||
painter->save();
|
||||
if (translatedPixmap) {
|
||||
painter->resetTransform();
|
||||
if (tapped) {
|
||||
painter->translate(((qreal) translatedSize.height()) / 2, ((qreal) translatedSize.width()) / 2);
|
||||
painter->rotate(90);
|
||||
painter->translate(-((qreal) translatedSize.width()) / 2, -((qreal) translatedSize.height()) / 2);
|
||||
}
|
||||
painter->drawPixmap(translatedPixmap->rect(), *translatedPixmap, translatedPixmap->rect());
|
||||
QTransform pixmapTransform;
|
||||
pixmapTransform.translate(totalBoundingRect.width() / 2, totalBoundingRect.height() / 2);
|
||||
pixmapTransform.rotate(tapAngle);
|
||||
QPointF transPoint = QPointF(-w / 2, -h / 2);
|
||||
pixmapTransform.translate(transPoint.x(), transPoint.y());
|
||||
painter->setTransform(pixmapTransform);
|
||||
|
||||
painter->drawPixmap(QPointF(0, 0), *translatedPixmap);
|
||||
} else {
|
||||
QFont f("Times");
|
||||
f.setStyleHint(QFont::Serif);
|
||||
|
|
@ -105,6 +115,21 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
void AbstractCardItem::animationEvent()
|
||||
{
|
||||
int delta = 18;
|
||||
if (!tapped)
|
||||
delta *= -1;
|
||||
|
||||
tapAngle += delta;
|
||||
|
||||
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(tapAngle).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
|
||||
update();
|
||||
|
||||
if ((tapped && (tapAngle >= 90)) || (!tapped && (tapAngle <= 0)))
|
||||
animationTimer->stop();
|
||||
}
|
||||
|
||||
void AbstractCardItem::setName(const QString &_name)
|
||||
{
|
||||
disconnect(info, 0, this, 0);
|
||||
|
|
@ -120,14 +145,19 @@ void AbstractCardItem::setColor(const QString &_color)
|
|||
update();
|
||||
}
|
||||
|
||||
void AbstractCardItem::setTapped(bool _tapped)
|
||||
void AbstractCardItem::setTapped(bool _tapped, bool canAnimate)
|
||||
{
|
||||
if (tapped == _tapped)
|
||||
return;
|
||||
|
||||
tapped = _tapped;
|
||||
if (tapped)
|
||||
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(90).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
|
||||
else
|
||||
setTransform(QTransform());
|
||||
update();
|
||||
if (settingsCache->getTapAnimation() && canAnimate)
|
||||
animationTimer->start(25);
|
||||
else {
|
||||
tapAngle = tapped ? 90 : 0;
|
||||
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(tapAngle).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
class CardInfo;
|
||||
class Player;
|
||||
class QTimer;
|
||||
|
||||
const int CARD_WIDTH = 72;
|
||||
const int CARD_HEIGHT = 102;
|
||||
|
|
@ -15,8 +16,12 @@ protected:
|
|||
CardInfo *info;
|
||||
QString name;
|
||||
bool tapped;
|
||||
int tapAngle;
|
||||
QString color;
|
||||
private:
|
||||
QTimer *animationTimer;
|
||||
private slots:
|
||||
void animationEvent();
|
||||
void pixmapUpdated();
|
||||
signals:
|
||||
void hovered(AbstractCardItem *card);
|
||||
|
|
@ -33,7 +38,7 @@ public:
|
|||
QString getColor() const { return color; }
|
||||
void setColor(const QString &_color);
|
||||
bool getTapped() const { return tapped; }
|
||||
void setTapped(bool _tapped);
|
||||
void setTapped(bool _tapped, bool canAnimate = false);
|
||||
void processHoverEvent();
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ CardDatabase::CardDatabase(QObject *parent)
|
|||
CardDatabase::~CardDatabase()
|
||||
{
|
||||
clear();
|
||||
delete noCard;
|
||||
}
|
||||
|
||||
void CardDatabase::clear()
|
||||
|
|
@ -453,7 +454,7 @@ bool CardDatabase::loadFromFile(const QString &fileName)
|
|||
}
|
||||
}
|
||||
qDebug(QString("%1 cards in %2 sets loaded").arg(cardHash.size()).arg(setHash.size()).toLatin1());
|
||||
return true;
|
||||
return !cardHash.isEmpty();
|
||||
}
|
||||
|
||||
bool CardDatabase::saveToFile(const QString &fileName)
|
||||
|
|
|
|||
|
|
@ -151,43 +151,57 @@ void GeneralSettingsPage::retranslateUi()
|
|||
|
||||
AppearanceSettingsPage::AppearanceSettingsPage()
|
||||
{
|
||||
QIcon deleteIcon(":/resources/icon_delete.svg");
|
||||
|
||||
handBgLabel = new QLabel;
|
||||
handBgEdit = new QLineEdit(settingsCache->getHandBgPath());
|
||||
handBgEdit->setReadOnly(true);
|
||||
QPushButton *handBgClearButton = new QPushButton(deleteIcon, QString());
|
||||
connect(handBgClearButton, SIGNAL(clicked()), this, SLOT(handBgClearButtonClicked()));
|
||||
QPushButton *handBgButton = new QPushButton("...");
|
||||
connect(handBgButton, SIGNAL(clicked()), this, SLOT(handBgButtonClicked()));
|
||||
|
||||
tableBgLabel = new QLabel;
|
||||
tableBgEdit = new QLineEdit(settingsCache->getTableBgPath());
|
||||
tableBgEdit->setReadOnly(true);
|
||||
QPushButton *tableBgClearButton = new QPushButton(deleteIcon, QString());
|
||||
connect(tableBgClearButton, SIGNAL(clicked()), this, SLOT(tableBgClearButtonClicked()));
|
||||
QPushButton *tableBgButton = new QPushButton("...");
|
||||
connect(tableBgButton, SIGNAL(clicked()), this, SLOT(tableBgButtonClicked()));
|
||||
|
||||
playerAreaBgLabel = new QLabel;
|
||||
playerAreaBgEdit = new QLineEdit(settingsCache->getPlayerBgPath());
|
||||
playerAreaBgEdit->setReadOnly(true);
|
||||
QPushButton *playerAreaBgClearButton = new QPushButton(deleteIcon, QString());
|
||||
connect(playerAreaBgClearButton, SIGNAL(clicked()), this, SLOT(playerAreaBgClearButtonClicked()));
|
||||
QPushButton *playerAreaBgButton = new QPushButton("...");
|
||||
connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked()));
|
||||
|
||||
cardBackPicturePathLabel = new QLabel;
|
||||
cardBackPicturePathEdit = new QLineEdit(settingsCache->getCardBackPicturePath());
|
||||
cardBackPicturePathEdit->setReadOnly(true);
|
||||
QPushButton *cardBackPicturePathClearButton = new QPushButton(deleteIcon, QString());
|
||||
connect(cardBackPicturePathClearButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathClearButtonClicked()));
|
||||
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);
|
||||
zoneBgGrid->addWidget(handBgButton, 0, 2);
|
||||
zoneBgGrid->addWidget(handBgClearButton, 0, 2);
|
||||
zoneBgGrid->addWidget(handBgButton, 0, 3);
|
||||
zoneBgGrid->addWidget(tableBgLabel, 1, 0);
|
||||
zoneBgGrid->addWidget(tableBgEdit, 1, 1);
|
||||
zoneBgGrid->addWidget(tableBgButton, 1, 2);
|
||||
zoneBgGrid->addWidget(tableBgClearButton, 1, 2);
|
||||
zoneBgGrid->addWidget(tableBgButton, 1, 3);
|
||||
zoneBgGrid->addWidget(playerAreaBgLabel, 2, 0);
|
||||
zoneBgGrid->addWidget(playerAreaBgEdit, 2, 1);
|
||||
zoneBgGrid->addWidget(playerAreaBgButton, 2, 2);
|
||||
zoneBgGrid->addWidget(playerAreaBgClearButton, 2, 2);
|
||||
zoneBgGrid->addWidget(playerAreaBgButton, 2, 3);
|
||||
zoneBgGrid->addWidget(cardBackPicturePathLabel, 3, 0);
|
||||
zoneBgGrid->addWidget(cardBackPicturePathEdit, 3, 1);
|
||||
zoneBgGrid->addWidget(cardBackPicturePathButton, 3, 2);
|
||||
zoneBgGrid->addWidget(cardBackPicturePathClearButton, 3, 2);
|
||||
zoneBgGrid->addWidget(cardBackPicturePathButton, 3, 3);
|
||||
|
||||
zoneBgGroupBox = new QGroupBox;
|
||||
zoneBgGroupBox->setLayout(zoneBgGrid);
|
||||
|
|
@ -202,12 +216,12 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
handGroupBox = new QGroupBox;
|
||||
handGroupBox->setLayout(handGrid);
|
||||
|
||||
economicGridCheckBox = new QCheckBox;
|
||||
economicGridCheckBox->setChecked(settingsCache->getEconomicGrid());
|
||||
connect(economicGridCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setEconomicGrid(int)));
|
||||
economicalGridCheckBox = new QCheckBox;
|
||||
economicalGridCheckBox->setChecked(settingsCache->getEconomicalGrid());
|
||||
connect(economicalGridCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setEconomicalGrid(int)));
|
||||
|
||||
QGridLayout *tableGrid = new QGridLayout;
|
||||
tableGrid->addWidget(economicGridCheckBox, 0, 0, 1, 2);
|
||||
tableGrid->addWidget(economicalGridCheckBox, 0, 0, 1, 2);
|
||||
|
||||
tableGroupBox = new QGroupBox;
|
||||
tableGroupBox->setLayout(tableGrid);
|
||||
|
|
@ -248,13 +262,19 @@ void AppearanceSettingsPage::retranslateUi()
|
|||
horizontalHandCheckBox->setText(tr("Display hand horizontally (wastes space)"));
|
||||
|
||||
tableGroupBox->setTitle(tr("Table grid layout"));
|
||||
economicGridCheckBox->setText(tr("Economic layout"));
|
||||
economicalGridCheckBox->setText(tr("Economical layout"));
|
||||
|
||||
zoneViewGroupBox->setTitle(tr("Zone view layout"));
|
||||
zoneViewSortByNameCheckBox->setText(tr("Sort by name"));
|
||||
zoneViewSortByTypeCheckBox->setText(tr("Sort by type"));
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::handBgClearButtonClicked()
|
||||
{
|
||||
handBgEdit->setText(QString());
|
||||
settingsCache->setHandBgPath(QString());
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::handBgButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
|
|
@ -265,6 +285,12 @@ void AppearanceSettingsPage::handBgButtonClicked()
|
|||
settingsCache->setHandBgPath(path);
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::tableBgClearButtonClicked()
|
||||
{
|
||||
tableBgEdit->setText(QString());
|
||||
settingsCache->setTableBgPath(QString());
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::tableBgButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
|
|
@ -275,6 +301,12 @@ void AppearanceSettingsPage::tableBgButtonClicked()
|
|||
settingsCache->setTableBgPath(path);
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::playerAreaBgClearButtonClicked()
|
||||
{
|
||||
playerAreaBgEdit->setText(QString());
|
||||
settingsCache->setPlayerBgPath(QString());
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::playerAreaBgButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
|
|
@ -285,6 +317,12 @@ void AppearanceSettingsPage::playerAreaBgButtonClicked()
|
|||
settingsCache->setPlayerBgPath(path);
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::cardBackPicturePathClearButtonClicked()
|
||||
{
|
||||
cardBackPicturePathEdit->setText(QString());
|
||||
settingsCache->setCardBackPicturePath(QString());
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::cardBackPicturePathButtonClicked()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
|
||||
|
|
@ -307,8 +345,19 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
generalGroupBox = new QGroupBox;
|
||||
generalGroupBox->setLayout(generalGrid);
|
||||
|
||||
tapAnimationCheckBox = new QCheckBox;
|
||||
tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation());
|
||||
connect(tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
|
||||
|
||||
QGridLayout *animationGrid = new QGridLayout;
|
||||
animationGrid->addWidget(tapAnimationCheckBox, 0, 0);
|
||||
|
||||
animationGroupBox = new QGroupBox;
|
||||
animationGroupBox->setLayout(animationGrid);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(generalGroupBox);
|
||||
mainLayout->addWidget(animationGroupBox);
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
|
@ -317,6 +366,8 @@ void UserInterfaceSettingsPage::retranslateUi()
|
|||
{
|
||||
generalGroupBox->setTitle(tr("General interface settings"));
|
||||
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
|
||||
animationGroupBox->setTitle(tr("Animation settings"));
|
||||
tapAnimationCheckBox->setText(tr("&Tap/untap animation"));
|
||||
}
|
||||
|
||||
MessagesSettingsPage::MessagesSettingsPage()
|
||||
|
|
@ -472,17 +523,22 @@ void DlgSettings::changeEvent(QEvent *event)
|
|||
|
||||
void DlgSettings::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!db->getLoadSuccess()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Your card database is invalid. Please check if the path is set correctly."));
|
||||
event->ignore();
|
||||
} else if (!QDir(settingsCache->getDeckPath()).exists()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("The path to your deck directory is invalid."));
|
||||
event->ignore();
|
||||
} else if (!QDir(settingsCache->getPicsPath()).exists()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("The path to your card pictures directory is invalid."));
|
||||
event->ignore();
|
||||
} else
|
||||
event->accept();
|
||||
if (!db->getLoadSuccess())
|
||||
if (QMessageBox::critical(this, tr("Error"), tr("Your card database is invalid. Would you like to go back and set the correct path?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
if (!QDir(settingsCache->getDeckPath()).exists())
|
||||
if (QMessageBox::critical(this, tr("Error"), tr("The path to your deck directory is invalid. Would you like to go back and set the correct path?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
if (!QDir(settingsCache->getPicsPath()).exists())
|
||||
if (QMessageBox::critical(this, tr("Error"), tr("The path to your card pictures directory is invalid. Would you like to go back and set the correct path?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void DlgSettings::retranslateUi()
|
||||
|
|
|
|||
|
|
@ -48,9 +48,13 @@ private:
|
|||
class AppearanceSettingsPage : public AbstractSettingsPage {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void handBgClearButtonClicked();
|
||||
void handBgButtonClicked();
|
||||
void tableBgClearButtonClicked();
|
||||
void tableBgButtonClicked();
|
||||
void playerAreaBgClearButtonClicked();
|
||||
void playerAreaBgButtonClicked();
|
||||
void cardBackPicturePathClearButtonClicked();
|
||||
void cardBackPicturePathButtonClicked();
|
||||
signals:
|
||||
void handBgChanged(const QString &path);
|
||||
|
|
@ -60,7 +64,7 @@ signals:
|
|||
private:
|
||||
QLabel *handBgLabel, *tableBgLabel, *playerAreaBgLabel, *cardBackPicturePathLabel;
|
||||
QLineEdit *handBgEdit, *tableBgEdit, *playerAreaBgEdit, *cardBackPicturePathEdit;
|
||||
QCheckBox *horizontalHandCheckBox, *economicGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
||||
QCheckBox *horizontalHandCheckBox, *economicalGridCheckBox, *zoneViewSortByNameCheckBox, *zoneViewSortByTypeCheckBox;
|
||||
QGroupBox *zoneBgGroupBox, *handGroupBox, *tableGroupBox, *zoneViewGroupBox;
|
||||
public:
|
||||
AppearanceSettingsPage();
|
||||
|
|
@ -71,7 +75,8 @@ class UserInterfaceSettingsPage : public AbstractSettingsPage {
|
|||
Q_OBJECT
|
||||
private:
|
||||
QCheckBox *doubleClickToPlayCheckBox;
|
||||
QGroupBox *generalGroupBox;
|
||||
QCheckBox *tapAnimationCheckBox;
|
||||
QGroupBox *generalGroupBox, *animationGroupBox;
|
||||
public:
|
||||
UserInterfaceSettingsPage();
|
||||
void retranslateUi();
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ void Player::setCardAttrHelper(CardItem *card, const QString &aname, const QStri
|
|||
if (!(!tapped && card->getDoesntUntap() && allCards)) {
|
||||
if (!allCards)
|
||||
emit logSetTapped(this, card->getName(), tapped);
|
||||
card->setTapped(tapped);
|
||||
card->setTapped(tapped, true);
|
||||
}
|
||||
} else if (aname == "attacking")
|
||||
card->setAttacking(avalue == "1");
|
||||
|
|
@ -958,7 +958,7 @@ void Player::addZone(CardZone *z)
|
|||
|
||||
Counter *Player::addCounter(ServerInfo_Counter *counter)
|
||||
{
|
||||
return addCounter(counter->getId(), counter->getName(), counter->getColor(), counter->getRadius(), counter->getCount());
|
||||
return addCounter(counter->getId(), counter->getName(), counter->getColor().getQColor(), counter->getRadius(), counter->getCount());
|
||||
}
|
||||
|
||||
Counter *Player::addCounter(int counterId, const QString &name, QColor color, int radius, int value)
|
||||
|
|
@ -1012,9 +1012,9 @@ ArrowItem *Player::addArrow(ServerInfo_Arrow *arrow)
|
|||
return 0;
|
||||
|
||||
if (targetCard)
|
||||
return addArrow(arrow->getId(), startCard, targetCard, arrow->getColor());
|
||||
return addArrow(arrow->getId(), startCard, targetCard, arrow->getColor().getQColor());
|
||||
else
|
||||
return addArrow(arrow->getId(), startCard, targetPlayer->getPlayerTarget(), arrow->getColor());
|
||||
return addArrow(arrow->getId(), startCard, targetPlayer->getPlayerTarget(), arrow->getColor().getQColor());
|
||||
}
|
||||
|
||||
ArrowItem *Player::addArrow(int arrowId, CardItem *startCard, ArrowTarget *targetItem, const QColor &color)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ SettingsCache::SettingsCache()
|
|||
picDownload = settings->value("personal/picturedownload", false).toBool();
|
||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||
horizontalHand = settings->value("hand/horizontal", false).toBool();
|
||||
economicGrid = settings->value("table/economic", false).toBool();
|
||||
economicalGrid = settings->value("table/economic", false).toBool();
|
||||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||
|
||||
zoneViewSortByName = settings->value("zoneview/sortbyname", false).toBool();
|
||||
zoneViewSortByType = settings->value("zoneview/sortbytype", false).toBool();
|
||||
|
|
@ -100,11 +101,17 @@ void SettingsCache::setHorizontalHand(int _horizontalHand)
|
|||
emit horizontalHandChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setEconomicGrid(int _economicGrid)
|
||||
void SettingsCache::setEconomicalGrid(int _economicalGrid)
|
||||
{
|
||||
economicGrid = _economicGrid;
|
||||
settings->setValue("table/economic", economicGrid);
|
||||
emit economicGridChanged();
|
||||
economicalGrid = _economicalGrid;
|
||||
settings->setValue("table/economic", economicalGrid);
|
||||
emit economicalGridChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setTapAnimation(int _tapAnimation)
|
||||
{
|
||||
tapAnimation = _tapAnimation;
|
||||
settings->setValue("cards/tapanimation", tapAnimation);
|
||||
}
|
||||
|
||||
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ signals:
|
|||
void cardBackPicturePathChanged();
|
||||
void picDownloadChanged();
|
||||
void horizontalHandChanged();
|
||||
void economicGridChanged();
|
||||
void economicalGridChanged();
|
||||
private:
|
||||
QSettings *settings;
|
||||
|
||||
|
|
@ -27,7 +27,8 @@ private:
|
|||
bool picDownload;
|
||||
bool doubleClickToPlay;
|
||||
bool horizontalHand;
|
||||
bool economicGrid;
|
||||
bool economicalGrid;
|
||||
bool tapAnimation;
|
||||
bool zoneViewSortByName, zoneViewSortByType;
|
||||
public:
|
||||
SettingsCache();
|
||||
|
|
@ -42,7 +43,8 @@ public:
|
|||
bool getPicDownload() const { return picDownload; }
|
||||
bool getDoubleClickToPlay() const { return doubleClickToPlay; }
|
||||
bool getHorizontalHand() const { return horizontalHand; }
|
||||
bool getEconomicGrid() const { return economicGrid; }
|
||||
bool getEconomicalGrid() const { return economicalGrid; }
|
||||
bool getTapAnimation() const { return tapAnimation; }
|
||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||
public slots:
|
||||
|
|
@ -57,7 +59,8 @@ public slots:
|
|||
void setPicDownload(int _picDownload);
|
||||
void setDoubleClickToPlay(int _doubleClickToPlay);
|
||||
void setHorizontalHand(int _horizontalHand);
|
||||
void setEconomicGrid(int _economicGrid);
|
||||
void setEconomicalGrid(int _economicalGrid);
|
||||
void setTapAnimation(int _tapAnimation);
|
||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include <QLabel>
|
||||
#include <QTreeView>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
|
|
@ -338,12 +339,65 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
|
|||
emit openMessageDialog(item->data(2, Qt::UserRole).toString(), true);
|
||||
}
|
||||
|
||||
UserInfoBox::UserInfoBox(AbstractClient *_client, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
avatarLabel = new QLabel;
|
||||
nameLabel = new QLabel;
|
||||
QFont nameFont = nameLabel->font();
|
||||
nameFont.setBold(true);
|
||||
nameFont.setPointSize(nameFont.pointSize() * 1.5);
|
||||
nameLabel->setFont(nameFont);
|
||||
countryLabel1 = new QLabel;
|
||||
countryLabel2 = new QLabel;
|
||||
userLevelLabel1 = new QLabel;
|
||||
userLevelLabel2 = new QLabel;
|
||||
|
||||
QGridLayout *mainLayout = new QGridLayout;
|
||||
mainLayout->addWidget(avatarLabel, 0, 0, 3, 1);
|
||||
mainLayout->addWidget(nameLabel, 0, 1, 1, 2);
|
||||
mainLayout->addWidget(countryLabel1, 1, 1, 1, 1);
|
||||
mainLayout->addWidget(countryLabel2, 1, 2, 1, 1);
|
||||
mainLayout->addWidget(userLevelLabel1, 2, 1, 1, 1);
|
||||
mainLayout->addWidget(userLevelLabel2, 2, 2, 1, 1);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
Command_GetUserInfo *cmd = new Command_GetUserInfo;
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(processResponse(ProtocolResponse *)));
|
||||
_client->sendCommand(cmd);
|
||||
}
|
||||
|
||||
void UserInfoBox::retranslateUi()
|
||||
{
|
||||
countryLabel1->setText(tr("Location:"));
|
||||
userLevelLabel1->setText(tr("User level:"));
|
||||
}
|
||||
|
||||
void UserInfoBox::processResponse(ProtocolResponse *response)
|
||||
{
|
||||
Response_GetUserInfo *resp = qobject_cast<Response_GetUserInfo *>(response);
|
||||
if (!resp)
|
||||
return;
|
||||
ServerInfo_User *user = resp->getUserInfo();
|
||||
|
||||
QPixmap avatarPixmap;
|
||||
if (!avatarPixmap.loadFromData(user->getAvatarBmp()))
|
||||
avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, user->getUserLevel());
|
||||
avatarLabel->setPixmap(avatarPixmap);
|
||||
|
||||
nameLabel->setText(user->getName());
|
||||
countryLabel2->setPixmap(CountryPixmapGenerator::generatePixmap(15, user->getCountry()));
|
||||
userLevelLabel2->setPixmap(UserLevelPixmapGenerator::generatePixmap(15, user->getUserLevel()));
|
||||
}
|
||||
|
||||
TabServer::TabServer(AbstractClient *_client, QWidget *parent)
|
||||
: Tab(parent), client(_client)
|
||||
{
|
||||
gameSelector = new GameSelector(client);
|
||||
chatChannelSelector = new ChatChannelSelector(client);
|
||||
serverMessageLog = new ServerMessageLog(client);
|
||||
userInfoBox = new UserInfoBox(client);
|
||||
userList = new UserList(client);
|
||||
|
||||
connect(gameSelector, SIGNAL(gameJoined(int)), this, SIGNAL(gameJoined(int)));
|
||||
|
|
@ -359,9 +413,13 @@ TabServer::TabServer(AbstractClient *_client, QWidget *parent)
|
|||
vbox->addWidget(gameSelector);
|
||||
vbox->addLayout(hbox);
|
||||
|
||||
QVBoxLayout *vbox2 = new QVBoxLayout;
|
||||
vbox2->addWidget(userInfoBox);
|
||||
vbox2->addWidget(userList);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addLayout(vbox, 3);
|
||||
mainLayout->addWidget(userList, 1);
|
||||
mainLayout->addLayout(vbox2, 1);
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
|
@ -371,5 +429,6 @@ void TabServer::retranslateUi()
|
|||
gameSelector->retranslateUi();
|
||||
chatChannelSelector->retranslateUi();
|
||||
serverMessageLog->retranslateUi();
|
||||
userInfoBox->retranslateUi();
|
||||
userList->retranslateUi();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class QTreeWidgetItem;
|
|||
class QPushButton;
|
||||
class QCheckBox;
|
||||
class QTextEdit;
|
||||
class QLabel;
|
||||
|
||||
class GamesModel;
|
||||
class GamesProxyModel;
|
||||
|
|
@ -101,6 +102,17 @@ public:
|
|||
void retranslateUi();
|
||||
};
|
||||
|
||||
class UserInfoBox : public QWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QLabel *avatarLabel, *nameLabel, *countryLabel1, *countryLabel2, *userLevelLabel1, *userLevelLabel2;
|
||||
private slots:
|
||||
void processResponse(ProtocolResponse *response);
|
||||
public:
|
||||
UserInfoBox(AbstractClient *_client, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
};
|
||||
|
||||
class TabServer : public Tab {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
|
|
@ -114,6 +126,7 @@ private:
|
|||
ChatChannelSelector *chatChannelSelector;
|
||||
ServerMessageLog *serverMessageLog;
|
||||
UserList *userList;
|
||||
UserInfoBox *userInfoBox;
|
||||
public:
|
||||
TabServer(AbstractClient *_client, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
|||
: CardZone(_p, "table", true, false, true, parent), active(false)
|
||||
{
|
||||
connect(settingsCache, SIGNAL(tableBgPathChanged()), this, SLOT(updateBgPixmap()));
|
||||
connect(settingsCache, SIGNAL(economicGridChanged()), this, SLOT(reorganizeCards()));
|
||||
connect(settingsCache, SIGNAL(economicalGridChanged()), this, SLOT(reorganizeCards()));
|
||||
updateBgPixmap();
|
||||
|
||||
if (settingsCache->getEconomicGrid())
|
||||
if (settingsCache->getEconomicalGrid())
|
||||
height = 2 * boxLineWidth + (int) (14.0 / 3 * CARD_HEIGHT + 3 * paddingY);
|
||||
else
|
||||
height = 2 * boxLineWidth + 4 * CARD_HEIGHT + 3 * paddingY;
|
||||
|
|
@ -210,7 +210,7 @@ CardItem *TableZone::getCardFromCoords(const QPointF &point) const
|
|||
QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
|
||||
{
|
||||
qreal x, y;
|
||||
if ((gridPoint.y() == 3) && (settingsCache->getEconomicGrid())) {
|
||||
if ((gridPoint.y() == 3) && (settingsCache->getEconomicalGrid())) {
|
||||
x = marginX + (CARD_WIDTH * gridPoint.x() + CARD_WIDTH * (gridPoint.x() / 3)) / 2;
|
||||
y = boxLineWidth + (CARD_HEIGHT + paddingY) * gridPoint.y() + (gridPoint.x() % 3 * CARD_HEIGHT) / 3;
|
||||
} else {
|
||||
|
|
@ -245,7 +245,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
|||
|
||||
int resultY = (int) (y / (CARD_HEIGHT + paddingY));
|
||||
|
||||
if ((resultY == 3) && (settingsCache->getEconomicGrid()))
|
||||
if ((resultY == 3) && (settingsCache->getEconomicalGrid()))
|
||||
return QPoint(
|
||||
(int) (x * 2 / CARD_WIDTH - floor(x / (2 * CARD_WIDTH))),
|
||||
3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue