direct way and has no glitches with developer cvar being toggled
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9707
d7cf8633-e32d-0410-b094-
e92efae38249
-/*
-================
-Con_MeasureConsoleLine
-
-Counts the number of lines for a line on the console.
-================
-*/
-int Con_MeasureConsoleLine(int lineno)
-{
- float width = vid_conwidth.value;
- con_text_info_t ti;
- con_lineinfo_t *li = &CON_LINES(lineno);
-
- //if(con.lines[lineno].mask & CON_MASK_LOADEDHISTORY)
- // return 0;
-
- ti.fontsize = con_textsize.value;
- ti.font = FONT_CONSOLE;
-
- return COM_Wordwrap(li->start, li->len, 0, width, Con_WordWidthFunc, &ti, Con_CountLineFunc, NULL);
-}
-
/*
================
Con_LineHeight
/*
================
Con_LineHeight
Returns the height of a given console line; calculates it if necessary.
================
*/
Returns the height of a given console line; calculates it if necessary.
================
*/
-int Con_LineHeight(int i)
+int Con_LineHeight(int lineno)
- con_lineinfo_t *li = &CON_LINES(i);
- int h = li->height;
- if(h != -1)
- return h;
- return li->height = Con_MeasureConsoleLine(i);
+ con_lineinfo_t *li = &CON_LINES(lineno);
+ if ((li->mask & CON_MASK_DEVELOPER) && !developer.integer)
+ return 0;
+ if(li->height == -1)
+ {
+ float width = vid_conwidth.value;
+ con_text_info_t ti;
+ con_lineinfo_t *li = &CON_LINES(lineno);
+ ti.fontsize = con_textsize.value;
+ ti.font = FONT_CONSOLE;
+ li->height = COM_Wordwrap(li->start, li->len, 0, width, Con_WordWidthFunc, &ti, Con_CountLineFunc, NULL);
+ }
+ return li->height;
return COM_Wordwrap(li->start, li->len, 0, width, Con_WordWidthFunc, &ti, Con_DisplayLineFunc, &ti);
}
return COM_Wordwrap(li->start, li->len, 0, width, Con_WordWidthFunc, &ti, Con_DisplayLineFunc, &ti);
}
/*
================
Con_LastVisibleLine
/*
================
Con_LastVisibleLine
con_backscroll.
================
*/
con_backscroll.
================
*/
-void Con_LastVisibleLine(int *last, int *limitlast)
+static void Con_LastVisibleLine(int *last, int *limitlast)
{
int lines_seen = 0;
int i;
{
int lines_seen = 0;
int i;
// FIXME uses con in a non abstracted way
*limitlast = 1;
}
// FIXME uses con in a non abstracted way
*limitlast = 1;
}
*/
void Con_DrawConsole (int lines)
{
*/
void Con_DrawConsole (int lines)
{
- int i, last, limitlast;
- float y;
-
+ if (con_backscroll < 0)
+ con_backscroll = 0;
+
con_vislines = lines;
// draw the background
con_vislines = lines;
// draw the background
DrawQ_String_Font(vid_conwidth.integer - DrawQ_TextWidth_Font(engineversion, 0, false, FONT_CONSOLE) * con_textsize.value, lines - con_textsize.value, engineversion, 0, con_textsize.value, con_textsize.value, 1, 0, 0, 1, 0, NULL, true, FONT_CONSOLE);
// draw the text
DrawQ_String_Font(vid_conwidth.integer - DrawQ_TextWidth_Font(engineversion, 0, false, FONT_CONSOLE) * con_textsize.value, lines - con_textsize.value, engineversion, 0, con_textsize.value, con_textsize.value, 1, 0, 0, 1, 0, NULL, true, FONT_CONSOLE);
// draw the text
+#if 1
+ {
+ int i;
+ int count = CON_LINES_COUNT;
+ float ymax = con_vislines - 2 * con_textsize.value;
+ float y = ymax + con_textsize.value * con_backscroll;
+ for (i = 0;i < count && y >= 0;i++)
+ y -= Con_DrawConsoleLine(y - con_textsize.value, CON_LINES_COUNT - 1 - i, 0, ymax) * con_textsize.value;
+ // fix any excessive scrollback for the next frame
+ if (i >= count && y >= 0)
+ {
+ con_backscroll -= (int)(y / con_textsize.value);
+ if (con_backscroll < 0)
+ con_backscroll = 0;
+ }
+ }
+#else
if(CON_LINES_COUNT > 0)
{
if(CON_LINES_COUNT > 0)
{
+ int i, last, limitlast;
+ float y;
float ymax = con_vislines - 2 * con_textsize.value;
Con_LastVisibleLine(&last, &limitlast);
y = ymax - con_textsize.value;
float ymax = con_vislines - 2 * con_textsize.value;
Con_LastVisibleLine(&last, &limitlast);
y = ymax - con_textsize.value;
// draw the input prompt, user text, and cursor if desired
Con_DrawInput ();
// draw the input prompt, user text, and cursor if desired
Con_DrawInput ();
if (key == K_HOME || key == K_KP_HOME)
{
if (keydown[K_CTRL])
if (key == K_HOME || key == K_KP_HOME)
{
if (keydown[K_CTRL])
- con_backscroll = INT_MAX;
+ con_backscroll = CON_TEXTSIZE;
else
key_linepos = 1;
return;
else
key_linepos = 1;
return;