table grid improvement, unfinished
This commit is contained in:
parent
914261df11
commit
0d774b5d48
16 changed files with 231 additions and 289 deletions
|
@ -36,7 +36,6 @@ HEADERS += src/counter.h \
|
||||||
src/pilezone.h \
|
src/pilezone.h \
|
||||||
src/carddragitem.h \
|
src/carddragitem.h \
|
||||||
src/zoneviewlayout.h \
|
src/zoneviewlayout.h \
|
||||||
src/playerarea.h \
|
|
||||||
src/carddatabasemodel.h \
|
src/carddatabasemodel.h \
|
||||||
src/window_deckeditor.h \
|
src/window_deckeditor.h \
|
||||||
src/decklist.h \
|
src/decklist.h \
|
||||||
|
@ -45,7 +44,8 @@ HEADERS += src/counter.h \
|
||||||
src/abstractgraphicsitem.h \
|
src/abstractgraphicsitem.h \
|
||||||
src/dlg_settings.h \
|
src/dlg_settings.h \
|
||||||
src/phasestoolbar.h \
|
src/phasestoolbar.h \
|
||||||
src/chatwidget.h
|
src/chatwidget.h \
|
||||||
|
src/gamescene.h
|
||||||
SOURCES += src/counter.cpp \
|
SOURCES += src/counter.cpp \
|
||||||
src/gameselector.cpp \
|
src/gameselector.cpp \
|
||||||
src/dlg_creategame.cpp \
|
src/dlg_creategame.cpp \
|
||||||
|
@ -75,7 +75,6 @@ SOURCES += src/counter.cpp \
|
||||||
src/pilezone.cpp \
|
src/pilezone.cpp \
|
||||||
src/carddragitem.cpp \
|
src/carddragitem.cpp \
|
||||||
src/zoneviewlayout.cpp \
|
src/zoneviewlayout.cpp \
|
||||||
src/playerarea.cpp \
|
|
||||||
src/carddatabasemodel.cpp \
|
src/carddatabasemodel.cpp \
|
||||||
src/window_deckeditor.cpp \
|
src/window_deckeditor.cpp \
|
||||||
src/decklist.cpp \
|
src/decklist.cpp \
|
||||||
|
@ -84,5 +83,6 @@ SOURCES += src/counter.cpp \
|
||||||
src/abstractgraphicsitem.cpp \
|
src/abstractgraphicsitem.cpp \
|
||||||
src/dlg_settings.cpp \
|
src/dlg_settings.cpp \
|
||||||
src/phasestoolbar.cpp \
|
src/phasestoolbar.cpp \
|
||||||
src/chatwidget.cpp
|
src/chatwidget.cpp \
|
||||||
|
src/gamescene.cpp
|
||||||
TRANSLATIONS += translations/cockatrice_de.ts translations/cockatrice_en.ts
|
TRANSLATIONS += translations/cockatrice_de.ts translations/cockatrice_en.ts
|
||||||
|
|
|
@ -241,7 +241,7 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
else {
|
else {
|
||||||
TableZone *table = (TableZone *) zone->getPlayer()->getZones()->findZone("table");
|
TableZone *table = (TableZone *) zone->getPlayer()->getZones()->findZone("table");
|
||||||
QPoint gridPoint = table->getFreeGridPoint(info->getTableRow());
|
QPoint gridPoint = table->getFreeGridPoint(info->getTableRow());
|
||||||
table->handleDropEvent(id, zone, table->mapFromGrid(gridPoint).toPoint(), false);
|
table->handleDropEventByGrid(id, zone, gridPoint, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <QGraphicsScene>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
@ -11,14 +10,13 @@
|
||||||
#include "handzone.h"
|
#include "handzone.h"
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
#include "dlg_startgame.h"
|
#include "dlg_startgame.h"
|
||||||
#include "playerarea.h"
|
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
|
#include "gamescene.h"
|
||||||
|
|
||||||
Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_actionsMenu, QMenu *_cardMenu, int playerId, const QString &playerName, QObject *parent)
|
Game::Game(CardDatabase *_db, Client *_client, GameScene *_scene, QMenu *_actionsMenu, QMenu *_cardMenu, int playerId, const QString &playerName, QObject *parent)
|
||||||
: QObject(parent), actionsMenu(_actionsMenu), cardMenu(_cardMenu), db(_db), client(_client), scene(_scene), started(false), currentPhase(-1)
|
: QObject(parent), actionsMenu(_actionsMenu), cardMenu(_cardMenu), db(_db), client(_client), scene(_scene), started(false), currentPhase(-1)
|
||||||
{
|
{
|
||||||
QRectF sr = scene->sceneRect();
|
localPlayer = addPlayer(playerId, playerName, true);
|
||||||
localPlayer = addPlayer(playerId, playerName, QPointF(0, sr.y() + sr.height() / 2 + 2), true);
|
|
||||||
|
|
||||||
connect(client, SIGNAL(gameEvent(const ServerEventData &)), this, SLOT(gameEvent(const ServerEventData &)));
|
connect(client, SIGNAL(gameEvent(const ServerEventData &)), this, SLOT(gameEvent(const ServerEventData &)));
|
||||||
connect(client, SIGNAL(playerListReceived(QList<ServerPlayer *>)), this, SLOT(playerListReceived(QList<ServerPlayer *>)));
|
connect(client, SIGNAL(playerListReceived(QList<ServerPlayer *>)), this, SLOT(playerListReceived(QList<ServerPlayer *>)));
|
||||||
|
@ -186,9 +184,10 @@ void Game::initSayMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *Game::addPlayer(int playerId, const QString &playerName, QPointF base, bool local)
|
Player *Game::addPlayer(int playerId, const QString &playerName, bool local)
|
||||||
{
|
{
|
||||||
Player *newPlayer = new Player(playerName, playerId, base, local, db, client, scene, this);
|
Player *newPlayer = new Player(playerName, playerId, local, db, client, this);
|
||||||
|
scene->addPlayer(newPlayer);
|
||||||
|
|
||||||
connect(newPlayer, SIGNAL(sigShowCardMenu(QPoint)), this, SLOT(showCardMenu(QPoint)));
|
connect(newPlayer, SIGNAL(sigShowCardMenu(QPoint)), this, SLOT(showCardMenu(QPoint)));
|
||||||
connect(newPlayer, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)), this, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)));
|
connect(newPlayer, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)), this, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)));
|
||||||
|
@ -214,7 +213,7 @@ void Game::playerListReceived(QList<ServerPlayer *> playerList)
|
||||||
int id = temp->getPlayerId();
|
int id = temp->getPlayerId();
|
||||||
|
|
||||||
if (id != localPlayer->getId())
|
if (id != localPlayer->getId())
|
||||||
addPlayer(id, temp->getName(), QPointF(0, 0), false);
|
addPlayer(id, temp->getName(), false);
|
||||||
|
|
||||||
delete temp;
|
delete temp;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +247,7 @@ void Game::gameEvent(const ServerEventData &msg)
|
||||||
emit logSay(p, msg.getEventData()[0]);
|
emit logSay(p, msg.getEventData()[0]);
|
||||||
break;
|
break;
|
||||||
case eventJoin: {
|
case eventJoin: {
|
||||||
Player *newPlayer = addPlayer(msg.getPlayerId(), msg.getPlayerName(), QPointF(0, 0), false);
|
Player *newPlayer = addPlayer(msg.getPlayerId(), msg.getPlayerName(), false);
|
||||||
emit logJoin(newPlayer);
|
emit logJoin(newPlayer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -387,7 +386,7 @@ void Game::actDecLife()
|
||||||
void Game::actSetLife()
|
void Game::actSetLife()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int life = QInputDialog::getInteger(0, tr("Set life"), tr("New life total:"), localPlayer->area->getCounter("life")->getValue(), 0, 2000000000, 1, &ok);
|
int life = QInputDialog::getInteger(0, tr("Set life"), tr("New life total:"), localPlayer->getCounter("life")->getValue(), 0, 2000000000, 1, &ok);
|
||||||
if (ok)
|
if (ok)
|
||||||
client->setCounter("life", life);
|
client->setCounter("life", life);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "playerlist.h"
|
#include "playerlist.h"
|
||||||
|
|
||||||
class ServerPlayer;
|
class ServerPlayer;
|
||||||
class QGraphicsScene;
|
class GameScene;
|
||||||
class Player;
|
class Player;
|
||||||
class Client;
|
class Client;
|
||||||
class ServerEventData;
|
class ServerEventData;
|
||||||
|
@ -29,12 +29,12 @@ private:
|
||||||
|
|
||||||
CardDatabase *db;
|
CardDatabase *db;
|
||||||
Client *client;
|
Client *client;
|
||||||
QGraphicsScene *scene;
|
GameScene *scene;
|
||||||
PlayerList players;
|
PlayerList players;
|
||||||
Player *localPlayer;
|
Player *localPlayer;
|
||||||
bool started;
|
bool started;
|
||||||
int currentPhase;
|
int currentPhase;
|
||||||
Player *addPlayer(int playerId, const QString &playerName, QPointF base, bool local);
|
Player *addPlayer(int playerId, const QString &playerName, bool local);
|
||||||
void initSayMenu();
|
void initSayMenu();
|
||||||
public slots:
|
public slots:
|
||||||
void actNextPhase();
|
void actNextPhase();
|
||||||
|
@ -93,7 +93,7 @@ signals:
|
||||||
void logSetActivePlayer(Player *player);
|
void logSetActivePlayer(Player *player);
|
||||||
void setActivePhase(int phase);
|
void setActivePhase(int phase);
|
||||||
public:
|
public:
|
||||||
Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_actionsMenu, QMenu *_cardMenu, int playerId, const QString &playerName, QObject *parent = 0);
|
Game(CardDatabase *_db, Client *_client, GameScene *_scene, QMenu *_actionsMenu, QMenu *_cardMenu, int playerId, const QString &playerName, QObject *parent = 0);
|
||||||
~Game();
|
~Game();
|
||||||
Player *getLocalPlayer() const { return localPlayer; }
|
Player *getLocalPlayer() const { return localPlayer; }
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
|
@ -7,10 +7,18 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent)
|
||||||
setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing/* | QPainter::SmoothPixmapTransform*/);
|
setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing/* | QPainter::SmoothPixmapTransform*/);
|
||||||
setDragMode(RubberBandDrag);
|
setDragMode(RubberBandDrag);
|
||||||
// setViewportUpdateMode(FullViewportUpdate);
|
// setViewportUpdateMode(FullViewportUpdate);
|
||||||
|
|
||||||
|
connect(scene, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(updateSceneRect(const QRectF &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::resizeEvent(QResizeEvent *event)
|
void GameView::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
QGraphicsView::resizeEvent(event);
|
QGraphicsView::resizeEvent(event);
|
||||||
fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
|
updateSceneRect(scene()->sceneRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameView::updateSceneRect(const QRectF &rect)
|
||||||
|
{
|
||||||
|
qDebug(QString("updateSceneRect = %1,%2").arg(rect.width()).arg(rect.height()).toLatin1());
|
||||||
|
fitInView(rect, Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
||||||
class GameView : public QGraphicsView {
|
class GameView : public QGraphicsView {
|
||||||
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
public slots:
|
||||||
|
void updateSceneRect(const QRectF &rect);
|
||||||
public:
|
public:
|
||||||
void scaleToScene();
|
|
||||||
GameView(QGraphicsScene *scene, QWidget *parent = 0);
|
GameView(QGraphicsScene *scene, QWidget *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
HandZone::HandZone(Player *_p, QGraphicsItem *parent)
|
HandZone::HandZone(Player *_p, int _zoneHeight, QGraphicsItem *parent)
|
||||||
: CardZone(_p, "hand", false, false, _p->getLocal(), parent)
|
: CardZone(_p, "hand", false, false, _p->getLocal(), parent), zoneHeight(_zoneHeight)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString bgPath = settings.value("zonebg/hand").toString();
|
QString bgPath = settings.value("zonebg/hand").toString();
|
||||||
|
@ -17,7 +17,7 @@ HandZone::HandZone(Player *_p, QGraphicsItem *parent)
|
||||||
|
|
||||||
QRectF HandZone::boundingRect() const
|
QRectF HandZone::boundingRect() const
|
||||||
{
|
{
|
||||||
return QRectF(0, 0, 100, 578);
|
return QRectF(0, 0, 100, zoneHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
class HandZone : public CardZone {
|
class HandZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
QPixmap bgPixmap;
|
QPixmap bgPixmap;
|
||||||
|
int zoneHeight;
|
||||||
public:
|
public:
|
||||||
HandZone(Player *_p, QGraphicsItem *parent = 0);
|
HandZone(Player *_p, int _zoneHeight, QGraphicsItem *parent = 0);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
|
|
|
@ -1,20 +1,51 @@
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "cardzone.h"
|
#include "cardzone.h"
|
||||||
#include "playerarea.h"
|
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
#include "zoneviewzone.h"
|
#include "zoneviewzone.h"
|
||||||
#include "zoneviewwidget.h"
|
#include "zoneviewwidget.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include <QGraphicsScene>
|
#include "pilezone.h"
|
||||||
|
#include "tablezone.h"
|
||||||
|
#include "handzone.h"
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QPainter>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene, Game *_parent)
|
Player::Player(const QString &_name, int _id, bool _local, CardDatabase *_db, Client *_client, Game *_parent)
|
||||||
: QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), active(false), base(_base), local(_local), db(_db), client(_client)
|
: QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), active(false), local(_local), db(_db), client(_client)
|
||||||
{
|
{
|
||||||
area = new PlayerArea(this);
|
QSettings settings;
|
||||||
area->setPos(_base);
|
QString bgPath = settings.value("zonebg/playerarea").toString();
|
||||||
_scene->addItem(area);
|
if (!bgPath.isEmpty())
|
||||||
|
bgPixmap.load(bgPath);
|
||||||
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
|
||||||
|
QPointF base = QPointF(55, 50);
|
||||||
|
|
||||||
|
PileZone *deck = new PileZone(this, "deck", true, false, this);
|
||||||
|
deck->setPos(base);
|
||||||
|
|
||||||
|
qreal h = deck->boundingRect().height() + 20;
|
||||||
|
|
||||||
|
PileZone *grave = new PileZone(this, "grave", false, true, this);
|
||||||
|
grave->setPos(base + QPointF(0, h));
|
||||||
|
|
||||||
|
PileZone *rfg = new PileZone(this, "rfg", false, true, this);
|
||||||
|
rfg->setPos(base + QPointF(0, 2 * h));
|
||||||
|
|
||||||
|
PileZone *sb = new PileZone(this, "sb", false, true, this);
|
||||||
|
sb->setVisible(false);
|
||||||
|
|
||||||
|
CardZone *table = new TableZone(this, this);
|
||||||
|
CardZone *hand = new HandZone(this, table->boundingRect().height(), this);
|
||||||
|
|
||||||
|
base = QPointF(deck->boundingRect().width() + 60, 0);
|
||||||
|
hand->setPos(base);
|
||||||
|
base += QPointF(hand->boundingRect().width(), 0);
|
||||||
|
table->setPos(base);
|
||||||
|
|
||||||
|
bRect = QRectF(0, 0, base.x() + table->boundingRect().width(), base.y() + table->boundingRect().height());
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
aMoveHandToTopLibrary = new QAction(this);
|
aMoveHandToTopLibrary = new QAction(this);
|
||||||
|
@ -93,7 +124,7 @@ Player::~Player()
|
||||||
for (int i = 0; i < zones.size(); i++)
|
for (int i = 0; i < zones.size(); i++)
|
||||||
delete zones.at(i);
|
delete zones.at(i);
|
||||||
|
|
||||||
delete area;
|
clearCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::retranslateUi()
|
void Player::retranslateUi()
|
||||||
|
@ -230,7 +261,7 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
zones.at(i)->clearContents();
|
zones.at(i)->clearContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
area->clearCounters();
|
clearCounters();
|
||||||
|
|
||||||
CardZone *deck = zones.findZone("deck");
|
CardZone *deck = zones.findZone("deck");
|
||||||
for (; deck_cards; deck_cards--)
|
for (; deck_cards; deck_cards--)
|
||||||
|
@ -359,7 +390,7 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
int colorValue = data[1].toInt();
|
int colorValue = data[1].toInt();
|
||||||
int value = data[2].toInt();
|
int value = data[2].toInt();
|
||||||
QColor color(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256);
|
QColor color(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256);
|
||||||
area->addCounter(counterName, color, value);
|
addCounter(counterName, color, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eventSetCounter: {
|
case eventSetCounter: {
|
||||||
|
@ -368,7 +399,7 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
}
|
}
|
||||||
int value = data[1].toInt();
|
int value = data[1].toInt();
|
||||||
QString counterName = data[0];
|
QString counterName = data[0];
|
||||||
Counter *c = area->getCounter(counterName);
|
Counter *c = getCounter(counterName);
|
||||||
int oldValue = c->getValue();
|
int oldValue = c->getValue();
|
||||||
c->setValue(value);
|
c->setValue(value);
|
||||||
emit logSetCounter(this, c->getName(), value, oldValue);
|
emit logSetCounter(this, c->getName(), value, oldValue);
|
||||||
|
@ -387,5 +418,90 @@ void Player::showCardMenu(const QPoint &p)
|
||||||
void Player::setActive(bool _active)
|
void Player::setActive(bool _active)
|
||||||
{
|
{
|
||||||
active = _active;
|
active = _active;
|
||||||
area->update();
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF Player::boundingRect() const
|
||||||
|
{
|
||||||
|
return bRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||||
|
{
|
||||||
|
if (bgPixmap.isNull())
|
||||||
|
painter->fillRect(boundingRect(), QColor(200, 200, 200));
|
||||||
|
else
|
||||||
|
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||||
|
|
||||||
|
QString nameStr = getName();
|
||||||
|
QFont font("Times");
|
||||||
|
font.setPixelSize(20);
|
||||||
|
// font.setWeight(QFont::Bold);
|
||||||
|
|
||||||
|
int totalWidth = CARD_WIDTH + 60;
|
||||||
|
|
||||||
|
if (getActive()) {
|
||||||
|
QFontMetrics fm(font);
|
||||||
|
double w = fm.width(nameStr) * 1.7;
|
||||||
|
double h = fm.height() * 1.7;
|
||||||
|
if (w < h)
|
||||||
|
w = h;
|
||||||
|
|
||||||
|
painter->setPen(Qt::transparent);
|
||||||
|
QRadialGradient grad(QPointF(0.5, 0.5), 0.5);
|
||||||
|
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||||
|
grad.setColorAt(0, QColor(150, 200, 150, 255));
|
||||||
|
grad.setColorAt(0.7, QColor(150, 200, 150, 255));
|
||||||
|
grad.setColorAt(1, QColor(150, 150, 150, 0));
|
||||||
|
painter->setBrush(QBrush(grad));
|
||||||
|
|
||||||
|
painter->drawEllipse(QRectF(((double) (totalWidth - w)) / 2, 0, w, h));
|
||||||
|
}
|
||||||
|
painter->setFont(font);
|
||||||
|
painter->setPen(QPen(Qt::black));
|
||||||
|
painter->drawText(QRectF(0, 0, totalWidth, 40), Qt::AlignCenter, nameStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Counter *Player::getCounter(const QString &name, bool remove)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < counterList.size(); i++) {
|
||||||
|
Counter *temp = counterList.at(i);
|
||||||
|
if (temp->getName() == name) {
|
||||||
|
if (remove)
|
||||||
|
counterList.removeAt(i);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::addCounter(const QString &name, QColor color, int value)
|
||||||
|
{
|
||||||
|
counterList.append(new Counter(this, name, color, value, this));
|
||||||
|
rearrangeCounters();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::delCounter(const QString &name)
|
||||||
|
{
|
||||||
|
delete getCounter(name, true);
|
||||||
|
rearrangeCounters();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::clearCounters()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < counterList.size(); i++)
|
||||||
|
delete counterList.at(i);
|
||||||
|
counterList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::rearrangeCounters()
|
||||||
|
{
|
||||||
|
const int counterAreaWidth = 55;
|
||||||
|
qreal y = 50;
|
||||||
|
for (int i = 0; i < counterList.size(); i++) {
|
||||||
|
Counter *temp = counterList.at(i);
|
||||||
|
QRectF br = temp->boundingRect();
|
||||||
|
temp->setPos((counterAreaWidth - br.width()) / 2, y);
|
||||||
|
y += br.height() + 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@ class Client;
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QAction;
|
class QAction;
|
||||||
class PlayerArea;
|
|
||||||
class ZoneViewZone;
|
class ZoneViewZone;
|
||||||
class Game;
|
class Game;
|
||||||
|
class Counter;
|
||||||
|
|
||||||
class Player : public QObject {
|
class Player : public QObject, public QGraphicsItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
signals:
|
signals:
|
||||||
void moveCard(int cardId, QString startZone, QString targetZone, int x, int y);
|
void moveCard(int cardId, QString startZone, QString targetZone, int x, int y);
|
||||||
|
@ -52,16 +52,30 @@ private:
|
||||||
QString name;
|
QString name;
|
||||||
int id;
|
int id;
|
||||||
bool active;
|
bool active;
|
||||||
QPointF base;
|
|
||||||
bool local;
|
bool local;
|
||||||
ZoneList zones;
|
ZoneList zones;
|
||||||
CardDatabase *db;
|
CardDatabase *db;
|
||||||
void setCardAttrHelper(CardItem *card, const QString &aname, const QString &avalue, bool allCards);
|
void setCardAttrHelper(CardItem *card, const QString &aname, const QString &avalue, bool allCards);
|
||||||
|
|
||||||
|
QPixmap bgPixmap;
|
||||||
|
QRectF bRect;
|
||||||
|
|
||||||
|
QList<Counter *> counterList;
|
||||||
|
void rearrangeCounters();
|
||||||
public:
|
public:
|
||||||
PlayerArea *area;
|
enum { Type = typeOther };
|
||||||
|
int type() const { return Type; }
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
Counter *getCounter(const QString &name, bool remove = false);
|
||||||
|
void addCounter(const QString &name, QColor color, int value);
|
||||||
|
void delCounter(const QString &name);
|
||||||
|
void clearCounters();
|
||||||
|
|
||||||
Client *client;
|
Client *client;
|
||||||
void addZone(CardZone *z);
|
void addZone(CardZone *z);
|
||||||
Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene, Game *_parent);
|
Player(const QString &_name, int _id, bool _local, CardDatabase *_db, Client *_client, Game *_parent);
|
||||||
~Player();
|
~Player();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
QMenu *getPlayerMenu() const { return playerMenu; }
|
QMenu *getPlayerMenu() const { return playerMenu; }
|
||||||
|
|
|
@ -1,135 +0,0 @@
|
||||||
#include "playerarea.h"
|
|
||||||
#include "player.h"
|
|
||||||
#include "tablezone.h"
|
|
||||||
#include "handzone.h"
|
|
||||||
#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);
|
|
||||||
|
|
||||||
PileZone *deck = new PileZone(_player, "deck", true, false, this);
|
|
||||||
deck->setPos(base);
|
|
||||||
|
|
||||||
qreal h = deck->boundingRect().height() + 20;
|
|
||||||
|
|
||||||
PileZone *grave = new PileZone(_player, "grave", false, true, this);
|
|
||||||
grave->setPos(base + QPointF(0, h));
|
|
||||||
|
|
||||||
PileZone *rfg = new PileZone(_player, "rfg", false, true, this);
|
|
||||||
rfg->setPos(base + QPointF(0, 2 * h));
|
|
||||||
|
|
||||||
PileZone *sb = new PileZone(_player, "sb", false, true, this);
|
|
||||||
sb->setVisible(false);
|
|
||||||
|
|
||||||
base = QPointF(deck->boundingRect().width() + 60, 0);
|
|
||||||
|
|
||||||
CardZone *hand = new HandZone(_player, this);
|
|
||||||
hand->setPos(base);
|
|
||||||
base += QPointF(hand->boundingRect().width(), 0);
|
|
||||||
|
|
||||||
CardZone *table = new TableZone(_player, this);
|
|
||||||
table->setPos(base);
|
|
||||||
|
|
||||||
bRect = QRectF(0, 0, base.x() + table->boundingRect().width(), base.y() + table->boundingRect().height());
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerArea::~PlayerArea()
|
|
||||||
{
|
|
||||||
clearCounters();
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF PlayerArea::boundingRect() const
|
|
||||||
{
|
|
||||||
return bRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerArea::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
|
||||||
{
|
|
||||||
if (bgPixmap.isNull())
|
|
||||||
painter->fillRect(boundingRect(), QColor(200, 200, 200));
|
|
||||||
else
|
|
||||||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
|
||||||
|
|
||||||
QString nameStr = player->getName();
|
|
||||||
QFont font("Times");
|
|
||||||
font.setPixelSize(20);
|
|
||||||
// font.setWeight(QFont::Bold);
|
|
||||||
|
|
||||||
int totalWidth = CARD_WIDTH + 60;
|
|
||||||
|
|
||||||
if (player->getActive()) {
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
double w = fm.width(nameStr) * 1.7;
|
|
||||||
double h = fm.height() * 1.7;
|
|
||||||
if (w < h)
|
|
||||||
w = h;
|
|
||||||
|
|
||||||
painter->setPen(Qt::transparent);
|
|
||||||
QRadialGradient grad(QPointF(0.5, 0.5), 0.5);
|
|
||||||
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
|
|
||||||
grad.setColorAt(0, QColor(150, 200, 150, 255));
|
|
||||||
grad.setColorAt(0.7, QColor(150, 200, 150, 255));
|
|
||||||
grad.setColorAt(1, QColor(150, 150, 150, 0));
|
|
||||||
painter->setBrush(QBrush(grad));
|
|
||||||
|
|
||||||
painter->drawEllipse(QRectF(((double) (totalWidth - w)) / 2, 0, w, h));
|
|
||||||
}
|
|
||||||
painter->setFont(font);
|
|
||||||
painter->setPen(QPen(Qt::black));
|
|
||||||
painter->drawText(QRectF(0, 0, totalWidth, 40), Qt::AlignCenter, nameStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
Counter *PlayerArea::getCounter(const QString &name, bool remove)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < counterList.size(); i++) {
|
|
||||||
Counter *temp = counterList.at(i);
|
|
||||||
if (temp->getName() == name) {
|
|
||||||
if (remove)
|
|
||||||
counterList.removeAt(i);
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerArea::addCounter(const QString &name, QColor color, int value)
|
|
||||||
{
|
|
||||||
counterList.append(new Counter(player, name, color, value, this));
|
|
||||||
rearrangeCounters();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerArea::delCounter(const QString &name)
|
|
||||||
{
|
|
||||||
delete getCounter(name, true);
|
|
||||||
rearrangeCounters();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerArea::clearCounters()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < counterList.size(); i++)
|
|
||||||
delete counterList.at(i);
|
|
||||||
counterList.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerArea::rearrangeCounters()
|
|
||||||
{
|
|
||||||
const int counterAreaWidth = 55;
|
|
||||||
qreal y = 50;
|
|
||||||
for (int i = 0; i < counterList.size(); i++) {
|
|
||||||
Counter *temp = counterList.at(i);
|
|
||||||
QRectF br = temp->boundingRect();
|
|
||||||
temp->setPos((counterAreaWidth - br.width()) / 2, y);
|
|
||||||
y += br.height() + 10;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
#ifndef PLAYERAREA_H
|
|
||||||
#define PLAYERAREA_H
|
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include "carditem.h"
|
|
||||||
|
|
||||||
class Player;
|
|
||||||
class Counter;
|
|
||||||
|
|
||||||
class PlayerArea : public QGraphicsItem {
|
|
||||||
private:
|
|
||||||
QPixmap bgPixmap;
|
|
||||||
QRectF bRect;
|
|
||||||
Player *player;
|
|
||||||
QList<Counter *> counterList;
|
|
||||||
|
|
||||||
void rearrangeCounters();
|
|
||||||
public:
|
|
||||||
enum { Type = typeOther };
|
|
||||||
int type() const { return Type; }
|
|
||||||
PlayerArea(Player *_player, QGraphicsItem *parent = 0);
|
|
||||||
~PlayerArea();
|
|
||||||
QRectF boundingRect() const;
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
|
||||||
|
|
||||||
Counter *getCounter(const QString &name, bool remove = false);
|
|
||||||
void addCounter(const QString &name, QColor color, int value);
|
|
||||||
void delCounter(const QString &name);
|
|
||||||
void clearCounters();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -4,56 +4,15 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
||||||
: CardZone(_p, "table", true, false, true, parent), width(864), height(578)
|
: CardZone(_p, "table", true, false, true, parent), width(864), height(536)
|
||||||
{
|
{
|
||||||
gridPoints << (QList<QPoint>() << QPoint(8, 12)
|
|
||||||
<< QPoint(9, 13)
|
|
||||||
<< QPoint(10, 14)
|
|
||||||
<< QPoint(12, 12)
|
|
||||||
<< QPoint(13, 13)
|
|
||||||
<< QPoint(14, 14)
|
|
||||||
<< QPoint(4, 12)
|
|
||||||
<< QPoint(5, 13)
|
|
||||||
<< QPoint(6, 14)
|
|
||||||
<< QPoint(16, 12)
|
|
||||||
<< QPoint(17, 13)
|
|
||||||
<< QPoint(18, 14)
|
|
||||||
<< QPoint(0, 12)
|
|
||||||
<< QPoint(1, 13)
|
|
||||||
<< QPoint(2, 14)
|
|
||||||
<< QPoint(20, 12)
|
|
||||||
<< QPoint(21, 13)
|
|
||||||
<< QPoint(22, 14))
|
|
||||||
<< (QList<QPoint>() << QPoint(10, 8)
|
|
||||||
<< QPoint(13, 8)
|
|
||||||
<< QPoint(7, 8)
|
|
||||||
<< QPoint(16, 8)
|
|
||||||
<< QPoint(4, 8)
|
|
||||||
<< QPoint(19, 8)
|
|
||||||
<< QPoint(1, 8)
|
|
||||||
<< QPoint(22, 8))
|
|
||||||
<< (QList<QPoint>() << QPoint(10, 4)
|
|
||||||
<< QPoint(13, 4)
|
|
||||||
<< QPoint(7, 4)
|
|
||||||
<< QPoint(16, 4)
|
|
||||||
<< QPoint(4, 4)
|
|
||||||
<< QPoint(19, 4)
|
|
||||||
<< QPoint(1, 4)
|
|
||||||
<< QPoint(22, 4))
|
|
||||||
<< (QList<QPoint>() << QPoint(10, 0)
|
|
||||||
<< QPoint(13, 0)
|
|
||||||
<< QPoint(7, 0)
|
|
||||||
<< QPoint(16, 0)
|
|
||||||
<< QPoint(4, 0)
|
|
||||||
<< QPoint(19, 0)
|
|
||||||
<< QPoint(1, 0)
|
|
||||||
<< QPoint(22, 0));
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString bgPath = settings.value("zonebg/table").toString();
|
QString bgPath = settings.value("zonebg/table").toString();
|
||||||
if (!bgPath.isEmpty())
|
if (!bgPath.isEmpty())
|
||||||
bgPixmap.load(bgPath);
|
bgPixmap.load(bgPath);
|
||||||
|
|
||||||
setCacheMode(DeviceCoordinateCache);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
setAcceptsHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF TableZone::boundingRect() const
|
QRectF TableZone::boundingRect() const
|
||||||
|
@ -90,7 +49,11 @@ void TableZone::addCardImpl(CardItem *card, int _x, int _y)
|
||||||
|
|
||||||
void TableZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown)
|
void TableZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown)
|
||||||
{
|
{
|
||||||
QPoint gridPoint = mapToGrid(dropPoint);
|
handleDropEventByGrid(cardId, startZone, mapToGrid(dropPoint), faceDown);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TableZone::handleDropEventByGrid(int cardId, CardZone *startZone, const QPoint &gridPoint, bool faceDown)
|
||||||
|
{
|
||||||
player->client->moveCard(cardId, startZone->getName(), getName(), gridPoint.x(), gridPoint.y(), faceDown);
|
player->client->moveCard(cardId, startZone->getName(), getName(), gridPoint.x(), gridPoint.y(), faceDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,13 +87,21 @@ CardItem *TableZone::getCardFromGrid(const QPoint &gridPoint) const
|
||||||
|
|
||||||
QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
|
QPointF TableZone::mapFromGrid(const QPoint &gridPoint) const
|
||||||
{
|
{
|
||||||
return QPointF(gridPoint.x() * CARD_WIDTH / gridPointsPerCardX,
|
if (gridPoint.y() == 3)
|
||||||
gridPoint.y() * CARD_HEIGHT / gridPointsPerCardY);
|
return QPointF(
|
||||||
|
20 + (CARD_WIDTH * gridPoint.x() + CARD_WIDTH * (gridPoint.x() / 3)) / gridPointsPerCardX,
|
||||||
|
(CARD_HEIGHT + paddingY) * gridPoint.y() / gridPointsPerCardY + (gridPoint.x() % 3 * CARD_HEIGHT) / 3
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return QPointF(
|
||||||
|
20 + CARD_WIDTH * gridPoint.x() / gridPointsPerCardX,
|
||||||
|
(CARD_HEIGHT + paddingY) * gridPoint.y() / gridPointsPerCardY
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
||||||
{
|
{
|
||||||
qreal x = mapPoint.x();
|
qreal x = mapPoint.x() - 20;
|
||||||
qreal y = mapPoint.y();
|
qreal y = mapPoint.y();
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
x = 0;
|
x = 0;
|
||||||
|
@ -141,16 +112,27 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
||||||
else if (y > height - CARD_HEIGHT)
|
else if (y > height - CARD_HEIGHT)
|
||||||
y = height - CARD_HEIGHT;
|
y = height - CARD_HEIGHT;
|
||||||
|
|
||||||
return QPoint((int) round(((double) x * gridPointsPerCardX) / CARD_WIDTH), (int) round(((double) y * gridPointsPerCardY) / CARD_HEIGHT));
|
if (y >= (CARD_HEIGHT + paddingY) * 3 - 1)
|
||||||
|
return QPoint(
|
||||||
|
(int) round(((double) x * gridPointsPerCardX) / CARD_WIDTH - x / (2 * CARD_WIDTH)),
|
||||||
|
3
|
||||||
|
);
|
||||||
|
else
|
||||||
|
return QPoint(
|
||||||
|
(int) round(((double) x * gridPointsPerCardX) / CARD_WIDTH),
|
||||||
|
(int) round(((double) y * gridPointsPerCardY) / (CARD_HEIGHT + paddingY))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint TableZone::getFreeGridPoint(int row) const
|
QPoint TableZone::getFreeGridPoint(int row) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(row < gridPoints.size());
|
int x = 0;
|
||||||
|
int y = 3 - row;
|
||||||
QList<QPoint> pointList = gridPoints[row];
|
if (y == 3)
|
||||||
for (int i = 0; i < pointList.size(); i++)
|
while (getCardFromGrid(QPoint(x, y)))
|
||||||
if (!getCardFromGrid(pointList[i]))
|
++x;
|
||||||
return pointList[i];
|
else
|
||||||
return QPoint(0, 0);
|
while (((x >= 2) && getCardFromGrid(QPoint(x - 2, y))) || ((x >= 1) && getCardFromGrid(QPoint(x - 1, y))) || getCardFromGrid(QPoint(x, y)) || getCardFromGrid(QPoint(x + 1, y)) || getCardFromGrid(QPoint(x + 2, y)))
|
||||||
|
++x;
|
||||||
|
return QPoint(x, y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
class TableZone : public CardZone {
|
class TableZone : public CardZone {
|
||||||
private:
|
private:
|
||||||
int width, height;
|
int width, height;
|
||||||
QList<QList<QPoint> > gridPoints;
|
|
||||||
QPixmap bgPixmap;
|
QPixmap bgPixmap;
|
||||||
public:
|
public:
|
||||||
static const int gridPointsPerCardX = 2;
|
static const int gridPointsPerCardX = 2;
|
||||||
static const int gridPointsPerCardY = 3;
|
static const int gridPointsPerCardY = 1;
|
||||||
|
static const int paddingY = 20;
|
||||||
|
|
||||||
TableZone(Player *_p, QGraphicsItem *parent = 0);
|
TableZone(Player *_p, QGraphicsItem *parent = 0);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
|
@ -18,6 +18,7 @@ public:
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void toggleTapped();
|
void toggleTapped();
|
||||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
||||||
|
void handleDropEventByGrid(int cardId, CardZone *startZone, const QPoint &gridPoint, bool faceDown);
|
||||||
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
||||||
QPointF mapFromGrid(const QPoint &gridPoint) const;
|
QPointF mapFromGrid(const QPoint &gridPoint) const;
|
||||||
QPoint mapToGrid(const QPointF &mapPoint) const;
|
QPoint mapToGrid(const QPointF &mapPoint) const;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "messagelogwidget.h"
|
#include "messagelogwidget.h"
|
||||||
#include "phasestoolbar.h"
|
#include "phasestoolbar.h"
|
||||||
#include "gameview.h"
|
#include "gameview.h"
|
||||||
|
#include "gamescene.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "carddatabase.h"
|
#include "carddatabase.h"
|
||||||
|
@ -154,15 +155,6 @@ void MainWindow::actExit()
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateSceneSize()
|
|
||||||
{
|
|
||||||
QRectF sr = scene->sceneRect();
|
|
||||||
QSizeF zoneSize = zoneLayout->size();
|
|
||||||
qDebug(QString("updateSceneSize: width=%1").arg(1096 + zoneSize.width()).toLatin1());
|
|
||||||
scene->setSceneRect(sr.x(), sr.y(), 1096 + zoneSize.width(), sr.height());
|
|
||||||
view->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::actSay()
|
void MainWindow::actSay()
|
||||||
{
|
{
|
||||||
if (sayEdit->text().isEmpty())
|
if (sayEdit->text().isEmpty())
|
||||||
|
@ -178,6 +170,7 @@ void MainWindow::playerIdReceived(int id, QString name)
|
||||||
connect(game, SIGNAL(hoverCard(QString)), this, SLOT(hoverCard(QString)));
|
connect(game, SIGNAL(hoverCard(QString)), this, SLOT(hoverCard(QString)));
|
||||||
connect(game, SIGNAL(playerAdded(Player *)), this, SLOT(playerAdded(Player *)));
|
connect(game, SIGNAL(playerAdded(Player *)), this, SLOT(playerAdded(Player *)));
|
||||||
connect(game, SIGNAL(playerRemoved(Player *)), this, SLOT(playerRemoved(Player *)));
|
connect(game, SIGNAL(playerRemoved(Player *)), this, SLOT(playerRemoved(Player *)));
|
||||||
|
connect(game, SIGNAL(playerRemoved(Player *)), scene, SLOT(removePlayer(Player *)));
|
||||||
connect(game, SIGNAL(setActivePhase(int)), phasesToolbar, SLOT(setActivePhase(int)));
|
connect(game, SIGNAL(setActivePhase(int)), phasesToolbar, SLOT(setActivePhase(int)));
|
||||||
connect(phasesToolbar, SIGNAL(signalUntapAll()), game, SLOT(actUntapAll()));
|
connect(phasesToolbar, SIGNAL(signalUntapAll()), game, SLOT(actUntapAll()));
|
||||||
playerAdded(game->getLocalPlayer());
|
playerAdded(game->getLocalPlayer());
|
||||||
|
@ -281,16 +274,11 @@ MainWindow::MainWindow(QTranslator *_translator, QWidget *parent)
|
||||||
|
|
||||||
db = new CardDatabase(this);
|
db = new CardDatabase(this);
|
||||||
|
|
||||||
scene = new QGraphicsScene(0, 0, 1096, 1160, this);
|
|
||||||
view = new GameView(scene);
|
|
||||||
view->hide();
|
|
||||||
|
|
||||||
// view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
|
||||||
|
|
||||||
zoneLayout = new ZoneViewLayout(db);
|
zoneLayout = new ZoneViewLayout(db);
|
||||||
zoneLayout->setPos(1096, 0);
|
scene = new GameScene(zoneLayout, this);
|
||||||
scene->addItem(zoneLayout);
|
view = new GameView(scene);
|
||||||
connect(zoneLayout, SIGNAL(sizeChanged()), this, SLOT(updateSceneSize()));
|
// view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||||
|
view->hide();
|
||||||
|
|
||||||
cardInfo = new CardInfoWidget(db);
|
cardInfo = new CardInfoWidget(db);
|
||||||
messageLog = new MessageLogWidget;
|
messageLog = new MessageLogWidget;
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
class QGraphicsScene;
|
|
||||||
class GameView;
|
class GameView;
|
||||||
|
class GameScene;
|
||||||
class Game;
|
class Game;
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
class Player;
|
class Player;
|
||||||
|
@ -63,8 +63,6 @@ private slots:
|
||||||
void actFullScreen(bool checked);
|
void actFullScreen(bool checked);
|
||||||
void actSettings();
|
void actSettings();
|
||||||
void actExit();
|
void actExit();
|
||||||
|
|
||||||
void updateSceneSize();
|
|
||||||
signals:
|
signals:
|
||||||
void logConnecting(QString hostname);
|
void logConnecting(QString hostname);
|
||||||
void logDisconnected();
|
void logDisconnected();
|
||||||
|
@ -86,7 +84,7 @@ private:
|
||||||
ChatWidget *chatWidget;
|
ChatWidget *chatWidget;
|
||||||
|
|
||||||
Client *client;
|
Client *client;
|
||||||
QGraphicsScene *scene;
|
GameScene *scene;
|
||||||
GameView *view;
|
GameView *view;
|
||||||
Game *game;
|
Game *game;
|
||||||
CardDatabase *db;
|
CardDatabase *db;
|
||||||
|
|
Loading…
Reference in a new issue