// //////////////////////////////////////////////////////////////////////////// // show a text option. void displayTextOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_UNUSED PIELIGHT *pColours) { SDWORD fx,fy, fw; W_BUTTON *psBut; bool hilight = false; bool greyOut = psWidget->UserData; // if option is unavailable. psBut = (W_BUTTON *)psWidget; iV_SetFont(psBut->FontID); if(widgGetMouseOver(psWScreen) == psBut->id) // if mouse is over text then hilight. { hilight = true; } fw = iV_GetTextWidth(psBut->pText); fy = yOffset + psWidget->y + (psWidget->height - iV_GetTextLineSize())/2 - iV_GetTextAboveBase(); if (psWidget->style & WBUT_TXTCENTRE) //check for centering, calculate offset. { fx = xOffset + psWidget->x + ((psWidget->width - fw) / 2); } else { fx = xOffset + psWidget->x; } if(greyOut) // unavailable { iV_SetTextColour(WZCOL_TEXT_DARK); } else // available { if(hilight) // hilight { iV_SetTextColour(WZCOL_TEXT_BRIGHT); } else // dont highlight { iV_SetTextColour(WZCOL_TEXT_MEDIUM); } } iV_DrawText( psBut->pText, fx, fy); return; }
bool runMultiRequester(UDWORD id, UDWORD *mode, char *chosen, UDWORD *chosenValue, bool *isHoverPreview) { static unsigned hoverId = 0; static unsigned hoverStartTime = 0; if( (id == M_REQUEST_CLOSE) || CancelPressed() ) // user hit close box || hit the cancel key { closeMultiRequester(); *mode = 0; return true; } bool hoverPreview = false; if (id == 0 && context == MULTIOP_MAP) { id = widgGetMouseOver(psRScreen); if (id != hoverId) { hoverId = id; hoverStartTime = wzGetTicks() + HOVER_PREVIEW_TIME; } if (id == hoverPreviewId || hoverStartTime > wzGetTicks()) { id = 0; // Don't re-render preview nor render preview before HOVER_PREVIEW_TIME. } hoverPreview = true; } if (id >= M_REQUEST_BUT && id <= M_REQUEST_BUTM) // chose a file. { strcpy(chosen,((W_BUTTON *)widgGetFromID(psRScreen,id))->pText ); *chosenValue = ((W_BUTTON *)widgGetFromID(psRScreen,id))->UserData ; *mode = context; *isHoverPreview = hoverPreview; hoverPreviewId = id; if (!hoverPreview) { closeMultiRequester(); } return true; } if (hoverPreview) { id = 0; } switch (id) { case M_REQUEST_C1: closeMultiRequester(); addMultiRequest(MultiCustomMapsPath, ".wrf", MULTIOP_MAP, 1, current_numplayers); break; case M_REQUEST_C2: closeMultiRequester(); addMultiRequest(MultiCustomMapsPath, ".wrf", MULTIOP_MAP, 2, current_numplayers); break; case M_REQUEST_C3: closeMultiRequester(); addMultiRequest(MultiCustomMapsPath, ".wrf", MULTIOP_MAP, 3, current_numplayers); break; case M_REQUEST_AP: closeMultiRequester(); addMultiRequest(MultiCustomMapsPath, ".wrf", MULTIOP_MAP, current_tech, 0); break; default: for (unsigned numPlayers = 2; numPlayers <= MAX_PLAYERS_IN_GUI; ++numPlayers) { if (id == M_REQUEST_NP[numPlayers - 2]) { closeMultiRequester(); addMultiRequest(MultiCustomMapsPath, ".wrf", MULTIOP_MAP, current_tech, numPlayers); break; } } break; } return false; }