Skip to content

Commit

Permalink
- validate text data before drawing the console.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Sep 14, 2023
1 parent ffa7891 commit 30c2524
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions src/common/console/c_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,48 +648,51 @@ void C_DrawConsole ()
conbuffer->FormatText(CurrentConsoleFont, ConWidth / textScale);
unsigned int consolelines = conbuffer->GetFormattedLineCount();
FBrokenLines *blines = conbuffer->GetLines();
FBrokenLines *printline = blines + consolelines - 1 - RowAdjust;

int bottomline = ConBottom / textScale - CurrentConsoleFont->GetHeight()*2 - 4;

for(FBrokenLines *p = printline; p >= blines && lines > 0; p--, lines--)
if (blines != nullptr)
{
if (textScale == 1)
{
DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE);
}
else
{
DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text,
DTA_VirtualWidth, twod->GetWidth() / textScale,
DTA_VirtualHeight, twod->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
}
}
FBrokenLines* printline = blines + consolelines - 1 - RowAdjust;

if (ConBottom >= 20)
{
if (gamestate != GS_STARTUP)
int bottomline = ConBottom / textScale - CurrentConsoleFont->GetHeight() * 2 - 4;

for (FBrokenLines* p = printline; p >= blines && lines > 0; p--, lines--)
{
auto now = I_msTime();
if (now > CursorTicker)
if (textScale == 1)
{
CursorTicker = now + 500;
cursoron = !cursoron;
DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE);
}
CmdLine.Draw(left, bottomline, textScale, cursoron);
}
if (RowAdjust && ConBottom >= CurrentConsoleFont->GetHeight()*7/2)
{
// Indicate that the view has been scrolled up (10)
// and if we can scroll no further (12)
if (textScale == 1)
DrawChar(twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE);
else
DrawChar(twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10,
{
DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text,
DTA_VirtualWidth, twod->GetWidth() / textScale,
DTA_VirtualHeight, twod->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
}
}

if (ConBottom >= 20)
{
if (gamestate != GS_STARTUP)
{
auto now = I_msTime();
if (now > CursorTicker)
{
CursorTicker = now + 500;
cursoron = !cursoron;
}
CmdLine.Draw(left, bottomline, textScale, cursoron);
}
if (RowAdjust && ConBottom >= CurrentConsoleFont->GetHeight() * 7 / 2)
{
// Indicate that the view has been scrolled up (10)
// and if we can scroll no further (12)
if (textScale == 1)
DrawChar(twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE);
else
DrawChar(twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10,
DTA_VirtualWidth, twod->GetWidth() / textScale,
DTA_VirtualHeight, twod->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
}
}
}
}
Expand Down

0 comments on commit 30c2524

Please sign in to comment.