OpenBarnyard
 
Loading...
Searching...
No Matches
ALoadScreen Class Reference

#include <ALoadScreen.h>

Public Member Functions

 ALoadScreen ()
 
virtual ~ALoadScreen ()
 
void Create ()
 
void StartLoading (TINT a_iUnused, TBOOL a_bRender)
 
void SetLoadingState (TBOOL a_bIsLoading, TBOOL a_bUpdateUI)
 
void Update (TFLOAT a_fDeltaTime=1.0f, TBOOL a_bRender=true)
 
void ResetIndicators (TBOOL a_bRender)
 
void Reset ()
 

Static Public Attributes

static constexpr const TCHARms_LoadTextures []
 
static constexpr TUINT32 NUM_LOAD_TEXTURES = TARRAYSIZE( ms_LoadTextures )
 
static constexpr TUINT32 NUM_LOAD_INDICATORS = 9
 
static constexpr TFLOAT ICON_SWITCH_INTERVAL = 0.4f
 

Detailed Description

Definition at line 8 of file ALoadScreen.h.

Constructor & Destructor Documentation

◆ ALoadScreen()

ALoadScreen::ALoadScreen ( )

Definition at line 23 of file ALoadScreen.cpp.

24{
25 m_bIsLoadingScreen = TFALSE;
26 m_bFlag = TFALSE;
27 m_iNumCowIcons = 1;
28 m_fTotalTime = 0.0f;
29 m_fTimer = 0.8f;
30}
#define TFALSE
Definition Typedefs.h:24

◆ ~ALoadScreen()

ALoadScreen::~ALoadScreen ( )
virtual

Definition at line 34 of file ALoadScreen.cpp.

35{
36}

Member Function Documentation

◆ Create()

void ALoadScreen::Create ( )

Definition at line 39 of file ALoadScreen.cpp.

40{
42 {
43 TASSERT( m_aTextureSections[ i ] == TNULL, "ALoadScreen is already created" );
44 m_aTextureSections[ i ] = AGUI2TextureSectionManager::GetTextureSection( ms_LoadTextures[ i ] );
45 TASSERT( m_aTextureSections[ i ] != TNULL, "Unable to find texture section" );
46 }
47
48 auto pRootElement = AGUI2::GetRootElement();
49
50 TFLOAT fWidth;
51 TFLOAT fHeight;
52 pRootElement->GetDimensions( fWidth, fHeight );
53
54 m_CanvasElement.SetDimensions( fWidth, fHeight );
55 m_CanvasElement.SetColour( TCOLOR( 0, 0, 0 ) );
56 m_CanvasElement.Hide();
57
58 pRootElement->AddChildTail( m_CanvasElement );
59
60 TFLOAT fRectPosX = fWidth * 0.1f;
61
62 for ( TUINT i = 0; i < NUM_LOAD_INDICATORS; i++ )
63 {
64 auto pTexSection = m_aTextureSections[ i % NUM_LOAD_TEXTURES ];
65 auto pRectangle = &m_aRectangles[ i ];
66
67 pRectangle->SetDimensions( pTexSection->GetWidth(), pTexSection->GetHeight() );
68 pRectangle->SetTextureSection( pTexSection );
69 pRectangle->SetAttachment( AGUI2ATTACHMENT_BOTTOMLEFT, AGUI2ATTACHMENT_BOTTOMLEFT );
70 pRectangle->SetTransform( fRectPosX, -fHeight * 0.075f );
71 pRectangle->Hide();
72
73 pRootElement->AddChildTail( *pRectangle );
74 fRectPosX += ( fWidth * 0.8f ) / NUM_LOAD_INDICATORS;
75 }
76
77 auto pFont = AGUI2FontManager::FindFont( "Rekord26" );
78 auto pLoadingString = ALocaleManager::Interface()->GetString( 1123 );
79
80 m_TextBox.Create( pFont, pFont->GetTextWidth( pLoadingString, 1.0f ) );
81 m_TextBox.SetScale( 1.0f );
82 m_TextBox.SetText( pLoadingString );
84 m_TextBox.SetTransform( 0.0f, -fHeight * 0.08f );
85 m_TextBox.Hide();
86
87 pRootElement->AddChildTail( m_TextBox );
88 m_oTimer.Reset();
89
90 m_fTimer = 0.8f;
91 m_fTotalTime = 0.0f;
92}
#define TASSERT(X,...)
Definition Defines.h:138
#define T2_FOREACH_ARRAY(arrName, iteratorName)
Definition T2Iterator.h:10
#define TCOLOR(R, G, B)
Definition TColor.h:4
unsigned int TUINT
Definition Typedefs.h:8
float TFLOAT
Definition Typedefs.h:4
#define TNULL
Definition Typedefs.h:23
@ AGUI2ATTACHMENT_BOTTOMLEFT
@ AGUI2ATTACHMENT_BOTTOMCENTER
static constexpr const TCHAR * ms_LoadTextures[]
Definition ALoadScreen.h:11
static constexpr TUINT32 NUM_LOAD_TEXTURES
Definition ALoadScreen.h:16
static constexpr TUINT32 NUM_LOAD_INDICATORS
Definition ALoadScreen.h:17
static AGUI2Element * GetRootElement()
Definition AGUI2.h:31
static AGUI2Font * FindFont(const TCHAR *a_szFontName)
static AGUI2TextureSection * GetTextureSection(const TCHAR *a_szSectionName)
static ALocaleManager * Interface()

