1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-03 23:19:22 +02:00

zaczytywanie tekstów do menu głównego, przygotowania do obsługi obiektów na mapie

This commit is contained in:
mateuszb
2007-06-12 18:17:33 +00:00
parent 59d60f76d7
commit 252252ce6d
8 changed files with 157 additions and 4 deletions

109
CPreGameTextHandler.cpp Normal file
View File

@@ -0,0 +1,109 @@
#include "CPreGameTextHandler.h"
#include "stdafx.h"
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;
}