Merge branch 'experimental' of git://cockatrice.git.sourceforge.net/gitroot/cockatrice/cockatrice
This commit is contained in:
commit
60722e6e47
16 changed files with 897 additions and 784 deletions
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
|
|
|
@ -82,9 +82,8 @@ void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &transla
|
|||
painter->setFont(f);
|
||||
}
|
||||
|
||||
void AbstractCardItem::paintPicture(QPainter *painter, int angle)
|
||||
void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedSize, int angle)
|
||||
{
|
||||
QSizeF translatedSize = getTranslatedSize(painter);
|
||||
QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect());
|
||||
qreal scaleFactor = translatedSize.width() / boundingRect().width();
|
||||
|
||||
|
@ -143,15 +142,20 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
|||
{
|
||||
painter->save();
|
||||
|
||||
paintPicture(painter, tapAngle);
|
||||
QSizeF translatedSize = getTranslatedSize(painter);
|
||||
paintPicture(painter, translatedSize, tapAngle);
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
transformPainter(painter, translatedSize, tapAngle);
|
||||
if (isSelected()) {
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||
painter->drawRect(QRectF(0.5, 0.5, translatedSize.width() - 1, translatedSize.height() - 1));
|
||||
} else if (isHovered) {
|
||||
painter->setPen(Qt::yellow);
|
||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||
painter->drawRect(QRectF(0.5, 0.5, translatedSize.width() - 1, translatedSize.height() - 1));
|
||||
}
|
||||
painter->restore();
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ public:
|
|||
AbstractCardItem(const QString &_name = QString(), Player *_owner = 0, QGraphicsItem *parent = 0);
|
||||
~AbstractCardItem();
|
||||
QRectF boundingRect() const;
|
||||
void paintPicture(QPainter *painter, int angle);
|
||||
QSizeF getTranslatedSize(QPainter *painter) const;
|
||||
void paintPicture(QPainter *painter, const QSizeF &translatedSize, int angle);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
CardInfo *getInfo() const { return info; }
|
||||
QString getName() const { return name; }
|
||||
|
@ -52,7 +53,6 @@ public:
|
|||
void processHoverEvent();
|
||||
void deleteCardInfoPopup() { emit deleteCardInfoPopup(name); }
|
||||
protected:
|
||||
QSizeF getTranslatedSize(QPainter *painter) const;
|
||||
void transformPainter(QPainter *painter, const QSizeF &translatedSize, int angle);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "cardzone.h"
|
||||
#include "tablezone.h"
|
||||
#include "zoneviewzone.h"
|
||||
#include <QGraphicsScene>
|
||||
#include "gamescene.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QCursor>
|
||||
#include <QPainter>
|
||||
|
@ -22,7 +22,7 @@ void CardDragItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||
|
||||
void CardDragItem::updatePosition(const QPointF &cursorScenePos)
|
||||
{
|
||||
QList<QGraphicsItem *> colliding = scene()->items(cursorScenePos);
|
||||
QList<QGraphicsItem *> colliding = scene()->items(cursorScenePos, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder, static_cast<GameScene *>(scene())->getViewTransform());
|
||||
|
||||
CardZone *cardZone = 0;
|
||||
ZoneViewZone *zoneViewZone = 0;
|
||||
|
|
|
@ -394,8 +394,10 @@ CardDragItem *CardItem::createDragItem(int _id, const QPointF &_pos, const QPoin
|
|||
{
|
||||
deleteDragItem();
|
||||
dragItem = new CardDragItem(this, _id, _pos, faceDown);
|
||||
dragItem->setVisible(false);
|
||||
scene()->addItem(dragItem);
|
||||
dragItem->updatePosition(_scenePos);
|
||||
dragItem->setVisible(true);
|
||||
|
||||
return dragItem;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QSet>
|
||||
#include <QBasicTimer>
|
||||
#include <QGraphicsView>
|
||||
|
||||
GameScene::GameScene(PhasesToolbar *_phasesToolbar, QObject *parent)
|
||||
: QGraphicsScene(parent), phasesToolbar(_phasesToolbar)
|
||||
|
@ -25,8 +26,8 @@ GameScene::~GameScene()
|
|||
|
||||
void GameScene::retranslateUi()
|
||||
{
|
||||
for (int i = 0; i < views.size(); ++i)
|
||||
views[i]->retranslateUi();
|
||||
for (int i = 0; i < zoneViews.size(); ++i)
|
||||
zoneViews[i]->retranslateUi();
|
||||
}
|
||||
|
||||
void GameScene::addPlayer(Player *player)
|
||||
|
@ -111,47 +112,52 @@ void GameScene::rearrange()
|
|||
|
||||
void GameScene::toggleZoneView(Player *player, const QString &zoneName, int numberCards)
|
||||
{
|
||||
for (int i = 0; i < views.size(); i++) {
|
||||
ZoneViewZone *temp = views[i]->getZone();
|
||||
for (int i = 0; i < zoneViews.size(); i++) {
|
||||
ZoneViewZone *temp = zoneViews[i]->getZone();
|
||||
if ((temp->getName() == zoneName) && (temp->getPlayer() == player)) { // view is already open
|
||||
views[i]->close();
|
||||
zoneViews[i]->close();
|
||||
if (temp->getNumberCards() == numberCards)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ZoneViewWidget *item = new ZoneViewWidget(player, player->getZones().value(zoneName), numberCards, false);
|
||||
views.append(item);
|
||||
zoneViews.append(item);
|
||||
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeZoneView(ZoneViewWidget *)));
|
||||
addItem(item);
|
||||
item->setPos(100, 100);
|
||||
item->setPos(50, 50);
|
||||
}
|
||||
|
||||
void GameScene::addRevealedZoneView(Player *player, CardZone *zone, const QList<ServerInfo_Card *> &cardList)
|
||||
{
|
||||
ZoneViewWidget *item = new ZoneViewWidget(player, zone, -2, true, cardList);
|
||||
views.append(item);
|
||||
zoneViews.append(item);
|
||||
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeZoneView(ZoneViewWidget *)));
|
||||
addItem(item);
|
||||
item->setPos(100, 100);
|
||||
item->setPos(50, 50);
|
||||
}
|
||||
|
||||
void GameScene::removeZoneView(ZoneViewWidget *item)
|
||||
{
|
||||
views.removeAt(views.indexOf(item));
|
||||
zoneViews.removeAt(zoneViews.indexOf(item));
|
||||
removeItem(item);
|
||||
}
|
||||
|
||||
void GameScene::clearViews()
|
||||
{
|
||||
for (int i = 0; i < views.size(); ++i)
|
||||
views[i]->close();
|
||||
for (int i = 0; i < zoneViews.size(); ++i)
|
||||
zoneViews[i]->close();
|
||||
}
|
||||
|
||||
void GameScene::closeMostRecentZoneView()
|
||||
{
|
||||
if (!views.isEmpty())
|
||||
views.last()->close();
|
||||
if (!zoneViews.isEmpty())
|
||||
zoneViews.last()->close();
|
||||
}
|
||||
|
||||
QTransform GameScene::getViewTransform() const
|
||||
{
|
||||
return views().at(0)->transform();
|
||||
}
|
||||
|
||||
void GameScene::processViewSizeChange(const QSize &newSize)
|
||||
|
@ -191,7 +197,7 @@ void GameScene::processViewSizeChange(const QSize &newSize)
|
|||
|
||||
void GameScene::updateHover(const QPointF &scenePos)
|
||||
{
|
||||
QList<QGraphicsItem *> itemList = items(scenePos);
|
||||
QList<QGraphicsItem *> itemList = items(scenePos, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder, getViewTransform());
|
||||
|
||||
// Search for the topmost zone and ignore all cards not belonging to that zone.
|
||||
CardZone *zone = 0;
|
||||
|
|
|
@ -23,7 +23,7 @@ private:
|
|||
PhasesToolbar *phasesToolbar;
|
||||
QList<Player *> players;
|
||||
QList<QList<Player *> > playersByColumn;
|
||||
QList<ZoneViewWidget *> views;
|
||||
QList<ZoneViewWidget *> zoneViews;
|
||||
QSize viewSize;
|
||||
QPointer<CardItem> hoveredCard;
|
||||
QBasicTimer *animationTimer;
|
||||
|
@ -34,6 +34,7 @@ public:
|
|||
~GameScene();
|
||||
void retranslateUi();
|
||||
void processViewSizeChange(const QSize &newSize);
|
||||
QTransform getViewTransform() const;
|
||||
|
||||
void startRubberBand(const QPointF &selectionOrigin);
|
||||
void resizeRubberBand(const QPointF &cursorPoint);
|
||||
|
|
|
@ -25,7 +25,7 @@ QRectF PileZone::boundingRect() const
|
|||
void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
if (!cards.isEmpty())
|
||||
cards.at(0)->paintPicture(painter, 90);
|
||||
cards.at(0)->paintPicture(painter, cards.at(0)->getTranslatedSize(painter), 90);
|
||||
|
||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||
|
||||
|
|
|
@ -268,6 +268,9 @@ void WndDeckEditor::updateCardInfoRight(const QModelIndex ¤t, const QModel
|
|||
void WndDeckEditor::updateSearch(const QString &search)
|
||||
{
|
||||
databaseDisplayModel->setCardNameBeginning(search);
|
||||
QModelIndexList sel = databaseView->selectionModel()->selectedRows();
|
||||
if (sel.isEmpty() && databaseDisplayModel->rowCount())
|
||||
databaseView->selectionModel()->setCurrentIndex(databaseDisplayModel->index(0, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
}
|
||||
|
||||
bool WndDeckEditor::confirmClose()
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#include <QGraphicsLinearLayout>
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
#include "zoneviewwidget.h"
|
||||
#include "carditem.h"
|
||||
#include "zoneviewzone.h"
|
||||
|
@ -8,19 +13,70 @@
|
|||
#include "gamescene.h"
|
||||
#include "protocol_items.h"
|
||||
#include "settingscache.h"
|
||||
#include "gamescene.h"
|
||||
|
||||
TitleLabel::TitleLabel()
|
||||
: QGraphicsWidget(), text(" ")
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
void TitleLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
|
||||
{
|
||||
QBrush windowBrush = palette().window();
|
||||
windowBrush.setColor(windowBrush.color().darker(150));
|
||||
painter->fillRect(boundingRect(), windowBrush);
|
||||
painter->drawText(boundingRect(), Qt::AlignLeft | Qt::AlignVCenter, text);
|
||||
}
|
||||
|
||||
QSizeF TitleLabel::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
||||
{
|
||||
QFont f;
|
||||
QFontMetrics fm(f);
|
||||
if (which == Qt::MaximumSize)
|
||||
return QSizeF(constraint.width(), fm.size(Qt::TextSingleLine, text).height() + 10);
|
||||
else
|
||||
return fm.size(Qt::TextSingleLine, text);
|
||||
}
|
||||
|
||||
void TitleLabel::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
buttonDownPos = static_cast<GameScene *>(scene())->getViewTransform().inverted().map(event->pos());
|
||||
event->accept();
|
||||
} else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void TitleLabel::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
emit mouseMoved(event->scenePos() - buttonDownPos);
|
||||
}
|
||||
|
||||
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, const QList<ServerInfo_Card *> &cardList)
|
||||
: QGraphicsWidget(0, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint | Qt::WindowTitleHint/* | Qt::WindowCloseButtonHint*/), player(_player)
|
||||
: QGraphicsWidget(0, Qt::Tool | Qt::FramelessWindowHint), player(_player)
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setZValue(2000000006);
|
||||
setFlag(ItemIgnoresTransformations);
|
||||
setAutoFillBackground(true);
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(10);
|
||||
setFont(font);
|
||||
|
||||
QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
titleLabel = new TitleLabel;
|
||||
connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF)));
|
||||
closeButton = new QPushButton("X");
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||
closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget;
|
||||
closeButtonProxy->setWidget(closeButton);
|
||||
|
||||
hbox->addItem(titleLabel);
|
||||
hbox->addItem(closeButtonProxy);
|
||||
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
|
||||
|
||||
vbox->addItem(hbox);
|
||||
|
||||
if (numberCards < 0) {
|
||||
sortByNameCheckBox = new QCheckBox;
|
||||
QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
|
||||
|
@ -67,7 +123,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
|
|||
|
||||
void ZoneViewWidget::retranslateUi()
|
||||
{
|
||||
setWindowTitle(zone->getTranslatedName(false, CaseNominative));
|
||||
titleLabel->setText(zone->getTranslatedName(false, CaseNominative));
|
||||
if (sortByNameCheckBox)
|
||||
sortByNameCheckBox->setText(tr("sort by name"));
|
||||
if (sortByTypeCheckBox)
|
||||
|
@ -76,6 +132,11 @@ void ZoneViewWidget::retranslateUi()
|
|||
shuffleCheckBox->setText(tr("shuffle when closing"));
|
||||
}
|
||||
|
||||
void ZoneViewWidget::moveWidget(QPointF scenePos)
|
||||
{
|
||||
setPos(scenePos);
|
||||
}
|
||||
|
||||
void ZoneViewWidget::resizeToZoneContents()
|
||||
{
|
||||
QRectF zoneRect = zone->getOptimumRect();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef ZONEVIEWWIDGET_H
|
||||
#define ZONEVIEWWIDGET_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class CardZone;
|
||||
class ZoneViewZone;
|
||||
class Player;
|
||||
|
@ -13,12 +13,32 @@ class QScrollBar;
|
|||
class QCheckBox;
|
||||
class GameScene;
|
||||
class ServerInfo_Card;
|
||||
class QGraphicsSceneMouseEvent;
|
||||
|
||||
class TitleLabel : public QGraphicsWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QString text;
|
||||
QPointF buttonDownPos;
|
||||
public:
|
||||
TitleLabel();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/);
|
||||
void setText(const QString &_text) { text = _text; update(); }
|
||||
signals:
|
||||
void mouseMoved(QPointF scenePos);
|
||||
protected:
|
||||
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
};
|
||||
|
||||
class ZoneViewWidget : public QGraphicsWidget {
|
||||
Q_OBJECT
|
||||
private:
|
||||
ZoneViewZone *zone;
|
||||
|
||||
TitleLabel *titleLabel;
|
||||
QPushButton *closeButton;
|
||||
QScrollBar *scrollBar;
|
||||
QCheckBox *sortByNameCheckBox, *sortByTypeCheckBox, *shuffleCheckBox;
|
||||
|
||||
|
@ -29,6 +49,7 @@ signals:
|
|||
private slots:
|
||||
void resizeToZoneContents();
|
||||
void zoneDeleted();
|
||||
void moveWidget(QPointF scenePos);
|
||||
public:
|
||||
ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards = 0, bool _revealZone = false, const QList<ServerInfo_Card *> &cardList = QList<ServerInfo_Card *>());
|
||||
ZoneViewZone *getZone() const { return zone; }
|
||||
|
|
|
@ -5095,7 +5095,7 @@ Bitte geben Sie einen Namen ein:</translation>
|
|||
<message>
|
||||
<location filename="../src/tab_game.cpp" line="294"/>
|
||||
<source>&Concede</source>
|
||||
<translation></translation>
|
||||
<translation>&Aufgeben</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/tab_game.cpp" line="295"/>
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -41,6 +41,7 @@ Section "Application" SecApplication
|
|||
File data\QtSvg4.dll
|
||||
File data\QtXml4.dll
|
||||
File data\QtMultimedia4.dll
|
||||
File data\QtScript4.dll
|
||||
|
||||
SetOutPath "$INSTDIR\zonebg"
|
||||
File /r ..\zonebg\*.*
|
||||
|
|
Loading…
Reference in a new issue