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/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/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 8db0d630b..6df915d3c 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1475,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 @@ -1509,7 +1515,7 @@ void ST_Drawer(void) for (i = 0; i <= r_splitscreen; i++) { stplyr = &players[displayplayers[i]]; - st_fadein = ST_FadeIn(stplyr); + 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 741e8c013..6754acf0e 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -86,7 +86,7 @@ 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; diff --git a/src/v_video.cpp b/src/v_video.cpp index 9efcbb90a..cb886aad8 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -734,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) { @@ -759,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; @@ -1108,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))<