2016-03-12 04:58:56 +00:00
|
|
|
#include "CGuiTextPane.hpp"
|
2016-03-22 02:27:46 +00:00
|
|
|
#include "CFontImageDef.hpp"
|
|
|
|
#include "CGuiFrame.hpp"
|
|
|
|
#include "CGuiSys.hpp"
|
|
|
|
#include "CGuiWidgetDrawParms.hpp"
|
|
|
|
#include "Graphics/CGraphics.hpp"
|
|
|
|
#include "Graphics/CGraphicsPalette.hpp"
|
2016-03-12 04:58:56 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2017-01-22 01:40:12 +00:00
|
|
|
CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim,
|
2016-04-14 21:42:47 +00:00
|
|
|
const zeus::CVector3f& vec, ResId fontId, const CGuiTextProperties& props,
|
2016-03-22 02:27:46 +00:00
|
|
|
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
|
|
|
|
s32 extentX, s32 extentY)
|
2017-01-22 01:40:12 +00:00
|
|
|
: CGuiPane(parms, dim, vec), xd4_textSupport(fontId, props, fontCol, outlineCol,
|
2017-01-29 03:58:16 +00:00
|
|
|
zeus::CColor::skWhite, extentX, extentY, sp, xac_drawFlags) {}
|
2016-03-22 02:27:46 +00:00
|
|
|
|
|
|
|
void CGuiTextPane::Update(float dt)
|
|
|
|
{
|
|
|
|
CGuiWidget::Update(dt);
|
2016-09-16 23:43:33 +00:00
|
|
|
xd4_textSupport.Update(dt);
|
2016-03-22 02:27:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiTextPane::GetIsFinishedLoadingWidgetSpecific() const
|
|
|
|
{
|
2016-09-16 23:43:33 +00:00
|
|
|
return xd4_textSupport.GetIsTextSupportFinishedLoading();
|
2016-03-22 02:27:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiTextPane::SetDimensions(const zeus::CVector2f& dim, bool initVBO)
|
|
|
|
{
|
|
|
|
CGuiPane::SetDimensions(dim, initVBO);
|
|
|
|
if (initVBO)
|
|
|
|
InitializeBuffers();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiTextPane::ScaleDimensions(const zeus::CVector3f& scale)
|
2016-03-12 04:58:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-22 02:27:46 +00:00
|
|
|
void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
|
|
|
|
{
|
|
|
|
if (!GetIsVisible())
|
|
|
|
return;
|
|
|
|
|
|
|
|
zeus::CVector2f dims = GetDimensions();
|
|
|
|
|
2016-09-16 23:43:33 +00:00
|
|
|
if (xd4_textSupport.x34_extentX)
|
|
|
|
dims.x /= float(xd4_textSupport.x34_extentX);
|
2016-03-22 02:27:46 +00:00
|
|
|
else
|
|
|
|
dims.x = 0.f;
|
|
|
|
|
2016-09-16 23:43:33 +00:00
|
|
|
if (xd4_textSupport.x38_extentY)
|
|
|
|
dims.y /= float(xd4_textSupport.x38_extentY);
|
2016-03-22 02:27:46 +00:00
|
|
|
else
|
|
|
|
dims.y = 0.f;
|
|
|
|
|
2016-03-22 08:15:00 +00:00
|
|
|
zeus::CTransform local =
|
2017-01-30 04:16:20 +00:00
|
|
|
zeus::CTransform::Translate(xc0_verts.front().m_pos + xc8_scaleCenter) *
|
2016-03-22 08:15:00 +00:00
|
|
|
zeus::CTransform::Scale(dims.x, 1.f, dims.y);
|
2016-03-22 02:27:46 +00:00
|
|
|
CGraphics::SetModelMatrix(x34_worldXF * local);
|
|
|
|
|
2016-12-15 22:37:34 +00:00
|
|
|
zeus::CColor geomCol = xa8_color2;
|
2016-03-22 02:27:46 +00:00
|
|
|
geomCol.a *= parms.x0_alphaMod;
|
2016-09-16 23:43:33 +00:00
|
|
|
const_cast<CGuiTextPane*>(this)->xd4_textSupport.SetGeometryColor(geomCol);
|
2016-03-22 02:27:46 +00:00
|
|
|
|
2017-01-29 03:58:16 +00:00
|
|
|
# if 0
|
2016-12-15 22:37:34 +00:00
|
|
|
CGraphics::SetDepthWriteMode(xb6_31_depthTest, ERglEnum::LEqual, xb7_24_depthWrite);
|
2016-03-22 02:27:46 +00:00
|
|
|
|
2016-12-15 22:37:34 +00:00
|
|
|
switch (xac_drawFlags)
|
2016-03-22 02:27:46 +00:00
|
|
|
{
|
|
|
|
case EGuiModelDrawFlags::Shadeless:
|
|
|
|
case EGuiModelDrawFlags::Opaque:
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One,
|
|
|
|
ERglBlendFactor::Zero, ERglLogicOp::Clear);
|
2016-09-16 23:43:33 +00:00
|
|
|
xd4_textSupport.Render();
|
2016-03-22 02:27:46 +00:00
|
|
|
break;
|
|
|
|
case EGuiModelDrawFlags::Alpha:
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
|
|
|
|
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
|
2016-09-16 23:43:33 +00:00
|
|
|
xd4_textSupport.Render();
|
2016-03-22 02:27:46 +00:00
|
|
|
break;
|
|
|
|
case EGuiModelDrawFlags::Additive:
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
|
|
|
|
ERglBlendFactor::One, ERglLogicOp::Clear);
|
2016-09-16 23:43:33 +00:00
|
|
|
xd4_textSupport.Render();
|
2016-03-22 02:27:46 +00:00
|
|
|
break;
|
|
|
|
case EGuiModelDrawFlags::AlphaAdditiveOverdraw:
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
|
|
|
|
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
|
2016-09-16 23:43:33 +00:00
|
|
|
xd4_textSupport.Render();
|
|
|
|
const_cast<CGuiTextPane*>(this)->xd4_textSupport.SetGeometryColor
|
2016-03-22 02:27:46 +00:00
|
|
|
(geomCol * zeus::CColor(geomCol.a, geomCol.a, geomCol.a, 1.f));
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One,
|
|
|
|
ERglBlendFactor::One, ERglLogicOp::Clear);
|
2016-09-16 23:43:33 +00:00
|
|
|
xd4_textSupport.Render();
|
2016-03-22 02:27:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-01-29 03:58:16 +00:00
|
|
|
#else
|
|
|
|
xd4_textSupport.Render();
|
|
|
|
#endif
|
2016-03-22 02:27:46 +00:00
|
|
|
}
|
|
|
|
|
2017-01-22 01:40:12 +00:00
|
|
|
std::shared_ptr<CGuiWidget> CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
|
2016-03-12 04:58:56 +00:00
|
|
|
{
|
2017-01-22 01:40:12 +00:00
|
|
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
|
|
|
|
zeus::CVector2f dim = zeus::CVector2f::ReadBig(in);
|
|
|
|
zeus::CVector3f vec = zeus::CVector3f::ReadBig(in);
|
2016-03-22 02:27:46 +00:00
|
|
|
u32 fontId = in.readUint32Big();
|
|
|
|
bool wordWrap = in.readBool();
|
2017-01-30 04:16:20 +00:00
|
|
|
bool horizontal = in.readBool();
|
2016-03-12 04:58:56 +00:00
|
|
|
EJustification justification = EJustification(in.readUint32Big());
|
|
|
|
EVerticalJustification vJustification = EVerticalJustification(in.readUint32Big());
|
2017-01-30 04:16:20 +00:00
|
|
|
CGuiTextProperties props(wordWrap, horizontal, justification, vJustification);
|
2016-03-22 02:27:46 +00:00
|
|
|
zeus::CColor fontCol;
|
|
|
|
fontCol.readRGBABig(in);
|
|
|
|
zeus::CColor outlineCol;
|
|
|
|
outlineCol.readRGBABig(in);
|
|
|
|
int extentX = in.readFloatBig();
|
|
|
|
int extentY = in.readFloatBig();
|
2017-01-22 01:40:12 +00:00
|
|
|
std::shared_ptr<CGuiTextPane> ret =
|
|
|
|
std::make_shared<CGuiTextPane>(parms, sp, dim, vec, fontId, props,
|
|
|
|
fontCol, outlineCol, extentX, extentY);
|
|
|
|
ret->ParseBaseInfo(frame, in, parms);
|
2017-01-21 15:46:51 +00:00
|
|
|
ret->InitializeBuffers();
|
2017-01-30 04:16:20 +00:00
|
|
|
ret->TextSupport()->SetText(u"");
|
2017-01-22 01:40:12 +00:00
|
|
|
return ret;
|
2016-03-12 04:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|