CHeroWindow.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "stdafx.h"
  2. #include "CHeroWindow.h"
  3. #include "SDL.h"
  4. #include "SDL_Extensions.h"
  5. #include "CAdvmapInterface.h"
  6. #include "AdventureMapButton.h"
  7. extern SDL_Surface * ekran;
  8. CHeroWindow::CHeroWindow(int playerColor)
  9. {
  10. background = SDL_LoadBMP("Data\\HEROSCR4.bmp");
  11. CSDL_Ext::blueToPlayersAdv(background, playerColor);
  12. pos.x = 65;
  13. pos.y = 8;
  14. pos.h = background->h;
  15. pos.w = background->w;
  16. quitButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::quit, 674, 524, "hsbtns.def", this);
  17. }
  18. CHeroWindow::~CHeroWindow()
  19. {
  20. SDL_FreeSurface(background);
  21. delete quitButton;
  22. }
  23. void CHeroWindow::show(SDL_Surface *to)
  24. {
  25. if(!to)
  26. to=ekran;
  27. blitAt(background,pos.x,pos.y,to);
  28. quitButton->show();
  29. }
  30. void CHeroWindow::setHero(const CGHeroInstance *hero)
  31. {
  32. curHero = hero;
  33. }
  34. void CHeroWindow::quit()
  35. {
  36. for(int i=0; i<LOCPLINT->objsToBlit.size(); ++i)
  37. {
  38. if( dynamic_cast<CHeroWindow*>( LOCPLINT->objsToBlit[i] ) )
  39. {
  40. LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+i);
  41. }
  42. }
  43. quitButton->deactivate();
  44. LOCPLINT->adventureInt->show();
  45. }
  46. void CHeroWindow::activate()
  47. {
  48. quitButton->activate();
  49. }