CCursorHandler.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. /*
  8. * CCursorHandler.cpp, part of VCMI engine
  9. *
  10. * Authors: listed in file AUTHORS in main folder
  11. *
  12. * License: GNU General Public License v2.0 or later
  13. * Full text of license available in license.txt file, in main folder
  14. *
  15. */
  16. extern SDL_Surface * screen;
  17. void CCursorHandler::initCursor()
  18. {
  19. mode = number = xpos = ypos = 0;
  20. help = CSDL_Ext::newSurface(32,32);
  21. cursors.push_back(CDefHandler::giveDef("CRADVNTR.DEF"));
  22. cursors.push_back(CDefHandler::giveDef("CRCOMBAT.DEF"));
  23. cursors.push_back(CDefHandler::giveDef("CRDEFLT.DEF"));
  24. cursors.push_back(CDefHandler::giveDef("CRSPELL.DEF"));
  25. SDL_ShowCursor(SDL_DISABLE);
  26. }
  27. void CCursorHandler::changeGraphic(const int & type, const int & no)
  28. {
  29. mode = type;
  30. number = no;
  31. }
  32. void CCursorHandler::cursorMove(const int & x, const int & y)
  33. {
  34. xpos = x;
  35. ypos = y;
  36. }
  37. void CCursorHandler::draw1()
  38. {
  39. if(!Show) return;
  40. int x = xpos, y = ypos;
  41. if((mode==1 && number!=6) || mode ==3)
  42. {
  43. x-=16;
  44. y-=16;
  45. }
  46. else if(mode==0 && number>0)
  47. {
  48. x-=12;
  49. y-=10;
  50. }
  51. SDL_BlitSurface(screen, &genRect(32,32,x,y), help, &genRect(32,32,0,0));
  52. blitAt(cursors[mode]->ourImages[number].bitmap,x,y);
  53. }
  54. void CCursorHandler::draw2()
  55. {
  56. if(!Show) return;
  57. int x = xpos, y = ypos;
  58. if((mode==1 && number!=6) || mode == 3)
  59. {
  60. x-=16;
  61. y-=16;
  62. }
  63. else if(mode==0 && number>0)
  64. {
  65. x-=12;
  66. y-=10;
  67. }
  68. blitAt(help,x,y);
  69. }