Skip to content

Commit 24a234b

Browse files
authored
Merge pull request #1590 from OutpostUniverse/useGetDefaultFont
Use `getDefaultFont()`
2 parents 3b2608a + 9cfc8cd commit 24a234b

17 files changed

+39
-38
lines changed

appOPHD/States/MainMenuState.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void MainMenuState::initialize()
5959
mFileIoDialog.anchored(false);
6060
mFileIoDialog.hide();
6161

62-
const NAS2D::Font* tiny_font = &fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal);
62+
const NAS2D::Font* tiny_font = &Control::getDefaultFont();
6363
lblVersion.font(tiny_font);
6464
lblVersion.color(NAS2D::Color::White);
6565

appOPHD/States/MapViewState.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "../Constants/Strings.h"
1111
#include "../Constants/UiConstants.h"
1212

13-
#include "../Cache.h"
1413
#include "../PointerType.h"
1514
#include "../MeanSolarDistance.h"
1615
#include "../ProductCatalogue.h"
@@ -297,7 +296,7 @@ void MapViewState::initialize()
297296

298297
eventHandler.textInputMode(true);
299298

300-
MAIN_FONT = &fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal);
299+
MAIN_FONT = &Control::getDefaultFont();
301300

302301
mPathSolver = std::make_unique<micropather::MicroPather>(mTileMap.get(), 250, 6, false);
303302
}

appOPHD/States/MapViewStateDraw.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "Route.h"
88

99
#include "../Constants/UiConstants.h"
10-
#include "../Cache.h"
1110
#include "../StructureManager.h"
1211
#include "../Map/TileMap.h"
1312
#include "../MapObjects/Mine.h"
@@ -32,7 +31,7 @@ void MapViewState::drawSystemButton() const
3231
// Turns
3332
const auto turnImageRect = NAS2D::Rectangle<int>{{128, 0}, {constants::ResourceIconSize, constants::ResourceIconSize}};
3433
renderer.drawSubImage(mUiIcons, position, turnImageRect);
35-
const auto& font = fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal);
34+
const auto& font = Control::getDefaultFont();
3635
renderer.drawText(font, std::to_string(mTurnCount), position + textOffset, NAS2D::Color::White);
3736

3837
position = mTooltipSystemButton.rect().position + NAS2D::Vector{constants::MarginTight, constants::MarginTight};

appOPHD/States/PlanetSelectState.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace
3030

3131
PlanetSelectState::PlanetSelectState() :
3232
mFontBold{fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryMedium)},
33-
mTinyFont{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal)},
33+
mTinyFont{Control::getDefaultFont()},
3434
mBg{"sys/bg1.png"},
3535
mCloud1{"sys/cloud_1.png"},
3636
mCloud2{"sys/cloud_2.png"},

appOPHD/UI/GameOverDialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ void GameOverDialog::update()
4040

4141
renderer.drawImage(mHeader, position() + NAS2D::Vector{5, 25});
4242

43-
const auto& font = fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal);
43+
const auto& font = Control::getDefaultFont();
4444
renderer.drawText(font, "You have failed. Your colony is dead.", position() + NAS2D::Vector{5, 290}, NAS2D::Color::White);
4545
}

appOPHD/UI/IconGrid.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using namespace NAS2D;
1616

1717

1818
IconGrid::IconGrid(const std::string& filePath, int iconEdgeSize, int margin) :
19-
mFont{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal)},
19+
mFont{Control::getDefaultFont()},
2020
mIconSize{iconEdgeSize},
2121
mIconMargin{margin},
2222
mIconSheet{imageCache.load(filePath)},

appOPHD/UI/MajorEventAnnouncement.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ void MajorEventAnnouncement::update()
5353

5454
renderer.drawImage(mHeader, position() + NAS2D::Vector{5, 25});
5555

56-
const auto& font = fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal);
56+
const auto& font = Control::getDefaultFont();
5757
renderer.drawText(font, mMessage, position() + NAS2D::Vector{5, 290}, NAS2D::Color::White);
5858
}

appOPHD/UI/MineOperationsWindow.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ using namespace NAS2D;
2323

2424
MineOperationsWindow::MineOperationsWindow() :
2525
Window{constants::WindowMineOperations},
26-
mFont{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal)},
27-
mFontBold{fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryNormal)},
26+
mFont{Control::getDefaultFont()},
27+
mFontBold{Control::getDefaultFontBold()},
2828
mUiIcon{imageCache.load("ui/interface/mine.png")},
2929
mIcons{imageCache.load("ui/icons.png")},
3030
mPanel{

appOPHD/UI/NavControl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void NavControl::draw() const
101101
}
102102

103103
// Display the levels "bar"
104-
const auto& font = fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal);
104+
const auto& font = Control::getDefaultFont();
105105
const auto stepSizeWidth = font.width("IX");
106106
auto position = mRect.endPoint() - NAS2D::Vector{5, 30 - constants::Margin};
107107
for (int i = mMapView.maxDepth(); i >= 0; i--)

