File: MapRendererContext.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 (173 lines) | stat: -rw-r--r-- 5,953 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * MapRendererContext.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 "IMapRendererContext.h"

#include "../lib/GameConstants.h"
#include "../lib/int3.h"

VCMI_LIB_NAMESPACE_BEGIN
struct ObjectPosInfo;
VCMI_LIB_NAMESPACE_END

struct MapRendererContextState;

class MapRendererBaseContext : public IMapRendererContext
{
public:
	const MapRendererContextState & viewState;
	bool settingsSessionSpectate = false;

	explicit MapRendererBaseContext(const MapRendererContextState & viewState);

	uint32_t getObjectRotation(ObjectInstanceID objectID) const;

	int3 getMapSize() const override;
	bool isInMap(const int3 & coordinates) const override;
	bool isVisible(const int3 & coordinates) const override;
	bool tileAnimated(const int3 & coordinates) const override;

	bool isActiveHero(const CGObjectInstance* obj) const override;

	const TerrainTile & getMapTile(const int3 & coordinates) const override;
	const MapObjectsList & getObjects(const int3 & coordinates) const override;
	const CGObjectInstance * getObject(ObjectInstanceID objectID) const override;
	const CGPath * currentPath() const override;

	size_t objectGroupIndex(ObjectInstanceID objectID) const override;
	Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
	double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
	size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
	size_t terrainImageIndex(size_t groupSize) const override;
	size_t overlayImageIndex(const int3 & coordinates) const override;
	std::string overlayText(const int3 & coordinates) const override;
	ColorRGBA overlayTextColor(const int3 & coordinates) const override;

	double viewTransitionProgress() const override;
	bool filterGrayscale() const override;
	bool showRoads() const override;
	bool showRivers() const override;
	bool showBorder() const override;
	bool showImageOverlay() const override;
	bool showTextOverlay() const override;
	bool showGrid() const override;
	bool showVisitable() const override;
	bool showBlocked() const override;
	bool showSpellRange(const int3 & position) const override;
};

class MapRendererAdventureContext : public MapRendererBaseContext
{
public:
	uint32_t animationTime = 0;
	bool settingShowGrid = false;
	bool settingShowVisitable = false;
	bool settingShowBlocked = false;
	bool settingSpellRange= false;
	bool settingTextOverlay = false;
	bool settingsAdventureObjectAnimation = true;
	bool settingsAdventureTerrainAnimation = true;

	explicit MapRendererAdventureContext(const MapRendererContextState & viewState);

	const CGPath * currentPath() const override;
	size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
	size_t terrainImageIndex(size_t groupSize) const override;
	std::string overlayText(const int3 & coordinates) const override;
	ColorRGBA overlayTextColor(const int3 & coordinates) const override;

	bool showBorder() const override;
	bool showGrid() const override;
	bool showVisitable() const override;
	bool showBlocked() const override;
	bool showTextOverlay() const override;

	bool showSpellRange(const int3 & position) const override;
};

class MapRendererAdventureTransitionContext : public MapRendererAdventureContext
{
public:
	double progress = 0;

	explicit MapRendererAdventureTransitionContext(const MapRendererContextState & viewState);

	double viewTransitionProgress() const override;
};

class MapRendererAdventureFadingContext : public MapRendererAdventureContext
{
public:
	ObjectInstanceID target;
	double progress;

	explicit MapRendererAdventureFadingContext(const MapRendererContextState & viewState);

	bool tileAnimated(const int3 & coordinates) const override;
	double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
};

class MapRendererAdventureMovingContext : public MapRendererAdventureContext
{
public:
	ObjectInstanceID target;
	int3 tileFrom;
	int3 tileDest;
	double progress;

	explicit MapRendererAdventureMovingContext(const MapRendererContextState & viewState);

	bool tileAnimated(const int3 & coordinates) const override;
	size_t objectGroupIndex(ObjectInstanceID objectID) const override;
	Point objectImageOffset(ObjectInstanceID objectID, const int3 & coordinates) const override;
	size_t objectImageIndex(ObjectInstanceID objectID, size_t groupSize) const override;
};

class MapRendererWorldViewContext : public MapRendererBaseContext
{
protected:
	size_t selectOverlayImageForObject(const ObjectPosInfo & object) const;

public:
	explicit MapRendererWorldViewContext(const MapRendererContextState & viewState);

	size_t overlayImageIndex(const int3 & coordinates) const override;
	bool showImageOverlay() const override;
};

class MapRendererSpellViewContext : public MapRendererWorldViewContext
{
public:
	std::vector<ObjectPosInfo> additionalOverlayIcons;
	bool showAllTerrain = false;

	explicit MapRendererSpellViewContext(const MapRendererContextState & viewState);

	bool isVisible(const int3 & coordinates) const override;
	double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
	size_t overlayImageIndex(const int3 & coordinates) const override;
};

class MapRendererPuzzleMapContext : public MapRendererBaseContext
{
public:
	std::unique_ptr<CGPath> grailPos;

	explicit MapRendererPuzzleMapContext(const MapRendererContextState & viewState);
	~MapRendererPuzzleMapContext();

	const CGPath * currentPath() const override;
	double objectTransparency(ObjectInstanceID objectID, const int3 & coordinates) const override;
	bool isVisible(const int3 & coordinates) const override;
	bool filterGrayscale() const override;
	bool showRoads() const override;
	bool showRivers() const override;
};