23 #include "servertooltip.h" 25 #include "configuration/doomseekerconfig.h" 26 #include "pathfinder/wadpathfinder.h" 27 #include "serverapi/tooltips/tooltipgenerator.h" 28 #include "serverapi/playerslist.h" 29 #include "serverapi/server.h" 34 QString FONT_COLOR_MISSING =
"#ff0000";
35 QString FONT_COLOR_OPTIONAL =
"#ff9f00";
36 QString FONT_COLOR_FOUND =
"#009f00";
39 QString ServerTooltip::createIwadToolTip(ServerPtr server)
41 if (!server->isKnown())
46 bool bFindIwad = gConfig.doomseeker.bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn;
49 static const QString FORMAT_TEMPLATE =
"<font color=\"%1\">%2</font>";
54 QString msg = path.path();
57 msg +=
" " + L10n::tr(
"(alias of: %1)").arg(server->iwad());
59 return FORMAT_TEMPLATE.arg(FONT_COLOR_FOUND, msg);
63 return FORMAT_TEMPLATE.arg(FONT_COLOR_MISSING, L10n::tr(
"MISSING"));
70 QString ServerTooltip::createPlayersToolTip(ServerCPtr server)
72 if (server == NULL || !server->isKnown())
80 ret =
"<div style='white-space: pre'>";
82 if(server->players().numClients() != 0)
88 delete tooltipGenerator;
92 QString ServerTooltip::createPortToolTip(ServerCPtr server)
94 if (server == NULL || !server->isKnown())
98 if (server->isLocked())
99 ret +=
"Password protected\n";
100 if (server->isLockedInGame())
101 ret +=
"Password protected in-game\n";
102 if (server->isSecure())
103 ret +=
"Enforces master bans\n";
104 return ret.trimmed();
107 QString ServerTooltip::createPwadsToolTip(ServerPtr server)
109 if (server == NULL || !server->isKnown() || server->numWads() == 0)
115 static const QString toolTip =
"<div style='white-space: pre'>%1</div>";
118 const QList<PWad>& pwads = server->wads();
121 bool bFindWads = gConfig.doomseeker.bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn;
126 QStringList pwadsFormatted;
127 foreach (
const PWad &wad, pwads)
129 pwadsFormatted << createPwadToolTipInfo(wad, server);
132 content =
"<table cellspacing=1>";
133 content += pwadsFormatted.join(
"\n");
134 content +=
"</table>";
138 foreach (
const PWad &wad, pwads)
140 content += wad.
name() +
"\n";
145 return toolTip.arg(content);
148 QString ServerTooltip::createPwadToolTipInfo(
const PWad& pwad,
const ServerPtr &server)
152 QString fontColor =
"#777777";
155 cells << pwad.
name();
158 fontColor = FONT_COLOR_FOUND;
159 cells << path.path();
165 fontColor = FONT_COLOR_OPTIONAL;
166 cells << L10n::tr(
"OPTIONAL");
170 fontColor = FONT_COLOR_MISSING;
171 cells << L10n::tr(
"MISSING");
176 cells << L10n::tr(
"ALIAS");
183 QString formattedStringBegin = QString(
"<tr style=\"color: %1;\">").arg(fontColor);
184 QString formattedStringMiddle;
186 foreach (
const QString &cell, cells)
188 formattedStringMiddle += QString(
"<td style=\"padding-right: 5;\">%1</td>").arg(cell);
191 return formattedStringBegin + formattedStringMiddle +
"</tr>";
194 QString ServerTooltip::createServerNameToolTip(ServerCPtr server)
206 if (!generalInfo.isEmpty())
208 ret =
"<div style='white-space: pre'>";
213 delete tooltipGenerator;
bool isOptional() const
Is this WAD required to join the server?
const QString & name() const
File name of the WAD.