metaforce/Runtime/GuiSys/CGuiPane.cpp

66 lines
1.6 KiB
C++
Raw Normal View History

#include "CGuiPane.hpp"
2016-03-14 00:58:19 +00:00
#include "CGuiAnimController.hpp"
#include "CGuiLogicalEventTrigger.hpp"
namespace urde
{
2016-03-17 22:19:25 +00:00
CGuiPane::CGuiPane(const CGuiWidgetParms& parms, float xDim, float zDim,
const zeus::CVector3f& scaleCenter)
: CGuiWidget(parms), xf8_xDim(xDim), xfc_zDim(zDim), x108_scaleCenter(scaleCenter)
{
InitializeBuffers();
}
2016-03-16 20:49:35 +00:00
void CGuiPane::ScaleDimensions(const zeus::CVector3f& scale)
{
2016-03-17 22:19:25 +00:00
InitializeBuffers();
for (specter::View::TexShaderVert& v : x100_verts)
{
v.m_pos -= x108_scaleCenter;
v.m_pos *= scale;
v.m_pos += x108_scaleCenter;
}
2016-03-16 20:49:35 +00:00
}
2016-03-17 22:19:25 +00:00
void CGuiPane::SetDimensions(const zeus::CVector2f& dim, bool initVBO)
2016-03-16 20:49:35 +00:00
{
2016-03-17 22:19:25 +00:00
xf8_xDim = dim.x;
xfc_zDim = dim.y;
if (initVBO)
InitializeBuffers();
2016-03-16 20:49:35 +00:00
}
2016-03-17 22:19:25 +00:00
zeus::CVector2f CGuiPane::GetDimensions() const
2016-03-16 20:49:35 +00:00
{
2016-03-17 22:19:25 +00:00
return {xf8_xDim, xfc_zDim};
2016-03-16 20:49:35 +00:00
}
void CGuiPane::InitializeBuffers()
{
2016-03-17 22:19:25 +00:00
if (x100_verts.size() < 4)
x100_verts.resize(4);
x100_verts[0].m_pos.assign(-xf8_xDim * 0.5f, 0.f, xfc_zDim * 0.5f);
x100_verts[1].m_pos.assign(-xf8_xDim * 0.5f, 0.f, -xfc_zDim * 0.5f);
x100_verts[2].m_pos.assign(xf8_xDim * 0.5f, 0.f, xfc_zDim * 0.5f);
x100_verts[3].m_pos.assign(xf8_xDim * 0.5f, 0.f, -xfc_zDim * 0.5f);
2016-03-16 20:49:35 +00:00
}
void CGuiPane::WriteData(COutputStream& out, bool flag) const
{
}
CGuiPane* CGuiPane::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
2016-03-17 22:19:25 +00:00
float x = in.readFloatBig();
float z = in.readFloatBig();
zeus::CVector3f scaleCenter;
scaleCenter.readBig(in);
return new CGuiPane(parms, x, z, scaleCenter);
}
}