From bc7532e4dd9622fcc17cbe5acfb7260b5f13dfc2 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Mon, 18 Jun 2007 10:49:06 +0000 Subject: [PATCH] =?UTF-8?q?lepsze=20przewijanie,=20wczytywanie=20wi=C4=99k?= =?UTF-8?q?szej=20ilosci=20tekst=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CArtHandler.cpp | 2 + CCreatureHandler.cpp | 181 +++++++++++++++++++++++++++++++++++++++++++ CCreatureHandler.h | 11 +++ CHeroHandler.cpp | 81 +++++++++++++++++++ CHeroHandler.h | 16 ++++ CMT.cpp | 86 +++++++++++++++----- 6 files changed, 359 insertions(+), 18 deletions(-) diff --git a/CArtHandler.cpp b/CArtHandler.cpp index e17f04ac2..8fdc4e6e4 100644 --- a/CArtHandler.cpp +++ b/CArtHandler.cpp @@ -201,6 +201,8 @@ void CArtHandler::loadArtifacts() 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 //if(nart.name!=std::string("-1") && nart.name!=std::string("-2")) + nart.description += "\n\n"; + nart.description += nart.desc2; this->artifacts.push_back(nart); delete[10000] read; } diff --git a/CCreatureHandler.cpp b/CCreatureHandler.cpp index 2cee4c067..dd4de3e7f 100644 --- a/CCreatureHandler.cpp +++ b/CCreatureHandler.cpp @@ -25,7 +25,10 @@ void CCreatureHandler::loadCreatures() while(i190 && buf.substr(i, buf.size()-i).find('\r')==std::string::npos) + { + loadAnimationInfo(); break; + } 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 creatures; void loadCreatures(); + void loadAnimationInfo(); + void loadUnitAnimInfo(CCreature & unit, std::string & src, int & i); }; #endif //CCREATUREHANDLER_H \ No newline at end of file diff --git a/CHeroHandler.cpp b/CHeroHandler.cpp index 674f2f944..33a2e956d 100644 --- a/CHeroHandler.cpp +++ b/CHeroHandler.cpp @@ -185,3 +185,84 @@ void CHeroHandler::loadBiographies() 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; iname = buf.substr(befi, i-befi); + ++i; + + befi=i; + for(i; iaggression = atof(buf.substr(befi, i-befi).c_str()); + ++i; + + befi=i; + for(i; iinitialAttack = atoi(buf.substr(befi, i-befi).c_str()); + ++i; + + befi=i; + for(i; iinitialDefence = atoi(buf.substr(befi, i-befi).c_str()); + ++i; + + befi=i; + for(i; iinitialPower = atoi(buf.substr(befi, i-befi).c_str()); + ++i; + + befi=i; + for(i; iinitialKnowledge = atoi(buf.substr(befi, i-befi).c_str()); + ++i; + + + } +} diff --git a/CHeroHandler.h b/CHeroHandler.h index ee0b38deb..9b6c70f93 100644 --- a/CHeroHandler.h +++ b/CHeroHandler.h @@ -19,6 +19,20 @@ public: 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 proSec; //probabilities of gaining secondary skills (out of 112), in id order + int selectionProbability[9]; //probability of selection in towns +}; + class CHeroInstance { public: @@ -32,9 +46,11 @@ class CHeroHandler { public: nodrze heroes; + std::vector heroClasses; void loadHeroes(); void loadSpecialAbilities(); void loadBiographies(); + void loadHeroClasses(); }; diff --git a/CMT.cpp b/CMT.cpp index c6f8b3bcc..e81e9f7c1 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -240,15 +240,15 @@ int _tmain(int argc, _TCHAR* argv[]) CArtHandler * arth = new CArtHandler; arth->loadArtifacts(); cgi->arth = arth; - CHeroHandler * heroh = new CHeroHandler; - heroh->loadHeroes(); - cgi->heroh = heroh; CCreatureHandler * creh = new CCreatureHandler; creh->loadCreatures(); cgi->creh = creh; CAbilityHandler * abilh = new CAbilityHandler; abilh->loadAbilities(); cgi->abilh = abilh; + CHeroHandler * heroh = new CHeroHandler; + heroh->loadHeroes(); + cgi->heroh = heroh; CSpellHandler * spellh = new CSpellHandler; spellh->loadSpells(); cgi->spellh = spellh; @@ -281,6 +281,10 @@ int _tmain(int argc, _TCHAR* argv[]) //SDL_Surface * ss = ac->defs[0]->ourImages[0].bitmap; //SDL_BlitSurface(ss, NULL, ekran, NULL); + bool scrollingLeft = false; + bool scrollingRight = false; + bool scrollingUp = false; + bool scrollingDown = false; for(;;) // main loop { try @@ -295,26 +299,22 @@ int _tmain(int argc, _TCHAR* argv[]) { case SDLK_LEFT: { - if(xx>0) - xx--; + scrollingLeft = true; break; } case (SDLK_RIGHT): { - if(xxmap.width-25) - xx++; + scrollingRight = true; break; } case (SDLK_UP): { - if(yy>0) - yy--; + scrollingUp = true; break; } case (SDLK_DOWN): { - if(yymap.height-18) - yy++; + scrollingDown = true; break; } case (SDLK_q): @@ -332,18 +332,68 @@ int _tmain(int argc, _TCHAR* argv[]) break; } } - SDL_FillRect(ekran, NULL, SDL_MapRGB(ekran->format, 0, 0, 0)); - SDL_Surface * help = mh->terrainRect(xx,yy,25,18,zz); - SDL_BlitSurface(help,NULL,ekran,NULL); - SDL_FreeSurface(help); - SDL_Flip(ekran); - } + } //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(xxmap.width-25) + xx++; + } + if(scrollingUp) + { + if(yy>0) + yy--; + } + if(scrollingDown) + { + if(yymap.height-18) + yy++; + } + + SDL_FillRect(ekran, NULL, SDL_MapRGB(ekran->format, 0, 0, 0)); + SDL_Surface * help = mh->terrainRect(xx,yy,25,18,zz); + SDL_BlitSurface(help,NULL,ekran,NULL); + SDL_FreeSurface(help); + SDL_Flip(ekran); + ///////// } catch(...) { continue; } - SDL_Delay(30); //give time for other apps + SDL_Delay(25); //give time for other apps } return 0; }