CQuestLog.h 2.9 KB

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