Commit 8eeec5ac authored by poixen's avatar poixen
Browse files

Merge pull request #1087 from poixen/room_type

Added game type to tab title
parents 544666a3 7ac0f6f4
...@@ -359,6 +359,9 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay) ...@@ -359,6 +359,9 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
splitter->restoreState(settingsCache->getTabGameSplitterSizes()); splitter->restoreState(settingsCache->getTabGameSplitterSizes());
messageLog->logReplayStarted(gameInfo.game_id()); messageLog->logReplayStarted(gameInfo.game_id());
for (int i = gameInfo.game_types_size() - 1; i >= 0; i--)
gameTypes.append(roomGameTypes.find(gameInfo.game_types(i)).value());
} }
TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes) TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes)
...@@ -490,6 +493,9 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client ...@@ -490,6 +493,9 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
splitter->restoreState(settingsCache->getTabGameSplitterSizes()); splitter->restoreState(settingsCache->getTabGameSplitterSizes());
messageLog->logGameJoined(gameInfo.game_id()); messageLog->logGameJoined(gameInfo.game_id());
for (int i = gameInfo.game_types_size() - 1; i >= 0; i--)
gameTypes.append(roomGameTypes.find(gameInfo.game_types(i)).value());
} }
void TabGame::addMentionTag(QString value) { void TabGame::addMentionTag(QString value) {
...@@ -1159,10 +1165,32 @@ CardItem *TabGame::getCard(int playerId, const QString &zoneName, int cardId) co ...@@ -1159,10 +1165,32 @@ CardItem *TabGame::getCard(int playerId, const QString &zoneName, int cardId) co
QString TabGame::getTabText() const QString TabGame::getTabText() const
{ {
QString gameTypeInfo;
if (gameTypes.size() != 0) {
gameTypeInfo = gameTypes.at(0);
if (gameTypes.size() > 1)
gameTypeInfo.append("...");
}
QString gameDesc(gameInfo.description().c_str());
QString gameId(QString::number(gameInfo.game_id()));
QString tabText;
if (replay) if (replay)
return tr("Replay %1: %2").arg(gameInfo.game_id()).arg(QString::fromStdString(gameInfo.description())); tabText.append(tr("REPLAY "));
else if (!gameTypeInfo.isEmpty())
return tr("Game %1: %2").arg(gameInfo.game_id()).arg(QString::fromStdString(gameInfo.description())); tabText.append(gameTypeInfo + " ");
if (!gameDesc.isEmpty()) {
if (gameDesc.length() >= 15)
tabText.append("| " + gameDesc.left(15) + "... ");
else
tabText.append("| " + gameDesc + " ");
}
if (!tabText.isEmpty())
tabText.append("| ");
tabText.append("#" + gameId);
return tabText;
} }
Player *TabGame::getActiveLocalPlayer() const Player *TabGame::getActiveLocalPlayer() const
......
...@@ -115,6 +115,7 @@ private: ...@@ -115,6 +115,7 @@ private:
int activePlayer; int activePlayer;
CardItem *activeCard; CardItem *activeCard;
bool gameClosed; bool gameClosed;
QStringList gameTypes;
// Replay related members // Replay related members
GameReplay *replay; GameReplay *replay;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment