cosmetic improvements

This commit is contained in:
Max-Wilhelm Bruker 2009-05-24 16:07:55 +02:00
parent 1e702642a4
commit 748d9bb603
4 changed files with 19 additions and 18 deletions

View file

@ -16,7 +16,7 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
: QObject(), actionsMenu(_actionsMenu), cardMenu(_cardMenu), db(_db), client(_client), scene(_scene), started(false) : QObject(), actionsMenu(_actionsMenu), cardMenu(_cardMenu), db(_db), client(_client), scene(_scene), started(false)
{ {
QRectF sr = scene->sceneRect(); QRectF sr = scene->sceneRect();
localPlayer = addPlayer(playerId, playerName, QPointF(0, sr.y() + sr.height() / 2), true); localPlayer = addPlayer(playerId, playerName, QPointF(0, sr.y() + sr.height() / 2 + 2), true);
connect(client, SIGNAL(gameEvent(ServerEventData *)), this, SLOT(gameEvent(ServerEventData *))); connect(client, SIGNAL(gameEvent(ServerEventData *)), this, SLOT(gameEvent(ServerEventData *)));
connect(client, SIGNAL(playerListReceived(QList<ServerPlayer *>)), this, SLOT(playerListReceived(QList<ServerPlayer *>))); connect(client, SIGNAL(playerListReceived(QList<ServerPlayer *>)), this, SLOT(playerListReceived(QList<ServerPlayer *>)));

View file

@ -14,11 +14,9 @@ QRectF HandZone::boundingRect() const
return QRectF(0, 0, 100, 510); return QRectF(0, 0, 100, 510);
} }
void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{ {
Q_UNUSED(option); painter->fillRect(boundingRect(), Qt::darkGreen);
Q_UNUSED(widget);
painter->fillRect(boundingRect(), QColor("green"));
} }
void HandZone::reorganizeCards() void HandZone::reorganizeCards()
@ -31,10 +29,13 @@ void HandZone::reorganizeCards()
qreal totalHeight = boundingRect().height(); qreal totalHeight = boundingRect().height();
qreal cardWidth = cards->at(0)->boundingRect().width(); qreal cardWidth = cards->at(0)->boundingRect().width();
qreal cardHeight = cards->at(0)->boundingRect().height(); qreal cardHeight = cards->at(0)->boundingRect().height();
qreal x = (totalWidth - cardWidth) / 2; qreal xspace = 5;
qreal x1 = xspace;
qreal x2 = totalWidth - xspace - cardWidth;
for (int i = 0; i < cardCount; i++) { for (int i = 0; i < cardCount; i++) {
CardItem *c = cards->at(i); CardItem *c = cards->at(i);
qreal x = i % 2 ? x2 : x1;
// If the total height of the cards is smaller than the available height, // If the total height of the cards is smaller than the available height,
// the cards do not need to overlap and are displayed in the center of the area. // the cards do not need to overlap and are displayed in the center of the area.
if (cardHeight * cardCount > totalHeight) if (cardHeight * cardCount > totalHeight)

View file

@ -51,14 +51,14 @@ QRectF PlayerArea::boundingRect() const
return bRect; return bRect;
} }
void PlayerArea::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void PlayerArea::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{ {
painter->save(); painter->save();
painter->fillRect(boundingRect(), QColor(200, 200, 200)); painter->fillRect(boundingRect(), QColor(200, 200, 200));
painter->setFont(QFont("Times", 16, QFont::Bold)); painter->setFont(QFont("Times", 16, QFont::Bold));
painter->setPen(QPen(QColor("black"))); painter->setPen(QPen(Qt::black));
painter->drawText(QRectF(0, 0, CARD_WIDTH + 60, 40), Qt::AlignCenter, player->getName()); painter->drawText(QRectF(0, 0, CARD_WIDTH + 60, 40), Qt::AlignCenter, player->getName());
painter->restore(); painter->restore();
@ -99,7 +99,7 @@ void PlayerArea::clearCounters()
void PlayerArea::rearrangeCounters() void PlayerArea::rearrangeCounters()
{ {
const int counterAreaWidth = 55; const int counterAreaWidth = 55;
int y = 50; qreal y = 50;
for (int i = 0; i < counterList.size(); i++) { for (int i = 0; i < counterList.size(); i++) {
Counter *temp = counterList.at(i); Counter *temp = counterList.at(i);
QRectF br = temp->boundingRect(); QRectF br = temp->boundingRect();

View file

@ -225,7 +225,7 @@ MainWindow::MainWindow(QWidget *parent)
int cardCount = db->loadFromFile("../cards.dat"); int cardCount = db->loadFromFile("../cards.dat");
qDebug(QString("%1 cards loaded").arg(cardCount).toLatin1()); qDebug(QString("%1 cards loaded").arg(cardCount).toLatin1());
scene = new QGraphicsScene(0, 0, 952, 1020, this); scene = new QGraphicsScene(0, 0, 952, 1024, this);
view = new GameView(scene); view = new GameView(scene);
// view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); // view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));