#include "CStringTable.hpp" namespace urde { const std::vector CStringTable::skLanguages = { 'ENGL', 'FREN', 'GERM', 'SPAN', 'ITAL', 'DUTC', 'JAPN' }; FourCC CStringTable::mCurrentLanguage = CStringTable::skLanguages[0]; CStringTable::CStringTable(CInputStream& in) { LoadStringTable(in); } void CStringTable::LoadStringTable(CInputStream &in) { in.readUint32Big(); in.readUint32Big(); u32 langCount = in.readUint32Big(); x0_stringCount = in.readUint32Big(); std::vector> langOffsets; for (u32 i = 0 ; i 0) { if (langOffsets[lang].first == mCurrentLanguage) { offset = langOffsets[lang].second; break; } lang++; } in.seek(offset); u32 dataLen = in.readUint32Big(); m_bufLen = dataLen; x4_data.reset(new u8[dataLen]); in.readUBytesToBuf(x4_data.get(), dataLen); for (u32 i = 0 ; i(x4_data.get() + i); *off = hecl::SBig(*off); } for (u32 i = x0_stringCount * 4 ; i(x4_data.get() + i); *chr = hecl::SBig(*chr); } } std::wstring CStringTable::GetString(s32 str) const { if (str < 0 || str >= x0_stringCount) return L"Invalid"; u32 off = *(reinterpret_cast(x4_data.get() + str * 4)); CMemoryInStream tmp(x4_data.get() + off, m_bufLen - off); return tmp.readWString(); } void CStringTable::SetLanguage(s32 lang) { mCurrentLanguage = skLanguages[lang]; } }