◆ Reset()

void ALoadScreen::Reset ( )

Definition at line 179 of file ALoadScreen.cpp.

180{
181 if ( m_bFlag )
182 {
183 AGUISystem::GetSingleton()->SetPicture( TPString8() );
184 AGUISystem::GetSingleton()->ResetPicture();
185 }
186
187 m_bFlag = TFALSE;
188 m_oTimer.Reset();
189 m_fTimer = 0.8f;
190
191 for ( TUINT i = 0; i < NUM_LOAD_INDICATORS; i++ )
192 {
193 auto pRectangle = &m_aRectangles[ i ];
194 pRectangle->Hide();
195 }
196
197 m_CanvasElement.Hide();
198 m_TextBox.Hide();
199
200 m_bIsLoadingScreen = TFALSE;
201}

◆ ResetIndicators()

void ALoadScreen::ResetIndicators ( TBOOL a_bRender)

Definition at line 167 of file ALoadScreen.cpp.

168{
169 if ( m_bIsLoadingScreen )
170 {
171 m_iNumCowIcons = 0;
172 m_iCowPos = 0;
173
174 UpdateUI( a_bRender );
175 }
176}

◆ SetLoadingState()

void ALoadScreen::SetLoadingState ( TBOOL a_bIsLoading,
TBOOL a_bUpdateUI )

Definition at line 123 of file ALoadScreen.cpp.

124{
125 m_bIsLoadingScreen = a_bIsLoading;
126
127 if ( !m_bFlag )
128 {
129 if ( a_bIsLoading ) m_CanvasElement.Show();
130 else
131 m_CanvasElement.Hide();
132 }
133
134 if ( !a_bIsLoading )
135 {
136 m_iNumCowIcons = 0;
137 }
138
139 if ( a_bIsLoading ) m_TextBox.Show();
140 else
141 m_TextBox.Hide();
142
143 if ( a_bUpdateUI ) UpdateUI( a_bIsLoading );
144}

◆ StartLoading()

void ALoadScreen::StartLoading ( TINT a_iUnused,
TBOOL a_bRender )

Definition at line 95 of file ALoadScreen.cpp.

96{
97 m_bIsLoadingScreen = TTRUE;
98
99 if ( !m_bFlag )
100 {
101 m_CanvasElement.Show();
102 }
103
104 m_TextBox.Show();
105 m_iNumCowIcons = 1;
106 m_iCowPos = 0;
107 m_bFlag = TFALSE;
108
109 m_oTimer.Reset();
110 m_fTimer = 0.0f;
111 m_fTotalTime = 0.0f;
112
113 for ( TUINT i = 0; i < NUM_LOAD_INDICATORS; i++ )
114 {
115 m_aRectangles[ i ].Show();
116 }
117
118 m_TextBox.Show();
119 UpdateUI( a_bRender );
120}
#define TTRUE
Definition Typedefs.h:25

◆ Update()

void ALoadScreen::Update ( TFLOAT a_fDeltaTime = 1.0f,
TBOOL a_bRender = true )

Definition at line 147 of file ALoadScreen.cpp.

148{
149 if ( m_bIsLoadingScreen )
150 {
151 m_oTimer.Update();
152 m_fTimer += m_oTimer.GetDelta();
153 m_fTotalTime += m_oTimer.GetDelta();
154
155 if ( m_fTimer >= ICON_SWITCH_INTERVAL )
156 {
157 m_fTimer = 0.0f;
158
159 if ( m_iNumCowIcons < 3 ) m_iNumCowIcons++;
160 m_iCowPos = ( m_iCowPos + 1 ) % NUM_LOAD_INDICATORS;
161 UpdateUI( a_bRender );
162 }
163 }
164}
static constexpr TFLOAT ICON_SWITCH_INTERVAL
Definition ALoadScreen.h:18

Member Data Documentation

◆ ICON_SWITCH_INTERVAL

TFLOAT ALoadScreen::ICON_SWITCH_INTERVAL = 0.4f
staticconstexpr

Definition at line 18 of file ALoadScreen.h.

◆ ms_LoadTextures

const TCHAR* ALoadScreen::ms_LoadTextures[]
staticconstexpr
Initial value:
= {
"Loader_Cow_01",
"Loader_Cow_02",
}

Definition at line 11 of file ALoadScreen.h.

11 {
12 "Loader_Cow_01",
13 "Loader_Cow_02",
14 };

◆ NUM_LOAD_INDICATORS

TUINT32 ALoadScreen::NUM_LOAD_INDICATORS = 9
staticconstexpr

Definition at line 17 of file ALoadScreen.h.

◆ NUM_LOAD_TEXTURES

TUINT32 ALoadScreen::NUM_LOAD_TEXTURES = TARRAYSIZE( ms_LoadTextures )
staticconstexpr

Definition at line 16 of file ALoadScreen.h.


The documentation for this class was generated from the following files: