2
0

CCursorHandler.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "stdafx.h"
  2. #include "CCursorHandler.h"
  3. #include "SDL.h"
  4. #include "SDL_Extensions.h"
  5. #include "CGameInfo.h"
  6. #include "hch/CDefHandler.h"
  7. extern SDL_Surface * screen;
  8. void CCursorHandler::initCursor()
  9. {
  10. mode = number = xpos = ypos = 0;
  11. help = CSDL_Ext::newSurface(32,32);
  12. cursors.push_back(CDefHandler::giveDef("CRADVNTR.DEF"));
  13. cursors.push_back(CDefHandler::giveDef("CRCOMBAT.DEF"));
  14. cursors.push_back(CDefHandler::giveDef("CRDEFLT.DEF"));
  15. cursors.push_back(CDefHandler::giveDef("CRSPELL.DEF"));
  16. SDL_ShowCursor(SDL_DISABLE);
  17. }
  18. void CCursorHandler::changeGraphic(const int & type, const int & no)
  19. {
  20. mode = type;
  21. number = no;
  22. }
  23. void CCursorHandler::cursorMove(const int & x, const int & y)
  24. {
  25. xpos = x;
  26. ypos = y;
  27. }
  28. void CCursorHandler::draw1()
  29. {
  30. if(!Show) return;
  31. int x = xpos, y = ypos;
  32. if((mode==1 && number!=6) || mode ==3)
  33. {
  34. x-=16;
  35. y-=16;
  36. }
  37. else if(mode==0 && number>0)
  38. {
  39. x-=12;
  40. y-=10;
  41. }
  42. SDL_BlitSurface(screen, &genRect(32,32,x,y), help, &genRect(32,32,0,0));
  43. blitAt(cursors[mode]->ourImages[number].bitmap,x,y);
  44. }
  45. void CCursorHandler::draw2()
  46. {
  47. if(!Show) return;
  48. int x = xpos, y = ypos;
  49. if((mode==1 && number!=6) || mode == 3)
  50. {
  51. x-=16;
  52. y-=16;
  53. }
  54. else if(mode==0 && number>0)
  55. {
  56. x-=12;
  57. y-=10;
  58. }
  59. blitAt(help,x,y);
  60. }