minor fixes; added round clock
This commit is contained in:
parent
02f2fb9764
commit
5544de3213
9 changed files with 28 additions and 8 deletions
|
@ -67,9 +67,6 @@ void HandZone::reorganizeCards()
|
|||
qreal totalWidth = boundingRect().width() - 2 * xPadding;
|
||||
qreal cardWidth = cards.at(0)->boundingRect().width();
|
||||
|
||||
if (cardWidth * cardCount < totalWidth)
|
||||
cardWidth += 5;
|
||||
|
||||
for (int i = 0; i < cardCount; i++) {
|
||||
CardItem *c = cards.at(i);
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ void SelectZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
selectionOrigin = event->pos();
|
||||
static_cast<GameScene *>(scene())->startRubberBand(event->scenePos());
|
||||
event->accept();
|
||||
}
|
||||
} else
|
||||
CardZone::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void SelectZone::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
|
|
@ -169,6 +169,8 @@ TabGame::TabGame(QList<AbstractClient *> &_clients, int _gameId, const QString &
|
|||
cardInfo = new CardInfoWidget(CardInfoWidget::ModeGameTab);
|
||||
playerListWidget = new PlayerListWidget;
|
||||
playerListWidget->setFocusPolicy(Qt::NoFocus);
|
||||
timeElapsedLabel = new QLabel;
|
||||
timeElapsedLabel->setAlignment(Qt::AlignCenter);
|
||||
messageLog = new MessageLogWidget;
|
||||
connect(messageLog, SIGNAL(cardNameHovered(QString)), cardInfo, SLOT(setCard(QString)));
|
||||
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
|
@ -190,6 +192,7 @@ TabGame::TabGame(QList<AbstractClient *> &_clients, int _gameId, const QString &
|
|||
QVBoxLayout *verticalLayout = new QVBoxLayout;
|
||||
verticalLayout->addWidget(cardInfo);
|
||||
verticalLayout->addWidget(playerListWidget, 1);
|
||||
verticalLayout->addWidget(timeElapsedLabel);
|
||||
verticalLayout->addWidget(messageLog, 5);
|
||||
verticalLayout->addLayout(hLayout);
|
||||
|
||||
|
@ -651,6 +654,13 @@ void TabGame::eventPing(Event_Ping *event, GameEventContext * /*context*/)
|
|||
const QList<ServerInfo_PlayerPing *> &pingList = event->getPingList();
|
||||
for (int i = 0; i < pingList.size(); ++i)
|
||||
playerListWidget->updatePing(pingList[i]->getPlayerId(), pingList[i]->getPingTime());
|
||||
|
||||
int seconds = event->getSecondsElapsed();
|
||||
int minutes = seconds / 60;
|
||||
seconds -= minutes * 60;
|
||||
int hours = minutes / 60;
|
||||
minutes -= hours * 60;
|
||||
timeElapsedLabel->setText(QString::number(hours).rightJustified(2, '0') + ":" + QString::number(minutes).rightJustified(2, '0') + ":" + QString::number(seconds).rightJustified(2, '0'));
|
||||
}
|
||||
|
||||
void TabGame::newCardAdded(AbstractCardItem *card)
|
||||
|
|
|
@ -99,6 +99,7 @@ private:
|
|||
CardInfoWidget *infoPopup;
|
||||
CardInfoWidget *cardInfo;
|
||||
PlayerListWidget *playerListWidget;
|
||||
QLabel *timeElapsedLabel;
|
||||
MessageLogWidget *messageLog;
|
||||
QLabel *sayLabel;
|
||||
QLineEdit *sayEdit;
|
||||
|
|
|
@ -414,9 +414,10 @@ Event_PlayerPropertiesChanged::Event_PlayerPropertiesChanged(int _playerId, Serv
|
|||
insertItem(_properties);
|
||||
}
|
||||
|
||||
Event_Ping::Event_Ping(const QList<ServerInfo_PlayerPing *> &_pingList)
|
||||
Event_Ping::Event_Ping(int _secondsElapsed, const QList<ServerInfo_PlayerPing *> &_pingList)
|
||||
: GameEvent("ping", -1)
|
||||
{
|
||||
insertItem(new SerializableItem_Int("seconds_elapsed", _secondsElapsed));
|
||||
for (int i = 0; i < _pingList.size(); ++i)
|
||||
itemList.append(_pingList[i]);
|
||||
}
|
||||
|
|
|
@ -399,9 +399,10 @@ public:
|
|||
class Event_Ping : public GameEvent {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Event_Ping(const QList<ServerInfo_PlayerPing *> &_pingList = QList<ServerInfo_PlayerPing *>());
|
||||
Event_Ping(int _secondsElapsed = -1, const QList<ServerInfo_PlayerPing *> &_pingList = QList<ServerInfo_PlayerPing *>());
|
||||
static SerializableItem *newItem() { return new Event_Ping; }
|
||||
int getItemId() const { return ItemId_Event_Ping; }
|
||||
int getSecondsElapsed() const { return static_cast<SerializableItem_Int *>(itemMap.value("seconds_elapsed"))->getData(); }
|
||||
QList<ServerInfo_PlayerPing *> getPingList() const { return typecastItemList<ServerInfo_PlayerPing *>(); }
|
||||
};
|
||||
|
||||
|
|
|
@ -119,6 +119,9 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName) co
|
|||
|
||||
bool Server_CardZone::isColumnStacked(int x, int y) const
|
||||
{
|
||||
if (!has_coords)
|
||||
return false;
|
||||
|
||||
QMap<int, Server_Card *> coordMap;
|
||||
for (int i = 0; i < cards.size(); ++i)
|
||||
if (cards[i]->getY() == y)
|
||||
|
@ -129,6 +132,9 @@ bool Server_CardZone::isColumnStacked(int x, int y) const
|
|||
|
||||
bool Server_CardZone::isColumnEmpty(int x, int y) const
|
||||
{
|
||||
if (!has_coords)
|
||||
return true;
|
||||
|
||||
QMap<int, Server_Card *> coordMap;
|
||||
for (int i = 0; i < cards.size(); ++i)
|
||||
if (cards[i]->getY() == y)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
Server_Game::Server_Game(Server_ProtocolHandler *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, bool _spectatorsAllowed, bool _spectatorsNeedPassword, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, Server_Room *parent)
|
||||
: QObject(parent), creatorInfo(new ServerInfo_User(_creator->getUserInfo())), gameStarted(false), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers), activePlayer(-1), activePhase(-1), spectatorsAllowed(_spectatorsAllowed), spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0)
|
||||
: QObject(parent), creatorInfo(new ServerInfo_User(_creator->getUserInfo())), gameStarted(false), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers), activePlayer(-1), activePhase(-1), spectatorsAllowed(_spectatorsAllowed), spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0), secondsElapsed(0)
|
||||
{
|
||||
addPlayer(_creator, false, false);
|
||||
|
||||
|
@ -56,6 +56,8 @@ Server_Game::~Server_Game()
|
|||
|
||||
void Server_Game::pingClockTimeout()
|
||||
{
|
||||
++secondsElapsed;
|
||||
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
QList<ServerInfo_PlayerPing *> pingList;
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
|
@ -70,7 +72,7 @@ void Server_Game::pingClockTimeout()
|
|||
pingTime = -1;
|
||||
pingList.append(new ServerInfo_PlayerPing(player->getPlayerId(), pingTime));
|
||||
}
|
||||
sendGameEvent(new Event_Ping(pingList));
|
||||
sendGameEvent(new Event_Ping(secondsElapsed, pingList));
|
||||
|
||||
const int maxTime = static_cast<Server_Room *>(parent())->getServer()->getMaxGameInactivityTime();
|
||||
if (allPlayersInactive) {
|
||||
|
|
|
@ -46,6 +46,7 @@ private:
|
|||
bool spectatorsCanTalk;
|
||||
bool spectatorsSeeEverything;
|
||||
int inactivityCounter;
|
||||
int secondsElapsed;
|
||||
QTimer *pingClock;
|
||||
signals:
|
||||
void gameClosing();
|
||||
|
|
Loading…
Reference in a new issue