]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
reworked console rendering, now uses con_backscroll in a much more
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 27 Dec 2009 13:04:00 +0000 (13:04 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 27 Dec 2009 13:04:00 +0000 (13:04 +0000)
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

console.c
keys.c

index 32cacb17f0d1ee4d8bdaede52b658448c6161cd0..36fe15ce7dd65839d1f8b6d397ba114be47e05af 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1660,28 +1660,6 @@ void Con_DrawNotify (void)
        }
 }
 
-/*
-================
-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
@@ -1689,13 +1667,21 @@ Con_LineHeight
 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;
 }
 
 /*
@@ -1731,6 +1717,7 @@ int Con_DrawConsoleLine(float y, int lineno, float ymin, float ymax)
        return COM_Wordwrap(li->start, li->len, 0, width, Con_WordWidthFunc, &ti, Con_DisplayLineFunc, &ti);
 }
 
+#if 0
 /*
 ================
 Con_LastVisibleLine
@@ -1739,7 +1726,7 @@ Calculates the last visible line index and how much to show of it based on
 con_backscroll.
 ================
 */
-void Con_LastVisibleLine(int *last, int *limitlast)
+static void Con_LastVisibleLine(int *last, int *limitlast)
 {
        int lines_seen = 0;
        int i;
@@ -1770,6 +1757,7 @@ void Con_LastVisibleLine(int *last, int *limitlast)
                // FIXME uses con in a non abstracted way
        *limitlast = 1;
 }
+#endif
 
 /*
 ================
@@ -1781,12 +1769,12 @@ The typing input line at the bottom should only be drawn if typing is allowed
 */
 void Con_DrawConsole (int lines)
 {
-       int i, last, limitlast;
-       float y;
-
        if (lines <= 0)
                return;
 
+       if (con_backscroll < 0)
+               con_backscroll = 0;
+
        con_vislines = lines;
 
 // draw the background
@@ -1794,8 +1782,27 @@ void Con_DrawConsole (int lines)
        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)
        {
+               int i, last, limitlast;
+               float y;
                float ymax = con_vislines - 2 * con_textsize.value;
                Con_LastVisibleLine(&last, &limitlast);
                y = ymax - con_textsize.value;
@@ -1816,6 +1823,7 @@ void Con_DrawConsole (int lines)
                        --i;
                }
        }
+#endif
 
 // draw the input prompt, user text, and cursor if desired
        Con_DrawInput ();
diff --git a/keys.c b/keys.c
index d9d7d067d1cf5789711c03093ea21fdd2d7c15ba..e0177edbb5fd7f051f2afaa52c09563102868379 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -921,7 +921,7 @@ Key_Console (int key, int unicode)
        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;