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

#include <AAssetLoader.h>

Public Member Functions

 AAssetLoader ()=delete
 

Static Public Member Functions

static TBOOL LoadAssetPackFromLibrary (const TCHAR *a_szLibraryName, TBOOL a_bStream)
 
static TBOOL CreateAssetsFromLibrary (const TCHAR *a_szLibraryName)
 
static TBOOL Load (const TCHAR *a_szFileName, AAssetType a_eAssetType, TBOOL a_bStream)
 
static void Close (AAssetType a_eAssetType)
 
static void * GetSymbolAddress (const TCHAR *a_szFileName, const TCHAR *a_szSymbolName, AAssetType a_eAssetType)
 
template<class T>
static T * CastSymbol (const TCHAR *a_szFileName, const TCHAR *a_szSymbolName, AAssetType a_eAssetType)
 
static Toshi::TTRB * GetAssetTRB (AAssetType a_eAssetType)
 

Detailed Description

Definition at line 13 of file AAssetLoader.h.

Constructor & Destructor Documentation

◆ AAssetLoader()

AAssetLoader::AAssetLoader ( )
delete

Member Function Documentation

◆ CastSymbol()

template<class T>
static T * AAssetLoader::CastSymbol ( const TCHAR * a_szFileName,
const TCHAR * a_szSymbolName,
AAssetType a_eAssetType )
inlinestatic

Definition at line 31 of file AAssetLoader.h.

32 {
33 return TSTATICCAST(
34 T,
35 GetSymbolAddress( a_szFileName, a_szSymbolName, a_eAssetType )
36 );
37 }
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
static void * GetSymbolAddress(const TCHAR *a_szFileName, const TCHAR *a_szSymbolName, AAssetType a_eAssetType)

◆ Close()

void AAssetLoader::Close ( AAssetType a_eAssetType)
static

Definition at line 170 of file AAssetLoader.cpp.

171{
172 if ( ms_pTRBFiles[ a_eAssetType ] )
173 {
174 ms_pTRBFiles[ a_eAssetType ]->Close();
175 delete ms_pTRBFiles[ a_eAssetType ];
176 ms_pTRBFiles[ a_eAssetType ] = TNULL;
177 }
178}
#define TNULL
Definition Typedefs.h:23

◆ CreateAssetsFromLibrary()

TBOOL AAssetLoader::CreateAssetsFromLibrary ( const TCHAR * a_szLibraryName)
static

Definition at line 62 of file AAssetLoader.cpp.

63{
65
66 TString8 libFileName;
67 TranslateLibraryName( libFileName, a_szLibraryName );
68
69 TTRB libTrb;
70 auto eResult = libTrb.Load( libFileName );
71
72 if ( eResult == TTRB::ERROR_OK )
73 {
74 auto pProperties = PBProperties::LoadFromTRB( libTrb );
75 TVALIDPTR( pProperties );
76
77 TFIXME( "Create other assets" );
78
79 // Load material libraries
80 auto pMatlibs = pProperties->GetProperty( "matlib" );
81
82 if ( pMatlibs )
83 {
84 AMaterialLibraryManager::GetSingleton()->LoadLibrariesFromProperties(
85 pMatlibs,
87 TTRUE
88 );
89
90 g_oLoadScreen.Update( 1.0f, TTRUE );
91 }
92
93 // Load keyframe libraries
94 auto pKeyframes = pProperties->GetProperty( "keylib" );
95
96 if ( pKeyframes )
97 {
98 AKeyFrameLibraryManager::GetSingleton()->LoadLibrariesFromProperties(
99 pKeyframes,
101 );
102
103 g_oLoadScreen.Update( 1.0f, TTRUE );
104 }
105
106 // Load animatable object types
107 auto pAnimObjTypes = pProperties->GetProperty( "AnimObjTypes" );
108
109 if ( pAnimObjTypes )
110 {
111 AAnimatableObjectManager::GetSingleton()->LoadTypesFromLibrary( a_szLibraryName );
112
113 g_oLoadScreen.Update( 1.0f, TTRUE );
114 }
115
116 return TTRUE;
117 }
118
119 return TFALSE;
120}
#define TFIXME(DESC)
Definition Defines.h:135
#define TVALIDPTR(PTR)
Definition Defines.h:139
#define TPROFILER_SCOPE()
Definition Profiler.h:17
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
ALoadScreen g_oLoadScreen
@ AAssetType_AssetPack
Definition AAssetLoader.h:7
ERROR Load(const TCHAR *a_szFilePath, TUINT32 a_uiUnknown=0)
Definition TTRB.cpp:38
@ ERROR_OK
Definition TTRB.h:258
void Update(TFLOAT a_fDeltaTime=1.0f, TBOOL a_bRender=true)
static Toshi::TTRB * GetAssetTRB(AAssetType a_eAssetType)

