CQuestLog.h 3.0 KB

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