| Line 70... |
Line 70... |
| 70 |
return !m_pTexts->empty();
|
70 |
return !m_pTexts->empty();
|
| 71 |
}
|
71 |
}
|
| 72 |
|
72 |
|
| 73 |
Utils::WString CTextDB::_parseText(int iLang, const Utils::WString &sText, const Utils::WString &sReplace) const
|
73 |
Utils::WString CTextDB::_parseText(int iLang, const Utils::WString &sText, const Utils::WString &sReplace) const
|
| 74 |
{
|
74 |
{
|
| 75 |
Utils::WString::size_type pos = sReplace.find_first_of(L",", 0);
|
75 |
std::wstring::size_type pos = sReplace.toStdWString().find_first_of(L",", 0);
|
| 76 |
if ( pos != Utils::WString::npos ) {
|
76 |
if ( pos != std::wstring::npos ) {
|
| 77 |
int iPage = Utils::WString(sReplace.substr(1, pos));
|
77 |
int iPage = Utils::WString(sReplace.substr(1, pos));
|
| 78 |
int iID = Utils::WString(sReplace.substr(pos + 1, sReplace.length() - pos - 2));
|
78 |
int iID = Utils::WString(sReplace.substr(pos + 1, sReplace.length() - pos - 2));
|
| 79 |
return sText.findReplace(sReplace, this->get(iLang, iPage, iID));
|
79 |
return sText.findReplace(sReplace, this->get(iLang, iPage, iID));
|
| 80 |
}
|
80 |
}
|
| 81 |
|
81 |
|
| Line 84... |
Line 84... |
| 84 |
|
84 |
|
| 85 |
Utils::WString CTextDB::_parseText(int iLang, const Utils::WString &sText) const
|
85 |
Utils::WString CTextDB::_parseText(int iLang, const Utils::WString &sText) const
|
| 86 |
{
|
86 |
{
|
| 87 |
Utils::WString sNewText = sText;
|
87 |
Utils::WString sNewText = sText;
|
| 88 |
|
88 |
|
| 89 |
Utils::WString::size_type pos = sNewText.find_first_of(L"{", 0);
|
89 |
std::wstring::size_type pos = sNewText.toStdWString().find_first_of(L"{", 0);
|
| 90 |
while ( pos != Utils::WString::npos ) {
|
90 |
while ( pos != std::wstring::npos ) {
|
| 91 |
Utils::WString::size_type endPos = sNewText.find_first_of(L"}", pos);
|
91 |
std::wstring::size_type endPos = sNewText.toStdWString().find_first_of(L"}", pos);
|
| 92 |
if ( endPos != Utils::WString::npos ) {
|
92 |
if ( endPos != std::wstring::npos ) {
|
| 93 |
sNewText = this->_parseText(iLang, sNewText, sNewText.substr(pos, (endPos - pos) + 1));
|
93 |
sNewText = this->_parseText(iLang, sNewText, sNewText.substr(pos, (endPos - pos) + 1));
|
| 94 |
pos = sNewText.find_first_of(L"{", 0);
|
94 |
pos = sNewText.toStdWString().find_first_of(L"{", 0);
|
| 95 |
}
|
95 |
}
|
| 96 |
else
|
96 |
else
|
| 97 |
pos = sNewText.find_first_of(L"{", pos);
|
97 |
pos = sNewText.toStdWString().find_first_of(L"{", pos);
|
| 98 |
}
|
98 |
}
|
| 99 |
|
99 |
|
| 100 |
return sNewText;
|
100 |
return sNewText;
|
| 101 |
}
|
101 |
}
|
| 102 |
|
102 |
|
| 103 |
void CTextDB::_parseFileLine(int iFromPage, int iToPage, int iLang, const Utils::WString &sLine)
|
103 |
void CTextDB::_parseFileLine(int iFromPage, int iToPage, int iLang, const Utils::WString &sLine)
|
| 104 |
{
|
104 |
{
|
| 105 |
if ( m_iInPage ) {
|
105 |
if ( m_iInPage ) {
|
| 106 |
// check for end of page
|
106 |
// check for end of page
|
| 107 |
size_t pos = sLine.find(L"</page>");
|
107 |
size_t pos = sLine.toStdWString().find(L"</page>");
|
| 108 |
if ( pos != Utils::WString::npos ) {
|
108 |
if ( pos != std::wstring::npos ) {
|
| 109 |
m_iInPage = 0;
|
109 |
m_iInPage = 0;
|
| 110 |
}
|
110 |
}
|
| 111 |
else {
|
111 |
else {
|
| 112 |
this->_parsePage(iLang, sLine);
|
112 |
this->_parsePage(iLang, sLine);
|
| 113 |
}
|
113 |
}
|
| 114 |
}
|
114 |
}
|
| 115 |
else {
|
115 |
else {
|
| 116 |
size_t pos = sLine.find(L"<page id=\"");
|
116 |
size_t pos = sLine.toStdWString().find(L"<page id=\"");
|
| 117 |
if ( pos != Utils::WString::npos ) {
|
117 |
if ( pos != std::wstring::npos ) {
|
| 118 |
pos += 10; // move to the end of the search string (after ")
|
118 |
pos += 10; // move to the end of the search string (after ")
|
| 119 |
size_t endPos = sLine.find(L"\"", pos);
|
119 |
size_t endPos = sLine.toStdWString().find(L"\"", pos);
|
| 120 |
int iPageID = Utils::WString(sLine.substr(pos, endPos - pos));
|
120 |
int iPageID = Utils::WString(sLine.substr(pos, endPos - pos));
|
| 121 |
int iGameID = iPageID / 10000;
|
121 |
int iGameID = iPageID / 10000;
|
| 122 |
iPageID %= 10000; // make sure we remove the game id
|
122 |
iPageID %= 10000; // make sure we remove the game id
|
| 123 |
if ( iFromPage > 0 && iPageID < iFromPage ) return; // out of range
|
123 |
if ( iFromPage > 0 && iPageID < iFromPage ) return; // out of range
|
| 124 |
if ( iToPage > 0 && iPageID > iToPage) return; // out of range
|
124 |
if ( iToPage > 0 && iPageID > iToPage) return; // out of range
|
| Line 132... |
Line 132... |
| 132 |
|
132 |
|
| 133 |
|
133 |
|
| 134 |
void CTextDB::_parsePage(int iLang, const Utils::WString &sLine)
|
134 |
void CTextDB::_parsePage(int iLang, const Utils::WString &sLine)
|
| 135 |
{
|
135 |
{
|
| 136 |
// move to the id number
|
136 |
// move to the id number
|
| 137 |
size_t pos = sLine.find(L"<t id=\"");
|
137 |
size_t pos = sLine.toStdWString().find(L"<t id=\"");
|
| 138 |
if ( pos == Utils::WString::npos ) return;
|
138 |
if ( pos == std::wstring::npos ) return;
|
| 139 |
|
139 |
|
| 140 |
pos += 7; // move past to the "
|
140 |
pos += 7; // move past to the "
|
| 141 |
size_t endPos = sLine.find(L"\"", pos);
|
141 |
size_t endPos = sLine.toStdWString().find(L"\"", pos);
|
| 142 |
if ( endPos == Utils::WString::npos ) return;
|
142 |
if ( endPos == std::wstring::npos ) return;
|
| 143 |
|
143 |
|
| 144 |
// get the number to add
|
144 |
// get the number to add
|
| 145 |
int iID = Utils::WString(sLine.substr(pos, endPos - pos));
|
145 |
int iID = Utils::WString(sLine.substr(pos, endPos - pos));
|
| 146 |
|
146 |
|
| 147 |
// now find the text
|
147 |
// now find the text
|
| 148 |
pos = sLine.find(L">", endPos);
|
148 |
pos = sLine.toStdWString().find(L">", endPos);
|
| 149 |
if ( pos == Utils::WString::npos ) return;
|
149 |
if ( pos == std::wstring::npos ) return;
|
| 150 |
++pos;
|
150 |
++pos;
|
| 151 |
endPos = sLine.find(L"</t>", pos);
|
151 |
endPos = sLine.toStdWString().find(L"</t>", pos);
|
| 152 |
if ( endPos == Utils::WString::npos ) return;
|
152 |
if ( endPos == std::wstring::npos ) return;
|
| 153 |
|
153 |
|
| 154 |
this->_addText(iLang, iID, sLine.substr(pos, endPos - pos));
|
154 |
this->_addText(iLang, iID, sLine.substr(pos, endPos - pos));
|
| 155 |
}
|
155 |
}
|
| 156 |
|
156 |
|
| 157 |
void CTextDB::_addText(int iLang, int iID, const Utils::WString &sText)
|
157 |
void CTextDB::_addText(int iLang, int iID, const Utils::WString &sText)
|