2012-07-06 22:12:04 +03:00
|
|
|
/*
|
2012-07-08 09:33:41 +03:00
|
|
|
* CQuestLog.h, part of VCMI engine
|
2012-07-06 22:12:04 +03:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../widgets/TextControls.h"
|
|
|
|
#include "../widgets/MiscWidgets.h"
|
|
|
|
#include "../widgets/Images.h"
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../adventureMap/CMinimap.h"
|
2017-07-13 10:26:03 +02:00
|
|
|
#include "CWindowObject.h"
|
2012-07-06 22:12:04 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2012-07-06 22:12:04 +03:00
|
|
|
class CCreature;
|
|
|
|
class CStackInstance;
|
2022-07-26 15:07:42 +02:00
|
|
|
class CGHeroInstance;
|
|
|
|
struct QuestInfo;
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2014-08-03 14:16:19 +03:00
|
|
|
class CButton;
|
2015-02-17 04:47:49 +02:00
|
|
|
class CToggleButton;
|
2015-02-14 03:21:31 +02:00
|
|
|
class CComponentBox;
|
2012-07-06 22:12:04 +03:00
|
|
|
class LRClickableAreaWText;
|
2014-08-03 14:16:19 +03:00
|
|
|
class CButton;
|
2012-07-06 22:12:04 +03:00
|
|
|
class CPicture;
|
|
|
|
class CCreaturePic;
|
|
|
|
class LRClickableAreaWTextComp;
|
|
|
|
class CSlider;
|
|
|
|
class CLabel;
|
|
|
|
|
2015-02-14 00:34:53 +02:00
|
|
|
const int QUEST_COUNT = 6;
|
2015-02-14 02:38:28 +02:00
|
|
|
const int DESCRIPTION_HEIGHT_MAX = 355;
|
2012-07-07 11:45:45 +03:00
|
|
|
|
2013-08-29 16:46:27 +03:00
|
|
|
class CQuestLabel : public LRClickableAreaWText, public CMultiLineLabel
|
2012-07-07 11:45:45 +03:00
|
|
|
{
|
|
|
|
public:
|
2013-06-26 14:18:27 +03:00
|
|
|
std::function<void()> callback;
|
2012-07-07 11:45:45 +03:00
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
CQuestLabel(Rect position, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT, const SDL_Color &Color = Colors::WHITE, const std::string &Text = "")
|
|
|
|
: CMultiLineLabel (position, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, Text){};
|
2023-07-08 13:33:04 +02:00
|
|
|
void clickPressed(const Point & cursorPosition) override;
|
2023-06-02 15:42:18 +02:00
|
|
|
void showAll(Canvas & to) override;
|
2012-07-07 11:45:45 +03:00
|
|
|
};
|
|
|
|
|
2012-07-21 23:16:54 +03:00
|
|
|
class CQuestIcon : public CAnimImage
|
2012-07-06 22:12:04 +03:00
|
|
|
{
|
2012-07-08 19:36:20 +03:00
|
|
|
public:
|
2014-03-23 15:59:03 +03:00
|
|
|
std::function<void()> callback; //TODO: merge with other similar classes?
|
2012-07-08 19:36:20 +03:00
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
CQuestIcon(const std::string &defname, int index, int x=0, int y=0);
|
2012-07-08 19:36:20 +03:00
|
|
|
|
2023-07-08 13:33:04 +02:00
|
|
|
void clickPressed(const Point & cursorPosition) override;
|
2023-06-02 15:42:18 +02:00
|
|
|
void showAll(Canvas & to) override;
|
2012-07-08 19:36:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class CQuestMinimap : public CMinimap
|
|
|
|
{
|
2018-04-07 13:34:11 +02:00
|
|
|
std::vector<std::shared_ptr<CQuestIcon>> icons;
|
2012-07-08 19:36:20 +03:00
|
|
|
|
2023-07-08 13:33:04 +02:00
|
|
|
void clickPressed(const Point & cursorPosition) override{}; //minimap ignores clicking on its surface
|
2012-07-08 19:36:20 +03:00
|
|
|
void iconClicked();
|
2023-06-22 21:11:48 +02:00
|
|
|
void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override{};
|
2012-07-06 23:19:54 +03:00
|
|
|
|
|
|
|
public:
|
2012-07-07 11:45:45 +03:00
|
|
|
const QuestInfo * currentQuest;
|
|
|
|
|
2018-04-07 13:34:11 +02:00
|
|
|
CQuestMinimap(const Rect & position);
|
2012-07-06 23:19:54 +03:00
|
|
|
//should be called to invalidate whole map - different player or level
|
2012-07-07 11:45:45 +03:00
|
|
|
void update();
|
2012-07-08 19:36:20 +03:00
|
|
|
void addQuestMarks (const QuestInfo * q);
|
2012-07-06 23:19:54 +03:00
|
|
|
|
2023-06-02 15:42:18 +02:00
|
|
|
void showAll(Canvas & to) override;
|
2012-07-06 22:12:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class CQuestLog : public CWindowObject
|
|
|
|
{
|
2012-07-07 11:45:45 +03:00
|
|
|
int questIndex;
|
|
|
|
const QuestInfo * currentQuest;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CComponentBox> componentsBox;
|
2015-02-17 04:47:49 +02:00
|
|
|
bool hideComplete;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::shared_ptr<CToggleButton> hideCompleteButton;
|
|
|
|
std::shared_ptr<CLabel> hideCompleteLabel;
|
2012-07-07 11:45:45 +03:00
|
|
|
|
2012-07-06 23:19:54 +03:00
|
|
|
const std::vector<QuestInfo> quests;
|
2018-04-07 13:34:11 +02:00
|
|
|
std::vector<std::shared_ptr<CQuestLabel>> labels;
|
|
|
|
std::shared_ptr<CTextBox> description;
|
|
|
|
std::shared_ptr<CQuestMinimap> minimap;
|
|
|
|
std::shared_ptr<CSlider> slider; //scrolls quests
|
|
|
|
std::shared_ptr<CButton> ok;
|
2012-07-06 22:12:04 +03:00
|
|
|
|
|
|
|
public:
|
2018-04-07 13:34:11 +02:00
|
|
|
CQuestLog(const std::vector<QuestInfo> & Quests);
|
2012-07-06 22:12:04 +03:00
|
|
|
|
|
|
|
~CQuestLog(){};
|
|
|
|
|
2015-02-14 02:38:28 +02:00
|
|
|
void selectQuest (int which, int labelId);
|
2012-07-06 22:12:04 +03:00
|
|
|
void updateMinimap (int which){};
|
|
|
|
void printDescription (int which){};
|
2012-07-07 11:45:45 +03:00
|
|
|
void sliderMoved (int newpos);
|
2015-02-17 04:47:49 +02:00
|
|
|
void recreateLabelList();
|
2012-07-07 11:45:45 +03:00
|
|
|
void recreateQuestList (int pos);
|
2015-02-17 04:47:49 +02:00
|
|
|
void toggleComplete(bool on);
|
2023-06-02 15:42:18 +02:00
|
|
|
void showAll (Canvas & to) override;
|
2014-07-13 18:39:45 +03:00
|
|
|
};
|