- 2D drawer cleanup.

This commit is contained in:
Christoph Oelckers 2020-04-11 19:46:57 +02:00
commit b18faacab0
36 changed files with 1032 additions and 1147 deletions

View file

@ -220,13 +220,13 @@ public:
else
{
DrawChar(twod, CurrentConsoleFont, CR_ORANGE, x, y, '\x1c',
DTA_VirtualWidth, screen->GetWidth() / scale,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
DTA_KeepRatio, true, TAG_DONE);
DrawText(twod, CurrentConsoleFont, CR_ORANGE, x + CurrentConsoleFont->GetCharWidth(0x1c), y,
&Text[StartPos],
DTA_VirtualWidth, screen->GetWidth() / scale,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
DTA_KeepRatio, true, TAG_DONE);
@ -235,7 +235,7 @@ public:
DrawChar(twod, CurrentConsoleFont, CR_YELLOW,
x + CurrentConsoleFont->GetCharWidth(0x1c) + (CursorPosCells - StartPosCells) * CurrentConsoleFont->GetCharWidth(0xb),
y, '\xb',
DTA_VirtualWidth, screen->GetWidth() / scale,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
DTA_KeepRatio, true, TAG_DONE);
}
@ -281,7 +281,7 @@ public:
unsigned LengthCells = CalcCellSize((unsigned)Text.length());
int n = StartPosCells;
unsigned cols = ConCols / active_con_scale();
unsigned cols = ConCols / active_con_scale(twod);
if (StartPosCells >= LengthCells)
{ // Start of visible line is beyond end of line
@ -794,7 +794,7 @@ void FNotifyBuffer::AddString(int printlevel, FString source)
}
}
width = DisplayWidth / active_con_scaletext(generic_ui);
width = DisplayWidth / active_con_scaletext(twod, generic_ui);
FFont *font = generic_ui ? NewSmallFont : AlternativeSmallFont;
if (font == nullptr) return; // Without an initialized font we cannot handle the message (this is for those which come here before the font system is ready.)
@ -1112,18 +1112,18 @@ void FNotifyBuffer::Draw()
else
color = PrintColors[notify.PrintLevel];
int scale = active_con_scaletext(generic_ui);
int scale = active_con_scaletext(twod, generic_ui);
if (!center)
screen->DrawText (font, color, 0, line, notify.Text,
DTA_VirtualWidth, screen->GetWidth() / scale,
DrawText(twod, font, color, 0, line, notify.Text,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
DTA_KeepRatio, true,
DTA_Alpha, alpha, TAG_DONE);
else
screen->DrawText (font, color, (screen->GetWidth() -
DrawText(twod, font, color, (twod->GetWidth() -
font->StringWidth (notify.Text) * scale) / 2 / scale,
line, notify.Text,
DTA_VirtualWidth, screen->GetWidth() / scale,
DTA_VirtualWidth, twod->GetWidth() / scale,
DTA_VirtualHeight, screen->GetHeight() / scale,
DTA_KeepRatio, true,
DTA_Alpha, alpha, TAG_DONE);
@ -1146,7 +1146,7 @@ void C_DrawConsole ()
static int oldbottom = 0;
int lines, left, offset;
int textScale = active_con_scale();
int textScale = active_con_scale(twod);
left = LEFTMARGIN;
lines = (ConBottom/textScale-CurrentConsoleFont->GetHeight()*2)/CurrentConsoleFont->GetHeight();
@ -1174,8 +1174,8 @@ void C_DrawConsole ()
visheight = ConBottom;
screen->DrawTexture (conpic, 0, visheight - screen->GetHeight(),
DTA_DestWidth, screen->GetWidth(),
DrawTexture(twod, conpic, 0, visheight - screen->GetHeight(),
DTA_DestWidth, twod->GetWidth(),
DTA_DestHeight, screen->GetHeight(),
DTA_ColorOverlay, conshade,
DTA_Alpha, (gamestate != GS_FULLCONSOLE) ? (double)con_alpha : 1.,
@ -1183,22 +1183,22 @@ void C_DrawConsole ()
TAG_DONE);
if (conline && visheight < screen->GetHeight())
{
screen->Clear (0, visheight, screen->GetWidth(), visheight+1, 0, 0);
ClearRect(twod, 0, visheight, twod->GetWidth(), visheight+1, 0, 0);
}
if (ConBottom >= 12)
{
if (textScale == 1)
screen->DrawText (CurrentConsoleFont, CR_ORANGE, SCREENWIDTH - 8 -
DrawText(twod, CurrentConsoleFont, CR_ORANGE, SCREENWIDTH - 8 -
CurrentConsoleFont->StringWidth (GetVersionString()),
ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4,
GetVersionString(), TAG_DONE);
else
screen->DrawText(CurrentConsoleFont, CR_ORANGE, SCREENWIDTH / textScale - 8 -
DrawText(twod, CurrentConsoleFont, CR_ORANGE, SCREENWIDTH / textScale - 8 -
CurrentConsoleFont->StringWidth(GetVersionString()),
ConBottom / textScale - CurrentConsoleFont->GetHeight() - 4,
GetVersionString(),
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualWidth, twod->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
@ -1225,12 +1225,12 @@ void C_DrawConsole ()
{
if (textScale == 1)
{
screen->DrawText(CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE);
DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text, TAG_DONE);
}
else
{
screen->DrawText(CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text,
DTA_VirtualWidth, screen->GetWidth() / textScale,
DrawText(twod, CurrentConsoleFont, CR_TAN, LEFTMARGIN, offset + lines * CurrentConsoleFont->GetHeight(), p->Text,
DTA_VirtualWidth, twod->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
}
@ -1253,10 +1253,10 @@ void C_DrawConsole ()
// Indicate that the view has been scrolled up (10)
// and if we can scroll no further (12)
if (textScale == 1)
screen->DrawChar (CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE);
DrawChar(twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10, TAG_DONE);
else
screen->DrawChar(CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10,
DTA_VirtualWidth, screen->GetWidth() / textScale,
DrawChar(twod, CurrentConsoleFont, CR_GREEN, 0, bottomline, RowAdjust == conbuffer->GetFormattedLineCount() ? 12 : 10,
DTA_VirtualWidth, twod->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
}
@ -1378,7 +1378,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
case GK_PGUP:
if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
{ // Scroll console buffer up one page
RowAdjust += (SCREENHEIGHT-4)/active_con_scale() /
RowAdjust += (SCREENHEIGHT-4)/active_con_scale(twod) /
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3;
}
else if (RowAdjust < conbuffer->GetFormattedLineCount())
@ -1401,7 +1401,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer)
case GK_PGDN:
if (ev->data3 & (GKM_SHIFT|GKM_CTRL))
{ // Scroll console buffer down one page
const int scrollamt = (SCREENHEIGHT-4)/active_con_scale() /
const int scrollamt = (SCREENHEIGHT-4)/active_con_scale(twod) /
((gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) ? CurrentConsoleFont->GetHeight() : CurrentConsoleFont->GetHeight()*2) - 3;
if (RowAdjust < scrollamt)
{
@ -2034,7 +2034,7 @@ static bool C_TabCompleteList ()
Printf ("%s%-*s", colorcode, int(maxwidth), TabCommands[i].TabName.GetChars());
x += maxwidth;
if (x > ConCols / active_con_scale() - maxwidth)
if (x > ConCols / active_con_scale(twod) - maxwidth)
{
x = 0;
Printf ("\n");