CQuestLog.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * CQuestLog.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../widgets/TextControls.h"
  12. #include "../widgets/MiscWidgets.h"
  13. #include "../widgets/Images.h"
  14. #include "../adventureMap/CMinimap.h"
  15. #include "CWindowObject.h"
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. class CCreature;
  18. class CStackInstance;
  19. class CGHeroInstance;
  20. struct QuestInfo;
  21. VCMI_LIB_NAMESPACE_END
  22. class CButton;
  23. class CToggleButton;
  24. class CComponentBox;
  25. class LRClickableAreaWText;
  26. class CButton;
  27. class CPicture;
  28. class CCreaturePic;
  29. class LRClickableAreaWTextComp;
  30. class CSlider;
  31. class CLabel;
  32. const int QUEST_COUNT = 6;
  33. const int DESCRIPTION_HEIGHT_MAX = 355;
  34. class CQuestLabel : public LRClickableAreaWText, public CMultiLineLabel
  35. {
  36. public:
  37. std::function<void()> callback;
  38. CQuestLabel(Rect position, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT, const ColorRGBA &Color = Colors::WHITE, const std::string &Text = "")
  39. : CMultiLineLabel (position, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, Text){};
  40. void clickPressed(const Point & cursorPosition) override;
  41. void showAll(Canvas & to) override;
  42. };
  43. class CQuestIcon : public CAnimImage
  44. {
  45. public:
  46. std::function<void()> callback; //TODO: merge with other similar classes?
  47. CQuestIcon(const AnimationPath & defname, int index, int x=0, int y=0);
  48. void clickPressed(const Point & cursorPosition) override;
  49. void showAll(Canvas & to) override;
  50. };
  51. class CQuestMinimap : public CMinimap
  52. {
  53. std::vector<std::shared_ptr<CQuestIcon>> icons;
  54. void clickPressed(const Point & cursorPosition) override{}; //minimap ignores clicking on its surface
  55. void iconClicked();
  56. void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override{};
  57. public:
  58. const QuestInfo * currentQuest;
  59. CQuestMinimap(const Rect & position);
  60. //should be called to invalidate whole map - different player or level
  61. void update();
  62. void addQuestMarks (const QuestInfo * q);
  63. void showAll(Canvas & to) override;
  64. };
  65. class CQuestLog : public CWindowObject
  66. {
  67. int questIndex;
  68. const QuestInfo * currentQuest;
  69. std::shared_ptr<CComponentBox> componentsBox;
  70. bool hideComplete;
  71. std::shared_ptr<CToggleButton> hideCompleteButton;
  72. std::shared_ptr<CLabel> hideCompleteLabel;
  73. const std::vector<QuestInfo> quests;
  74. std::vector<std::shared_ptr<CQuestLabel>> labels;
  75. std::shared_ptr<CTextBox> description;
  76. std::shared_ptr<CQuestMinimap> minimap;
  77. std::shared_ptr<CSlider> slider; //scrolls quests
  78. std::shared_ptr<CButton> ok;
  79. public:
  80. CQuestLog(const std::vector<QuestInfo> & Quests);
  81. ~CQuestLog(){};
  82. void selectQuest (int which, int labelId);
  83. void updateMinimap (int which){};
  84. void printDescription (int which){};
  85. void sliderMoved (int newpos);
  86. void recreateLabelList();
  87. void recreateQuestList (int pos);
  88. void toggleComplete(bool on);
  89. void showAll (Canvas & to) override;
  90. };