2016-03-11 00:23:16 +00:00
|
|
|
#include "CGuiSys.hpp"
|
2016-03-12 04:58:56 +00:00
|
|
|
#include "CGuiWidget.hpp"
|
|
|
|
#include "CGuiHeadWidget.hpp"
|
|
|
|
#include "CGuiLight.hpp"
|
|
|
|
#include "CGuiCamera.hpp"
|
|
|
|
#include "CGuiGroup.hpp"
|
|
|
|
#include "CGuiPane.hpp"
|
|
|
|
#include "CAuiImagePane.hpp"
|
|
|
|
#include "CAuiMeter.hpp"
|
|
|
|
#include "CGuiModel.hpp"
|
|
|
|
#include "CGuiTableGroup.hpp"
|
|
|
|
#include "CGuiSliderGroup.hpp"
|
|
|
|
#include "CGuiTextPane.hpp"
|
|
|
|
#include "CAuiEnergyBarT01.hpp"
|
2016-03-21 05:02:56 +00:00
|
|
|
#include "CTextParser.hpp"
|
|
|
|
#include "CSimplePool.hpp"
|
2016-03-21 22:01:19 +00:00
|
|
|
#include "CTextExecuteBuffer.hpp"
|
2017-01-30 04:16:20 +00:00
|
|
|
#include "CGuiFrame.hpp"
|
2016-03-11 00:23:16 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
2017-01-22 01:40:12 +00:00
|
|
|
std::shared_ptr<CGuiWidget> CGuiSys::CreateWidgetInGame(FourCC type, CInputStream& in,
|
|
|
|
CGuiFrame* frame, CSimplePool* sp)
|
2016-03-12 04:58:56 +00:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case SBIG('BWIG'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiWidget::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('HWIG'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiHeadWidget::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('LITE'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiLight::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('CAMR'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiCamera::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('GRUP'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiGroup::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('PANE'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiPane::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('IMGP'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CAuiImagePane::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('METR'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CAuiMeter::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('MODL'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiModel::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('TBGP'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiTableGroup::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('SLGP'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiSliderGroup::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('TXPN'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CGuiTextPane::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
case SBIG('ENRG'):
|
2017-01-22 01:40:12 +00:00
|
|
|
return CAuiEnergyBarT01::Create(frame, in, sp);
|
2016-03-12 04:58:56 +00:00
|
|
|
default: break;
|
|
|
|
}
|
2017-01-22 01:40:12 +00:00
|
|
|
return {};
|
2016-03-12 04:58:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 00:23:16 +00:00
|
|
|
CGuiSys::CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode)
|
2016-12-15 22:37:34 +00:00
|
|
|
: x0_resFactory(resFactory), x4_resStore(resStore), x8_mode(mode),
|
|
|
|
xc_textExecuteBuf(new CTextExecuteBuffer()),
|
|
|
|
x10_textParser(new CTextParser(resStore))
|
2016-03-11 00:23:16 +00:00
|
|
|
{
|
2016-12-15 22:37:34 +00:00
|
|
|
g_TextExecuteBuf = xc_textExecuteBuf.get();
|
|
|
|
g_TextParser = x10_textParser.get();
|
2016-03-11 00:23:16 +00:00
|
|
|
}
|
|
|
|
|
2017-01-30 04:16:20 +00:00
|
|
|
void CGuiSys::OnViewportResize()
|
|
|
|
{
|
|
|
|
for (CGuiFrame* frame : m_registeredFrames)
|
|
|
|
ViewportResizeFrame(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiSys::ViewportResizeFrame(CGuiFrame* frame)
|
|
|
|
{
|
|
|
|
float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
|
|
|
|
if (frame->m_aspectConstraint > 0.f)
|
|
|
|
{
|
|
|
|
float hPad, vPad;
|
|
|
|
if (vpAspectRatio >= frame->m_aspectConstraint)
|
|
|
|
{
|
|
|
|
hPad = frame->m_aspectConstraint / vpAspectRatio;
|
2017-01-30 06:58:59 +00:00
|
|
|
vPad = frame->m_aspectConstraint / 1.38f;
|
2017-01-30 04:16:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hPad = 1.f;
|
2017-01-30 06:58:59 +00:00
|
|
|
vPad = vpAspectRatio / 1.38f;
|
2017-01-30 04:16:20 +00:00
|
|
|
}
|
|
|
|
frame->m_aspectTransform = zeus::CTransform::Scale({hPad, 1.f, vPad});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:23:16 +00:00
|
|
|
}
|