change action's text to "unconcede" when player is conceded (#5351)

This commit is contained in:
RickyRister 2024-12-27 16:01:36 -08:00 committed by GitHub
parent 8bc5a9d581
commit 37b78a9a4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -536,6 +536,12 @@ void TabGame::updatePlayerListDockTitle()
(playerListDock->isWindow() ? tabText : QString()));
}
bool TabGame::isMainPlayerConceded() const
{
Player *player = players.value(localPlayerId, nullptr);
return player && player->getConceded();
}
void TabGame::retranslateUi()
{
QString tabText = " | " + (replay ? tr("Replay") : tr("Game")) + " #" + QString::number(gameInfo.game_id());
@ -577,7 +583,11 @@ void TabGame::retranslateUi()
if (aGameInfo)
aGameInfo->setText(tr("Game &information"));
if (aConcede) {
aConcede->setText(tr("&Concede"));
if (isMainPlayerConceded()) {
aConcede->setText(tr("Un&concede"));
} else {
aConcede->setText(tr("&Concede"));
}
}
if (aLeaveGame) {
aLeaveGame->setText(tr("&Leave game"));
@ -874,6 +884,9 @@ Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
}
}
// update menu text when player concedes so that "concede" gets updated to "unconcede"
connect(newPlayer, &Player::playerCountChanged, this, &TabGame::retranslateUi);
emit playerAdded(newPlayer);
return newPlayer;
}

View file

@ -177,6 +177,8 @@ private:
Player *addPlayer(int playerId, const ServerInfo_User &info);
bool isMainPlayerConceded() const;
void startGame(bool resuming);
void stopGame();
void closeGame();