mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-15 11:46:56 +02:00
lepsze przewijanie, wczytywanie większej ilosci tekstów
This commit is contained in:
parent
78ad4d39f0
commit
bc7532e4dd
@ -201,6 +201,8 @@ void CArtHandler::loadArtifacts()
|
|||||||
while(nart.desc2[nart.desc2.size()-1]!='"' ||
|
while(nart.desc2[nart.desc2.size()-1]!='"' ||
|
||||||
( (nart.name==std::string("£uk Penetracji")||nart.name==std::string("Bow of Seeking")) && bowCounter<4) ); //do - while end
|
( (nart.name==std::string("£uk Penetracji")||nart.name==std::string("Bow of Seeking")) && bowCounter<4) ); //do - while end
|
||||||
//if(nart.name!=std::string("-1") && nart.name!=std::string("-2"))
|
//if(nart.name!=std::string("-1") && nart.name!=std::string("-2"))
|
||||||
|
nart.description += "\n\n";
|
||||||
|
nart.description += nart.desc2;
|
||||||
this->artifacts.push_back(nart);
|
this->artifacts.push_back(nart);
|
||||||
delete[10000] read;
|
delete[10000] read;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,10 @@ void CCreatureHandler::loadCreatures()
|
|||||||
while(i<buf.size())
|
while(i<buf.size())
|
||||||
{
|
{
|
||||||
if(creatures.size()>190 && buf.substr(i, buf.size()-i).find('\r')==std::string::npos)
|
if(creatures.size()>190 && buf.substr(i, buf.size()-i).find('\r')==std::string::npos)
|
||||||
|
{
|
||||||
|
loadAnimationInfo();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
CCreature ncre;
|
CCreature ncre;
|
||||||
|
|
||||||
@ -261,3 +264,181 @@ void CCreatureHandler::loadCreatures()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCreatureHandler::loadAnimationInfo()
|
||||||
|
{
|
||||||
|
std::ifstream inp("H3bitmap.lod\\CRANIM.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==2)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=2;
|
||||||
|
for(int dd=0; dd<creatures.size(); ++dd)
|
||||||
|
{
|
||||||
|
loadUnitAnimInfo(creatures[dd], buf, i);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCreatureHandler::loadUnitAnimInfo(CCreature & unit, std::string & src, int & i)
|
||||||
|
{
|
||||||
|
int befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.timeBetweenFidgets = atof(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
while(unit.timeBetweenFidgets == 0.0)
|
||||||
|
{
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\r')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=2;
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.timeBetweenFidgets = atof(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.walkAnimationTime = atof(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.attackAnimationTime = atof(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.flightAnimationDistance = atof(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.upperRightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.upperRightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.rightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.rightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.lowerRightMissleOffsetX = atoi(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.lowerRightMissleOffsetY = atoi(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
|
||||||
|
for(int jjj=0; jjj<12; ++jjj)
|
||||||
|
{
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.missleFrameAngles[jjj] = atof(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.troopCountLocationOffset= atoi(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unit.attackClimaxFrame = atoi(src.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
for(i; i<src.size(); ++i)
|
||||||
|
{
|
||||||
|
if(src[i]=='\r')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=2;
|
||||||
|
}
|
||||||
|
@ -13,6 +13,15 @@ public:
|
|||||||
std::string abilityText; //description of abilities
|
std::string abilityText; //description of abilities
|
||||||
std::string abilityRefs; //references to abilities, in textformat
|
std::string abilityRefs; //references to abilities, in textformat
|
||||||
int idNumber;
|
int idNumber;
|
||||||
|
|
||||||
|
///animation info
|
||||||
|
float timeBetweenFidgets, walkAnimationTime, attackAnimationTime, flightAnimationDistance;
|
||||||
|
int upperRightMissleOffsetX, rightMissleOffsetX, lowerRightMissleOffsetX, upperRightMissleOffsetY, rightMissleOffsetY, lowerRightMissleOffsetY;
|
||||||
|
float missleFrameAngles[12];
|
||||||
|
int troopCountLocationOffset, attackClimaxFrame;
|
||||||
|
///end of anim info
|
||||||
|
|
||||||
|
|
||||||
//TODO - zdolnoœci - na typie wyliczeniowym czy czymœ
|
//TODO - zdolnoœci - na typie wyliczeniowym czy czymœ
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,6 +38,8 @@ class CCreatureHandler
|
|||||||
public:
|
public:
|
||||||
std::vector<CCreature> creatures;
|
std::vector<CCreature> creatures;
|
||||||
void loadCreatures();
|
void loadCreatures();
|
||||||
|
void loadAnimationInfo();
|
||||||
|
void loadUnitAnimInfo(CCreature & unit, std::string & src, int & i);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //CCREATUREHANDLER_H
|
#endif //CCREATUREHANDLER_H
|
@ -185,3 +185,84 @@ void CHeroHandler::loadBiographies()
|
|||||||
i+=2;
|
i+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHeroHandler::loadHeroClasses()
|
||||||
|
{
|
||||||
|
std::ifstream inp("H3bitmap.lod\\HCTRAITS.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) //omitting rubbish
|
||||||
|
{
|
||||||
|
if(buf[i]=='\r')
|
||||||
|
++hmcr;
|
||||||
|
if(hmcr==2)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i+=2;
|
||||||
|
for(int ss=0; ss<18; ++ss) //18 classes of hero (including conflux)
|
||||||
|
{
|
||||||
|
CHeroClass * hc = new CHeroClass;
|
||||||
|
int befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hc->name = buf.substr(befi, i-befi);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hc->aggression = atof(buf.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hc->initialAttack = atoi(buf.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hc->initialDefence = atoi(buf.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hc->initialPower = atoi(buf.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
befi=i;
|
||||||
|
for(i; i<andame; ++i)
|
||||||
|
{
|
||||||
|
if(buf[i]=='\t')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hc->initialKnowledge = atoi(buf.substr(befi, i-befi).c_str());
|
||||||
|
++i;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -19,6 +19,20 @@ public:
|
|||||||
bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
|
bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CHeroClass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string name;
|
||||||
|
float aggression;
|
||||||
|
int initialAttack, initialDefence, initialPower, initialKnowledge;
|
||||||
|
int proAttack[2]; //probability of gaining attack point on levels [0]: 2 - 9; [1]: 10+ (out of 100)
|
||||||
|
int proDefence[2]; //probability of gaining defence point on levels [0]: 2 - 9; [1]: 10+ (out of 100)
|
||||||
|
int proPower[2]; //probability of gaining power point on levels [0]: 2 - 9; [1]: 10+ (out of 100)
|
||||||
|
int proKnowledge[2]; //probability of gaining knowledge point on levels [0]: 2 - 9; [1]: 10+ (out of 100)
|
||||||
|
std::vector<int> proSec; //probabilities of gaining secondary skills (out of 112), in id order
|
||||||
|
int selectionProbability[9]; //probability of selection in towns
|
||||||
|
};
|
||||||
|
|
||||||
class CHeroInstance
|
class CHeroInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -32,9 +46,11 @@ class CHeroHandler
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nodrze<CHero> heroes;
|
nodrze<CHero> heroes;
|
||||||
|
std::vector<CHeroClass> heroClasses;
|
||||||
void loadHeroes();
|
void loadHeroes();
|
||||||
void loadSpecialAbilities();
|
void loadSpecialAbilities();
|
||||||
void loadBiographies();
|
void loadBiographies();
|
||||||
|
void loadHeroClasses();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
78
CMT.cpp
78
CMT.cpp
@ -240,15 +240,15 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
CArtHandler * arth = new CArtHandler;
|
CArtHandler * arth = new CArtHandler;
|
||||||
arth->loadArtifacts();
|
arth->loadArtifacts();
|
||||||
cgi->arth = arth;
|
cgi->arth = arth;
|
||||||
CHeroHandler * heroh = new CHeroHandler;
|
|
||||||
heroh->loadHeroes();
|
|
||||||
cgi->heroh = heroh;
|
|
||||||
CCreatureHandler * creh = new CCreatureHandler;
|
CCreatureHandler * creh = new CCreatureHandler;
|
||||||
creh->loadCreatures();
|
creh->loadCreatures();
|
||||||
cgi->creh = creh;
|
cgi->creh = creh;
|
||||||
CAbilityHandler * abilh = new CAbilityHandler;
|
CAbilityHandler * abilh = new CAbilityHandler;
|
||||||
abilh->loadAbilities();
|
abilh->loadAbilities();
|
||||||
cgi->abilh = abilh;
|
cgi->abilh = abilh;
|
||||||
|
CHeroHandler * heroh = new CHeroHandler;
|
||||||
|
heroh->loadHeroes();
|
||||||
|
cgi->heroh = heroh;
|
||||||
CSpellHandler * spellh = new CSpellHandler;
|
CSpellHandler * spellh = new CSpellHandler;
|
||||||
spellh->loadSpells();
|
spellh->loadSpells();
|
||||||
cgi->spellh = spellh;
|
cgi->spellh = spellh;
|
||||||
@ -281,6 +281,10 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
//SDL_Surface * ss = ac->defs[0]->ourImages[0].bitmap;
|
//SDL_Surface * ss = ac->defs[0]->ourImages[0].bitmap;
|
||||||
//SDL_BlitSurface(ss, NULL, ekran, NULL);
|
//SDL_BlitSurface(ss, NULL, ekran, NULL);
|
||||||
|
|
||||||
|
bool scrollingLeft = false;
|
||||||
|
bool scrollingRight = false;
|
||||||
|
bool scrollingUp = false;
|
||||||
|
bool scrollingDown = false;
|
||||||
for(;;) // main loop
|
for(;;) // main loop
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -295,26 +299,22 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
{
|
{
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
{
|
{
|
||||||
if(xx>0)
|
scrollingLeft = true;
|
||||||
xx--;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_RIGHT):
|
case (SDLK_RIGHT):
|
||||||
{
|
{
|
||||||
if(xx<ac->map.width-25)
|
scrollingRight = true;
|
||||||
xx++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_UP):
|
case (SDLK_UP):
|
||||||
{
|
{
|
||||||
if(yy>0)
|
scrollingUp = true;
|
||||||
yy--;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_DOWN):
|
case (SDLK_DOWN):
|
||||||
{
|
{
|
||||||
if(yy<ac->map.height-18)
|
scrollingDown = true;
|
||||||
yy++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (SDLK_q):
|
case (SDLK_q):
|
||||||
@ -332,18 +332,68 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} //keydown end
|
||||||
|
else if(sEvent.type==SDL_KEYUP)
|
||||||
|
{
|
||||||
|
switch (sEvent.key.keysym.sym)
|
||||||
|
{
|
||||||
|
case SDLK_LEFT:
|
||||||
|
{
|
||||||
|
scrollingLeft = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (SDLK_RIGHT):
|
||||||
|
{
|
||||||
|
scrollingRight = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (SDLK_UP):
|
||||||
|
{
|
||||||
|
scrollingUp = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (SDLK_DOWN):
|
||||||
|
{
|
||||||
|
scrollingDown = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//keyup end
|
||||||
|
} //event end
|
||||||
|
|
||||||
|
/////////////// scrolling terrain
|
||||||
|
if(scrollingLeft)
|
||||||
|
{
|
||||||
|
if(xx>0)
|
||||||
|
xx--;
|
||||||
|
}
|
||||||
|
if(scrollingRight)
|
||||||
|
{
|
||||||
|
if(xx<ac->map.width-25)
|
||||||
|
xx++;
|
||||||
|
}
|
||||||
|
if(scrollingUp)
|
||||||
|
{
|
||||||
|
if(yy>0)
|
||||||
|
yy--;
|
||||||
|
}
|
||||||
|
if(scrollingDown)
|
||||||
|
{
|
||||||
|
if(yy<ac->map.height-18)
|
||||||
|
yy++;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_FillRect(ekran, NULL, SDL_MapRGB(ekran->format, 0, 0, 0));
|
SDL_FillRect(ekran, NULL, SDL_MapRGB(ekran->format, 0, 0, 0));
|
||||||
SDL_Surface * help = mh->terrainRect(xx,yy,25,18,zz);
|
SDL_Surface * help = mh->terrainRect(xx,yy,25,18,zz);
|
||||||
SDL_BlitSurface(help,NULL,ekran,NULL);
|
SDL_BlitSurface(help,NULL,ekran,NULL);
|
||||||
SDL_FreeSurface(help);
|
SDL_FreeSurface(help);
|
||||||
SDL_Flip(ekran);
|
SDL_Flip(ekran);
|
||||||
}
|
/////////
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{ continue; }
|
{ continue; }
|
||||||
|
|
||||||
SDL_Delay(30); //give time for other apps
|
SDL_Delay(25); //give time for other apps
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user