CCursorHandler.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #include "../Gfx/Manager.h"
  3. class CAnimImage;
  4. /*
  5. * CCursorhandler.h, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. namespace ECursor
  14. {
  15. enum ECursorTypes { ADVENTURE, COMBAT, DEFAULT, SPELLBOOK };
  16. enum EBattleCursors { COMBAT_BLOCKED, COMBAT_MOVE, COMBAT_FLY, COMBAT_SHOOT,
  17. COMBAT_HERO, COMBAT_QUERY, COMBAT_POINTER,
  18. //various attack frames
  19. COMBAT_SHOOT_PENALTY = 15, COMBAT_SHOOT_CATAPULT, COMBAT_HEAL,
  20. COMBAT_SACRIFICE, COMBAT_TELEPORT};
  21. }
  22. /// handles mouse cursor
  23. class CCursorHandler
  24. {
  25. Gfx::PImage help;
  26. Gfx::PAnimation currentCursor;
  27. CAnimImage* dndObject; // if set, overrides currentCursor
  28. bool showing;
  29. public:
  30. /// position of cursor
  31. int xpos, ypos;
  32. /// Current cursor
  33. ECursor::ECursorTypes type;
  34. size_t frame;
  35. /// inits cursorHandler - run only once, it's not memleak-proof (rev 1333)
  36. CCursorHandler();
  37. /// changes cursor graphic for type type (0 - adventure, 1 - combat, 2 - default, 3 - spellbook) and frame index (not used for type 3)
  38. void changeGraphic(ECursor::ECursorTypes type, int index);
  39. /**
  40. * Replaces the cursor with a custom image.
  41. *
  42. * @param image Image to replace cursor with or NULL to use the normal
  43. * cursor. CursorHandler takes ownership of object
  44. */
  45. void dragAndDropCursor (CAnimImage * image);
  46. /// Draw cursor preserving original image below cursor
  47. void drawWithScreenRestore();
  48. /// Restore original image below cursor
  49. void drawRestored();
  50. /// Simple draw cursor
  51. void draw();
  52. void shiftPos( int &x, int &y );
  53. void hide() { showing=0; };
  54. void show() { showing=1; };
  55. /// change cursor's positions to (x, y)
  56. void cursorMove(int x, int y);
  57. /// Move cursor to screen center
  58. void centerCursor();
  59. ~CCursorHandler();
  60. };