appOPHD/UI/NotificationArea.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void drawNotificationIcon(NAS2D::Point<int> position, NotificationArea::Notifica
5151

5252
NotificationArea::NotificationArea() :
5353
mIcons{imageCache.load("ui/icons.png")},
54-
mFont{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal)},
54+
mFont{Control::getDefaultFont()},
5555
mNotificationIndex{NoSelection}
5656
{
5757
auto& eventhandler = Utility<EventHandler>::get();

appOPHD/UI/PopulationPanel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ namespace
4646

4747

4848
PopulationPanel::PopulationPanel(const Population& pop, const PopulationPool& popPool, const Morale& morale) :
49-
mFont{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal)},
50-
mFontBold{fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryNormal)},
49+
mFont{Control::getDefaultFont()},
50+
mFontBold{Control::getDefaultFontBold()},
5151
mIcons{imageCache.load("ui/icons.png")},
5252
mSkin
5353
{

appOPHD/UI/Reports/FactoryReport.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace
5151

5252

5353
FactoryReport::FactoryReport() :
54-
font{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal)},
54+
font{Control::getDefaultFont()},
5555
fontMedium{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryMedium)},
5656
fontMediumBold{fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryMedium)},
5757
fontBigBold{fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryHuge)},

appOPHD/UI/Reports/MineReport.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ using namespace NAS2D;
3030

3131

3232
MineReport::MineReport() :
33-
font{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal)},
34-
fontBold{fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryNormal)},
33+
font{Control::getDefaultFont()},
34+
fontBold{Control::getDefaultFontBold()},
3535
fontMedium{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryMedium)},
3636
fontMediumBold{fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryMedium)},
3737
fontBigBold{fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryHuge)},

appOPHD/UI/ResourceBreakdownPanel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace
2727

2828

2929
ResourceBreakdownPanel::ResourceBreakdownPanel() :
30-
mFont{fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal)},
30+
mFont{Control::getDefaultFont()},
3131
mIcons{imageCache.load("ui/icons.png")},
3232
mSkin{
3333
imageCache.load("ui/skin/window_top_left.png"),

appOPHD/UI/RobotInspector.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ RobotInspector::RobotInspector() :
3535
btnSelfDestruct{"Self Destruct", {this, &RobotInspector::onSelfDestruct}},
3636
btnCancel{constants::Cancel, {this, &RobotInspector::onCancel}}
3737
{
38-
const NAS2D::Font& mainFont = fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal);
39-
const NAS2D::Font& mainFontBold = fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryNormal);
38+
const NAS2D::Font& mainFont = Control::getDefaultFont();
39+
const NAS2D::Font& mainFontBold = Control::getDefaultFontBold();
4040

4141
constexpr int padding = constants::Margin * 2;
4242
const auto buttonSize = mainFont.size("Cancel Orders") + NAS2D::Vector{padding, padding};

appOPHD/UI/StringTable.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <NAS2D/Utility.h>
77
#include <NAS2D/Renderer/Renderer.h>
88

9+
#include <libControls/Control.h>
10+
911
#include <stdexcept>
1012
#include <algorithm>
1113

@@ -24,8 +26,8 @@ StringTable::StringTable(std::size_t columns, std::size_t rows) :
2426
{
2527
mCells.resize(columns * rows);
2628

27-
mDefaultFont = &fontCache.load(constants::FONT_PRIMARY, constants::FontPrimaryNormal);
28-
mDefaultTitleFont = &fontCache.load(constants::FONT_PRIMARY_BOLD, constants::FontPrimaryNormal);
29+
mDefaultFont = &Control::getDefaultFont();
30+
mDefaultTitleFont = &Control::getDefaultFontBold();
2931
}
3032

3133
void StringTable::draw(NAS2D::Renderer& renderer) const

appOPHD/UI/TextRender.cpp

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
11
#include "TextRender.h"
22

3-
#include "../Cache.h"
43
#include "../Constants/UiConstants.h"
54

65
#include <NAS2D/Resource/Font.h>
76
#include <NAS2D/Renderer/Renderer.h>
87
#include <NAS2D/Utility.h>
98

9+
#include <libControls/Control.h>
10+
1011

1112
void drawLabelAndValue(NAS2D::Point<int> position, const std::string& title, const std::string& text, NAS2D::Color color)
1213
{
1314
auto& renderer = NAS2D::Utility<NAS2D::Renderer>::get();
1415

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();
1718

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);
2122
}
2223

2324
void drawLabelAndValueLeftJustify(NAS2D::Point<int> position, int labelWidth, const std::string& title, const std::string& text, NAS2D::Color color)
2425
{
2526
auto& renderer = NAS2D::Utility<NAS2D::Renderer>::get();
2627

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();
2930

30-
renderer.drawText(*FONT_BOLD, title, position, color);
31+
renderer.drawText(fontBold, title, position, color);
3132
position.x += labelWidth;
32-
renderer.drawText(*FONT, text, position, color);
33+
renderer.drawText(font, text, position, color);
3334
}
3435

3536
void drawLabelAndValueRightJustify(NAS2D::Point<int> position, int labelWidth, const std::string& title, const std::string& text, NAS2D::Color color)
3637
{
3738
auto& renderer = NAS2D::Utility<NAS2D::Renderer>::get();
3839

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();
4142

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);
4546
}

0 commit comments

Comments
 (0)