MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / DrawFinishTexts

Method DrawFinishTexts

engine/Poseidon/Graphics/Core/EngineDrawing.cpp:33–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31{
32
33void Engine::DrawFinishTexts()
34{
35#ifndef ACCESS_ONLY
36 if (ShowFps() >= 1)
37 {
38 // TahomaB24 is hinted for screen at small sizes (the bigger B36
39 // variant rasterised crisp but the readout took up ~half the
40 // screen at 11 lines). size=0.025 → 15-px tall; integer-pixel
41 // shadow keeps it sharp.
42 Ref<Font> font = LoadFont(GetFontID("TahomaB24"));
43 PoseidonAssert(font);
44 const float size = 0.025f;
45
46 float fps = (_lastFrameDuration > 0) ? 1000.0f / _lastFrameDuration : 1000.0f;
47 float afps = 1000.0f / GetAvgFrameDuration();
48 float aLod = -10 * log10f(GScene->GetLodInvWidth());
49
50 const float margin = 0.01f;
51 const PackedColor color(Color(1.0f, 0.9f, 0.8f, 1.0f));
52 float y = margin;
53 // Integer-pixel shadow offset: sub-pixel offsets land both copies
54 // on the same texel and the alpha-blend just hazes the glyph
55 // edges instead of producing a clean drop-shadow.
56 const float xso = 1.0f / Width2D();
57 const float yso = 1.0f / Height2D();
58
59 auto drawRight = [&](float yPos, const char* fmt, double val)
60 {
61 char buf[64];
62 snprintf(buf, sizeof(buf), fmt, val);
63 float w = GetTextWidth(size, font, buf);
64 float x = 1.0f - margin - w;
65 DrawTextF(Point2DFloat(x + xso, yPos + yso), size, font, PackedBlack, "%s", buf);
66 DrawTextF(Point2DFloat(x, yPos), size, font, color, "%s", buf);
67 };
68
69 drawRight(y, "iFPS %7.2f", fps);
70 y += size;
71 drawRight(y, "aFPS %7.2f", afps);
72 y += size;
73 drawRight(y, "aLOD %7d", (int)aLod);
74 y += size;
75 }
76
77 // Viewer-mode help overlay (FreeType monospaced — see --fps comment
78 // above). `?` toggles visibility; --no-help starts hidden. When
79 // hidden we draw the "Press ? for help" hint so the keymap is
80 // discoverable. Cursor itself is rendered by ICursorOverlay
81 // wired in World::Init — not here. This block stays gated on
82 // IsViewerMode() because the help overlay text is genuinely
83 // viewer-specific (game mode has no equivalent help screen).
84 if (AppConfig::Instance().IsViewerMode() && GLOB_ENGINE && GLOB_ENGINE->TextBank())
85 {
86 static bool helpVisible = !AppConfig::Instance().ViewerNoHelp();
87 static bool toggleLatched = false;
88 auto& input = InputSubsystem::Instance();
89 // F1 is the universal toggle (works on every keyboard layout).
90 // Shift+/ is the secondary "?" combo — on US ANSI it produces `?`,

Callers

nothing calls this directly

Calls 15

GetFontIDFunction · 0.85
ColorClass · 0.85
GetLodInvWidthMethod · 0.80
IsViewerModeMethod · 0.80
ViewerNoHelpMethod · 0.80
IsKeyDownMethod · 0.80
GetCursorOverlayMethod · 0.80
Point2DFloatClass · 0.70
Rect2DPixelClass · 0.70
TextBankMethod · 0.45
IsLockedMethod · 0.45
UseMipmapMethod · 0.45

Tested by

no test coverage detected