AdventureMapButton.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "CPlayerInterface.h"
  3. #include "client/FunctionList.h"
  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. CFunctionList<void()> callback;
  13. bool colorChange, blocked,
  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. virtual void block(bool on); //if button is blocked then it'll change it's graphic to inactive (offset==2) and won't react on l-clicks
  19. void keyPressed (SDL_KeyboardEvent & key);
  20. void activate(); // makes button active
  21. void deactivate(); // makes button inactive (but doesn't delete)
  22. AdventureMapButton(); //c-tor
  23. AdventureMapButton( std::string Name, std::string HelpBox, CFunctionList<void()> Callback, int x, int y, std::string defName, bool activ=false, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
  24. //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
  25. void init( CFunctionList<void()> Callback, std::string Name, std::string HelpBox, bool playerColoredButton, std::string defName, std::vector<std::string> * add, int x, int y, bool activ );
  26. };
  27. //template<typename T>
  28. class CSlider : public IShowable, public MotionInterested, public ClickableL
  29. {
  30. public:
  31. AdventureMapButton left, right, slider; //if vertical then left=up
  32. int capacity,//how many elements can be active at same time
  33. amount, //how many elements
  34. value; //first active element
  35. bool horizontal, moving;
  36. CDefEssential *imgs ;
  37. boost::function<void(int)> moved;
  38. //void(T::*moved)(int to);
  39. //T* owner;
  40. void redrawSlider();
  41. void sliderClicked();
  42. void moveLeft();
  43. void clickLeft (tribool down);
  44. void mouseMoved (SDL_MouseMotionEvent & sEvent);
  45. void moveRight();
  46. void moveTo(int to);
  47. void activate(); // makes button active
  48. void deactivate(); // makes button inactive (but doesn't delete)
  49. void show(SDL_Surface * to = NULL);
  50. CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount,
  51. int Value=0, bool Horizontal=true);
  52. ~CSlider();
  53. };