CQuestLog.h 2.6 KB

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