CQuestLog.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 CComponent;
  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 = 9;
  30. class CQuestLabel : public LRClickableAreaWText, public CMultiLineLabel
  31. {
  32. public:
  33. std::function<void()> callback;
  34. CQuestLabel (Rect position, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = Colors::WHITE, const std::string &Text = "")
  35. : CMultiLineLabel (position, FONT_SMALL, TOPLEFT, Colors::WHITE, Text){};
  36. void clickLeft(tribool down, bool previousState);
  37. void showAll(SDL_Surface * to);
  38. };
  39. class CQuestIcon : public CAnimImage
  40. {
  41. public:
  42. std::function<void()> callback; //TODO: merge with other similar classes?
  43. CQuestIcon (const std::string &defname, int index, int x=0, int y=0);
  44. void clickLeft(tribool down, bool previousState);
  45. void showAll(SDL_Surface * to);
  46. };
  47. class CQuestMinimap : public CMinimap
  48. {
  49. std::vector <CQuestIcon *> icons;
  50. void clickLeft(tribool down, bool previousState){}; //minimap ignores clicking on its surface
  51. void iconClicked();
  52. void mouseMoved (const SDL_MouseMotionEvent & sEvent){};
  53. public:
  54. const QuestInfo * currentQuest;
  55. CQuestMinimap (const Rect & position);
  56. //should be called to invalidate whole map - different player or level
  57. void update();
  58. void setLevel(int level);
  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. const std::vector<QuestInfo> quests;
  67. std::vector<CQuestLabel *> labels;
  68. CTextBox * description;
  69. CQuestMinimap * minimap;
  70. CSlider * slider; //scrolls quests
  71. CButton *ok;
  72. void init ();
  73. public:
  74. CQuestLog (const std::vector<QuestInfo> & Quests);
  75. ~CQuestLog(){};
  76. void selectQuest (int which);
  77. void updateMinimap (int which){};
  78. void printDescription (int which){};
  79. void sliderMoved (int newpos);
  80. void recreateQuestList (int pos);
  81. void showAll (SDL_Surface * to);
  82. };