File: CQuestLog.h

package info (click to toggle)
vcmi 1.6.5%2Bdfsg-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 32,060 kB
  • sloc: cpp: 238,971; python: 265; sh: 224; xml: 157; ansic: 78; objc: 61; makefile: 49
file content (111 lines) | stat: -rw-r--r-- 3,015 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * CQuestLog.h, part of VCMI engine
 *
 * 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
 *
 */
#pragma once

#include "../widgets/TextControls.h"
#include "../widgets/MiscWidgets.h"
#include "../widgets/Images.h"
#include "../adventureMap/CMinimap.h"
#include "CWindowObject.h"

VCMI_LIB_NAMESPACE_BEGIN

class CCreature;
class CStackInstance;
class CGHeroInstance;
struct QuestInfo;

VCMI_LIB_NAMESPACE_END

class CButton;
class CToggleButton;
class CComponentBox;
class LRClickableAreaWText;
class CButton;
class CPicture;
class CCreaturePic;
class LRClickableAreaWTextComp;
class CSlider;
class CLabel;

const int QUEST_COUNT = 6;
const int DESCRIPTION_HEIGHT_MAX = 355;

class CQuestLabel : public LRClickableAreaWText, public CMultiLineLabel
{
public:
	std::function<void()> callback;

	CQuestLabel(Rect position, EFonts Font = FONT_SMALL, ETextAlignment Align = ETextAlignment::TOPLEFT, const ColorRGBA &Color = Colors::WHITE, const std::string &Text =  "")
		: CMultiLineLabel (position, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, Text){};
	void clickPressed(const Point & cursorPosition) override;
	void showAll(Canvas & to) override;
};

class CQuestIcon : public CAnimImage
{
public:
	std::function<void()> callback; //TODO: merge with other similar classes?

	CQuestIcon(const AnimationPath & defname, int index, int x=0, int y=0);

	void clickPressed(const Point & cursorPosition) override;
	void showAll(Canvas & to) override;
};

class CQuestMinimap : public CMinimap
{
	std::vector<std::shared_ptr<CQuestIcon>> icons;

	void clickPressed(const Point & cursorPosition) override{}; //minimap ignores clicking on its surface
	void iconClicked();
	void mouseDragged(const Point & cursorPosition, const Point & lastUpdateDistance) override{};

public:
	const QuestInfo * currentQuest;

	CQuestMinimap(const Rect & position);
	//should be called to invalidate whole map - different player or level
	void update();
	void addQuestMarks (const QuestInfo * q);

	void showAll(Canvas & to) override;
};

class CQuestLog : public CWindowObject
{
	int questIndex;
	const QuestInfo * currentQuest;
	std::shared_ptr<CComponentBox> componentsBox;
	bool hideComplete;
	std::shared_ptr<CToggleButton> hideCompleteButton;
	std::shared_ptr<CLabel> hideCompleteLabel;

	const std::vector<QuestInfo> quests;
	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;

public:
	CQuestLog(const std::vector<QuestInfo> & Quests);

	~CQuestLog(){};

	void selectQuest (int which, int labelId);
	void updateMinimap (int which){};
	void printDescription (int which){};
	void sliderMoved (int newpos);
	void recreateLabelList();
	void recreateQuestList (int pos);
	void toggleComplete(bool on);
	void showAll (Canvas & to) override;
};