2016-03-19 00:07:31 +00:00
|
|
|
#include "CFontRenderState.hpp"
|
|
|
|
#include "CRasterFont.hpp"
|
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
CFontRenderState::CFontRenderState()
|
|
|
|
{
|
2016-12-16 23:05:29 +00:00
|
|
|
x54_[0] = zeus::CColor::skWhite;
|
|
|
|
x54_[1] = zeus::CColor::skGrey;
|
|
|
|
x54_[2] = zeus::CColor::skWhite;
|
2016-03-19 00:07:31 +00:00
|
|
|
RefreshPalette();
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CColor CFontRenderState::ConvertToTextureSpace(const CTextColor& col) const
|
|
|
|
{
|
|
|
|
return col;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFontRenderState::PopState()
|
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
static_cast<CSaveableState&>(*this) = x10c_pushedStates.back();
|
|
|
|
x10c_pushedStates.pop_back();
|
2016-03-19 00:07:31 +00:00
|
|
|
RefreshPalette();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CFontRenderState::PushState()
|
|
|
|
{
|
2016-12-30 06:37:01 +00:00
|
|
|
x10c_pushedStates.push_back(*this);
|
2016-03-19 00:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-12-16 23:05:29 +00:00
|
|
|
x54_[int(tp)] = col;
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Foreground:
|
2016-12-16 23:05:29 +00:00
|
|
|
x54_[0] = col;
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
2016-03-21 22:01:19 +00:00
|
|
|
case EColorType::Background:
|
2016-12-16 23:05:29 +00:00
|
|
|
x54_[1] = col;
|
2016-03-19 00:07:31 +00:00
|
|
|
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-12-16 23:05:29 +00:00
|
|
|
if (!x48_font)
|
2016-03-19 00:07:31 +00:00
|
|
|
return;
|
2016-12-16 23:05:29 +00:00
|
|
|
switch (x48_font.GetObj()->GetMode())
|
2016-03-19 00:07:31 +00:00
|
|
|
{
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Main:
|
2016-12-16 23:05:29 +00:00
|
|
|
if (!x64_colorOverrides[0])
|
|
|
|
x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x54_[0]);
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Outline:
|
2016-12-16 23:05:29 +00:00
|
|
|
if (!x64_colorOverrides[0])
|
|
|
|
x0_drawStrOpts.x4_colors[0] = ConvertToTextureSpace(x54_[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-12-16 23:05:29 +00:00
|
|
|
if (!x48_font)
|
2016-03-19 00:07:31 +00:00
|
|
|
return;
|
2016-12-16 23:05:29 +00:00
|
|
|
if (x64_colorOverrides[1])
|
2016-03-19 00:07:31 +00:00
|
|
|
return;
|
2016-12-16 23:05:29 +00:00
|
|
|
if (x48_font.GetObj()->GetMode() == EColorType::Outline)
|
|
|
|
x0_drawStrOpts.x4_colors[1] = ConvertToTextureSpace(x54_[1]);
|
2016-03-19 00:07:31 +00:00
|
|
|
break;
|
2016-03-21 00:25:53 +00:00
|
|
|
case EColorType::Geometry:
|
2016-12-16 23:05:29 +00:00
|
|
|
if (!x64_colorOverrides[2])
|
|
|
|
x0_drawStrOpts.x4_colors[2] = ConvertToTextureSpace(x54_[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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|