CCursorHandler.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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(int type, int no)
  19. {
  20. mode = type;
  21. number = no;
  22. }
  23. void CCursorHandler::cursorMove(int x, int y)
  24. {
  25. xpos = x;
  26. ypos = y;
  27. }
  28. void CCursorHandler::draw1()
  29. {
  30. if(!Show) return;
  31. switch(mode)
  32. {
  33. case 0:
  34. SDL_BlitSurface(screen,&genRect(32,32,xpos,ypos),help,&genRect(32,32,0,0));
  35. blitAt(cursors[mode]->ourImages[number].bitmap,xpos,ypos);
  36. break;
  37. case 1:
  38. SDL_BlitSurface(screen,&genRect(32,32,xpos-16,ypos-16),help,&genRect(32,32,0,0));
  39. blitAt(cursors[mode]->ourImages[number].bitmap,xpos-16,ypos-16);
  40. break;
  41. }
  42. }
  43. void CCursorHandler::draw2()
  44. {
  45. if(!Show) return;
  46. blitAt(help,xpos,ypos);
  47. }