|
42 | 42 | #include "GameClient/Gadget.h" |
43 | 43 | #include "GameClient/GameText.h" |
44 | 44 | #include "GameClient/InGameUI.h" |
| 45 | +#include "GameClient/Display.h" |
45 | 46 | #include "GameClient/Shell.h" |
46 | 47 | #include "GameClient/ShellHooks.h" |
47 | 48 | #include "GameClient/KeyDefs.h" |
@@ -142,6 +143,8 @@ static Bool raiseMessageBoxes = false; |
142 | 143 | static Bool isInInit = FALSE; |
143 | 144 | static const Image *selectedImage = nullptr; |
144 | 145 | static const Image *unselectedImage = nullptr; |
| 146 | +static const Image *mapHoverPreview = nullptr; |
| 147 | +static GameWinDrawFunc mapListboxPreviewFunc = nullptr; |
145 | 148 |
|
146 | 149 | static bool isPopulatingLadderBox = false; |
147 | 150 | static Int maxPingEntries = 0; |
@@ -237,7 +240,41 @@ enum{ MAX_DISCONNECTS_COUNT = 5 }; |
237 | 240 | static Int MAX_DISCONNECTS[MAX_DISCONNECTS_COUNT] = {MAX_DISCONNECTS_ANY, MAX_DISCONNECTS_5, |
238 | 241 | MAX_DISCONNECTS_10, MAX_DISCONNECTS_25, |
239 | 242 | MAX_DISCONNECTS_50}; |
| 243 | +void updateMapHoverPreview(GameWindow* window, WinInstanceData* instData) |
| 244 | +{ |
| 245 | + if (mapListboxPreviewFunc) |
| 246 | + mapListboxPreviewFunc(window, instData); |
| 247 | + if (listboxMapSelect == nullptr) |
| 248 | + return; |
| 249 | + |
| 250 | + const MouseIO* mouseStatus = TheMouse->getMouseStatus(); |
| 251 | + Int mouseX = mouseStatus->pos.x; |
| 252 | + Int mouseY = mouseStatus->pos.y; |
| 253 | + Int listboxX, listboxY, listboxW, listboxH; |
| 254 | + listboxMapSelect->winGetScreenPosition(&listboxX, &listboxY); |
| 255 | + listboxMapSelect->winGetSize(&listboxW, &listboxH); |
240 | 256 |
|
| 257 | + // mouse is outside the listbox? |
| 258 | + if (mouseX < listboxX || mouseX > listboxX + listboxW || mouseY < listboxY || mouseY > listboxY + listboxH) |
| 259 | + return; |
| 260 | + |
| 261 | + Int hoveredRow, col; |
| 262 | + GadgetListBoxGetEntryBasedOnXY(listboxMapSelect, mouseX, mouseY, hoveredRow, col); |
| 263 | + const MapMetaData* mapData = (const MapMetaData*)GadgetListBoxGetItemData(listboxMapSelect, hoveredRow, 1); |
| 264 | + mapHoverPreview = mapData ? getMapPreviewImage(mapData->m_fileName) : nullptr; |
| 265 | + |
| 266 | + if (mapHoverPreview == nullptr) |
| 267 | + return; |
| 268 | + |
| 269 | + Real wScale = TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH; |
| 270 | + Real hScale = TheDisplay->getHeight() / (Real)DEFAULT_DISPLAY_HEIGHT; |
| 271 | + Real scale = (wScale + hScale) * 0.5f; |
| 272 | + Int previewSize = (Int)(50 * scale); |
| 273 | + Int offset = (Int)(20 * scale); |
| 274 | + Int previewX = mouseX + offset; |
| 275 | + Int previewY = mouseY - (previewSize / 2); |
| 276 | + TheWindowManager->winDrawImage(mapHoverPreview, previewX, previewY, previewX + previewSize, previewY + previewSize); |
| 277 | +} |
241 | 278 |
|
242 | 279 | void UpdateStartButton() |
243 | 280 | { |
@@ -903,6 +940,11 @@ void WOLQuickMatchMenuInit( WindowLayout *layout, void *userData ) |
903 | 940 | buttonWiden = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonWidenID); |
904 | 941 | quickmatchTextWindow = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, listboxQuickMatchID); |
905 | 942 | listboxMapSelect = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, listboxMapSelectID); |
| 943 | + if (listboxMapSelect) |
| 944 | + { |
| 945 | + mapListboxPreviewFunc = listboxMapSelect->winGetDrawFunc(); |
| 946 | + listboxMapSelect->winSetDrawFunc(updateMapHoverPreview); |
| 947 | + } |
906 | 948 | //textEntryMaxDisconnects = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMaxDisconnectsID ); |
907 | 949 | //textEntryMaxPoints = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMaxPointsID ); |
908 | 950 | //textEntryMinPoints = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMinPointsID ); |
|
0 commit comments