2016-03-12 04:58:56 +00:00
|
|
|
#include "CGuiTextPane.hpp"
|
2016-03-14 00:58:19 +00:00
|
|
|
#include "CGuiAnimController.hpp"
|
|
|
|
#include "CGuiLogicalEventTrigger.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
|
|
|
|
{
|
|
|
|
|
2016-03-22 02:27:46 +00:00
|
|
|
CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, float xDim, float zDim,
|
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)
|
|
|
|
: CGuiPane(parms, xDim, zDim, vec), x114_textSupport(fontId, props, fontCol, outlineCol,
|
|
|
|
zeus::CColor::skWhite, extentX, extentY,
|
|
|
|
&parms.x0_frame->GetGuiSys().GetResStore()) {}
|
|
|
|
|
|
|
|
void CGuiTextPane::Update(float dt)
|
|
|
|
{
|
|
|
|
CGuiWidget::Update(dt);
|
|
|
|
x114_textSupport.Update(dt);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiTextPane::GetIsFinishedLoadingWidgetSpecific() const
|
|
|
|
{
|
|
|
|
return x114_textSupport.GetIsTextSupportFinishedLoading();
|
|
|
|
}
|
|
|
|
|
|
|
|
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-08-15 20:58:07 +00:00
|
|
|
if (x114_textSupport.x34_extentX)
|
|
|
|
dims.x /= float(x114_textSupport.x34_extentX);
|
2016-03-22 02:27:46 +00:00
|
|
|
else
|
|
|
|
dims.x = 0.f;
|
|
|
|
|
2016-08-15 20:58:07 +00:00
|
|
|
if (x114_textSupport.x38_extentY)
|
|
|
|
dims.y /= float(x114_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 =
|
|
|
|
zeus::CTransform::Translate(x100_verts.front().m_pos + x108_scaleCenter) *
|
|
|
|
zeus::CTransform::Scale(dims.x, 1.f, dims.y);
|
2016-03-22 02:27:46 +00:00
|
|
|
CGraphics::SetModelMatrix(x34_worldXF * local);
|
|
|
|
|
|
|
|
zeus::CColor geomCol = xb4_;
|
|
|
|
geomCol.a *= parms.x0_alphaMod;
|
|
|
|
((CGuiTextPane*)this)->x114_textSupport.SetGeometryColor(geomCol);
|
|
|
|
|
|
|
|
CGraphics::SetDepthWriteMode(xf6_31_depthTest, ERglEnum::LEqual, xf7_24_depthWrite);
|
|
|
|
|
|
|
|
switch (xc4_drawFlags)
|
|
|
|
{
|
|
|
|
case EGuiModelDrawFlags::Shadeless:
|
|
|
|
case EGuiModelDrawFlags::Opaque:
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One,
|
|
|
|
ERglBlendFactor::Zero, ERglLogicOp::Clear);
|
|
|
|
x114_textSupport.Render();
|
|
|
|
break;
|
|
|
|
case EGuiModelDrawFlags::Alpha:
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
|
|
|
|
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
|
|
|
|
x114_textSupport.Render();
|
|
|
|
break;
|
|
|
|
case EGuiModelDrawFlags::Additive:
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
|
|
|
|
ERglBlendFactor::One, ERglLogicOp::Clear);
|
|
|
|
x114_textSupport.Render();
|
|
|
|
break;
|
|
|
|
case EGuiModelDrawFlags::AlphaAdditiveOverdraw:
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
|
|
|
|
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
|
|
|
|
x114_textSupport.Render();
|
|
|
|
((CGuiTextPane*)this)->x114_textSupport.SetGeometryColor
|
|
|
|
(geomCol * zeus::CColor(geomCol.a, geomCol.a, geomCol.a, 1.f));
|
|
|
|
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One,
|
|
|
|
ERglBlendFactor::One, ERglLogicOp::Clear);
|
|
|
|
x114_textSupport.Render();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-12 04:58:56 +00:00
|
|
|
CGuiTextPane* CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
|
|
|
{
|
|
|
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
2016-03-22 02:27:46 +00:00
|
|
|
float xDim = in.readFloatBig();
|
|
|
|
float zDim = in.readFloatBig();
|
2016-03-12 04:58:56 +00:00
|
|
|
zeus::CVector3f vec;
|
2016-03-14 00:58:19 +00:00
|
|
|
vec.readBig(in);
|
2016-03-22 02:27:46 +00:00
|
|
|
u32 fontId = in.readUint32Big();
|
|
|
|
bool wordWrap = in.readBool();
|
|
|
|
bool vertical = in.readBool();
|
2016-03-12 04:58:56 +00:00
|
|
|
EJustification justification = EJustification(in.readUint32Big());
|
|
|
|
EVerticalJustification vJustification = EVerticalJustification(in.readUint32Big());
|
2016-08-15 20:58:07 +00:00
|
|
|
CGuiTextProperties props(wordWrap, vertical, justification, vJustification, ETextDirection::Horizontal);
|
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();
|
2016-03-22 08:15:00 +00:00
|
|
|
return new CGuiTextPane(parms, xDim, zDim, vec, fontId, props,
|
|
|
|
fontCol, outlineCol, extentX, extentY);
|
2016-03-12 04:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|