2019-09-22 21:52:05 +00:00
|
|
|
#include "Runtime/GuiSys/CGuiPane.hpp"
|
2022-02-13 21:32:52 +00:00
|
|
|
#include "Runtime/GuiSys/CGuiWidgetDrawParms.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-03-12 04:58:56 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CGuiPane::CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim, const zeus::CVector3f& scaleCenter)
|
|
|
|
: CGuiWidget(parms), xb8_dim(dim), xc8_scaleCenter(scaleCenter) {
|
2020-05-10 02:23:42 +00:00
|
|
|
CGuiPane::InitializeBuffers();
|
2016-03-12 04:58:56 +00:00
|
|
|
}
|
|
|
|
|
2022-02-13 21:32:52 +00:00
|
|
|
void CGuiPane::Draw(const CGuiWidgetDrawParms& parms) {
|
|
|
|
CGraphics::SetModelMatrix(x34_worldXF * zeus::CTransform::Translate(xc8_scaleCenter));
|
|
|
|
if (GetIsVisible()) {
|
|
|
|
auto col = xa8_color2;
|
|
|
|
col.a() = parms.x0_alphaMod * xa8_color2.a();
|
|
|
|
|
2022-03-05 21:46:53 +00:00
|
|
|
CGraphics::SetTevOp(ERglTevStage::Stage0, CTevCombiners::skPassThru);
|
2022-07-29 20:16:55 +00:00
|
|
|
CGraphics::DrawPrimitive(GX_TRIANGLESTRIP, xc0_verts.data(), skDefaultNormal, col, xc0_verts.size());
|
2022-02-13 21:32:52 +00:00
|
|
|
}
|
|
|
|
CGuiWidget::Draw(parms);
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGuiPane::ScaleDimensions(const zeus::CVector3f& scale) {
|
|
|
|
InitializeBuffers();
|
2022-02-13 21:32:52 +00:00
|
|
|
for (auto& vert : xc0_verts) {
|
|
|
|
vert -= xc8_scaleCenter;
|
|
|
|
vert *= scale;
|
|
|
|
vert += xc8_scaleCenter;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-03-16 20:49:35 +00:00
|
|
|
}
|
|
|
|
|
2022-02-13 21:32:52 +00:00
|
|
|
void CGuiPane::SetDimensions(const zeus::CVector2f& dim, bool initBuffers) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xb8_dim = dim;
|
2022-02-13 21:32:52 +00:00
|
|
|
if (initBuffers)
|
2018-12-08 05:30:43 +00:00
|
|
|
InitializeBuffers();
|
2016-03-16 20:49:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector2f CGuiPane::GetDimensions() const { return xb8_dim; }
|
2016-03-16 20:49:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGuiPane::InitializeBuffers() {
|
2022-02-13 21:32:52 +00:00
|
|
|
#if 0
|
|
|
|
if (xc0_verts == nullptr) {
|
|
|
|
xc0_verts = new float[3 * 4];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
xc0_verts[0].assign(-xb8_dim.x() * 0.5f, 0.f, xb8_dim.y() * 0.5f);
|
|
|
|
xc0_verts[1].assign(-xb8_dim.x() * 0.5f, 0.f, -xb8_dim.y() * 0.5f);
|
|
|
|
xc0_verts[2].assign(xb8_dim.x() * 0.5f, 0.f, xb8_dim.y() * 0.5f);
|
|
|
|
xc0_verts[3].assign(xb8_dim.x() * 0.5f, 0.f, -xb8_dim.y() * 0.5f);
|
2016-03-16 20:49:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGuiPane::WriteData(COutputStream& out, bool flag) const {}
|
2016-03-16 20:49:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::shared_ptr<CGuiWidget> CGuiPane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) {
|
|
|
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
|
2022-02-18 07:37:54 +00:00
|
|
|
zeus::CVector2f dim = in.Get<zeus::CVector2f>();
|
|
|
|
zeus::CVector3f scaleCenter = in.Get<zeus::CVector3f>();
|
2018-12-08 05:30:43 +00:00
|
|
|
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiPane>(parms, dim, scaleCenter);
|
|
|
|
ret->ParseBaseInfo(frame, in, parms);
|
|
|
|
return ret;
|
2016-03-12 04:58:56 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|