make the console run at full speed no matter what demo_speed is at. what a

lot of work for such a simple concept :P
This commit is contained in:
Bill Currie 2003-07-25 22:21:47 +00:00
parent 1366ad4661
commit 6063fb75d9
20 changed files with 91 additions and 87 deletions

View file

@ -84,7 +84,7 @@ extern struct console_data_s con_data;
//extern byte *con_chars;
void Con_CheckResize (void);
void Con_DrawConsole (int lines);
void Con_DrawConsole (void);
void Con_Print (const char *fmt, va_list args);
void Con_Printf (const char *fmt, ...) __attribute__((format(printf,1,2)));
@ -141,4 +141,6 @@ void Menu_KeyEvent (knum_t key, short unicode, qboolean down);
void Menu_Enter (void);
void Menu_Leave (void);
extern struct cvar_s *con_size;
#endif // __console_h

View file

@ -42,7 +42,7 @@ void Draw_Pic (int x, int y, qpic_t *pic);
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
void Draw_TextBox (int x, int y, int width, int lines, byte alpha);
void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation);
void Draw_ConsoleBackground (int lines);
void Draw_ConsoleBackground (int lines, byte alpha);
void Draw_Crosshair (void);
void Draw_BeginDisc (void);
void Draw_EndDisc (void);

View file

@ -38,7 +38,7 @@
typedef void (QFPLUGIN *P_C_Print) (const char *fmt, va_list args);
typedef void (QFPLUGIN *P_C_ProcessInput) (void);
typedef void (QFPLUGIN *P_C_KeyEvent) (knum_t key, short unicode, qboolean down);
typedef void (QFPLUGIN *P_C_DrawConsole) (int lines);
typedef void (QFPLUGIN *P_C_DrawConsole) (void);
typedef void (QFPLUGIN *P_C_CheckResize) (void);
typedef void (QFPLUGIN *P_C_NewMap) (void);
@ -55,11 +55,13 @@ typedef struct console_data_s {
const char *dl_name;
int *dl_percent;
double *realtime;
double *frametime;
int force_commandline;
int ormask;
void (*quit)(void);
struct cbuf_s *cbuf;
struct view_s *view;
float lines;
} console_data_t;
#endif // __QF_plugin_console_h_

View file

@ -54,7 +54,6 @@ void SCR_DrawTime (void);
void SCR_DrawTurtle (void);
void SCR_DrawPause (void);
void SCR_CheckDrawCenterString (void);
void SCR_DrawConsole (void);
struct tex_s *SCR_ScreenShot (int width, int height);
void SCR_DrawStringToSnap (const char *s, struct tex_s *tex, int x, int y);
@ -76,7 +75,6 @@ extern qboolean hudswap;
extern struct cvar_s *scr_viewsize;
extern struct cvar_s *scr_fov;
extern struct cvar_s *scr_viewsize;
extern struct cvar_s *scr_consize;
// only the refresh window will be updated unless these variables are flagged
extern int scr_copytop;

View file

