diff --git a/doomsday/engine/portable/include/con_main.h b/doomsday/engine/portable/include/con_main.h index ef4069c147..0a0364a8c0 100644 --- a/doomsday/engine/portable/include/con_main.h +++ b/doomsday/engine/portable/include/con_main.h @@ -177,11 +177,13 @@ boolean Con_IsLocked(void); boolean Con_InputMode(void); -uint Con_CursorPosition(void); - char* Con_CommandLine(void); -cbuffer_t* Con_ConsoleBuffer(void); +uint Con_CommandLineCursorPosition(void); + +cbuffer_t* Con_HistoryBuffer(void); + +void Con_ResizeHistoryBuffer(void); fontnum_t Con_Font(void); diff --git a/doomsday/engine/portable/src/con_busy.c b/doomsday/engine/portable/src/con_busy.c index 5cff1ea44a..45bdd2c8da 100644 --- a/doomsday/engine/portable/src/con_busy.c +++ b/doomsday/engine/portable/src/con_busy.c @@ -566,7 +566,7 @@ void Con_BusyDrawConsoleOutput(void) float y, topY; uint i, newCount; - buffer = Con_ConsoleBuffer(); + buffer = Con_HistoryBuffer(); newCount = GetBufLines(buffer, visibleBusyLines); nowTime = Sys_GetRealSeconds(); if(newCount > 0) diff --git a/doomsday/engine/portable/src/con_main.c b/doomsday/engine/portable/src/con_main.c index e3854f5e34..7972748483 100644 --- a/doomsday/engine/portable/src/con_main.c +++ b/doomsday/engine/portable/src/con_main.c @@ -226,25 +226,33 @@ void Con_Register(void) Con_DataRegister(); } -static void resizeHistoryBuffer(void) +void Con_ResizeHistoryBuffer(void) { - assert(ConsoleInited); - { int maxLength = 70; - float cw; - - FR_SetFont(consoleFont); - FR_LoadDefaultAttrib(); - FR_SetTracking(consoleFontTracking); - FR_SetLeading(consoleFontLeading); - cw = (FR_TextWidth("AA") * consoleFontScale[0]) / 2; - if(0 != cw) + if(!ConsoleInited) { - maxLength = MIN_OF(theWindow->width / cw - 2, 250); + Con_Error("Con_ResizeHistoryBuffer: Console is not yet initialised."); + exit(1); // Unreachable. } - Con_BufferSetMaxLineLength(Con_ConsoleBuffer(), maxLength); + + if(!novideo && !isDedicated) + { + float cw; + + FR_SetFont(consoleFont); + FR_LoadDefaultAttrib(); + FR_SetTracking(consoleFontTracking); + FR_SetLeading(consoleFontLeading); + + cw = (FR_TextWidth("AA") * consoleFontScale[0]) / 2; + if(0 != cw) + { + maxLength = MIN_OF(theWindow->width / cw - 2, 250); + } } + + Con_BufferSetMaxLineLength(Con_HistoryBuffer(), maxLength); } static void PrepareCmdArgs(cmdargs_t *cargs, const char *lpCmdLine) @@ -427,12 +435,12 @@ char* Con_CommandLine(void) return cmdLine; } -cbuffer_t* Con_ConsoleBuffer(void) +cbuffer_t* Con_HistoryBuffer(void) { return histBuf; } -uint Con_CursorPosition(void) +uint Con_CommandLineCursorPosition(void) { return cmdCursor; } @@ -451,7 +459,7 @@ void Con_SetFont(fontnum_t font) if(consoleFont == font) return; consoleFont = font; - resizeHistoryBuffer(); + Con_ResizeHistoryBuffer(); } con_textfilter_t Con_PrintFilter(void) @@ -486,7 +494,7 @@ void Con_SetFontScale(float scaleX, float scaleY) consoleFontScale[0] = MAX_OF(.5f, scaleX); if(scaleY > 0.0001f) consoleFontScale[1] = MAX_OF(.5f, scaleY); - resizeHistoryBuffer(); + Con_ResizeHistoryBuffer(); } float Con_FontLeading(void) @@ -501,7 +509,7 @@ void Con_SetFontLeading(float value) if(!ConsoleInited) Con_Error("Con_SetFontLeading: Console is not yet initialised."); consoleFontLeading = MAX_OF(.1f, value); - resizeHistoryBuffer(); + Con_ResizeHistoryBuffer(); } int Con_FontTracking(void) @@ -516,7 +524,7 @@ void Con_SetFontTracking(int value) if(!ConsoleInited) Con_Error("Con_SetFontTracking: Console is not yet initialised."); consoleFontTracking = MAX_OF(0, value); - resizeHistoryBuffer(); + Con_ResizeHistoryBuffer(); } /** diff --git a/doomsday/engine/portable/src/rend_console.c b/doomsday/engine/portable/src/rend_console.c index 9b9deba1e9..3341eeb78e 100644 --- a/doomsday/engine/portable/src/rend_console.c +++ b/doomsday/engine/portable/src/rend_console.c @@ -589,8 +589,8 @@ static void drawConsole(float consoleAlpha) static const cbline_t** lines = 0; static int bufferSize = 0; - cbuffer_t* buffer = Con_ConsoleBuffer(); - uint cmdCursor = Con_CursorPosition(); + cbuffer_t* buffer = Con_HistoryBuffer(); + uint cmdCursor = Con_CommandLineCursorPosition(); char* cmdLine = Con_CommandLine(); float scale[2], y, fontScaledY, gtosMulY = theWindow->height / 200.0f; char buff[LOCALBUFFSIZE]; @@ -714,9 +714,8 @@ static void drawConsole(float consoleAlpha) y = ConsoleY * gtosMulY - (lineHeight * scale[1]) - textOffsetY; - cmdLineLength = strlen(cmdLine); - maxLineLength = Con_BufferMaxLineLength(buffer); - maxLineLength -= 1; /*prompt length*/ + cmdLineLength = (uint)strlen(cmdLine); + maxLineLength = Con_BufferMaxLineLength(buffer) - 1/*prompt length*/; if(cmdLineLength >= maxLineLength) {