|
@@ -11,9 +11,18 @@
|
|
|
#include "StdInc.h"
|
|
|
#include "IFont.h"
|
|
|
|
|
|
+#include "../gui/CGuiHandler.h"
|
|
|
+
|
|
|
+#include "../render/IScreenHandler.h"
|
|
|
+
|
|
|
#include "../../lib/Point.h"
|
|
|
#include "../../lib/texts/TextOperations.h"
|
|
|
|
|
|
+int IFont::getScalingFactor() const
|
|
|
+{
|
|
|
+ return GH.screenHandler().getScalingFactor();
|
|
|
+}
|
|
|
+
|
|
|
size_t IFont::getStringWidth(const std::string & data) const
|
|
|
{
|
|
|
size_t width = 0;
|
|
@@ -32,13 +41,13 @@ void IFont::renderTextLeft(SDL_Surface * surface, const std::string & data, cons
|
|
|
|
|
|
void IFont::renderTextRight(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const
|
|
|
{
|
|
|
- Point size((int)getStringWidth(data), (int)getLineHeight());
|
|
|
+ Point size = Point((int)getStringWidth(data), (int)getLineHeight()) * getScalingFactor();
|
|
|
renderText(surface, data, color, pos - size);
|
|
|
}
|
|
|
|
|
|
void IFont::renderTextCenter(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const
|
|
|
{
|
|
|
- Point size((int)getStringWidth(data), (int)getLineHeight());
|
|
|
+ Point size = Point((int)getStringWidth(data), (int)getLineHeight()) * getScalingFactor();
|
|
|
renderText(surface, data, color, pos - size / 2);
|
|
|
}
|
|
|
|
|
@@ -49,31 +58,31 @@ void IFont::renderTextLinesLeft(SDL_Surface * surface, const std::vector<std::st
|
|
|
for(const std::string & line : data)
|
|
|
{
|
|
|
renderTextLeft(surface, line, color, currPos);
|
|
|
- currPos.y += (int)getLineHeight();
|
|
|
+ currPos.y += getLineHeight() * getScalingFactor();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void IFont::renderTextLinesRight(SDL_Surface * surface, const std::vector<std::string> & data, const ColorRGBA & color, const Point & pos) const
|
|
|
{
|
|
|
Point currPos = pos;
|
|
|
- currPos.y -= (int)data.size() * (int)getLineHeight();
|
|
|
+ currPos.y -= (int)data.size() * (int)getLineHeight() * getScalingFactor();
|
|
|
|
|
|
for(const std::string & line : data)
|
|
|
{
|
|
|
renderTextRight(surface, line, color, currPos);
|
|
|
- currPos.y += (int)getLineHeight();
|
|
|
+ currPos.y += getLineHeight() * getScalingFactor();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void IFont::renderTextLinesCenter(SDL_Surface * surface, const std::vector<std::string> & data, const ColorRGBA & color, const Point & pos) const
|
|
|
{
|
|
|
Point currPos = pos;
|
|
|
- currPos.y -= (int)data.size() * (int)getLineHeight() / 2;
|
|
|
+ currPos.y -= (int)data.size() * (int)getLineHeight() / 2 * getScalingFactor();
|
|
|
|
|
|
for(const std::string & line : data)
|
|
|
{
|
|
|
renderTextCenter(surface, line, color, currPos);
|
|
|
- currPos.y += (int)getLineHeight();
|
|
|
+ currPos.y += getLineHeight() * getScalingFactor();
|
|
|
}
|
|
|
}
|
|
|
|