OpenBarnyard
 
Loading...
Searching...
No Matches
AGUISystem.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "AGUISystem.h"
4#include "Render/ARenderer.h"
5#include "Memory/AMemory.h"
7
8//-----------------------------------------------------------------------------
9// Enables memory debugging.
10// Note: Should be the last include!
11//-----------------------------------------------------------------------------
12#include <Core/TMemoryDebugOn.h>
13
15
17
18TPSTRING8_DECLARE( Start );
19TPSTRING8_DECLARE( ParkManager );
20
22{
23 m_Unk1 = 0;
24 m_Unk2 = 0;
25 m_Unk3 = 0;
26 m_pStrings = new Toshi::TPString8[ 2 ];
27 m_pStrings[ 0 ] = TPS8( ParkManager );
28 m_pStrings[ 1 ] = TPS8( Start );
29}
30
32{
33 m_RenderGUIListener.Connect(
34 ARenderer::GetSingleton()->GetRenderGUIEmitter(),
35 this,
36 OnGUIRender,
37 0xffff8000
38 );
39
40 auto pDisplayParams = Toshi::TRenderInterface::GetSingleton()->GetCurrentDisplayParams();
41
42 for ( TUINT i = 0; i < NUM_RENDER_OBJECTS; i++ )
43 {
44 auto pViewport = new Toshi::TViewport( TTRUE );
45 pViewport->SetX( 0.0f );
46 pViewport->SetY( 0.0f );
47 pViewport->SetWidth( TFLOAT( pDisplayParams->uiWidth ) );
48 pViewport->SetHeight( TFLOAT( pDisplayParams->uiHeight ) );
49 pViewport->SetMinZ( 0.0f );
50 pViewport->SetMaxZ( 1.0f );
51 pViewport->SetBackgroundColor( 0, 0, 0, 0 );
52 pViewport->AllowBackgroundClear( TFALSE );
53 pViewport->AllowDepthClear( TTRUE );
54 pViewport->SetMemoryAllocatorBlock( AMemory::GetMemBlock( AMemory::POOL_Viewport ) );
55
56 m_pRenderObjects[ i ] = new PGUITRRenderObject( i );
57 m_pRenderObjects[ i ]->SetViewport( pViewport );
58 }
59
60 return TTRUE;
61}
62
64{
65 for ( TUINT i = 0; i < NUM_RENDER_OBJECTS; i++ )
66 {
67 delete m_pRenderObjects[ i ];
68 }
69
70 m_SomeListener.Disconnect();
71}
72
73TBOOL __stdcall AGUISystem::OnGUIRender( AGUISystem* a_pGUISystem, ARenderer* a_pRenderer, TINT* a_pUnknown )
74{
75 if ( *a_pUnknown == 0 )
76 {
77 a_pGUISystem->m_MatLibPicture.Render();
78 }
79
80 return TTRUE;
81}
82
84{
85 if ( ms_pSingleton->m_pRenderObjects[ 0 ] != TNULL )
86 {
87 auto pViewport = ms_pSingleton->m_pRenderObjects[ 0 ]->GetViewport();
88
89 if ( pViewport )
90 {
91 pViewport->AllowBackgroundClear( a_bAllow );
92 }
93 }
94}
95
96void AGUISystem::SetPicture( const Toshi::TPString8& a_rName )
97{
98 TBOOL bShowPicture = TFALSE;
99
100 if ( !a_rName.IsEmpty() && a_rName.GetString8().Length() != 0 )
101 {
102 bShowPicture = ( a_rName != m_MatLibPicture.GetName() );
103 }
104
105 if ( bShowPicture )
106 {
107 if ( ATerrainInterface::IsSingletonCreated() )
108 {
109 ATerrainInterface::GetSingleton()->WaitUntilLoaded();
110 }
111
112 m_MatLibPicture.Create( a_rName );
113 m_MatLibPicture.Flush();
114 m_MatLibPicture.Cache();
115 m_MatLibPicture.SetVisible();
116 }
117 else if ( a_rName.IsEmpty() || a_rName.GetString8().Length() == 0 )
118 {
119 m_MatLibPicture.Flush();
120 m_MatLibPicture.Create( a_rName );
121 m_MatLibPicture.SetHidden();
122 }
123}
124
126{
127 m_MatLibPicture.Flush();
128 m_MatLibPicture.Create( TPString8() );
129}
#define TOSHI_NAMESPACE_USING
Definition Defines.h:46
#define TDEFINE_CLASS(...)
Definition TObject.h:120
#define TPSTRING8_DECLARE(STR)
Definition TPString8.h:15
#define TPS8(STR)
Definition TPString8.h:16
T * TSingleton< T >::ms_pSingleton
Definition TSingleton.h:75
unsigned int TUINT
Definition Typedefs.h:8
float TFLOAT
Definition Typedefs.h:4
#define TNULL
Definition Typedefs.h:23
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
virtual void Render()
static constexpr TUINT NUM_RENDER_OBJECTS
Definition AGUISystem.h:13
static void AllowBackgroundClear(TBOOL a_bAllow)
void ResetPicture()
virtual TBOOL OnCreate() override
void SetPicture(const Toshi::TPString8 &a_rName)
virtual void OnDestroy() override
@ POOL_Viewport
Definition AMemory.h:40
static Toshi::TMemory::MemBlock * GetMemBlock(POOL a_ePool)
Definition AMemory.cpp:38