2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/GuiSys/CFontImageDef.hpp"
|
|
|
|
|
2020-05-21 05:40:28 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/Graphics/CTexture.hpp"
|
2016-03-20 00:32:30 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-03-20 00:32:30 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CFontImageDef::CFontImageDef(const std::vector<TToken<CTexture>>& texs, float interval,
|
|
|
|
const zeus::CVector2f& cropFactor)
|
|
|
|
: x0_fps(interval), x14_cropFactor(cropFactor) {
|
|
|
|
x4_texs.reserve(texs.size());
|
2020-03-14 22:45:34 +00:00
|
|
|
for (const TToken<CTexture>& tok : texs) {
|
|
|
|
x4_texs.emplace_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)
|
2018-12-08 05:30:43 +00:00
|
|
|
: x0_fps(0.f), x14_cropFactor(cropFactor) {
|
2020-03-14 22:45:34 +00:00
|
|
|
x4_texs.emplace_back(tex);
|
2016-03-20 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CFontImageDef::IsLoaded() const {
|
2020-05-21 05:40:28 +00:00
|
|
|
return std::all_of(x4_texs.cbegin(), x4_texs.cend(), [](const auto& token) { return token.IsLoaded(); });
|
2016-03-20 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
s32 CFontImageDef::CalculateBaseline() const {
|
|
|
|
const CTexture* tex = x4_texs.front().GetObj();
|
|
|
|
return s32(tex->GetHeight() * x14_cropFactor.y()) * 2.5f / 3.f;
|
2017-01-30 04:16:20 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
s32 CFontImageDef::CalculateHeight() const {
|
|
|
|
const CTexture* tex = x4_texs.front().GetObj();
|
|
|
|
s32 scaledH = tex->GetHeight() * x14_cropFactor.y();
|
|
|
|
return scaledH - (scaledH - CalculateBaseline());
|
2017-01-30 04:16:20 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|