23 #include "gameinfotip.h" 24 #include "serverapi/playerslist.h" 25 #include "serverapi/server.h" 36 const QString
GameInfoTip::UNLIMITED = QObject::tr("Unlimited");
43 GameInfoTip::~GameInfoTip()
47 QString GameInfoTip::generateHTML()
49 QString table =
"<table>";
50 table += timelimitHTML();
51 table += scorelimitHTML();
52 table += teamScoresHTML();
53 table += playersHTML();
59 QString GameInfoTip::playersHTML()
61 const QString PLAYERS = tr(
"Players");
64 int canJoin = d->server->maxPlayers() - players.
numClients();
70 QString html =
"<tr><td>" + PLAYERS +
": </td><td>%1 / %2 (%3 can join)</td></tr>";
71 html = html.arg(players.
numClients()).arg(d->server->numTotalSlots()).arg(canJoin);
76 QString GameInfoTip::limitHTML(QString limitName, QString valueArgsTemplate,
int value)
78 QString row =
"<tr><td>" + limitName +
": </td><td>" + valueArgsTemplate +
"</td></tr>";
82 row = row.arg(UNLIMITED);
92 QString GameInfoTip::scorelimitHTML()
94 const QString SCORELIMIT = tr(
"Scorelimit");
95 QString row = limitHTML(SCORELIMIT,
"%1", d->server->scoreLimit());
100 QString GameInfoTip::teamScoresHTML()
103 if (d->server->gameMode().isTeamGame())
105 teamScores =
"<tr><td colspan=\"2\">%1</td></tr>";
107 bool bPrependBar =
false;
108 for (
int i = 0; i < MAX_TEAMS; ++i)
110 if (d->server->players().numPlayersOnTeam(i) != 0)
116 teams += d->server->teamName(i) +
": " + QString::number(d->server->score(i));
120 teamScores = teamScores.arg(teams);
126 QString GameInfoTip::timelimitHTML()
128 const QString TIMELIMIT = tr(
"Timelimit");
129 int timeLimit = d->server->timeLimit();
130 QString row = limitHTML(TIMELIMIT,
"%1 %2", timeLimit);
132 QString timeLeft =
"";
135 timeLeft = tr(
"(%1 left)").arg(d->server->timeLeft());
137 row = row.arg(timeLeft);
int numClients() const
Overall number of people and bots on the server.