@ -53,6 +53,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/plugin.h"
#include "QF/qargs.h"
#include "QF/quakefs.h"
#include "QF/render.h"
#include "QF/screen.h"
#include "QF/sys.h"
#include "QF/va.h"
@ -78,6 +79,9 @@ static old_console_t *con;
static float con_cursorspeed = 4;
static cvar_t *con_notifytime; // seconds
static cvar_t *con_alpha;
static cvar_t *con_size;
static cvar_t *con_speed;
static cvar_t *cl_chatmode;
#define NUM_CON_TIMES 4
@ -660,8 +664,17 @@ draw_console_text (view_t *view)
static void
draw_console (view_t *view)
{
byte alpha;
if (con_data.force_commandline) {
alpha = 255;
} else {
float y = vid.height * con_size->value;
alpha = 255 * con_alpha->value * view->ylen / y;
alpha = min (alpha, 255);
}
// draw the background
Draw_ConsoleBackground (view->ylen);
Draw_ConsoleBackground (view->ylen, alpha);
// draw everything else
view_draw (view);
@ -711,13 +724,39 @@ draw_notify (view_t *view)
}
static void
C_DrawConsole (int lines)
setup_console (void)
{
if (console_view->ylen != lines)
view_resize (console_view, console_view->xlen, lines);
float lines;
if (con_data.force_commandline) {
lines = con_data.lines = vid.height;
} else if (key_dest == key_console) {
lines = vid.height * bound (0.2, con_size->value, 1);
} else {
lines = 0;
}
if (lines < con_data.lines) {
con_data.lines -= max (0.2, con_speed->value) * *con_data.frametime;
con_data.lines = max (con_data.lines, lines);
} else if (lines > con_data.lines) {
con_data.lines += max (0.2, con_speed->value) * *con_data.frametime;
con_data.lines = min (con_data.lines, lines);
}
if (con_data.lines >= vid.height - r_lineadj)
scr_copyeverything = 1;
}
static void
C_DrawConsole (void)
{
setup_console ();
if (console_view->ylen != con_data.lines)
view_resize (console_view, console_view->xlen, con_data.lines);
say_view->visible = key_dest == key_message;
console_view->visible = lines != 0;
console_view->visible = con_data.lines != 0;
menu_view->visible = key_dest == key_menu;
view_draw (con_data.view);
@ -768,6 +807,14 @@ C_Init (void)
"Controls when console text will be treated as a "
"chat message: 0 - never, 1 - always, 2 - smart");
con_alpha = Cvar_Get ("con_alpha", "0.6", CVAR_ARCHIVE, NULL,
"alpha value for the console background");
con_size = Cvar_Get ("con_size", "0.5", CVAR_ARCHIVE, NULL,
"Fraction of the screen the console covers when "
"down");
con_speed = Cvar_Get ("con_speed", "300", CVAR_ARCHIVE, NULL,
"How quickly the console scrolls up or down");
con_debuglog = COM_CheckParm ("-condebug");
con_data.view = view_new (0, 0, 320, 200, grav_northeast);

View file

@ -146,10 +146,10 @@ Con_SetOrMask (int mask)
}
void
Con_DrawConsole (int lines)
Con_DrawConsole (void)
{
if (con_module)
con_module->functions->console->pC_DrawConsole (lines);
con_module->functions->console->pC_DrawConsole ();
}
void

View file

@ -460,7 +460,7 @@ C_KeyEvent (knum_t key, short unicode, qboolean down)
}
static void
C_DrawConsole (int lines)
C_DrawConsole (void)
{
}

View file

