diff --git a/src/k_menu.h b/src/k_menu.h index 2e08260e9..4695e2b8f 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1181,6 +1181,7 @@ void M_HandleImageDef(INT32 choice); // For some menu highlights UINT16 M_GetCvPlayerColor(UINT8 pnum); +void M_PickMenuBGMap(void); void M_UpdateMenuBGImage(boolean forceReset); void M_DrawMenuBackground(void); void M_DrawMenuForeground(void); diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 04543d7f3..6a0bcfabb 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -183,9 +183,68 @@ static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv, boolean ontop) V_DrawScaledPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p); } - static patch_t *addonsp[NUM_EXT+5]; +static patch_t *bgMapImage; +void M_PickMenuBGMap(void) +{ + UINT16 *allowedMaps; + size_t allowedMapsCount = 0; + UINT16 ret = 0; + INT32 i; + + allowedMaps = Z_Malloc(nummapheaders * sizeof(UINT16), PU_STATIC, NULL); + + for (i = 0; i < nummapheaders; i++) + { + if (mapheaderinfo[i] == NULL || mapheaderinfo[i]->lumpnum == LUMPERROR) + { + // Doesn't exist? + continue; + } + + if (mapheaderinfo[i]->thumbnailPic == NULL) + { + // No image... + continue; + } + + if ((mapheaderinfo[i]->typeoflevel & (TOL_SPECIAL|TOL_VERSUS)) != 0) + { + // Don't spoil Special Stages or bosses. + continue; + } + + if ((mapheaderinfo[i]->menuflags & LF2_HIDEINMENU) == LF2_HIDEINMENU) + { + // "Hide in menu"... geddit?! + continue; + } + + if (M_MapLocked(i + 1) == true) + { + // We haven't earned this one. + continue; + } + + // Got past the gauntlet, so we can allow this one. + allowedMaps[ allowedMapsCount++ ] = i; + } + + if (allowedMapsCount > 0) + { + ret = allowedMaps[ M_RandomKey(allowedMapsCount) ]; + } + Z_Free(allowedMaps); + + bgMapImage = mapheaderinfo[ret]->thumbnailPic; + + if (bgMapImage == NULL) + { + bgMapImage = W_CachePatchName("MENUBG4", PU_CACHE); + } +} + static fixed_t bgText1Scroll = 0; static fixed_t bgText2Scroll = 0; static fixed_t bgImageScroll = 0; @@ -213,6 +272,11 @@ void M_UpdateMenuBGImage(boolean forceReset) { bgImageScroll = (3 * BASEVIDWIDTH) * (FRACUNIT / 4); } + + if (forceReset == true) + { + M_PickMenuBGMap(); + } } void M_DrawMenuBackground(void) @@ -223,7 +287,14 @@ void M_DrawMenuBackground(void) fixed_t text1loop = SHORT(text1->height)*FRACUNIT; fixed_t text2loop = SHORT(text2->width)*FRACUNIT; - V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("MENUBG4", PU_CACHE), NULL); + if (bgMapImage == NULL) + { + M_PickMenuBGMap(); + } + + V_DrawFixedPatch(0, 0, FRACUNIT, 0, bgMapImage, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SLATE, GTC_MENUCACHE)); + V_DrawFixedPatch(0, 0, FRACUNIT, V_ADD, W_CachePatchName("MENUCUTD", PU_CACHE), NULL); + V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("MENUCUT", PU_CACHE), NULL); V_DrawFixedPatch(-bgImageScroll, 0, FRACUNIT, 0, W_CachePatchName("MENUBG1", PU_CACHE), NULL); V_DrawFixedPatch(-bgImageScroll, 0, FRACUNIT, 0, W_CachePatchName(bgImageName, PU_CACHE), NULL); diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 0e0b98b42..f28db9a53 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -605,6 +605,8 @@ void M_StartControlPanel(void) } } + M_PickMenuBGMap(); + if (M_GameTrulyStarted() == false) { // Are you ready for the First Boot Experience? diff --git a/src/y_inter.c b/src/y_inter.c index 180b3acc1..5a384c16f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -2086,8 +2086,6 @@ void Y_StartIntermission(void) Automate_Run(AEV_INTERMISSIONSTART); bgpatch = W_CachePatchName("MENUBG", PU_STATIC); widebgpatch = W_CachePatchName("WEIRDRES", PU_STATIC); - - M_UpdateMenuBGImage(true); } // ======