-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathStringTablePanel.cpp
More file actions
71 lines (51 loc) · 1.79 KB
/
StringTablePanel.cpp
File metadata and controls
71 lines (51 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "StringTablePanel.h"
StringTablePanel::StringTablePanel( wxWindow* parent )
:
BaseStringTablePanel( parent )
{
}
void StringTablePanel::LoadStringTable(const void* data, size_t dataSize)
{
wxGridTableBase* table = m_grid->GetTable();
m_grid->Freeze();
table->DeleteRows(0, table->GetRowsCount());
table->DeleteCols(0, table->GetColsCount());
const char* dataPos = (const char*) data;
wxUint32 langCount = *reinterpret_cast<const wxUint32*>(dataPos);
dataPos += sizeof(langCount);
table->AppendCols(langCount - 1);
for (wxUint32 langIndex = 0; langIndex < langCount; langIndex++)
{
// Parse string table
// Skip ID
dataPos += sizeof(wxUint32);
wxUint32 idLen = *reinterpret_cast<const wxUint32*>(dataPos);
dataPos += sizeof(idLen);
wxString tableId(dataPos, idLen);
dataPos += idLen + 4;
if (langIndex > 0)
table->SetColLabelValue(langIndex - 1, tableId);
wxUint32 entryCount = *reinterpret_cast<const wxUint32*>(dataPos);
dataPos += sizeof(entryCount);
if (langIndex == 0)
table->AppendRows(entryCount);
const char* stringData = dataPos;
stringData += (entryCount + 1) * sizeof(wxUint32);
const wxUint32* tablePos = reinterpret_cast<const wxUint32*>(dataPos);
for (wxUint32 entryIndex = 0; entryIndex < entryCount; entryIndex++)
{
size_t strLen = tablePos[1] - *tablePos - 1;
wxString value = wxString::FromUTF8(&stringData[*tablePos], strLen);
if (langIndex == 0)
table->SetRowLabelValue(entryIndex, value);
else
table->SetValue(entryIndex, langIndex - 1, value);
tablePos++;
}
// Skip to next table
dataPos += entryCount * sizeof(wxUint32);
wxUint32 skipSize = *reinterpret_cast<const wxUint32*>(dataPos);
dataPos += skipSize + 4;
}
m_grid->Thaw();
}