@ -670,11 +670,9 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation)
several simple yet very cool GL effects. --KB
*/
void
Draw_ConsoleBackground (int lines)
Draw_ConsoleBackground (int lines, byte alpha)
{
byte alpha;
float ofs;
int y;
glpic_t *gl;
qpic_t *conback;
@ -707,14 +705,6 @@ Draw_ConsoleBackground (int lines)
else
ofs = (vid.conheight - lines) / (float) vid.conheight;
y = vid.height * scr_consize->value;
if (!r_active || lines > y) {
alpha = 255;
} else {
// set up to draw alpha console
alpha = 255 * (gl_conalpha->value * lines) / y;
}
color_0_8[3] = alpha;
qfglColor4ubv (color_0_8);

View file

@ -58,7 +58,6 @@ cvar_t *d_mipscale;
cvar_t *gl_affinemodels;
cvar_t *gl_clear;
cvar_t *gl_conalpha;
cvar_t *gl_conspin;
cvar_t *gl_constretch;
cvar_t *gl_dlight_polyblend;
@ -127,8 +126,6 @@ cvar_t *r_waterwarp;
cvar_t *r_zgraph;
cvar_t *scr_centertime;
cvar_t *scr_consize;
cvar_t *scr_conspeed;
cvar_t *scr_fov;
cvar_t *scr_fisheye;
cvar_t *scr_fviews;
@ -255,8 +252,6 @@ R_Init_Cvars (void)
"set to 1");
gl_clear = Cvar_Get ("gl_clear", "0", CVAR_NONE, NULL, "Set to 1 to make "
"background black. Useful for removing HOM effect");
gl_conalpha = Cvar_Get ("gl_conalpha", "0.6", CVAR_ARCHIVE, NULL,
"alpha value for the console background");
gl_conspin = Cvar_Get ("gl_conspin", "0", CVAR_ARCHIVE, NULL,
"speed at which the console spins");
gl_constretch = Cvar_Get ("gl_constretch", "0", CVAR_ARCHIVE, NULL,
@ -425,11 +420,6 @@ R_Init_Cvars (void)
"z-axis position");
scr_centertime = Cvar_Get ("scr_centertime", "2", CVAR_NONE, NULL, "How "
"long in seconds screen hints are displayed");
scr_consize = Cvar_Get ("scr_consize", "0.5", CVAR_ARCHIVE, NULL,
"Fraction of the screen the console covers when "
"down");
scr_conspeed = Cvar_Get ("scr_conspeed", "300", CVAR_NONE, NULL,
"How quickly the console scrolls up or down");
scr_fov = Cvar_Get ("fov", "90", CVAR_NONE, NULL, "Your field of view in "
"degrees. Smaller than 90 zooms in. Don't touch in "
"fisheye mode, use ffov instead.");

View file

@ -99,9 +99,6 @@ static __attribute__ ((unused)) const char rcsid[] =
int scr_copytop;
int scr_copyeverything;
float scr_con_current;
float scr_conlines; // lines of console to display
float oldfov;
int oldsbar;
@ -311,40 +308,10 @@ SCR_DrawPause (void)
void
SCR_SetUpToDrawConsole (void)
{
// decide on the height of the console
if (!r_active) {
scr_conlines = vid.height; // full screen
scr_con_current = scr_conlines;
} else if (key_dest == key_console)
scr_conlines = vid.height * bound (0.2, scr_consize->value, 1);
else
scr_conlines = 0; // none visible
if (scr_con_current >= vid.height - r_lineadj)
scr_copyeverything = 1;
if (scr_conlines < scr_con_current) {
scr_con_current -= scr_conspeed->value * r_frametime;
if (scr_conlines > scr_con_current)
scr_con_current = scr_conlines;
} else if (scr_conlines > scr_con_current) {
scr_con_current += scr_conspeed->value * r_frametime;
if (scr_conlines < scr_con_current)
scr_con_current = scr_conlines;
}
if (scr_con_current >= vid.height - r_lineadj)
scr_copyeverything = 1;
if (clearconsole++ < vid.numpages)
Sbar_Changed ();
}
void
SCR_DrawConsole (void)
{
Con_DrawConsole (scr_con_current);
}
/*
Find closest color in the palette for named color
*/

View file

@ -473,7 +473,7 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation)
void
Draw_ConsoleBackground (int lines)
Draw_ConsoleBackground (int lines, byte alpha)
{
int x, y, v;
byte *src, *dest;

View file

@ -129,11 +129,6 @@ SCR_CalcRefdef (void)
R_SetVrect (&vrect, &scr_vrect, r_lineadj);
// guard against going from one mode to another that's less than half the
// vertical resolution
if (scr_con_current > vid.height)
scr_con_current = vid.height;
// notify the refresh of the change
R_ViewChanged (&vrect, r_lineadj, vid.aspect);
}

View file

@ -630,7 +630,7 @@ Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte * translation)
void
Draw_ConsoleBackground (int lines)
Draw_ConsoleBackground (int lines, byte alpha)
{
int x, y, v;
byte *src;

View file

@ -130,11 +130,6 @@ SCR_CalcRefdef (void)
R_SetVrect (&vrect, &scr_vrect, r_lineadj);
// guard against going from one mode to another that's less than half the
// vertical resolution
if (scr_con_current > vid.height)
scr_con_current = vid.height;
// notify the refresh of the change
R_ViewChanged (&vrect, r_lineadj, vid.aspect);
}

