|
45 | 45 | #include "GameClient/GameWindowManager.h" |
46 | 46 | #include "GameClient/MessageBox.h" |
47 | 47 | #include "GameClient/MapUtil.h" |
| 48 | +#include "GameClient/Mouse.h" |
48 | 49 | #include "GameClient/GameText.h" |
49 | 50 | #include "GameClient/GameWindowTransitions.h" |
50 | 51 |
|
| 52 | +struct ReplayInfoCacheEntry |
| 53 | +{ |
| 54 | + RecorderClass::ReplayHeader header; |
| 55 | + ReplayGameInfo info; |
| 56 | + UnicodeString extraStr; |
| 57 | +}; |
| 58 | + |
| 59 | +static std::map<AsciiString, ReplayInfoCacheEntry> replayInfoCache; |
51 | 60 |
|
52 | 61 | // window ids ------------------------------------------------------------------------------------- |
53 | 62 | static NameKeyType parentReplayMenuID = NAMEKEY_INVALID; |
@@ -166,11 +175,40 @@ static UnicodeString createMapName(const AsciiString& filename, const ReplayGame |
166 | 175 | return mapName; |
167 | 176 | } |
168 | 177 |
|
| 178 | +//------------------------------------------------------------------------------------------------- |
| 179 | + |
| 180 | +static void replayTooltip(GameWindow* window, WinInstanceData* instData, UnsignedInt mouse) |
| 181 | +{ |
| 182 | + Int x, y, row, col; |
| 183 | + x = LOLONGTOSHORT(mouse); |
| 184 | + y = HILONGTOSHORT(mouse); |
| 185 | + |
| 186 | + GadgetListBoxGetEntryBasedOnXY(window, x, y, row, col); |
| 187 | + |
| 188 | + if (row == -1 || col == -1) |
| 189 | + { |
| 190 | + TheMouse->setCursorTooltip(UnicodeString::TheEmptyString); |
| 191 | + return; |
| 192 | + } |
| 193 | + |
| 194 | + UnicodeString replayFileName = GetReplayFilenameFromListbox(window, row); |
| 195 | + AsciiString replayFileNameAscii; |
| 196 | + replayFileNameAscii.translate(replayFileName); |
| 197 | + |
| 198 | + std::map<AsciiString, ReplayInfoCacheEntry>::const_iterator it = replayInfoCache.find(replayFileNameAscii); |
| 199 | + if (it != replayInfoCache.end()) |
| 200 | + TheMouse->setCursorTooltip(it->second.extraStr, -1, NULL, 1.5f); |
| 201 | + else |
| 202 | + TheMouse->setCursorTooltip(UnicodeString::TheEmptyString); |
| 203 | +} |
| 204 | + |
169 | 205 | //------------------------------------------------------------------------------------------------- |
170 | 206 | /** Populate the listbox with the names of the available replay files */ |
171 | 207 | //------------------------------------------------------------------------------------------------- |
172 | 208 | void PopulateReplayFileListbox(GameWindow *listbox) |
173 | 209 | { |
| 210 | + replayInfoCache.clear(); |
| 211 | + |
174 | 212 | if (!TheMapCache) |
175 | 213 | return; |
176 | 214 |
|
@@ -234,41 +272,46 @@ void PopulateReplayFileListbox(GameWindow *listbox) |
234 | 272 | // map |
235 | 273 | UnicodeString mapStr = createMapName(asciistr, info, mapData); |
236 | 274 |
|
237 | | -// // extra |
238 | | -// UnicodeString extraStr; |
239 | | -// if (header.localPlayerIndex >= 0) |
240 | | -// { |
241 | | -// // MP game |
242 | | -// time_t totalSeconds = header.endTime - header.startTime; |
243 | | -// Int hours = totalSeconds / 3600; |
244 | | -// Int mins = (totalSeconds % 3600) / 60; |
245 | | -// Int secs = totalSeconds % 60; |
246 | | -// Real fps = header.frameCount / totalSeconds; |
247 | | -// extraStr.format(L"%02d:%02d:%02d (%g fps) %hs", hours, mins, secs, fps, header.desyncGame ? "OOS " : ""); |
248 | | -// |
249 | | -// for (Int i=0; i<MAX_SLOTS; ++i) |
250 | | -// { |
251 | | -// const GameSlot *slot = info.getConstSlot(i); |
252 | | -// if (slot && slot->isHuman()) |
253 | | -// { |
254 | | -// if (i) |
255 | | -// extraStr.concat(L", "); |
256 | | -// if (header.playerDiscons[i]) |
257 | | -// extraStr.concat(L'*'); |
258 | | -// extraStr.concat(info.getConstSlot(i)->getName()); |
259 | | -// } |
260 | | -// } |
261 | | -// } |
262 | | -// else |
263 | | -// { |
264 | | -// // solo game |
265 | | -// time_t totalSeconds = header.endTime - header.startTime; |
266 | | -// Int hours = totalSeconds / 3600; |
267 | | -// Int mins = (totalSeconds % 3600) / 60; |
268 | | -// Int secs = totalSeconds % 60; |
269 | | -// Real fps = header.frameCount / totalSeconds; |
270 | | -// extraStr.format(L"%02d:%02d:%02d (%g fps)", hours, mins, secs, fps); |
271 | | -// } |
| 275 | + // extra |
| 276 | + UnicodeString extraStr; |
| 277 | + if (header.localPlayerIndex >= 0) |
| 278 | + { |
| 279 | + // MP game |
| 280 | + time_t totalSeconds = header.endTime - header.startTime; |
| 281 | + Int hours = totalSeconds / 3600; |
| 282 | + Int mins = (totalSeconds % 3600) / 60; |
| 283 | + Int secs = totalSeconds % 60; |
| 284 | + Real fps = header.frameCount / totalSeconds; |
| 285 | + extraStr.format(L"%02d:%02d:%02d (%g fps) %hs", hours, mins, secs, fps, header.desyncGame ? "OOS " : ""); |
| 286 | + |
| 287 | + for (Int i=0; i<MAX_SLOTS; ++i) |
| 288 | + { |
| 289 | + const GameSlot *slot = info.getConstSlot(i); |
| 290 | + if (slot && slot->isHuman()) |
| 291 | + { |
| 292 | + extraStr.concat(L"\n"); |
| 293 | + if (header.playerDiscons[i]) |
| 294 | + extraStr.concat(L'*'); |
| 295 | + extraStr.concat(info.getConstSlot(i)->getName()); |
| 296 | + } |
| 297 | + } |
| 298 | + } |
| 299 | + else |
| 300 | + { |
| 301 | + // solo game |
| 302 | + time_t totalSeconds = header.endTime - header.startTime; |
| 303 | + Int hours = totalSeconds / 3600; |
| 304 | + Int mins = (totalSeconds % 3600) / 60; |
| 305 | + Int secs = totalSeconds % 60; |
| 306 | + Real fps = header.frameCount / totalSeconds; |
| 307 | + extraStr.format(L"%02d:%02d:%02d (%g fps)", hours, mins, secs, fps); |
| 308 | + } |
| 309 | + |
| 310 | + ReplayInfoCacheEntry entry; |
| 311 | + entry.header = header; |
| 312 | + entry.info = info; |
| 313 | + entry.extraStr = extraStr; |
| 314 | + replayInfoCache[asciistr] = entry; |
272 | 315 |
|
273 | 316 | // pick a color |
274 | 317 | Color color; |
@@ -348,6 +391,7 @@ void ReplayMenuInit( WindowLayout *layout, void *userData ) |
348 | 391 | buttonLoad = TheWindowManager->winGetWindowFromId( parentReplayMenu, buttonLoadID ); |
349 | 392 | buttonBack = TheWindowManager->winGetWindowFromId( parentReplayMenu, buttonBackID ); |
350 | 393 | listboxReplayFiles = TheWindowManager->winGetWindowFromId( parentReplayMenu, listboxReplayFilesID ); |
| 394 | + listboxReplayFiles->winSetTooltipFunc(replayTooltip); |
351 | 395 | buttonDelete = TheWindowManager->winGetWindowFromId( parentReplayMenu, buttonDeleteID ); |
352 | 396 | buttonCopy = TheWindowManager->winGetWindowFromId( parentReplayMenu, buttonCopyID ); |
353 | 397 |
|
|
0 commit comments