2019-09-22 21:52:05 +00:00
|
|
|
#include "Runtime/GuiSys/CGuiSys.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/GuiSys/CAuiEnergyBarT01.hpp"
|
|
|
|
#include "Runtime/GuiSys/CAuiImagePane.hpp"
|
|
|
|
#include "Runtime/GuiSys/CAuiMeter.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiCamera.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiFrame.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiGroup.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiHeadWidget.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiLight.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiModel.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiPane.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiSliderGroup.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiTableGroup.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiTextPane.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiWidget.hpp"
|
|
|
|
#include "Runtime/GuiSys/CTextExecuteBuffer.hpp"
|
|
|
|
#include "Runtime/GuiSys/CTextParser.hpp"
|
2016-03-11 00:23:16 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-03-11 00:23:16 +00:00
|
|
|
|
2016-03-19 03:58:01 +00:00
|
|
|
CGuiSys* g_GuiSys = nullptr;
|
2016-03-21 22:01:19 +00:00
|
|
|
CTextExecuteBuffer* g_TextExecuteBuf = nullptr;
|
|
|
|
CTextParser* g_TextParser = nullptr;
|
2016-03-19 03:58:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::shared_ptr<CGuiWidget> CGuiSys::CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame,
|
2022-02-23 08:18:50 +00:00
|
|
|
CSimplePool* sp, u32 version) {
|
2019-07-20 04:27:21 +00:00
|
|
|
switch (type.toUint32()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
case SBIG('BWIG'):
|
|
|
|
return CGuiWidget::Create(frame, in, sp);
|
|
|
|
case SBIG('HWIG'):
|
|
|
|
return CGuiHeadWidget::Create(frame, in, sp);
|
|
|
|
case SBIG('LITE'):
|
|
|
|
return CGuiLight::Create(frame, in, sp);
|
|
|
|
case SBIG('CAMR'):
|
|
|
|
return CGuiCamera::Create(frame, in, sp);
|
|
|
|
case SBIG('GRUP'):
|
|
|
|
return CGuiGroup::Create(frame, in, sp);
|
|
|
|
case SBIG('PANE'):
|
|
|
|
return CGuiPane::Create(frame, in, sp);
|
|
|
|
case SBIG('IMGP'):
|
|
|
|
return CAuiImagePane::Create(frame, in, sp);
|
|
|
|
case SBIG('METR'):
|
|
|
|
return CAuiMeter::Create(frame, in, sp);
|
|
|
|
case SBIG('MODL'):
|
|
|
|
return CGuiModel::Create(frame, in, sp);
|
|
|
|
case SBIG('TBGP'):
|
|
|
|
return CGuiTableGroup::Create(frame, in, sp);
|
|
|
|
case SBIG('SLGP'):
|
|
|
|
return CGuiSliderGroup::Create(frame, in, sp);
|
|
|
|
case SBIG('TXPN'):
|
2022-02-23 08:18:50 +00:00
|
|
|
return CGuiTextPane::Create(frame, in, sp, version);
|
2018-12-08 05:30:43 +00:00
|
|
|
case SBIG('ENRG'):
|
|
|
|
return CAuiEnergyBarT01::Create(frame, in, sp);
|
|
|
|
default:
|
2019-07-20 04:27:21 +00:00
|
|
|
return {};
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-03-12 04:58:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 00:23:16 +00:00
|
|
|
CGuiSys::CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode)
|
2018-12-08 05:30:43 +00:00
|
|
|
: x0_resFactory(resFactory)
|
|
|
|
, x4_resStore(resStore)
|
|
|
|
, x8_mode(mode)
|
2019-09-12 03:50:38 +00:00
|
|
|
, xc_textExecuteBuf(std::make_unique<CTextExecuteBuffer>())
|
|
|
|
, x10_textParser(std::make_unique<CTextParser>(resStore)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
g_TextExecuteBuf = xc_textExecuteBuf.get();
|
|
|
|
g_TextParser = x10_textParser.get();
|
2016-03-11 00:23:16 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGuiSys::OnViewportResize() {
|
|
|
|
for (CGuiFrame* frame : m_registeredFrames)
|
|
|
|
ViewportResizeFrame(frame);
|
2017-01-30 04:16:20 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGuiSys::ViewportResizeFrame(CGuiFrame* frame) {
|
|
|
|
if (frame->m_aspectConstraint > 0.f) {
|
|
|
|
float hPad, vPad;
|
2019-01-23 07:52:19 +00:00
|
|
|
if (g_Viewport.aspect >= frame->m_aspectConstraint) {
|
|
|
|
hPad = frame->m_aspectConstraint / g_Viewport.aspect;
|
2018-12-08 05:30:43 +00:00
|
|
|
vPad = frame->m_aspectConstraint / 1.38f;
|
|
|
|
} else {
|
|
|
|
hPad = 1.f;
|
2019-01-23 07:52:19 +00:00
|
|
|
vPad = g_Viewport.aspect / 1.38f;
|
2017-11-19 23:48:09 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
frame->m_aspectTransform = zeus::CTransform::Scale({hPad, 1.f, vPad});
|
|
|
|
} else if (frame->m_maxAspect > 0.f) {
|
2019-01-23 07:52:19 +00:00
|
|
|
if (g_Viewport.aspect > frame->m_maxAspect)
|
|
|
|
frame->m_aspectTransform = zeus::CTransform::Scale({frame->m_maxAspect / g_Viewport.aspect, 1.f, 1.f});
|
2018-12-08 05:30:43 +00:00
|
|
|
else
|
2019-02-24 07:15:54 +00:00
|
|
|
frame->m_aspectTransform = zeus::CTransform();
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-01-30 04:16:20 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|