demo autorecord patch from RvB

This commit is contained in:
Bill Currie 2002-03-14 18:48:04 +00:00
parent 650912e75a
commit 33513ce67b
4 changed files with 82 additions and 24 deletions

View File

@ -192,6 +192,11 @@ integer (string text, integer key) control_options_f =
Cbuf_AddText ("set m_pitch -0.022\n");
}
break;
case "cl_autorecord":
if(cvar("cl_autorecord") == 0)
Cbuf_AddText ("set cl_autorecord 1\n");
else
Cbuf_AddText ("set cl_autorecord 0\n");
}
if(!(key == QFK_RIGHT || key == QFK_LEFT)) {
return 0;
@ -227,7 +232,7 @@ integer () options_controls_draw =
Draw_String (70, bar_pad + 10, "Mouse amp:");
draw_perc_bar (150, bar_pad + 10, 12, to_percentage (MIN_MOUSE_AMP, MAX_MOUSE_AMP, cvar("in_mouse_amp")));
Draw_String (150 + (12 + 4)*8 , bar_pad + 10, ftos(cvar("in_mouse_amp")));
tmp = cvar("m_pitch") < 0 ? "On" : "Off";
draw_val_item (70, 110, spacing, "Mouse Invert", tmp);
@ -247,9 +252,37 @@ void () options_controls_menu =
Menu_Item (54, 90, "freelook", control_options_f, 0);
Menu_Item (54, 100, "mouseamp", control_options_f, 1);
Menu_Item (54, 110, "m_pitch", control_options_f, 0);
Menu_Item (54, 120, "cl_autorecord", control_options_f, 0);
Menu_End ();
};
integer () options_features_draw =
{
local string tmp;
local integer cursor_pad = 0, spacing = 120, bar_pad;
Draw_Pic (16, 4, "gfx/qplaque.lmp");
Draw_CenterPic (160,4, "gfx/p_option.lmp");
Draw_String (54, 40, "Features");
Draw_String (54, 50, "--------");
tmp = cvar("cl_autorecord") != 0 ? "On" : "Off";
draw_val_item (70, 60, spacing, "Auto Record", tmp);
opt_cursor (62, (Menu_GetIndex() * 10) + 60 + cursor_pad);
return 1;
};
void () options_features_menu =
{
Menu_Begin (54, 70, "Features");
Menu_FadeScreen (1);
Menu_CenterPic (160, 4, "gfx/p_option.lmp");
Menu_Draw (options_features_draw);
Menu_Item (54, 70, "cl_autorecord", control_options_f, 0);
Menu_End ();
};
integer (integer key, integer unicode, integer down) options_keyevent =
{
@ -263,6 +296,9 @@ integer (integer key, integer unicode, integer down) options_keyevent =
void () options_menu =
{
local string tmp;
local integer spacing = 120;
Menu_Begin (54, 72, "");
Menu_FadeScreen (1);
Menu_Pic (16, 4, "gfx/qplaque.lmp");
@ -271,5 +307,7 @@ void () options_menu =
options_controls_menu ();
options_video_menu ();
options_audio_menu ();
options_features_menu ();
Menu_End ();
};

View File

@ -38,6 +38,7 @@ void CL_WriteDemoCmd (usercmd_t *pcmd);
void CL_Stop_f (void);
void CL_Record_f (void);
void CL_Record (const char *argv1);
void CL_ReRecord_f (void);
void CL_PlayDemo_f (void);
void CL_TimeDemo_f (void);

View File

@ -412,8 +412,9 @@ CL_WriteSetDemoMessage (void)
record <demoname> <server>
*/
void
CL_Record_f (void)
CL_Record (const char *argv1)
{
char buf_data[MAX_MSGLEN + 10]; // + 10 for header
char name[MAX_OSPATH];
@ -421,7 +422,7 @@ CL_Record_f (void)
char timestring[20];
char mapname[MAX_OSPATH];
int c, n, i, j, k, l=0;
int n, i, j, k, l=0;
int seq = 1;
entity_t *ent;
entity_state_t *es, blankes;
@ -429,23 +430,7 @@ CL_Record_f (void)
sizebuf_t buf;
time_t tim;
c = Cmd_Argc ();
if (c > 2) {
/* we use a demo name like year-month-day-hours-minutes-mapname.qwd
if there is no argument */
Con_Printf ("record [demoname]\n");
return;
}
if (cls.state != ca_active) {
Con_Printf ("You must be connected to record.\n");
return;
}
if (cls.demorecording)
CL_Stop_f ();
if (c < 2) {
if (!argv1) {
// Get time to a useable format
time (&tim);
strftime (timestring, 19, "%Y-%m-%d-%H-%M", localtime (&tim));
@ -471,7 +456,7 @@ CL_Record_f (void)
snprintf (name, sizeof (name), "%s/%s-%s", com_gamedir,
timestring, mapname);
} else {
snprintf (name, sizeof (name), "%s/%s", com_gamedir, Cmd_Argv(1));
snprintf (name, sizeof (name), "%s/%s", com_gamedir, argv1);
}
// open the demo file
@ -717,6 +702,29 @@ CL_Record_f (void)
// done
}
void
CL_Record_f (void)
{
if (Cmd_Argc () > 2) {
/* we use a demo name like year-month-day-hours-minutes-mapname.qwd
if there is no argument */
Con_Printf ("record [demoname]\n");
return;
}
if (cls.state != ca_active) {
Con_Printf ("You must be connected to record.\n");
return;
}
if (cls.demorecording)
CL_Stop_f ();
if (Cmd_Argc () == 2)
CL_Record (Cmd_Argv (1));
else
CL_Record (0);
}
/*
CL_ReRecord_f

View File

@ -165,7 +165,8 @@ cvar_t *cl_solid_players;
cvar_t *localid;
cvar_t *cl_port;
cvar_t *cl_port;
cvar_t *cl_autorecord;
static qboolean allowremotecmd = true;
@ -1110,12 +1111,20 @@ CL_SetState (cactive_t state)
IN_ClearStates ();
if (con_module)
con_module->data->console->force_commandline = 0;
// Auto demo recorder starts here
if(cl_autorecord->int_val && !cls.demoplayback && !cls.demorecording)
CL_Record (0); // FIXME might want a cvar here
} else {
r_active = false;
game_target = IMT_CONSOLE;
key_dest = key_console;
if (con_module)
con_module->data->console->force_commandline = 1;
// Auto demo recorder stops here
if(cl_autorecord->int_val && cls.demorecording)
CL_Stop_f ();
}
}
@ -1146,8 +1155,8 @@ CL_Init (void)
Cmd_AddCommand ("version", CL_Version_f, "Report version information");
Cmd_AddCommand ("changing", CL_Changing_f, "Used when maps are changing");
Cmd_AddCommand ("disconnect", CL_Disconnect_f, "Disconnect from server");
Cmd_AddCommand ("record", CL_Record_f, "Record a demo 'record filename "
"server'");
Cmd_AddCommand ("record", CL_Record_f, "Record a demo, if no filename argument is given\n"
"the demo will be called Year-Month-Day-Hour-Minute-Mapname");
Cmd_AddCommand ("rerecord", CL_ReRecord_f, "Rerecord a demo on the same "
"server");
Cmd_AddCommand ("snap", CL_RSShot_f, "Take a screenshot and upload it to "
@ -1332,6 +1341,8 @@ CL_Init_Cvars (void)
"Turn this on to save cpu when fps limited. "
"May affect frame rate adversely depending on "
"local machine/os conditions");
cl_autorecord = Cvar_Get ("cl_autorecord", "0", CVAR_ARCHIVE, NULL,
"Turn this on, if you want to record every game");
}
/*