diff --git a/src/cvars.cpp b/src/cvars.cpp index 9be834fad..a143a507f 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -446,7 +446,6 @@ consvar_t cv_splitplayers = Player("splitplayers", "One").values({{1, "One"}, {2 consvar_t cv_ticrate = Player(cvlist_screen)("showfps", "No").yes_no(); consvar_t cv_tilting = Player("tilting", "On").on_off(); -consvar_t cv_translucenthud = Player("translucenthud", "10").min_max(0, 10); // first time memory consvar_t cv_tutorialprompt = Player("tutorialprompt", "On").on_off(); diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index a336bd53c..3122be7f3 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -321,11 +321,11 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p flags |= HWR_GetBlendModeFlag(blendmode); if (alphalevel == 10) - Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; + Surf.PolyColor.s.alpha = softwaretranstogl_lo[V_GetHUDTranslucency(option)]; else if (alphalevel == 11) - Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; + Surf.PolyColor.s.alpha = softwaretranstogl[V_GetHUDTranslucency(option)]; else if (alphalevel == 12) - Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + Surf.PolyColor.s.alpha = softwaretranstogl_hi[V_GetHUDTranslucency(option)]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; @@ -475,11 +475,11 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, flags |= HWR_GetBlendModeFlag(blendmode); if (alphalevel == 10) - Surf.PolyColor.s.alpha = softwaretranstogl_lo[st_translucency]; + Surf.PolyColor.s.alpha = softwaretranstogl_lo[V_GetHUDTranslucency(option)]; else if (alphalevel == 11) - Surf.PolyColor.s.alpha = softwaretranstogl[st_translucency]; + Surf.PolyColor.s.alpha = softwaretranstogl[V_GetHUDTranslucency(option)]; else if (alphalevel == 12) - Surf.PolyColor.s.alpha = softwaretranstogl_hi[st_translucency]; + Surf.PolyColor.s.alpha = softwaretranstogl_hi[V_GetHUDTranslucency(option)]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; diff --git a/src/k_hud.c b/src/k_hud.c index b8734468c..e8935aa74 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3948,12 +3948,7 @@ static void K_drawKartMinimap(void) if (dofade) { - const tic_t length = TICRATE/2; - - if (!lt_exitticker) - return; - if (lt_exitticker < length) - minimaptrans = (((INT32)lt_exitticker)*minimaptrans)/((INT32)length); + minimaptrans = FixedMul(minimaptrans, (st_translucency * FRACUNIT) / 10); if (!minimaptrans) return; @@ -4281,7 +4276,7 @@ static void K_drawKartMinimap(void) if (localplayers[i] == -1) continue; // this doesn't interest us - if ((players[i].hyudorotimer > 0) && (leveltime & 1)) + if ((players[localplayers[i]].hyudorotimer > 0) && (leveltime & 1)) continue; mobj = players[localplayers[i]].mo; @@ -4355,7 +4350,7 @@ static void K_drawKartMinimap(void) } else { - K_drawKartProgressionMinimapIcon(players[i].distancetofinish, x, y, splitflags, workingPic, colormap); + K_drawKartProgressionMinimapIcon(players[localplayers[i]].distancetofinish, x, y, splitflags, workingPic, colormap); } } diff --git a/src/k_kart.c b/src/k_kart.c index 47be88c71..7ced55df6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8387,7 +8387,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) player->tripwireState = TRIPSTATE_NONE; } - if (player->spectator == false) + // If the player is out of the game, these visuals may + // look really strange. + if (player->spectator == false && !(player->pflags & PF_NOCONTEST)) { K_KartEbrakeVisuals(player); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index ad560dd1e..c5e6c0672 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1172,14 +1172,6 @@ static int libd_getlocaltransflag(lua_State *L) return 1; } -// Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int -static int libd_getusertransflag(lua_State *L) -{ - HUDONLY - lua_pushinteger(L, (10-cv_translucenthud.value)*V_10TRANS); // A bit weird that it's called "translucenthud" yet 10 is fully opaque :V - return 1; -} - // Return the time elapsed for the previous frame, in tics. static int libd_getDeltaTime(lua_State *L) { @@ -1226,7 +1218,6 @@ static luaL_Reg lib_draw[] = { {"renderer", libd_renderer}, {"localTransFlag", libd_getlocaltransflag}, {"drawOnMinimap", libd_drawOnMinimap}, - {"userTransFlag", libd_getusertransflag}, {"getDeltaTime", libd_getDeltaTime}, {NULL, NULL} }; diff --git a/src/menus/options-hud-1.c b/src/menus/options-hud-1.c index 54bb4449c..2a652528d 100644 --- a/src/menus/options-hud-1.c +++ b/src/menus/options-hud-1.c @@ -12,9 +12,6 @@ menuitem_t OPTIONS_HUD[] = {IT_STRING | IT_CVAR, "Show HUD (F3)", "Toggles HUD display. Great for taking screenshots!", NULL, {.cvar = &cv_showhud}, 0, 0}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, "HUD Opacity", "Non opaque values may have performance impacts in software mode.", - NULL, {.cvar = &cv_translucenthud}, 0, 0}, - {IT_SPACE | IT_NOTHING, NULL, NULL, NULL, {NULL}, 0, 0}, diff --git a/src/p_inter.c b/src/p_inter.c index fe914a571..86004ad50 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1134,7 +1134,7 @@ boolean P_CheckRacers(void) // SO, we're not done playing. // Let's see if it's time to start the death counter! - if (racecountdown == 0) + if (racecountdown == 0 && K_Cooperative() == false) { // If the winners are all done, then start the death timer. UINT8 winningPos = max(1, numPlaying / 2); diff --git a/src/r_main.h b/src/r_main.h index c201a50be..e7d0f8a87 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -123,7 +123,7 @@ extern struct RenderStats g_renderstats; // REFRESH - the actual rendering functions. // -extern consvar_t cv_showhud, cv_translucenthud; +extern consvar_t cv_showhud; extern consvar_t cv_homremoval; extern consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS]; diff --git a/src/st_stuff.c b/src/st_stuff.c index 1e738dc5f..6df915d3c 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -117,6 +117,7 @@ void ST_Ticker(boolean run) // 0 is default, any others are special palettes. INT32 st_palette = 0; UINT32 st_translucency = 10; +fixed_t st_fadein = 0; void ST_doPaletteStuff(void) { @@ -1424,6 +1425,35 @@ void ST_DrawServerSplash(boolean timelimited) } } +static fixed_t ST_CalculateFadeIn(player_t *player) +{ + const tic_t length = TICRATE/4; + + if (player->tally.hudSlide != 0) + { + tic_t timer = length - player->tally.hudSlide; + + return ((timer * FRACUNIT) + (FRACUNIT - rendertimefrac)) / length; + } + + tic_t timer = lt_exitticker; + + if (K_CheckBossIntro() == true || G_IsTitleCardAvailable() == false) + { + if (leveltime <= 16) + timer = 0; + else + timer = leveltime-16; + } + + if (timer < length) + { + return ((timer * FRACUNIT) + rendertimefrac) / length; + } + + return FRACUNIT; +} + void ST_Drawer(void) { boolean stagetitle = false; // Decide whether to draw the stage title or not @@ -1445,21 +1475,27 @@ void ST_Drawer(void) #endif if (rendermode != render_none) ST_doPaletteStuff(); - { -#if 0 - const tic_t length = TICRATE/2; + fixed_t localfadein[MAXSPLITSCREENPLAYERS]; - if (lt_exitticker) + // HUD fading for anything not tied to a single player, + // i.e. the minimap. Since individual splitscreen + // players' HUDs may fade away before other's, use the + // the last one remaining. + { + fixed_t maxFade = 0; + UINT8 i; + + for (i = 0; i <= r_splitscreen; i++) { - st_translucency = cv_translucenthud.value; - if (lt_exitticker < length) - st_translucency = (((INT32)(lt_ticker - lt_endtime))*st_translucency)/((INT32)length); + localfadein[i] = ST_CalculateFadeIn(&players[displayplayers[i]]); + + if (localfadein[i] > maxFade) + { + maxFade = localfadein[i]; + } } - else - st_translucency = 0; -#else - st_translucency = cv_translucenthud.value; -#endif + + st_translucency = FixedMul(10, maxFade); } // Check for a valid level title @@ -1479,6 +1515,7 @@ void ST_Drawer(void) for (i = 0; i <= r_splitscreen; i++) { stplyr = &players[displayplayers[i]]; + st_fadein = localfadein[i]; R_SetViewContext(VIEWCONTEXT_PLAYER1 + i); R_InterpolateView(rendertimefrac); // to assist with object tracking ST_overlayDrawer(); diff --git a/src/st_stuff.h b/src/st_stuff.h index c406bdcaf..6754acf0e 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -86,7 +86,8 @@ boolean ST_SameTeam(player_t *a, player_t *b); extern boolean st_overlay; // sb overlay on or off when fullscreen extern INT32 st_palette; // 0 is default, any others are special palettes. -extern UINT32 st_translucency; +extern UINT32 st_translucency; // HUD fading for elements not attached to specific players +extern fixed_t st_fadein; // transitioning value per player, FRACUNIT = fully in view extern lumpnum_t st_borderpatchnum; // patches, also used in intermission diff --git a/src/v_video.cpp b/src/v_video.cpp index 9e679607a..cb886aad8 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -573,33 +573,14 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du if ((options & V_SLIDEIN)) { - const tic_t length = TICRATE/4; - tic_t timer = lt_exitticker; - - if (K_CheckBossIntro() == true || G_IsTitleCardAvailable() == false) - { - if (leveltime <= 16) - timer = 0; - else - timer = leveltime-16; - } - - if (stplyr->tally.hudSlide != 0) - { - timer = length - stplyr->tally.hudSlide; - } - - if (timer < length) + if (st_fadein < FRACUNIT) { if ((options & (V_SNAPTORIGHT|V_SNAPTOLEFT|V_SPLITSCREEN)) != 0) { boolean slidefromright = false; - const INT32 offsetAmount = (screenwidth * FRACUNIT/2) / length; - fixed_t offset = (screenwidth * FRACUNIT/2) - (timer * offsetAmount); - - offset += FixedMul(offsetAmount, renderdeltatics); - offset /= FRACUNIT; + const fixed_t offsetAmount = (screenwidth * FRACUNIT/2); + INT32 offset = (offsetAmount - FixedMul(offsetAmount, st_fadein)) / FRACUNIT; if (r_splitscreen > 1) { @@ -621,11 +602,8 @@ void V_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du } else { - const INT32 offsetAmount = (screenheight * FRACUNIT/2) / length; - fixed_t offset = (screenheight * FRACUNIT/2) - (timer * offsetAmount); - - offset += FixedMul(offsetAmount, renderdeltatics); - offset /= FRACUNIT; + const fixed_t offsetAmount = (screenheight * FRACUNIT/2); + INT32 offset = (offsetAmount - FixedMul(offsetAmount, st_fadein)) / FRACUNIT; if (options & V_SNAPTOBOTTOM) { @@ -756,6 +734,39 @@ static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fix return *(v_translevel + (((*(v_colormap + source[ofs>>FRACBITS]))<<8)&0xff00) + (*dest&0xff)); } +UINT32 V_GetHUDTranslucency(INT32 scrn) +{ + if (scrn & V_SLIDEIN) + { + return 10; + } + + if (scrn & V_SPLITSCREEN) + { + return FixedMul(10, st_fadein); + } + + return st_translucency; +} + +static UINT32 V_GetAlphaLevel(INT32 scrn) +{ + switch (scrn & V_ALPHAMASK) + { + case V_HUDTRANSHALF: + return hudminusalpha[V_GetHUDTranslucency(scrn)]; + + case V_HUDTRANS: + return 10 - V_GetHUDTranslucency(scrn); + + case V_HUDTRANSDOUBLE: + return hudplusalpha[V_GetHUDTranslucency(scrn)]; + + default: + return (scrn & V_ALPHAMASK) >> V_ALPHASHIFT; + } +} + // Draws a patch scaled to arbitrary size. void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap) { @@ -781,18 +792,8 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if ((blendmode = ((scrn & V_BLENDMASK) >> V_BLENDSHIFT))) blendmode++; // realign to constants - if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) - { - if (alphalevel == 10) // V_HUDTRANSHALF - alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 11) // V_HUDTRANS - alphalevel = 10 - st_translucency; - else if (alphalevel == 12) // V_HUDTRANSDOUBLE - alphalevel = hudplusalpha[st_translucency]; - - if (alphalevel >= 10) // Still inelegible to render? - return; - } + if ((alphalevel = V_GetAlphaLevel(scrn)) >= 10) + return; dupx = vid.dupx; dupy = vid.dupy; @@ -1130,18 +1131,8 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) } #endif - if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) - { - if (alphalevel == 10) // V_HUDTRANSHALF - alphalevel = hudminusalpha[st_translucency]; - else if (alphalevel == 11) // V_HUDTRANS - alphalevel = 10 - st_translucency; - else if (alphalevel == 12) // V_HUDTRANSDOUBLE - alphalevel = hudplusalpha[st_translucency]; - - if (alphalevel >= 10) // Still inelegible to render? - return; - } + if ((alphalevel = V_GetAlphaLevel(c)) >= 10) + return; if (!(c & V_NOSCALESTART)) { diff --git a/src/v_video.h b/src/v_video.h index 03c06c71f..e1dc023c9 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -155,10 +155,6 @@ void V_CubeApply(RGBA_t *input); #define V_HUDTRANSHALF 0x000A0000 #define V_HUDTRANS 0x000B0000 // draw the hud translucent #define V_HUDTRANSDOUBLE 0x000C0000 -// Macros follow -#define V_USERHUDTRANSHALF ((10-(cv_translucenthud.value/2))<