From efd09f0a685f879986f29f73fe47c1b72b64d2cf Mon Sep 17 00:00:00 2001 From: mateuszb Date: Sat, 19 Jan 2008 18:58:24 +0000 Subject: [PATCH] fixed misc5 bug, hero backpack, strange bug with hero portrait (LClick) --- CHeroWindow.cpp | 112 +++++++++++++++++++++++++++++++++++++++++- CHeroWindow.h | 12 +++++ hch/CAmbarCendamo.cpp | 15 ++++-- 3 files changed, 133 insertions(+), 6 deletions(-) diff --git a/CHeroWindow.cpp b/CHeroWindow.cpp index e902a6374..3f8367efc 100644 --- a/CHeroWindow.cpp +++ b/CHeroWindow.cpp @@ -17,9 +17,9 @@ extern TTF_Font * GEOR16; CHeroWindow::CHeroWindow(int playerColor): artFeet(0), artHead(0), artLHand(0), artLRing(0), artMach1(0), artMach2(0), artMach3(0), artMach4(0), artMisc1(0), artMisc2(0), artMisc3(0), artMisc4(0), artMisc5(0), artNeck(0), artRhand(0), - artRRing(0), artShoulders(0), artSpellBook(0), artTorso(0) + artRRing(0), artShoulders(0), artSpellBook(0), artTorso(0), + backpackPos(0), player(playerColor) { - player = playerColor; background = CGI->bitmaph->loadBitmap("HEROSCR4.bmp"); CSDL_Ext::blueToPlayersAdv(background, playerColor); pos.x = 65; @@ -48,6 +48,13 @@ CHeroWindow::CHeroWindow(int playerColor): artFeet(0), artHead(0), artLHand(0), skillpics = CGI->spriteh->giveDef("pskil42.def"); flags = CGI->spriteh->giveDef("CREST58.DEF"); + //areas + portraitArea = new LClickableArea(); + portraitArea->pos.x = 83; + portraitArea->pos.y = 26; + portraitArea->pos.w = 58; + portraitArea->pos.h = 64; + } CHeroWindow::~CHeroWindow() @@ -91,6 +98,13 @@ CHeroWindow::~CHeroWindow() delete artShoulders; delete artSpellBook; delete artTorso; + for(int g=0; gshow(to); artSpellBook->show(to); artTorso->show(to); + for(int d=0; dshow(to); + } } void CHeroWindow::setHero(const CGHeroInstance *hero) @@ -152,6 +170,11 @@ void CHeroWindow::setHero(const CGHeroInstance *hero) delete artShoulders; delete artSpellBook; delete artTorso; + for(int g=0; gartFeet); artFeet->pos.x = 515; @@ -229,6 +252,14 @@ void CHeroWindow::setHero(const CGHeroInstance *hero) artTorso->pos.x = 509; artTorso->pos.y = 130; artTorso->pos.h = artTorso->pos.h = 44; + for(int s=0; s<5 && sartifacts.size(); ++s) + { + CArtPlace * add = new CArtPlace(curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]); + add->pos.x = 403 + 46*s; + add->pos.y = 365; + add->pos.h = add->pos.h = 44; + backpack.push_back(add); + } } void CHeroWindow::quit() @@ -263,9 +294,51 @@ void CHeroWindow::quit() if(dynamic_cast(LOCPLINT->lclickable[v])) LOCPLINT->lclickable.erase(LOCPLINT->lclickable.begin()+v); } + portraitArea->deactivate(); delete artFeet; artFeet = 0; + delete artHead; + artHead = 0; + delete artLHand; + artLHand = 0; + delete artLRing; + artLRing = 0; + delete artMach1; + artMach1 = 0; + delete artMach2; + artMach2 = 0; + delete artMach3; + artMach3 = 0; + delete artMach4; + artMach4 = 0; + delete artMisc1; + artMisc1 = 0; + delete artMisc2; + artMisc2 = 0; + delete artMisc3; + artMisc3 = 0; + delete artMisc4; + artMisc4 = 0; + delete artMisc5; + artMisc5 = 0; + delete artNeck; + artNeck = 0; + delete artRhand; + artRhand = 0; + delete artRRing; + artRRing = 0; + delete artShoulders; + artShoulders = 0; + delete artSpellBook; + artSpellBook = 0; + delete artTorso; + artTorso = 0; + for(int g=0; gactivate(); leftArtRoll->activate(); rightArtRoll->activate(); + portraitArea->activate(); for(int g=0; gactivate(); @@ -313,10 +387,28 @@ void CHeroWindow::gar4() void CHeroWindow::leftArtRoller() { + if(curHero->artifacts.size()>5) //if it is <=5, we have nothing to scroll + { + backpackPos+=curHero->artifacts.size()-1; //set new offset + + for(int s=0; s<5 && sartifacts.size(); ++s) //set new data + { + backpack[s]->ourArt = curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]; + } + } } void CHeroWindow::rightArtRoller() { + if(curHero->artifacts.size()>5) //if it is <=5, we have nothing to scroll + { + backpackPos+=1; //set new offset + + for(int s=0; s<5 && sartifacts.size(); ++s) //set new data + { + backpack[s]->ourArt = curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]; + } + } } void CHeroWindow::switchHero() @@ -509,3 +601,19 @@ void CArtPlace::show(SDL_Surface *to) blitAt(CGI->arth->artDefs->ourImages[ourArt->id].bitmap, pos.x, pos.y, to); } } + +void LClickableArea::activate() +{ + ClickableL::activate(); +} +void LClickableArea::deactivate() +{ + ClickableL::deactivate(); +} +void LClickableArea::clickLeft(boost::logic::tribool down) +{ + if(!down) + { + LOCPLINT->showInfoDialog("TEST TEST AAA", std::vector()); + } +} diff --git a/CHeroWindow.h b/CHeroWindow.h index 6748d98cc..2cca80aed 100644 --- a/CHeroWindow.h +++ b/CHeroWindow.h @@ -8,6 +8,14 @@ class CGHeroInstance; class CDefHandler; class CArtifact; +class LClickableArea: public ClickableL +{ +public: + virtual void clickLeft (tribool down); + virtual void activate(); + virtual void deactivate(); +}; + class CArtPlace: public ClickableL, public IShowable { public: @@ -39,6 +47,10 @@ class CHeroWindow: public IShowable, public virtual CIntObject * artFeet, * artSpellBook, * artMach1, * artMach2, * artMach3, * artMach4, * artMisc1, * artMisc2, * artMisc3, * artMisc4, * artMisc5, * artTorso, * artNeck, * artShoulders; //heroes' artifacts + std::vector backpack; //hero's visible backpack (only 5 elements!) + int backpackPos; //unmber of first art visible in backpack (in hero's vector) + //clickable areas + LClickableArea * portraitArea; public: CHeroWindow(int playerColor); //c-tor ~CHeroWindow(); //d-tor diff --git a/hch/CAmbarCendamo.cpp b/hch/CAmbarCendamo.cpp index 25d6bf1e2..f976105ea 100644 --- a/hch/CAmbarCendamo.cpp +++ b/hch/CAmbarCendamo.cpp @@ -829,11 +829,12 @@ void CAmbarCendamo::deh3m() //misc5 art //17 if(map.version>=SoD) { - id = readNormalNr(i, artidlen); i+=artidlen; + i+=2; + /*id = readNormalNr(i, artidlen); i+=artidlen; if(id!=artmask) spec->artMisc5 = &(CGameInfo::mainObj->arth->artifacts[id]); else - spec->artMisc5 = NULL; + spec->artMisc5 = NULL;*/ } //spellbook id = readNormalNr(i, artidlen); i+=artidlen; @@ -841,9 +842,15 @@ void CAmbarCendamo::deh3m() spec->artSpellBook = &(CGameInfo::mainObj->arth->artifacts[id]); else spec->artSpellBook = NULL; - //19 //???what is that? gap in file or what? + //19 //???what is that? gap in file or what? - it's probably fifth slot.. if(map.version>RoE) - i+=2; + { + id = readNormalNr(i, artidlen); i+=artidlen; + if(id!=artmask) + spec->artMisc5 = &(CGameInfo::mainObj->arth->artifacts[id]); + else + spec->artMisc5 = NULL; + } else i+=1; //bag artifacts //20