◆ GetAssetTRB()

static Toshi::TTRB * AAssetLoader::GetAssetTRB ( AAssetType a_eAssetType)
inlinestatic

Definition at line 40 of file AAssetLoader.h.

41 {
42 TASSERT( a_eAssetType < AAssetType_NUMOF );
43 return ms_pTRBFiles[ a_eAssetType ];
44 }
#define TASSERT(X,...)
Definition Defines.h:138
@ AAssetType_NUMOF

◆ GetSymbolAddress()

void * AAssetLoader::GetSymbolAddress ( const TCHAR * a_szFileName,
const TCHAR * a_szSymbolName,
AAssetType a_eAssetType )
static

Definition at line 181 of file AAssetLoader.cpp.

182{
183 if ( ms_pTRBFiles[ a_eAssetType ] )
184 {
185 TCHAR szName[ 256 ];
186 Toshi::TStringManager::String8Format( szName, sizeof( szName ), "%s_%s", a_szFileName, a_szSymbolName );
187 return ms_pTRBFiles[ a_eAssetType ]->GetSymbolAddress( szName );
188 }
189
190 return TNULL;
191}
char TCHAR
Definition Typedefs.h:20

◆ Load()

TBOOL AAssetLoader::Load ( const TCHAR * a_szFileName,
AAssetType a_eAssetType,
TBOOL a_bStream )
static

Definition at line 123 of file AAssetLoader.cpp.

124{
126
127 if ( !ms_pTRBFiles[ a_eAssetType ] )
128 {
129 // Create TTRB if it doesn't exist
130 ms_pTRBFiles[ a_eAssetType ] = new TTRB;
131 }
132 else
133 {
134 ms_pTRBFiles[ a_eAssetType ]->Close();
135 }
136
137 if ( a_bStream && AAssetStreaming::IsSingletonCreated() )
138 {
139 ATRBLoaderJob trbLoaderJob;
140 trbLoaderJob.InitJob( ms_pTRBFiles[ a_eAssetType ], a_szFileName );
141
142 AAssetStreaming::GetSingleton()->AddMainThreadJob( &trbLoaderJob );
143
144 while ( AAssetStreaming::GetSingleton()->HasActiveJobs() )
145 {
146 g_oLoadScreen.Update( 1.0f, TTRUE );
147#ifndef BARNYARD_COMMUNITY_PATCH
148 ThreadSleep( 5 );
149#endif // BARNYARD_COMMUNITY_PATCH
150 AAssetStreaming::GetSingleton()->Update();
151 }
152 }
153 else
154 {
155 auto eError = ms_pTRBFiles[ a_eAssetType ]->Load( a_szFileName );
156
157 if ( eError != TTRB::ERROR_OK )
158 {
159 delete ms_pTRBFiles[ a_eAssetType ];
160 ms_pTRBFiles[ a_eAssetType ] = TNULL;
161
162 return TFALSE;
163 }
164 }
165
166 return TTRUE;
167}
void ThreadSleep(TUINT dwMilliseconds)
void InitJob(Toshi::TTRB *a_pTRB, const TCHAR *a_szFileName)

◆ LoadAssetPackFromLibrary()

TBOOL AAssetLoader::LoadAssetPackFromLibrary ( const TCHAR * a_szLibraryName,
TBOOL a_bStream )
static

Definition at line 31 of file AAssetLoader.cpp.

32{
34
35 TString8 libFileName;
36 TranslateLibraryName( libFileName, a_szLibraryName );
37
38 TTRB libTrb;
39 auto eResult = libTrb.Load( libFileName );
40
41 if ( eResult == TTRB::ERROR_OK )
42 {
43 auto pProperties = PBProperties::LoadFromTRB( libTrb );
44 TVALIDPTR( pProperties );
45
46 // Load asset pack
47 auto pModelLib = pProperties->GetProperty( "modellib" );
48
49 if ( pModelLib )
50 {
51 TBOOL bResult = Load( pModelLib->GetString(), AAssetType_AssetPack, a_bStream );
52 TASSERT( bResult );
53 }
54
55 return TTRUE;
56 }
57
58 return TFALSE;
59}
bool TBOOL
Definition Typedefs.h:6
static TBOOL Load(const TCHAR *a_szFileName, AAssetType a_eAssetType, TBOOL a_bStream)

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