diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index bfcf0eea..aa1bb5f2 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -222,6 +222,14 @@ void CardInfo::clearPixmapCache() } } +void CardInfo::clearPixmapCacheMiss() +{ + if (!pixmap) + return; + if (pixmap->isNull()) + clearPixmapCache(); +} + void CardInfo::updatePixmapCache() { qDebug(QString("Updating pixmap cache for %1").arg(name).toLatin1()); @@ -456,6 +464,14 @@ void CardDatabase::updatePicDownload(int _picDownload) picDownload = settings.value("personal/picturedownload", 0).toInt(); } else picDownload = _picDownload; + + if (picDownload) { + QHashIterator cardIterator(cardHash); + while (cardIterator.hasNext()) { + CardInfo *c = cardIterator.next().value(); + c->clearPixmapCacheMiss(); + } + } } void CardDatabase::updatePicsPath(const QString &path) diff --git a/cockatrice/src/carddatabase.h b/cockatrice/src/carddatabase.h index c63bf0e0..0407fa83 100644 --- a/cockatrice/src/carddatabase.h +++ b/cockatrice/src/carddatabase.h @@ -83,6 +83,7 @@ public: QPixmap *loadPixmap(); QPixmap *getPixmap(QSize size); void clearPixmapCache(); + void clearPixmapCacheMiss(); void updatePixmapCache(); private slots: void picDownloadFinished(int id, bool error); diff --git a/cockatrice/src/client.cpp b/cockatrice/src/client.cpp index be9ce703..76278a56 100644 --- a/cockatrice/src/client.cpp +++ b/cockatrice/src/client.cpp @@ -226,10 +226,20 @@ void Client::readLine() ServerResponse resp; if (values[0] == "ok") resp = RespOk; + else if (values[0] == "name_not_found") + resp = RespNameNotFound; + else if (values[0] == "login_needed") + resp = RespLoginNeeded; + else if (values[0] == "syntax") + resp = RespSyntaxError; + else if (values[0] == "context") + resp = RespContextError; else if (values[0] == "password") - resp = RespPassword; + resp = RespPasswordWrong; + else if (values[0] == "spectators_not_allowed") + resp = RespSpectatorsNotAllowed; else - resp = RespErr; + resp = RespInvalid; pc->responseReceived(resp); } else if (prefix == "list_games") { if (values.size() != 8) { diff --git a/cockatrice/src/client.h b/cockatrice/src/client.h index b9665b34..6d3d434f 100644 --- a/cockatrice/src/client.h +++ b/cockatrice/src/client.h @@ -20,8 +20,13 @@ enum ProtocolStatus { StatusDisconnected, enum ServerResponse { RespOk, - RespPassword, - RespErr + RespNameNotFound, + RespLoginNeeded, + RespSyntaxError, + RespContextError, + RespPasswordWrong, + RespSpectatorsNotAllowed, + RespInvalid }; enum ServerEventType { diff --git a/cockatrice/src/dlg_creategame.cpp b/cockatrice/src/dlg_creategame.cpp index 9524df3a..095ef145 100644 --- a/cockatrice/src/dlg_creategame.cpp +++ b/cockatrice/src/dlg_creategame.cpp @@ -72,7 +72,7 @@ void DlgCreateGame::checkResponse(ServerResponse response) if (response == RespOk) accept(); else { - QMessageBox::critical(this, tr("Error"), tr("XXX")); + QMessageBox::critical(this, tr("Error"), tr("Server error.")); return; } } diff --git a/cockatrice/src/gameselector.cpp b/cockatrice/src/gameselector.cpp index 3892d7da..e95d4cdc 100644 --- a/cockatrice/src/gameselector.cpp +++ b/cockatrice/src/gameselector.cpp @@ -51,22 +51,19 @@ void GameSelector::actCreate() disableGameList(); } -void GameSelector::actRefresh() -{ - client->listGames(); -} - void GameSelector::checkResponse(ServerResponse response) { createButton->setEnabled(true); joinButton->setEnabled(true); spectateButton->setEnabled(true); - if (response == RespOk) - disableGameList(); - else { - QMessageBox::critical(this, tr("Error"), tr("XXX")); - return; + switch (response) { + case RespOk: disableGameList(); break; + case RespPasswordWrong: QMessageBox::critical(this, tr("Error"), tr("Wrong password.")); break; + case RespSpectatorsNotAllowed: QMessageBox::critical(this, tr("Error"), tr("Spectators are not allowed in this game.")); break; + case RespContextError: QMessageBox::critical(this, tr("Error"), tr("The game is already full.")); break; + case RespNameNotFound: QMessageBox::critical(this, tr("Error"), tr("The game does not exist any more.")); break; + default: ; } } @@ -77,7 +74,7 @@ void GameSelector::actJoin() QModelIndex ind = gameListView->currentIndex(); if (!ind.isValid()) return; - const ServerGame &game = gameListModel->getGame(ind.row()); + const ServerGame &game = gameListModel->getGame(ind.data(Qt::UserRole).toInt()); QString password; if (game.getHasPassword()) { bool ok; diff --git a/cockatrice/src/gameselector.h b/cockatrice/src/gameselector.h index 7cc21d55..6a44540d 100644 --- a/cockatrice/src/gameselector.h +++ b/cockatrice/src/gameselector.h @@ -20,7 +20,6 @@ public: private slots: void showFullGamesChanged(int state); void actCreate(); - void actRefresh(); void actJoin(); void checkResponse(ServerResponse response); private: diff --git a/cockatrice/src/gamesmodel.cpp b/cockatrice/src/gamesmodel.cpp index 0a76c0cf..68c382fe 100644 --- a/cockatrice/src/gamesmodel.cpp +++ b/cockatrice/src/gamesmodel.cpp @@ -8,7 +8,11 @@ GamesModel::~GamesModel() QVariant GamesModel::data(const QModelIndex &index, int role) const { - if ((role != Qt::DisplayRole) || !index.isValid()) + if (!index.isValid()) + return QVariant(); + if (role == Qt::UserRole) + return index.row(); + if (role != Qt::DisplayRole) return QVariant(); if ((index.row() >= gameList.size()) || (index.column() >= columnCount())) return QVariant(); diff --git a/cockatrice/src/messagelogwidget.cpp b/cockatrice/src/messagelogwidget.cpp index 492c702b..87bd88df 100644 --- a/cockatrice/src/messagelogwidget.cpp +++ b/cockatrice/src/messagelogwidget.cpp @@ -35,7 +35,7 @@ void MessageLogWidget::logSocketError(const QString &errorString) void MessageLogWidget::logServerError(ServerResponse response) { switch (response) { - case RespPassword: append(tr("Invalid password.")); break; + case RespPasswordWrong: append(tr("Invalid password.")); break; default: ; } } diff --git a/cockatrice/translations/cockatrice_de.ts b/cockatrice/translations/cockatrice_de.ts index beebaf7c..66457c68 100644 --- a/cockatrice/translations/cockatrice_de.ts +++ b/cockatrice/translations/cockatrice_de.ts @@ -304,12 +304,12 @@ F12 - + Set counter Zähler setzen - + New value for counter '%1': Neuer Wert für den Zähler '%1': @@ -433,8 +433,12 @@ + Server error. + Serverfehler. + + XXX - XXX + XXX @@ -770,42 +774,64 @@ GameSelector - + C&reate Spiel e&rstellen - + &Join &Teilnehmen - + + + + Error Fehler - XXX - XXX + XXX - + + Wrong password. + Falsches Passwort. + + + + Spectators are not allowed in this game. + In diesem Spiel sind keine Zuschauer zugelassen. + + + + The game is already full. + Das Spiel ist bereits voll. + + + + The game does not exist any more. + Dieses Spiel gibt es nicht mehr. + + + Join game Spiel beitreten - + Password: Passwort: - + &Show full games &Volle Spiele anzeigen - + J&oin as spectator &Zuschauen @@ -813,12 +839,12 @@ GamesModel - + yes ja - + no nein @@ -827,32 +853,32 @@ Spiel ID - + Creator Ersteller - + Description Beschreibung - + not allowed nicht erlaubt - + Password Passwort - + Players Spieler - + Spectators Zuschauer diff --git a/cockatrice/translations/cockatrice_en.ts b/cockatrice/translations/cockatrice_en.ts index eafe8ea6..5f7807f2 100644 --- a/cockatrice/translations/cockatrice_en.ts +++ b/cockatrice/translations/cockatrice_en.ts @@ -269,12 +269,12 @@ - + Set counter - + New value for counter '%1': @@ -398,7 +398,7 @@ - XXX + Server error. @@ -564,42 +564,60 @@ GameSelector - + C&reate - + &Join - + + + + Error - - XXX + + Wrong password. - + + Spectators are not allowed in this game. + + + + + The game is already full. + + + + + The game does not exist any more. + + + + Join game - + Password: - + &Show full games - + J&oin as spectator @@ -607,42 +625,42 @@ GamesModel - + yes - + no - + Creator - + Description - + not allowed - + Password - + Players - + Spectators