View file

@ -72,9 +72,7 @@ static SCR_Func scr_funcs[] = {
SCR_DrawPause,
SCR_CheckDrawCenterString,
Sbar_Draw,
SCR_DrawConsole,
// FIXME: MENUCODE
// M_Draw,
Con_DrawConsole,
0
};

View file

@ -87,6 +87,10 @@ double host_time;
double realtime; // without any filtering or bounding
double oldrealtime; // last frame run
double con_frametime;
double con_realtime;
double oldcon_realtime;
int host_framecount;
int host_hunklevel;
int minimum_memory;
@ -526,6 +530,8 @@ Host_FilterTime (float time)
float timedifference;
float timescale = 1.0;
con_realtime += time;
if (cls.demoplayback) {
timescale = max (0, demo_speed->value);
time *= timescale;
@ -542,6 +548,9 @@ Host_FilterTime (float time)
host_frametime = realtime - oldrealtime;
oldrealtime = realtime;
con_frametime = con_realtime - oldcon_realtime;
oldcon_realtime = con_realtime;
if (host_framerate->value > 0)
host_frametime = host_framerate->value;
else // don't allow really long or short frames
@ -937,7 +946,8 @@ Host_Init (void)
else
Con_Init ("client");
if (con_module) {
con_module->data->console->realtime = &realtime;
con_module->data->console->realtime = &con_realtime;
con_module->data->console->frametime = &con_frametime;
con_module->data->console->quit = Host_Quit_f;
con_module->data->console->cbuf = host_cbuf;
}

View file

@ -1023,7 +1023,7 @@ Sbar_Draw (void)
if ((sb_updates >= vid.numpages) && !headsup)
return;
if (scr_con_current == vid.height)
if (con_module && con_module->data->console->lines == vid.height)
return; // console is full screen
if (cls.state == ca_active

View file

@ -202,6 +202,10 @@ double realtime; // without any filtering or bounding
double oldrealtime; // last frame run
int host_framecount;
double con_frametime;
double con_realtime;
double oldcon_realtime;
int host_hunklevel;
byte *host_basepal;
@ -1433,6 +1437,8 @@ Host_SimulationTime (float time)
float fps, timedifference;
float timescale = 1.0;
con_realtime += time;
if (cls.demoplayback) {
timescale = max (0, demo_speed->value);
time *= timescale;
@ -1490,6 +1496,9 @@ Host_Frame (float time)
oldrealtime = realtime;
host_frametime = min (host_frametime, 0.2);
con_frametime = con_realtime - oldcon_realtime;
oldcon_realtime = con_realtime;
IN_ProcessEvents ();
// process gib threads
@ -1725,7 +1734,8 @@ Host_Init (void)
if (con_module) {
con_module->data->console->dl_name = cls.downloadname;
con_module->data->console->dl_percent = &cls.downloadpercent;
con_module->data->console->realtime = &realtime;
con_module->data->console->realtime = &con_realtime;
con_module->data->console->frametime = &con_frametime;
con_module->data->console->quit = CL_Quit_f;
con_module->data->console->cbuf = cl_cbuf;
}

View file

@ -78,7 +78,7 @@ static SCR_Func scr_funcs[] = {
SCR_DrawPause,
SCR_CheckDrawCenterString,
Sbar_Draw,
SCR_DrawConsole,
Con_DrawConsole,
0
};

View file

@ -958,7 +958,7 @@ Sbar_Draw (void)
if ((sb_updates >= vid.numpages) && !headsup)
return;
if (scr_con_current == vid.height)
if (con_module && con_module->data->console->lines == vid.height)
return;
if (cls.state == ca_active