diff --git a/AdventureMapButton.h b/AdventureMapButton.h index 1d1065d52..74686acd0 100644 --- a/AdventureMapButton.h +++ b/AdventureMapButton.h @@ -84,7 +84,8 @@ void AdventureMapButton::clickLeft (tribool down) template void AdventureMapButton::clickRight (tribool down) { - LOCPLINT->adventureInt->handleRightClick(helpBox,down,this); + if(helpBox.size()) //there is no point to show window with nothing inside... + LOCPLINT->adventureInt->handleRightClick(helpBox,down,this); } template void AdventureMapButton::hover (bool on) diff --git a/CHeroWindow.cpp b/CHeroWindow.cpp index 44743848e..23a721a0c 100644 --- a/CHeroWindow.cpp +++ b/CHeroWindow.cpp @@ -29,15 +29,16 @@ CHeroWindow::CHeroWindow(int playerColor): activeArtPlace = NULL; garInt = NULL; + ourBar = new CStatusBar(72, 567, "ADROLLVR.bmp", 660); - quitButton = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::quit, 674, 524, "hsbtns.def", this); - dismissButton = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::dismissCurrent, 519, 437, "hsbtns2.def", this); - questlogButton = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::questlog, 379, 437, "hsbtns4.def", this); + quitButton = new AdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(), &CHeroWindow::quit, 674, 524, "hsbtns.def", this); + dismissButton = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], &CHeroWindow::dismissCurrent, 519, 437, "hsbtns2.def", this); + questlogButton = new AdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), &CHeroWindow::questlog, 379, 437, "hsbtns4.def", this); - gar1button = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::gar1, 546, 491, "hsbtns6.def", this); + gar1button = new AdventureMapButton(CGI->generaltexth->heroscrn[23], CGI->generaltexth->heroscrn[29], &CHeroWindow::gar1, 546, 491, "hsbtns6.def", this); gar2button = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::gar2, 604, 491, "hsbtns8.def", this); - gar3button = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::gar3, 546, 527, "hsbtns7.def", this); - gar4button = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::gar4, 604, 527, "hsbtns9.def", this); + gar3button = new AdventureMapButton(CGI->generaltexth->heroscrn[24], CGI->generaltexth->heroscrn[30], &CHeroWindow::gar3, 546, 527, "hsbtns7.def", this); + gar4button = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[32], &CHeroWindow::gar4, 604, 527, "hsbtns9.def", this); leftArtRoll = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::leftArtRoller, 379, 364, "hsbtns3.def", this); rightArtRoll = new AdventureMapButton(std::string(), std::string(), &CHeroWindow::rightArtRoller, 632, 364, "hsbtns5.def", this); @@ -79,12 +80,14 @@ CHeroWindow::CHeroWindow(int playerColor): expArea->pos.y = 236; expArea->pos.w = 136; expArea->pos.h = 42; + expArea->hoverText = CGI->generaltexth->heroscrn[9]; spellPointsArea = new LRClickableAreaWText(); spellPointsArea->pos.x = 227; spellPointsArea->pos.y = 236; spellPointsArea->pos.w = 136; spellPointsArea->pos.h = 42; + spellPointsArea->hoverText = CGI->generaltexth->heroscrn[22]; for(int i=0; i<8; ++i) { @@ -120,6 +123,7 @@ CHeroWindow::~CHeroWindow() delete flags; delete garInt; + delete ourBar; for(int g=0; gshow(); garInt->show(); + ourBar->show(); for(int d=0; dgeneraltexth->heroscrn[16].c_str(), curHero->name.c_str(), curHero->type->heroClass->name.c_str()); + dismissButton->name = std::string(prhlp); + delete [] prhlp; + + prhlp = new char[200]; + sprintf(prhlp, CGI->generaltexth->allTexts[15].c_str(), curHero->name.c_str(), curHero->type->heroClass->name.c_str()); + portraitArea->hoverText = std::string(prhlp); + delete [] prhlp; + portraitArea->text = hero->biography; delete garInt; @@ -209,6 +225,11 @@ void CHeroWindow::setHero(const CGHeroInstance *hero) secSkillAreas[g]->text = hlp.substr(1, hlp.size()-2); break; } + + char * hlpp = new char[200]; + sprintf(hlpp, CGI->generaltexth->heroscrn[21].c_str(), CGI->abilh->levels[hero->secSkills[g].second].c_str(), CGI->abilh->abilities[hero->secSkills[g].first]->name.c_str()); + secSkillAreas[g]->hoverText = std::string(hlpp); + delete [] hlpp; } char * th = new char[200]; @@ -443,6 +464,10 @@ void CHeroWindow::setHero(const CGHeroInstance *hero) { artWorn[g]->myNumber = g; artWorn[g]->backNumber = -1; + char * hll = new char[200]; + sprintf(hll, CGI->generaltexth->heroscrn[1].c_str(), (artWorn[g]->ourArt ? artWorn[g]->ourArt->name.c_str() : "")); + artWorn[g]->hoverText = std::string(hll); + delete [] hll; } for(int s=0; s<5; ++s) @@ -537,6 +562,7 @@ void CHeroWindow::activate() spellPointsArea->activate(); garInt->activate(); + LOCPLINT->statusbar = ourBar; for(int v=0; vstatusbar->print(hoverText); + else if (LOCPLINT->statusbar->getCurrent()==hoverText) + LOCPLINT->statusbar->clear(); } void LClickableAreaHero::clickLeft(boost::logic::tribool down) @@ -1063,10 +1099,19 @@ void LRClickableAreaWTextComp::activate() { LClickableArea::activate(); RClickableArea::activate(); + Hoverable::activate(); } void LRClickableAreaWTextComp::deactivate() { LClickableArea::deactivate(); RClickableArea::deactivate(); + Hoverable::deactivate(); +} +void LRClickableAreaWTextComp::hover(bool on) +{ + Hoverable::hover(on); + if (on) + LOCPLINT->statusbar->print(hoverText); + else if (LOCPLINT->statusbar->getCurrent()==hoverText) + LOCPLINT->statusbar->clear(); } - diff --git a/CHeroWindow.h b/CHeroWindow.h index be8fcc165..31a156977 100644 --- a/CHeroWindow.h +++ b/CHeroWindow.h @@ -33,26 +33,28 @@ public: virtual void clickLeft (tribool down); }; -class LRClickableAreaWText: public LClickableArea, public RClickableArea +class LRClickableAreaWText: public LClickableArea, public RClickableArea, public Hoverable { public: - std::string text; + std::string text, hoverText; virtual void activate(); virtual void deactivate(); virtual void clickLeft (tribool down); virtual void clickRight (tribool down); + virtual void hover(bool on); }; -class LRClickableAreaWTextComp: public LClickableArea, public RClickableArea +class LRClickableAreaWTextComp: public LClickableArea, public RClickableArea, public Hoverable { public: - std::string text; + std::string text, hoverText; int baseType; int bonus, type; virtual void activate(); virtual void deactivate(); virtual void clickLeft (tribool down); virtual void clickRight (tribool down); + virtual void hover(bool on); }; class CArtPlace: public IShowable, public LRClickableAreaWTextComp @@ -84,6 +86,7 @@ class CHeroWindow: public IActivable, public IShowable, public virtual CIntObjec SDL_Surface * background, * curBack; const CGHeroInstance * curHero; CGarrisonInt * garInt; + CStatusBar * ourBar; //heroWindow's statusBar //general graphics CDefHandler * skillpics, *flags; diff --git a/hch/CGeneralTextHandler.cpp b/hch/CGeneralTextHandler.cpp index 7e25bc79c..6b6c9e84c 100644 --- a/hch/CGeneralTextHandler.cpp +++ b/hch/CGeneralTextHandler.cpp @@ -49,6 +49,15 @@ void CGeneralTextHandler::load() CGeneralTextHandler::loadToIt(tmp, strin2, itr, 3); jktexts.push_back(tmp); } + + itr = 0; + std::string strin3 = CGI->bitmaph->getTextFile("HEROSCRN.TXT"); + for(int hh=0; hh<33; ++hh) + { + std::string tmp; + CGeneralTextHandler::loadToIt(tmp, strin3, itr, 3); + heroscrn.push_back(tmp); + } } diff --git a/hch/CGeneralTextHandler.h b/hch/CGeneralTextHandler.h index a2cb9874e..290f6a458 100644 --- a/hch/CGeneralTextHandler.h +++ b/hch/CGeneralTextHandler.h @@ -12,6 +12,7 @@ public: std::vector arraytxt; std::vector primarySkillNames; std::vector jktexts; + std::vector heroscrn; /*std::string cantAddManager, experienceLimitScenarioReached, heroExperienceInfo, perDay, or, somethingVanquished, lastTownLostInfo, heroesAbandonedYou, heroesAbandonedHim; std::string couldNotSaveGame, errorOpeningFile, newgameUppercase, sureToDismissArmy, playersTurn, errorReceivingDataKeepTrying, somethingTheSomething, recruit, noRoomInGarrision, numberOFAdventuringHeroes, heroWithoutCreatures; std::string videoQuality, itemCantBeTraded, sureDismissHero, selectSpellTarget, invalidTeleportDestination, teleportHere, castSomething, castSomethingOnSomething, sureRetreat, notEnoughGold, capturedEnemyArtifact, none; diff --git a/hch/CHeroHandler.cpp b/hch/CHeroHandler.cpp index bf36b2d61..bc792b70d 100644 --- a/hch/CHeroHandler.cpp +++ b/hch/CHeroHandler.cpp @@ -507,6 +507,7 @@ unsigned int CHeroHandler::level(unsigned int experience) if(experience>=expPerLevel[i]) return i+add; } + return -1; } unsigned int CHeroHandler::reqExp(unsigned int level) @@ -524,6 +525,7 @@ unsigned int CHeroHandler::reqExp(unsigned int level) exp*=1.2; } } + return -1; } unsigned int CHeroInstance::getLowestCreatureSpeed()