Preview maps when hovering over them.

master
Cyp 2011-12-04 11:09:48 +01:00
parent 5718af7bd7
commit 48eda8df50
3 changed files with 46 additions and 9 deletions

View File

@ -3479,7 +3479,8 @@ void runMultiOptions(void)
{
static UDWORD lastrefresh = 0;
UDWORD id, value, i;
char sTemp[128];
char sTemp[128], oldGameMap[128];
int oldMaxPlayers;
PLAYERSTATS playerStats;
W_CONTEXT context;
@ -3551,7 +3552,8 @@ void runMultiOptions(void)
if(multiRequestUp)
{
id = widgRunScreen(psRScreen); // a requester box is up.
if( runMultiRequester(id,&id,(char*)&sTemp,&value))
bool isHoverPreview;
if (runMultiRequester(id, &id, (char *)&sTemp, &value, &isHoverPreview))
{
switch(id)
{
@ -3570,17 +3572,30 @@ void runMultiOptions(void)
netPlayersUpdated = true;
break;
case MULTIOP_MAP:
sstrcpy(oldGameMap, game.map);
oldMaxPlayers = game.maxPlayers;
sstrcpy(game.map, sTemp);
game.maxPlayers =(UBYTE) value;
loadMapPreview(true);
game.maxPlayers = value;
loadMapPreview(!isHoverPreview);
if (isHoverPreview)
{
sstrcpy(game.map, oldGameMap);
game.maxPlayers = oldMaxPlayers;
}
widgSetString(psWScreen,MULTIOP_MAP,sTemp);
addGameOptions();
break;
default:
loadMapPreview(false); // Restore the preview of the old map.
break;
}
addPlayerBox( !ingame.bHostSetup );
if (!isHoverPreview)
{
addPlayerBox( !ingame.bHostSetup );
}
}
}
else

View File

@ -158,6 +158,7 @@ static char const * M_REQUEST_NP_TIPS[] = { N_("2 players"), N_("3 players"),
#define R_BUT_H 30
bool multiRequestUp = false; //multimenu is up.
static unsigned hoverPreviewId;
static bool giftsUp[MAX_PLAYERS] = {true}; //gift buttons for player are up.
char debugMenuEntry[DEBUGMENU_MAX_ENTRIES][MAX_STR_LENGTH];
@ -604,6 +605,7 @@ void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD mo
}
}
multiRequestUp = true;
hoverPreviewId = 0;
// if it's map select then add the cam style buttons.
@ -663,24 +665,44 @@ static void closeMultiRequester(void)
return;
}
bool runMultiRequester(UDWORD id,UDWORD *mode, char *chosen,UDWORD *chosenValue)
bool runMultiRequester(UDWORD id, UDWORD *mode, char *chosen, UDWORD *chosenValue, bool *isHoverPreview)
{
if( (id == M_REQUEST_CLOSE) || CancelPressed() ) // user hit close box || hit the cancel key
{
closeMultiRequester();
*mode = 0;
return true;
}
if( id>=M_REQUEST_BUT && id<=M_REQUEST_BUTM) // chose a file.
bool hoverPreview = false;
if (id == 0 && context == MULTIOP_MAP)
{
id = widgGetMouseOver(psRScreen);
if (id == hoverPreviewId)
{
id = 0; // Don't re-render preview.
}
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 ;
closeMultiRequester();
*mode = context;
*isHoverPreview = hoverPreview;
hoverPreviewId = id;
if (!hoverPreview)
{
closeMultiRequester();
}
return true;
}
if (hoverPreview)
{
id = 0;
}
switch (id)
{

View File

@ -31,7 +31,7 @@
extern void addMultiRequest(const char* searchDir, const char* fileExtension, UDWORD id,UBYTE mapCam, UBYTE numPlayers);
extern bool multiRequestUp;
extern W_SCREEN *psRScreen; // requester stuff.
extern bool runMultiRequester(UDWORD id,UDWORD *contextmode, char *chosen,UDWORD *chosenValue);
bool runMultiRequester(UDWORD id, UDWORD *mode, char *chosen, UDWORD *chosenValue, bool *isHoverPreview);
extern void displayRequestOption(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *pColours);
// multimenu