MCPcopy Create free account
hub / github.com/ZDoom/Raze / CT_Drawer

Function CT_Drawer

source/core/ct_chat.cpp:222–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220//===========================================================================
221
222void CT_Drawer (void)
223{
224 auto drawer = twod;
225 FFont *displayfont = NewConsoleFont;
226
227 if (chatmodeon)
228 {
229 FStringf prompt("%s ", GStrings.GetString("TXT_SAY"));
230 int x, scalex, y, promptwidth;
231
232
233 scalex = 1;
234 int scale = active_con_scale(drawer);
235 int screen_width = twod->GetWidth() / scale;
236 int screen_height= twod->GetHeight() / scale;
237
238 y = screen_height - displayfont->GetHeight()-2;
239 auto res = GetReservedScreenSpace(hud_size);
240
241 promptwidth = displayfont->StringWidth (prompt) * scalex;
242 x = displayfont->GetCharWidth (displayfont->GetCursor()) * scalex * 2 + promptwidth;
243
244 FString printstr = ChatQueue;
245 // figure out if the text is wider than the screen
246 // if so, only draw the right-most portion of it.
247 const uint8_t *textp = (const uint8_t*)printstr.GetChars();
248 while(*textp)
249 {
250 auto textw = displayfont->StringWidth(textp);
251 if (x + textw * scalex < screen_width) break;
252 GetCharFromString(textp);
253 }
254 printstr += displayfont->GetCursor();
255
256 twod->AddColorOnlyQuad(0, y, screen_width, screen_height, 0x80000000);
257 DrawText(drawer, displayfont, CR_GREEN, 0, y, prompt.GetChars(),
258 DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE);
259 DrawText(drawer, displayfont, CR_GREY, promptwidth, y, printstr.GetChars(),
260 DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE);
261 }
262}
263
264//===========================================================================
265//

Callers 1

DrawOverlaysFunction · 0.85

Calls 12

active_con_scaleFunction · 0.85
GetReservedScreenSpaceFunction · 0.85
DrawTextFunction · 0.85
GetCursorMethod · 0.80
AddColorOnlyQuadMethod · 0.80
GetCharFromStringFunction · 0.50
GetStringMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45
StringWidthMethod · 0.45
GetCharWidthMethod · 0.45
GetCharsMethod · 0.45

Tested by

no test coverage detected