From 928b236af30ad4e8edddf136bbcf578d496885ea Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos Date: Sat, 19 Dec 2020 14:25:03 -0300 Subject: [PATCH] Disable by default, add menu option --- src/m_anigif.c | 39 ++++++++++++++++++++++++++++++--------- src/m_anigif.h | 1 + src/m_menu.c | 7 ++++--- src/screen.c | 6 +++++- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/m_anigif.c b/src/m_anigif.c index 7e5792b51..6839eb25c 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -51,15 +51,15 @@ consvar_t cv_gif_optimize = CVAR_INIT ("gif_optimize", "On", CV_SAVE, CV_OnOff, consvar_t cv_gif_downscale = CVAR_INIT ("gif_downscale", "On", CV_SAVE, CV_OnOff, NULL); consvar_t cv_gif_dynamicdelay = CVAR_INIT ("gif_dynamicdelay", "On", CV_SAVE, gif_dynamicdelay_cons_t, NULL); consvar_t cv_gif_localcolortable = CVAR_INIT ("gif_localcolortable", "On", CV_SAVE, CV_OnOff, NULL); -consvar_t cv_gif_split = CVAR_INIT ("gif_split", "Use last filename", CV_SAVE, gif_split_cons_t, NULL); -consvar_t cv_gif_sizelimit = CVAR_INIT ("gif_sizelimit", "8192", (CV_SAVE | CV_CALL), CV_Unsigned, CV_gifsizelimit_OnChange); -consvar_t cv_gif_showfilesize = CVAR_INIT ("gif_showfilesize", "On", CV_SAVE, CV_OnOff, NULL); -consvar_t cv_gif_showsplitcount = CVAR_INIT ("gif_showsplitcount", "On", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_gif_split = CVAR_INIT ("gif_split", "Off", CV_SAVE, gif_split_cons_t, NULL); +consvar_t cv_gif_sizelimit = CVAR_INIT ("gif_sizelimit", "0", (CV_SAVE | CV_CALL), CV_Unsigned, CV_gifsizelimit_OnChange); +consvar_t cv_gif_showfilesize = CVAR_INIT ("gif_showfilesize", "Off", CV_SAVE, CV_OnOff, NULL); +consvar_t cv_gif_showsplitcount = CVAR_INIT ("gif_showsplitcount", "Off", CV_SAVE, CV_OnOff, NULL); #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb static boolean gif_downscale = false; // like changing cvars mid output -static UINT8 gif_dynamicdelay = (UINT8)0; // and messing something up +static UINT8 gif_dynamicdelay = 0; // and messing something up // Palette handling static boolean gif_localcolortable = false; @@ -984,17 +984,22 @@ void GIF_displayinfo(void) y += ((vid.dupx > 1) ? 5 : 10); \ } - if (!gif_sizelimit) + if (!gif_out) return; if (cv_gif_showfilesize.value) { GIF_getinfosize(gif_totalsize, &filesize[0], &unit[0][0]); - GIF_getinfosize(gif_sizelimit, &filesize[1], &unit[1][0]); - string = va("%.2f%s/%.2f%s", filesize[0], unit[0], filesize[1], unit[1]); + if (gif_sizelimit) + { + GIF_getinfosize(gif_sizelimit, &filesize[1], &unit[1][0]); + string = va(M_GetText("GIF size: %.2f%s/%.2f%s"), filesize[0], unit[0], filesize[1], unit[1]); + } + else + string = va(M_GetText("GIF size: %.2f%s"), filesize[0], unit[0]); - if ((!cv_gif_split.value) + if (gif_sizelimit && (!cv_gif_split.value) && (gif_totalsize > (gif_sizelimit - (gif_sizelimit / 4))) && (gif_frames/5 & 1)) // flashing stringflags |= V_REDMAP; @@ -1008,6 +1013,22 @@ void GIF_displayinfo(void) string = va("GIF count: %d\n", (gif_splitcount + 1)); infoline(string); } + +#undef infoline +} + +boolean GIF_candisplayinfo(void) +{ + if (!gif_out) + return false; + + if (cv_gif_showfilesize.value) + return true; + + if (cv_gif_split.value && gif_splitcount && cv_gif_showsplitcount.value) + return true; + + return false; } // diff --git a/src/m_anigif.h b/src/m_anigif.h index 0f4b61013..2c964bcb0 100644 --- a/src/m_anigif.h +++ b/src/m_anigif.h @@ -26,6 +26,7 @@ INT32 GIF_open(const char *filename); void GIF_frame(void); INT32 GIF_close(void); void GIF_displayinfo(void); +boolean GIF_candisplayinfo(void); #endif extern consvar_t cv_gif_optimize, cv_gif_downscale, cv_gif_dynamicdelay, cv_gif_localcolortable; diff --git a/src/m_menu.c b/src/m_menu.c index 08eb18fa2..1e4213019 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1557,6 +1557,7 @@ static menuitem_t OP_ScreenshotOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 100}, {IT_STRING|IT_CVAR, NULL, "Local Color Table", &cv_gif_localcolortable, 105}, {IT_STRING|IT_CVAR, NULL, "Dynamic Delay", &cv_gif_dynamicdelay, 110}, + {IT_STRING|IT_CVAR, NULL, "Show File Size", &cv_gif_showfilesize, 115}, {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_apng_downscale, 95}, {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 100}, @@ -1573,9 +1574,9 @@ enum op_movie_folder = 11, op_screenshot_capture = 12, op_screenshot_gif_start = 13, - op_screenshot_gif_end = 16, - op_screenshot_apng_start = 17, - op_screenshot_apng_end = 21, + op_screenshot_gif_end = 17, + op_screenshot_apng_start = 18, + op_screenshot_apng_end = 22, }; static menuitem_t OP_EraseDataMenu[] = diff --git a/src/screen.c b/src/screen.c index ed1eaa31d..e28780a58 100644 --- a/src/screen.c +++ b/src/screen.c @@ -518,7 +518,11 @@ boolean SCR_UseDelayedOverlay(void) boolean SCR_NeedsDelayedOverlay(void) { - return (moviemode == MM_GIF); +#ifdef HAVE_ANIGIF + return (moviemode == MM_GIF && GIF_candisplayinfo()); +#else + return false; +#endif } // XMOD FPS display