OpenBarnyard
 
Loading...
Searching...
No Matches
T2Locale.h
Go to the documentation of this file.
1
11
12#pragma once
13#include "Toshi/TSingleton.h"
14#include "File/TTRB.h"
15
17
19
20class T2Locale : public Toshi::TSingleton<T2Locale>
21{
22public:
23 using Lang = TINT32;
24
30
31public:
32 T2Locale( const T2Locale& ) = delete;
33 T2Locale( const T2Locale&& ) = delete;
34
35 virtual ~T2Locale();
36 virtual const TCHAR* GetLanguageFilename( Lang lang ) = 0;
37
38 void SetLanguage( Lang langid );
39 Lang GetLanguage() const;
40
41 TINT GetNumStrings() const;
42 T2LocalisedString GetString( TINT a_iNumString );
43
44protected:
45 T2Locale( TINT langCount, size_t bufferSize, void* buffer );
46
47 static void* TRBAllocator( TTRB::AllocType alloctype, size_t size, short unk, size_t unk2, void* userData );
48 static void TRBDeallocator( TTRB::AllocType alloctype, void* ptr, short unk, size_t unk2, void* userData );
49
50 void* TRBAlloc( size_t size )
51 {
52 void* ptr = m_BufferPos;
53 m_BufferPos = static_cast<TCHAR*>( ptr ) + size;
54 return ptr;
55 }
56
57protected:
58 TTRB m_Locale; // 0x04
59 void* m_pBuffer; // 0x18
60 void* m_BufferPos; // 0x1C
62 Lang m_LangId; // 0x24
64};
65
TRB (Toshi Relocatable Binary) resource system for the Toshi engine.
TWCHAR * T2LocalisedString
Definition T2Locale.h:18
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
int32_t TINT32
Definition Typedefs.h:12
wchar_t TWCHAR
Definition Typedefs.h:21
char TCHAR
Definition Typedefs.h:20
int TINT
Definition Typedefs.h:7
bool TBOOL
Definition Typedefs.h:6
Definition TTRB.h:253
TUINT8 AllocType
Definition TTRB.h:269
TINT GetNumStrings() const
Definition T2Locale.cpp:71
T2Locale(const T2Locale &&)=delete
virtual const TCHAR * GetLanguageFilename(Lang lang)=0
T2LocalisedString GetString(TINT a_iNumString)
Definition T2Locale.cpp:76
void * TRBAlloc(size_t size)
Definition T2Locale.h:50
void * m_BufferPos
Definition T2Locale.h:60
LocaleStrings * m_StringTable
Definition T2Locale.h:61
T2Locale(TINT langCount, size_t bufferSize, void *buffer)
void * m_pBuffer
Definition T2Locale.h:59
Lang m_LangId
Definition T2Locale.h:62
static void * TRBAllocator(TTRB::AllocType alloctype, size_t size, short unk, size_t unk2, void *userData)
Definition T2Locale.cpp:43
virtual ~T2Locale()
Definition T2Locale.cpp:33
TINT32 Lang
Definition T2Locale.h:23
T2Locale(const T2Locale &)=delete
static void TRBDeallocator(TTRB::AllocType alloctype, void *ptr, short unk, size_t unk2, void *userData)
Definition T2Locale.cpp:48
TTRB m_Locale
Definition T2Locale.h:58
void SetLanguage(Lang langid)
Definition T2Locale.cpp:53
TBOOL m_bOwnsBuffer
Definition T2Locale.h:63
Lang GetLanguage() const
Definition T2Locale.cpp:66
T2LocalisedString * Strings
Definition T2Locale.h:28