AdventureMapButton.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "CPlayerInterface.h"
  3. #include <boost/function.hpp>
  4. #include <boost/bind.hpp>
  5. class AdventureMapButton
  6. : public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase
  7. {
  8. public:
  9. std::string name; //for status bar
  10. std::string helpBox; //for right-click help
  11. char key; //key shortcut
  12. boost::function<void()> callback;
  13. bool colorChange,
  14. actOnDown; //runs when mouse is pressed down over it, not when up
  15. void clickRight (tribool down);
  16. void clickLeft (tribool down);
  17. virtual void hover (bool on);
  18. void keyPressed (SDL_KeyboardEvent & key);
  19. void activate(); // makes button active
  20. void deactivate(); // makes button inactive (but doesn't delete)
  21. AdventureMapButton(); //c-tor
  22. AdventureMapButton( std::string Name, std::string HelpBox, boost::function<void()> Callback, int x, int y, std::string defName, bool activ=false, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
  23. };
  24. //template<typename T>
  25. class CSlider : public IShowable, public MotionInterested, public ClickableL
  26. {
  27. public:
  28. AdventureMapButton left, right, slider; //if vertical then left=up
  29. int capacity,//how many elements can be active at same time
  30. amount, //how many elements
  31. value; //first active element
  32. bool horizontal, moving;
  33. CDefEssential *imgs ;
  34. boost::function<void(int)> moved;
  35. //void(T::*moved)(int to);
  36. //T* owner;
  37. void redrawSlider();
  38. void sliderClicked();
  39. void moveLeft();
  40. void clickLeft (tribool down);
  41. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  42. void moveRight();
  43. void moveTo(int to);
  44. void activate(); // makes button active
  45. void deactivate(); // makes button inactive (but doesn't delete)
  46. void show(SDL_Surface * to = NULL);
  47. CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount,
  48. int Value=0, bool Horizontal=true);
  49. ~CSlider();
  50. };