//CFTTLangDatabase - [2020-04-13 11:57:46]
#ifndef _CFTTLANGDATABASE_H_
#define _CFTTLANGDATABASE_H_

#include "CFTTFile.h"
#include "CCustomTextEntry.h"

/*
0022044A CFTTLangDatabase::CFTTLangDatabase()
00220480 CFTTLangDatabase::~CFTTLangDatabase()
0022048C CFTTLangDatabase::Shutdown()
00220564 CFTTLangDatabase::Init(CFTTFile *,bool,char const*)
002206F4 CFTTLangDatabase::LoadStringIdsFrom(ELangType)
002208E0 CFTTLangDatabase::LoadLanguage(ELangType)
0022098C CFTTLangDatabase::Init(char const*,bool,char const*)
002209D4 CFTTLangDatabase::GetLanguageIndexAndOffset(ELangType,int &,int &)
00220A0E CFTTLangDatabase::BuildASCIITable()
00220A50 CFTTLangDatabase::SetCustomStrings()
00220A9C CFTTLangDatabase::GetSourceSize()
00220AA0 CFTTLangDatabase::HasLanguageCached()
00220AA8 CFTTLangDatabase::GetAsciiText(int)
00220AC4 CFTTLangDatabase::GetUnicodeText(int)
00220ACC CFTTLangDatabase::FindStringIDByName(char const*)
00220B2C CFTTLangDatabase::GetAsciiTextByName(char const*)
00220B60 CFTTLangDatabase::GetUnicodeTextByName(char const*,bool)
00220B80 CFTTLangDatabase::FormatTime(wchar_t *,int,float)
00220BFC CFTTLangDatabase::FormatSeconds(wchar_t *,int,float)
00220C60 CFTTLangDatabase::FormatStringSeparator(wchar_t *,int,wchar_t const*,wchar_t const*)
00220CCC CFTTLangDatabase::FormatInteger(wchar_t *,int,int)
00220DB0 CFTTLangDatabase::GetDecimalPoint()
00220DCC CFTTLangDatabase::FormatFloat(wchar_t *,int,float,int)
00220E80 CFTTLangDatabase::FormatPercentage(wchar_t *,int,int,int)
00220F78 CFTTLangDatabase::UpdateStrings(CCustomTextEntry **,int)

0x4C
*/
//-------------------------------------------------------------------------------------------------
//enum ELangType {
// ELangType_0,
// ELangType_1,
// ELangType_2,
// ELangType_3,
// ELangType_4,
// ELangType_5,
// ELangType_6,
//};
//-------------------------------------------------------------------------------------------------
//0x18
struct FTTL_Head {
  int dMgicNum_0;        //魔数
  int field_4;           //绝大多都是0
  int field_8;           //绝大多都是0
  int dLangTypeCount_C;  //语言类型的数量，如英文，中文，这里就是2
  int dLangCount_10;     //语言的条数
  int field_14;
};
//-------------------------------------------------------------------------------------------------
//0x8
struct FTTL_Node {
  int field_0;
  ELangType eType_4;
};
//-------------------------------------------------------------------------------------------------
class CCustomTextEntry;
//-------------------------------------------------------------------------------------------------
class CFTTLangDatabase {
public:
  //0022044A
  CFTTLangDatabase();

  //00220480
  ~CFTTLangDatabase();

  //0022048C
  void Shutdown();

  //00220564
  bool Init(CFTTFile *pFile, bool b, char const *pFilePath);

  //002206F4
  bool LoadStringIdsFrom(ELangType);

  //002208E0
  bool LoadLanguage(ELangType);

  //0022098C
  bool Init(char const *, bool, char const *);

  //002209D4
  bool GetLanguageIndexAndOffset(ELangType, int &, int &);

  //00220A0E
  void BuildASCIITable();

  //00220A50
  void SetCustomStrings();

  //00220A9C
  int GetSourceSize();

  //00220AA0
  bool HasLanguageCached();

  //00220AA8
  const char *GetAsciiText(int);

  //00220AC4
  wchar_t *GetUnicodeText(int);

  //00220ACC
  int FindStringIDByName(char const *p1);

  //00220B2C
  const char *GetAsciiTextByName(char const *pName);

  //00220B60
  wchar_t *GetUnicodeTextByName(char const *pName, bool b);

  //00220B80
  wchar_t *FormatTime(wchar_t *pOutBuf, int dLen, float f);

  //00220BFC
  wchar_t *FormatSeconds(wchar_t *pOutBuf, int dLen, float f);

  //00220C60
  wchar_t *FormatStringSeparator(wchar_t *pOutBuf,
                                 int dLen,
                                 wchar_t const *pW1,
                                 wchar_t const *pW2);

  //00220CCC
  wchar_t *FormatInteger(wchar_t *, int, int);

  //00220DB0
  wchar_t GetDecimalPoint();

  //00220DCC
  wchar_t *FormatFloat(wchar_t *, int, float, int);

  //00220E80
  void FormatPercentage(wchar_t *, int, int, int);

  //00220F78
  void UpdateStrings(CCustomTextEntry **ppEntry, int dCount);

  CFTTFile *pFile_0;
  wchar_t *pbuf_4;
  wchar_t **list_unicode_8;
  char *pbuf_C;
  char **list_Asciic_10;
  int dLangCount_14;  //volatile
  int dCount_18;
  FTTL_Node *list_Node_1C;
  ELangType eType_20;
  char *pFilePath_24;
  bool bCached_28;
  int field_2C;
  bool bIsAscii_30;
  int dSourceSize_34;
  char *pbuf_38;  //.text:00220816   STRB R1, [R0,R5] 通过这儿判断类型一定是 char*
  char **list_lang_3C;
  int *pbuf_40;
  CCustomTextEntry *pCCustomTextEntry_44;
  volatile int dCount_48;
};
//-------------------------------------------------------------------------------------------------
extern CFTTLangDatabase *g_pTextDbs;
//-------------------------------------------------------------------------------------------------
#endif  //_CFTTLANGDATABASE_H_