|
1 | 1 | #include "TextRender.h"
|
2 | 2 |
|
3 |
| -#include "../Cache.h" |
4 | 3 | #include "../Constants/UiConstants.h"
|
5 | 4 |
|
6 | 5 | #include <NAS2D/Resource/Font.h>
|
7 | 6 | #include <NAS2D/Renderer/Renderer.h>
|
8 | 7 | #include <NAS2D/Utility.h>
|
9 | 8 |
|
| 9 | +#include <libControls/Control.h> |
| 10 | + |
10 | 11 |
|
11 | 12 | void drawLabelAndValue(NAS2D::Point<int> position, const std::string& title, const std::string& text, NAS2D::Color color)
|
12 | 13 | {
|
13 | 14 | auto& renderer = NAS2D::Utility<NAS2D::Renderer>::get();
|
14 | 15 |
|
15 |
| - const NAS2D::Font* FONT = &fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal); |
16 |
| - const NAS2D::Font* FONT_BOLD = &fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryNormal); |
| 16 | + const auto& font = Control::getDefaultFont(); |
| 17 | + const auto& fontBold = Control::getDefaultFontBold(); |
17 | 18 |
|
18 |
| - renderer.drawText(*FONT_BOLD, title, position, color); |
19 |
| - position.x += FONT_BOLD->width(title); |
20 |
| - renderer.drawText(*FONT, text, position, color); |
| 19 | + renderer.drawText(fontBold, title, position, color); |
| 20 | + position.x += fontBold.width(title); |
| 21 | + renderer.drawText(font, text, position, color); |
21 | 22 | }
|
22 | 23 |
|
23 | 24 | void drawLabelAndValueLeftJustify(NAS2D::Point<int> position, int labelWidth, const std::string& title, const std::string& text, NAS2D::Color color)
|
24 | 25 | {
|
25 | 26 | auto& renderer = NAS2D::Utility<NAS2D::Renderer>::get();
|
26 | 27 |
|
27 |
| - const NAS2D::Font* FONT = &fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal); |
28 |
| - const NAS2D::Font* FONT_BOLD = &fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryNormal); |
| 28 | + const auto& font = Control::getDefaultFont(); |
| 29 | + const auto& fontBold = Control::getDefaultFontBold(); |
29 | 30 |
|
30 |
| - renderer.drawText(*FONT_BOLD, title, position, color); |
| 31 | + renderer.drawText(fontBold, title, position, color); |
31 | 32 | position.x += labelWidth;
|
32 |
| - renderer.drawText(*FONT, text, position, color); |
| 33 | + renderer.drawText(font, text, position, color); |
33 | 34 | }
|
34 | 35 |
|
35 | 36 | void drawLabelAndValueRightJustify(NAS2D::Point<int> position, int labelWidth, const std::string& title, const std::string& text, NAS2D::Color color)
|
36 | 37 | {
|
37 | 38 | auto& renderer = NAS2D::Utility<NAS2D::Renderer>::get();
|
38 | 39 |
|
39 |
| - const NAS2D::Font* FONT = &fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal); |
40 |
| - const NAS2D::Font* FONT_BOLD = &fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryNormal); |
| 40 | + const auto& font = Control::getDefaultFont(); |
| 41 | + const auto& fontBold = Control::getDefaultFontBold(); |
41 | 42 |
|
42 |
| - renderer.drawText(*FONT_BOLD, title, position, color); |
43 |
| - position.x += labelWidth - FONT->width(text); |
44 |
| - renderer.drawText(*FONT, text, position, color); |
| 43 | + renderer.drawText(fontBold, title, position, color); |
| 44 | + position.x += labelWidth - font.width(text); |
| 45 | + renderer.drawText(font, text, position, color); |
45 | 46 | }
|
0 commit comments