CHeroWindow.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 = CGI->bitmaph->loadBitmap("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. dismissButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::dismissCurrent, 519, 437, "hsbtns2.def", this);
  18. questlogButton = new AdventureMapButton<CHeroWindow>(std::string(), std::string(), &CHeroWindow::questlog, 379, 437, "hsbtns4.def", this);
  19. skillpics = CGI->spriteh->giveDef("pskil42.def");
  20. }
  21. CHeroWindow::~CHeroWindow()
  22. {
  23. SDL_FreeSurface(background);
  24. delete quitButton;
  25. delete dismissButton;
  26. delete questlogButton;
  27. if(curBack)
  28. SDL_FreeSurface(curBack);
  29. delete skillpics;
  30. }
  31. void CHeroWindow::show(SDL_Surface *to)
  32. {
  33. if(!to)
  34. to=ekran;
  35. blitAt(curBack,pos.x,pos.y,to);
  36. quitButton->show();
  37. dismissButton->show();
  38. questlogButton->show();
  39. }
  40. void CHeroWindow::setHero(const CGHeroInstance *hero)
  41. {
  42. curHero = hero;
  43. }
  44. void CHeroWindow::quit()
  45. {
  46. for(int i=0; i<LOCPLINT->objsToBlit.size(); ++i)
  47. {
  48. if( dynamic_cast<CHeroWindow*>( LOCPLINT->objsToBlit[i] ) )
  49. {
  50. LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+i);
  51. }
  52. }
  53. quitButton->deactivate();
  54. dismissButton->deactivate();
  55. questlogButton->deactivate();
  56. LOCPLINT->adventureInt->show();
  57. SDL_FreeSurface(curBack);
  58. curBack = NULL;
  59. }
  60. void CHeroWindow::activate()
  61. {
  62. quitButton->activate();
  63. dismissButton->activate();
  64. questlogButton->activate();
  65. curBack = CSDL_Ext::copySurface(background);
  66. blitAt(skillpics->ourImages[0].bitmap, 32, 111, curBack);
  67. blitAt(skillpics->ourImages[1].bitmap, 102, 111, curBack);
  68. blitAt(skillpics->ourImages[2].bitmap, 172, 111, curBack);
  69. blitAt(skillpics->ourImages[5].bitmap, 242, 111, curBack);
  70. blitAt(skillpics->ourImages[4].bitmap, 20, 230, curBack);
  71. blitAt(skillpics->ourImages[3].bitmap, 162, 230, curBack);
  72. }
  73. void CHeroWindow::dismissCurrent()
  74. {
  75. }
  76. void CHeroWindow::questlog()
  77. {
  78. }