Merge branch 'f9-f10' into 'master'

Turn F9 into a dedicated WebM button, add F10 as "lossless recording" button

See merge request KartKrew/Kart!1045
This commit is contained in:
James R 2023-03-17 06:25:50 +00:00
commit ba23836fc1
6 changed files with 72 additions and 33 deletions

View file

@ -154,6 +154,7 @@ static void Command_Playdemo_f(void);
static void Command_Timedemo_f(void); static void Command_Timedemo_f(void);
static void Command_Stopdemo_f(void); static void Command_Stopdemo_f(void);
static void Command_StartMovie_f(void); static void Command_StartMovie_f(void);
static void Command_StartLossless_f(void);
static void Command_StopMovie_f(void); static void Command_StopMovie_f(void);
static void Command_Map_f(void); static void Command_Map_f(void);
static void Command_RandomMap(void); static void Command_RandomMap(void);
@ -891,11 +892,12 @@ void D_RegisterClientCommands(void)
COM_AddCommand("screenshot", M_ScreenShot); COM_AddCommand("screenshot", M_ScreenShot);
COM_AddCommand("startmovie", Command_StartMovie_f); COM_AddCommand("startmovie", Command_StartMovie_f);
COM_AddCommand("startlossless", Command_StartLossless_f);
COM_AddCommand("stopmovie", Command_StopMovie_f); COM_AddCommand("stopmovie", Command_StopMovie_f);
COM_AddCommand("minigen", M_MinimapGenerate); COM_AddCommand("minigen", M_MinimapGenerate);
CV_RegisterVar(&cv_screenshot_colorprofile); CV_RegisterVar(&cv_screenshot_colorprofile);
CV_RegisterVar(&cv_moviemode); CV_RegisterVar(&cv_lossless_recorder);
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES #ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
M_AVRecorder_AddCommands(); M_AVRecorder_AddCommands();
@ -2503,7 +2505,12 @@ static void Command_Stopdemo_f(void)
static void Command_StartMovie_f(void) static void Command_StartMovie_f(void)
{ {
M_StartMovie(); M_StartMovie(MM_AVRECORDER);
}
static void Command_StartLossless_f(void)
{
M_StartMovie(cv_lossless_recorder.value);
} }
static void Command_StopMovie_f(void) static void Command_StopMovie_f(void)

View file

@ -561,8 +561,6 @@ extern consvar_t cv_autorecord;
void M_SetMenuDelay(UINT8 i); void M_SetMenuDelay(UINT8 i);
void Moviemode_mode_Onchange(void);
void M_SortServerList(void); void M_SortServerList(void);
void M_MapMenuControls(event_t *ev); void M_MapMenuControls(event_t *ev);

View file

