2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/GuiSys/CFontRenderState.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/GuiSys/CRasterFont.hpp"
|
2016-03-19 00:07:31 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-03-19 00:07:31 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CFontRenderState::CFontRenderState() {
|
2019-02-24 07:15:54 +00:00
|
|
|
x54_colors[0] = zeus::skWhite;
|
|
|
|
x54_colors[1] = zeus::skGrey;
|
|
|
|
x54_colors[2] = zeus::skWhite;
|
2018-12-08 05:30:43 +00:00
|
|
|
RefreshPalette();
|
2016-03-19 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CColor CFontRenderState::ConvertToTextureSpace(const CTextColor& col) const { return col; }
|
2016-03-19 00:07:31 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CFontRenderState::PopState() {
|
|
|
|
static_cast<CSaveableState&>(*this) = x10c_pushedStates.back();
|
|
|
|
x10c_pushedStates.pop_back();
|
|
|
|
RefreshPalette();
|
2016-03-19 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CFontRenderState::PushState() { x10c_pushedStates.push_back(*this); }
|
2016-03-19 00:07:31 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CFontRenderState::SetColor(EColorType tp, const CTextColor& col) {
|
|
|
|
switch (tp) {
|
|
|
|
case EColorType::Main:
|
|
|
|
case EColorType::Outline:
|
|
|
|
case EColorType::Geometry:
|
2020-05-21 05:33:31 +00:00
|
|
|
x54_colors[size_t(tp)] = col;
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case EColorType::Foreground:
|
|
|
|
x54_colors[0] = col;
|
|
|
|
break;
|
|
|
|
case EColorType::Background:
|
|
|
|
x54_colors[1] = col;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RefreshColor(tp);
|
2016-03-19 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CFontRenderState::RefreshPalette() {
|
|
|
|
RefreshColor(EColorType::Foreground);
|
|
|
|
RefreshColor(EColorType::Background);
|
2016-03-19 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CFontRenderState::RefreshColor(EColorType tp) {
|
|
|
|
switch (tp) {
|
|
|
|
case EColorType::Main:
|
|
|
|
if (!x48_font)
|
|
|
|
return;
|
|
|
|
switch (x48_font->GetMode()) {
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Main:
|
|
|
|
case EColorType::Outline:
|
2020-03-07 08:43:24 +00:00
|
|
|
if (!x64_colorOverrides[0]) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x54_colors[0]);
|
2020-03-07 08:43:24 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2016-03-19 00:07:31 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case EColorType::Outline:
|
|
|
|
if (!x48_font)
|
|
|
|
return;
|
|
|
|
if (x64_colorOverrides[1])
|
|
|
|
return;
|
|
|
|
if (x48_font->GetMode() == EColorType::Outline)
|
|
|
|
x0_drawStrOpts.x4_colors[1] = ConvertToTextureSpace(x54_colors[1]);
|
|
|
|
break;
|
|
|
|
case EColorType::Geometry:
|
|
|
|
if (!x64_colorOverrides[2])
|
|
|
|
x0_drawStrOpts.x4_colors[2] = ConvertToTextureSpace(x54_colors[2]);
|
|
|
|
break;
|
|
|
|
case EColorType::Foreground:
|
|
|
|
RefreshColor(EColorType::Main);
|
|
|
|
RefreshColor(EColorType::Geometry);
|
|
|
|
break;
|
|
|
|
case EColorType::Background:
|
|
|
|
RefreshColor(EColorType::Outline);
|
|
|
|
break;
|
|
|
|
}
|
2016-03-19 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|