MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / DisplayText

Method DisplayText

src/New/Type/DigitalDisplayTypeClass.cpp:75–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void DigitalDisplayTypeClass::DisplayText(Point2D& position, int length, int value, int maxValue, bool isBuilding, bool isInfantry, bool hasShield)
76{
77 wchar_t text[0x20];
78
79 if (Percentage.Get())
80 {
81 swprintf_s(text, L"%d", static_cast<int>((static_cast<double>(value) / maxValue) * 100));
82 wcscat_s(text, L"%%");
83 }
84 else if (HideMaxValue.Get(isInfantry))
85 {
86 swprintf_s(text, L"%d", value);
87 }
88 else
89 {
90 swprintf_s(text, L"%d/%d", value, maxValue);
91 }
92
93 double ratio = static_cast<double>(value) / maxValue;
94 COLORREF color = Drawing::RGB_To_Int(Text_Color.Get(ratio));
95 RectangleStruct rect = DSurface::Composite->GetRect();
96 rect.Height -= 32; // account for bottom bar
97 const int textHeight = 12;
98 const int pipsHeight = hasShield ? 4 : 0;
99
100 if (AnchorType.Vertical == VerticalPosition::Top)
101 position.Y -= textHeight + pipsHeight; // upper of healthbar and shieldbar
102
103 TextPrintType printType = static_cast<TextPrintType>(Align.Get())
104 | TextPrintType::FullShadow
105 | (Text_Background ? TextPrintType::Background : TextPrintType::LASTPOINT);
106
107 DSurface::Composite->DrawTextA(text, &rect, &position, color, 0, printType);
108}
109
110void DigitalDisplayTypeClass::DisplayShape(Point2D& position, int length, int value, int maxValue, bool isBuilding, bool isInfantry, bool hasShield)
111{

Callers

nothing calls this directly

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected