CQuestLog.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include "../widgets/CIntObjectClasses.h"
  3. #include "../widgets/CAnimation.h"
  4. #include "../widgets/AdventureMapClasses.h"
  5. /*
  6. * CQuestLog.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. class CCreature;
  15. class CStackInstance;
  16. class CAdventureMapButton;
  17. class CGHeroInstance;
  18. class CComponent;
  19. class LRClickableAreaWText;
  20. class CAdventureMapButton;
  21. class CPicture;
  22. class CCreaturePic;
  23. class LRClickableAreaWTextComp;
  24. class CSlider;
  25. class CLabel;
  26. struct QuestInfo;
  27. const int QUEST_COUNT = 9;
  28. class CQuestLabel : public LRClickableAreaWText, public CMultiLineLabel
  29. {
  30. public:
  31. std::function<void()> callback;
  32. CQuestLabel (Rect position, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = Colors::WHITE, const std::string &Text = "")
  33. : CMultiLineLabel (position, FONT_SMALL, TOPLEFT, Colors::WHITE, Text){};
  34. void clickLeft(tribool down, bool previousState);
  35. void showAll(SDL_Surface * to);
  36. };
  37. class CQuestIcon : public CAnimImage
  38. {
  39. public:
  40. std::function<void()> callback; //TODO: merge with other similar classes?
  41. CQuestIcon (const std::string &defname, int index, int x=0, int y=0);
  42. void clickLeft(tribool down, bool previousState);
  43. void showAll(SDL_Surface * to);
  44. };
  45. class CQuestMinimap : public CMinimap
  46. {
  47. std::vector <CQuestIcon *> icons;
  48. void clickLeft(tribool down, bool previousState){}; //minimap ignores clicking on its surface
  49. void iconClicked();
  50. void mouseMoved (const SDL_MouseMotionEvent & sEvent){};
  51. public:
  52. const QuestInfo * currentQuest;
  53. CQuestMinimap (const Rect & position);
  54. //should be called to invalidate whole map - different player or level
  55. void update();
  56. void setLevel(int level);
  57. void addQuestMarks (const QuestInfo * q);
  58. void showAll(SDL_Surface * to);
  59. };
  60. class CQuestLog : public CWindowObject
  61. {
  62. int questIndex;
  63. const QuestInfo * currentQuest;
  64. const std::vector<QuestInfo> quests;
  65. std::vector<CQuestLabel *> labels;
  66. CTextBox * description;
  67. CQuestMinimap * minimap;
  68. CSlider * slider; //scrolls quests
  69. CAdventureMapButton *ok;
  70. void init ();
  71. public:
  72. CQuestLog (const std::vector<QuestInfo> & Quests);
  73. ~CQuestLog(){};
  74. void selectQuest (int which);
  75. void updateMinimap (int which){};
  76. void printDescription (int which){};
  77. void sliderMoved (int newpos);
  78. void recreateQuestList (int pos);
  79. void showAll (SDL_Surface * to);
  80. };