2016-03-20 00:32:30 +00:00
|
|
|
#include "CFontImageDef.hpp"
|
2017-01-30 04:16:20 +00:00
|
|
|
#include "Graphics/CTexture.hpp"
|
2016-03-20 00:32:30 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2017-01-29 03:58:16 +00:00
|
|
|
CFontImageDef::CFontImageDef(const std::vector<TToken<CTexture>>& texs,
|
2017-01-30 06:58:59 +00:00
|
|
|
float interval, const zeus::CVector2f& cropFactor)
|
|
|
|
: x0_fps(interval), x14_cropFactor(cropFactor)
|
2016-03-20 00:32:30 +00:00
|
|
|
{
|
2017-01-29 03:58:16 +00:00
|
|
|
x4_texs.reserve(texs.size());
|
|
|
|
for (const TToken<CTexture>& tok : texs)
|
|
|
|
x4_texs.push_back(tok);
|
2016-03-20 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
2017-01-30 06:58:59 +00:00
|
|
|
CFontImageDef::CFontImageDef(const TToken<CTexture>& tex, const zeus::CVector2f& cropFactor)
|
|
|
|
: x0_fps(0.f), x14_cropFactor(cropFactor)
|
2016-03-20 00:32:30 +00:00
|
|
|
{
|
2017-01-29 03:58:16 +00:00
|
|
|
x4_texs.push_back(tex);
|
2016-03-20 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CFontImageDef::IsLoaded() const
|
|
|
|
{
|
|
|
|
for (const TToken<CTexture>& tok : x4_texs)
|
|
|
|
if (!tok.IsLoaded())
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-30 04:16:20 +00:00
|
|
|
s32 CFontImageDef::CalculateBaseline() const
|
|
|
|
{
|
|
|
|
const CTexture* tex = x4_texs.front().GetObj();
|
2017-01-30 06:58:59 +00:00
|
|
|
return s32(tex->GetHeight() * x14_cropFactor.y) * 2.5f / 3.f;
|
2017-01-30 04:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 CFontImageDef::CalculateHeight() const
|
|
|
|
{
|
|
|
|
const CTexture* tex = x4_texs.front().GetObj();
|
2017-01-30 06:58:59 +00:00
|
|
|
s32 scaledH = tex->GetHeight() * x14_cropFactor.y;
|
2017-01-30 04:16:20 +00:00
|
|
|
return scaledH - (scaledH - CalculateBaseline());
|
|
|
|
}
|
|
|
|
|
2016-03-20 00:32:30 +00:00
|
|
|
}
|