2016-03-19 00:07:31 +00:00
|
|
|
#include "CFontRenderState.hpp"
|
|
|
|
#include "CRasterFont.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
CFontRenderState::CFontRenderState()
|
|
|
|
{
|
|
|
|
x20_[0] = zeus::CColor::skWhite;
|
|
|
|
x20_[1] = zeus::CColor::skGrey;
|
|
|
|
x20_[2] = zeus::CColor::skWhite;
|
|
|
|
RefreshPalette();
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CColor CFontRenderState::ConvertToTextureSpace(const CTextColor& col) const
|
|
|
|
{
|
|
|
|
return col;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFontRenderState::PopState()
|
|
|
|
{
|
|
|
|
static_cast<CSaveableState&>(*this) = xa4_pushedStates.back();
|
|
|
|
xa4_pushedStates.pop_back();
|
|
|
|
RefreshPalette();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFontRenderState::PushState()
|
|
|
|
{
|
|
|
|
xa4_pushedStates.push_back(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFontRenderState::SetColor(EColorType tp, const CTextColor& col)
|
|
|
|
{
|
|
|
|
switch (tp)
|
|
|
|
{
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Main:
|
|
|
|
case EColorType::Outline:
|
|
|
|
case EColorType::Geometry:
|
2016-03-19 00:07:31 +00:00
|
|
|
x20_[int(tp)] = col;
|
|
|
|
break;
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Foreground:
|
2016-03-19 00:07:31 +00:00
|
|
|
x20_[0] = col;
|
|
|
|
break;
|
2016-03-21 22:01:19 +00:00
|
|
|
case EColorType::Background:
|
2016-03-19 00:07:31 +00:00
|
|
|
x20_[1] = col;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RefreshColor(tp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFontRenderState::RefreshPalette()
|
|
|
|
{
|
2016-03-21 00:25:53 +00:00
|
|
|
RefreshColor(EColorType::Foreground);
|
2016-03-21 22:01:19 +00:00
|
|
|
RefreshColor(EColorType::Background);
|
2016-03-19 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CFontRenderState::RefreshColor(EColorType tp)
|
|
|
|
{
|
|
|
|
switch (tp)
|
|
|
|
{
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Main:
|
2016-03-20 06:37:08 +00:00
|
|
|
if (!x14_font)
|
2016-03-19 00:07:31 +00:00
|
|
|
return;
|
2016-03-20 06:37:08 +00:00
|
|
|
switch (x14_font.GetObj()->GetMode())
|
2016-03-19 00:07:31 +00:00
|
|
|
{
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Main:
|
|
|
|
if (!x30_colorOverrides[0])
|
|
|
|
x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x20_[0]);
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Outline:
|
|
|
|
if (!x30_colorOverrides[0])
|
|
|
|
x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x20_[0]);
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
break;
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Outline:
|
2016-03-20 06:37:08 +00:00
|
|
|
if (!x14_font)
|
2016-03-19 00:07:31 +00:00
|
|
|
return;
|
2016-03-21 00:25:53 +00:00
|
|
|
if (x30_colorOverrides[1])
|
2016-03-19 00:07:31 +00:00
|
|
|
return;
|
2016-03-21 00:25:53 +00:00
|
|
|
if (x14_font.GetObj()->GetMode() == EColorType::Outline)
|
|
|
|
x0_drawStrOpts.x4_colors[1] = ConvertToTextureSpace(x20_[1]);
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Geometry:
|
|
|
|
if (!x30_colorOverrides[2])
|
|
|
|
x0_drawStrOpts.x4_colors[2] = ConvertToTextureSpace(x20_[2]);
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Foreground:
|
|
|
|
RefreshColor(EColorType::Main);
|
|
|
|
RefreshColor(EColorType::Geometry);
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
2016-03-21 22:01:19 +00:00
|
|
|
case EColorType::Background:
|
2016-03-21 00:25:53 +00:00
|
|
|
RefreshColor(EColorType::Outline);
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|