2007-06-12 21:17:33 +03:00
|
|
|
#include "stdafx.h"
|
2007-06-13 17:02:43 +03:00
|
|
|
#include "CPreGameTextHandler.h"
|
|
|
|
std::string CPreGameTextHandler::getTitle(std::string text)
|
|
|
|
{
|
|
|
|
std::string ret;
|
|
|
|
int i=0;
|
|
|
|
while ((text[i++]!='{'));
|
|
|
|
while ((text[i]!='}') && (i<text.length()))
|
|
|
|
ret+=text[i++];
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
std::string CPreGameTextHandler::getDescr(std::string text)
|
|
|
|
{
|
|
|
|
std::string ret;
|
|
|
|
int i=0;
|
|
|
|
while ((text[i++]!='}'));
|
|
|
|
i+=2;
|
|
|
|
while ((text[i]!='"') && (i<text.length()))
|
|
|
|
ret+=text[i++];
|
|
|
|
return ret;
|
|
|
|
}
|
2007-06-12 21:17:33 +03:00
|
|
|
void CPreGameTextHandler::loadTexts()
|
|
|
|
{
|
|
|
|
std::ifstream inp("H3bitmap.lod\\ZELP.TXT", std::ios::in|std::ios::binary);
|
|
|
|
inp.seekg(0,std::ios::end); // na koniec
|
|
|
|
int andame = inp.tellg(); // read length
|
|
|
|
inp.seekg(0,std::ios::beg); // wracamy na poczatek
|
|
|
|
char * bufor = new char[andame]; // allocate memory
|
|
|
|
inp.read((char*)bufor, andame); // read map file to buffer
|
|
|
|
std::string buf = std::string(bufor);
|
|
|
|
delete [andame] bufor;
|
|
|
|
int i=0; //buf iterator
|
|
|
|
int hmcr=0;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==3)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=3;
|
|
|
|
|
|
|
|
int befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mainNewGame = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
hmcr = 0;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=3;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mainLoadGame = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
hmcr = 0;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=3;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mainHighScores = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
hmcr = 0;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=3;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mainCredits = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
hmcr = 0;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=3;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mainQuit = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
}
|