aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/camera.h
blob: 2e4b760517523ecbbb2d0c301ccc34c853de9848 (plain)
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
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef ILLUSIONS_CAMERA_H
#define ILLUSIONS_CAMERA_H

#include "illusions/graphics.h"
#include "common/rect.h"
#include "common/stack.h"

namespace Illusions {

class BackgroundInstance;

struct CameraState {
	int _cameraMode;
	//field_2 dw
	bool _paused;
	int16 _panSpeed;
	int _someX, _someY;
	Common::Point _currPan;
	int _panXShl, _panYShl;
	WRect _bounds;
	uint32 _panNotifyId;
	uint32 _time28;
	uint32 _panStartTime;
	uint32 _pauseStartTime;
	uint32 _time2E;
	Common::Point _currPan2;
	Common::Point _panTargetPoint;
	Common::Point _trackingLimits;
	Common::Point _centerPt;
	uint32 _panObjectId;
	Common::Point *_panToPositionPtr;
	uint _pointFlags;
	//field_4A dw
};

struct CameraModeStackItem {
	int _cameraMode;
	uint32 _panObjectId;
	int16 _panSpeed;
	Common::Point _panTargetPoint;
	uint32 _panNotifyId;
};

class Camera {
public:
	Camera(IllusionsEngine *vm);
	void clearStack();
	void set(Common::Point &panPoint, WidthHeight &dimensions);
	void panCenterObject(uint32 objectId, int16 panSpeed);
	void panTrackObject(uint32 objectId);
	void panToPoint(Common::Point pt, int16 panSpeed, uint32 panNotifyId);
	void panEdgeFollow(uint32 objectId, int16 panSpeed);
	void stopPan();
	void pause();
	void unpause();
	void pushCameraMode();
	void popCameraMode();
	void clearCameraModeStack();
	void update(uint32 currTime);
	void setBounds(Common::Point minPt, Common::Point maxPt);
	void setBoundsToDimensions(WidthHeight &dimensions);
	Common::Point getCurrentPan();
	Common::Point getScreenOffset();
	Common::Point getTrackingLimits();
	bool isAtPanLimit(int limitNum);
	void setActiveState(CameraState &state);
	void getActiveState(CameraState &state);
	void refreshPan(BackgroundInstance *backgroundItem, WidthHeight &dimensions);
protected:
	IllusionsEngine *_vm;
	CameraState _activeState;
	Common::FixedStack<CameraModeStackItem, 8> _stack;

	int16 _screenWidth, _screenHeight;
	int16 _screenMidX, _screenMidY;
	Common::Point _centerObjectTrackingLimits;
	Common::Point _trackObjectTrackingLimits;
	int16 _trackObjectTrackingLimitsPanSpeed;

	void updateMode1(uint32 currTime);
	void updateMode2(uint32 currTime);
	void updateMode3(uint32 currTime);
	bool updatePan(uint32 currTime);
	bool isPanFinished();
	Common::Point getPtOffset(Common::Point pt);
	void recalcPan(uint32 currTime);
	bool calcPointFlags(Common::Point &pt, WRect &rect, uint &outFlags);
	void clipPanTargetPoint();
	void init();
	void initDuckman();
	void initBBDOU();
};

} // End of namespace Illusions

#endif // ILLUSIONS_CAMERA_H