@ -114,8 +114,8 @@ typedef off_t off64_t;
consvar_t cv_screenshot_colorprofile = CVAR_INIT ("screenshot_colorprofile", "Yes", CV_SAVE, CV_YesNo, NULL); consvar_t cv_screenshot_colorprofile = CVAR_INIT ("screenshot_colorprofile", "Yes", CV_SAVE, CV_YesNo, NULL);
static CV_PossibleValue_t moviemode_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {MM_AVRECORDER, "WebM"}, {0, NULL}}; static CV_PossibleValue_t lossless_recorder_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}};
consvar_t cv_moviemode = CVAR_INIT ("moviemode_mode", "WebM", CV_SAVE|CV_CALL, moviemode_cons_t, Moviemode_mode_Onchange); consvar_t cv_lossless_recorder = CVAR_INIT ("lossless_recorder", "GIF", CV_SAVE, lossless_recorder_cons_t, NULL);
static CV_PossibleValue_t zlib_mem_level_t[] = { static CV_PossibleValue_t zlib_mem_level_t[] = {
{1, "(Min Memory) 1"}, {1, "(Min Memory) 1"},
@ -1316,22 +1316,36 @@ static inline moviemode_t M_StartMovieAVRecorder(const char *pathname)
#endif #endif
} }
void M_StartMovie(void) void M_StartMovie(moviemode_t mode)
{ {
#if NUMSCREENS > 2 #if NUMSCREENS > 2
const char *folder;
char pathname[MAX_WADPATH]; char pathname[MAX_WADPATH];
if (moviemode) if (moviemode)
return; return;
strcpy(pathname, srb2home); switch (mode)
strcat(pathname, PATHSEP "media" PATHSEP "movies" PATHSEP); {
case MM_GIF:
folder = "gifs";
break;
case MM_AVRECORDER:
folder = "movies";
break;
default:
folder = "slideshows";
}
sprintf(pathname, "%s" PATHSEP "media" PATHSEP "%s" PATHSEP, srb2home, folder);
M_MkdirEach(pathname, M_PathParts(pathname) - 2, 0755); M_MkdirEach(pathname, M_PathParts(pathname) - 2, 0755);
if (rendermode == render_none) if (rendermode == render_none)
I_Error("Can't make a movie without a render system\n"); I_Error("Can't make a movie without a render system\n");
switch (cv_moviemode.value) switch (mode)
{ {
case MM_GIF: case MM_GIF:
moviemode = M_StartMovieGIF(pathname); moviemode = M_StartMovieGIF(pathname);
@ -1842,12 +1856,38 @@ boolean M_ScreenshotResponder(event_t *ev)
if (ch >= NUMKEYS && menuactive) // If it's not a keyboard key, then don't allow it in the menus! if (ch >= NUMKEYS && menuactive) // If it's not a keyboard key, then don't allow it in the menus!
return false; return false;
if (ch == KEY_F8 /*|| ch == gamecontrol[0][gc_screenshot][0] || ch == gamecontrol[0][gc_screenshot][1]*/) // remappable F8 switch (ch)
{
case KEY_F8:
M_ScreenShot(); M_ScreenShot();
else if (ch == KEY_F9 /*|| ch == gamecontrol[0][gc_recordgif][0] || ch == gamecontrol[0][gc_recordgif][1]*/) // remappable F9 break;
((moviemode) ? M_StopMovie : M_StartMovie)();
else case KEY_F9:
if (moviemode)
{
M_StopMovie();
}
else
{
M_StartMovie(MM_AVRECORDER);
}
break;
case KEY_F10:
if (moviemode)
{
M_StopMovie();
}
else
{
M_StartMovie(static_cast<moviemode_t>(cv_lossless_recorder.value));
}
break;
default:
return false; return false;
}
return true; return true;
} }

View file

@ -43,12 +43,12 @@ typedef enum {
extern moviemode_t moviemode; extern moviemode_t moviemode;
extern consvar_t cv_screenshot_colorprofile; extern consvar_t cv_screenshot_colorprofile;
extern consvar_t cv_moviemode; extern consvar_t cv_lossless_recorder;
extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits; extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits;
extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa; extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa;
extern consvar_t cv_apng_delay, cv_apng_downscale; extern consvar_t cv_apng_delay, cv_apng_downscale;
void M_StartMovie(void); void M_StartMovie(moviemode_t mode);
void M_LegacySaveFrame(void); void M_LegacySaveFrame(void);
void M_StopMovie(void); void M_StopMovie(void);

View file

@ -100,9 +100,6 @@ void M_InitOptions(INT32 choice)
// So that pause doesn't go to the main menu... // So that pause doesn't go to the main menu...
OPTIONS_MainDef.prevMenu = currentMenu; OPTIONS_MainDef.prevMenu = currentMenu;
// This will disable or enable the textboxes of the affected menus before we get to them.
Moviemode_mode_Onchange();
M_SetupNextMenu(&OPTIONS_MainDef, false); M_SetupNextMenu(&OPTIONS_MainDef, false);
} }

View file

@ -9,19 +9,23 @@
menuitem_t OPTIONS_DataScreenshot[] = menuitem_t OPTIONS_DataScreenshot[] =
{ {
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
{IT_HEADER, "MOVIE RECORDING (F9)", NULL, {IT_HEADER, "MOVIE RECORDING (F9)", NULL,
NULL, {NULL}, 0, 0}, NULL, {NULL}, 0, 0},
{IT_STRING | IT_CVAR, "Recording Format", "What file format will movies will be recorded in?",
NULL, {.cvar = &cv_moviemode}, 0, 0},
#ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES
{IT_STRING | IT_CVAR, "Real-Time Data", "If enabled, shows fps, duration and filesize of recording in real-time.", {IT_STRING | IT_CVAR, "Real-Time Data", "If enabled, shows fps, duration and filesize of recording in real-time.",
NULL, {.cvar = &cv_movie_showfps}, 0, 0}, NULL, {.cvar = &cv_movie_showfps}, 0, 0},
#else
{IT_SPACE | IT_NOTHING, NULL, NULL,
NULL, {NULL}, 0, 0},
#endif #endif
{IT_SPACE | IT_NOTHING, NULL, NULL,
NULL, {NULL}, 0, 0},
{IT_HEADER, "LOSSLESS RECORDING (F10)", NULL,
NULL, {NULL}, 0, 0},
{IT_STRING | IT_CVAR, "Recording Format", "What file format will lossless recordings use?",
NULL, {.cvar = &cv_lossless_recorder}, 0, 0},
}; };
menu_t OPTIONS_DataScreenshotDef = { menu_t OPTIONS_DataScreenshotDef = {
@ -39,10 +43,3 @@ menu_t OPTIONS_DataScreenshotDef = {
NULL, NULL,
NULL, NULL,
}; };
void Moviemode_mode_Onchange(void)
{
// opt 3 in a 0 based array, you get the idea...
OPTIONS_DataScreenshot[2].status =
(cv_moviemode.value == MM_AVRECORDER ? IT_CVAR|IT_STRING : IT_DISABLED);
}