1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ILLUSIONS_BBDOU_BBDOU_CURSOR_H
24 #define ILLUSIONS_BBDOU_BBDOU_CURSOR_H
25 
26 #include "illusions/specialcode.h"
27 
28 namespace Illusions {
29 
30 class IllusionsEngine_BBDOU;
31 class BbdouSpecialCode;
32 class Control;
33 
34 struct VerbState {
35 	int _cursorState;
36 	bool _verbActive[32];
37 	uint32 _verbId;
38 	bool _isBubbleVisible;
39 	uint32 _objectIds[2];
40 	int16 _index;
41 	bool _flag56;
42 	int _minPriority;
43 };
44 
45 struct CursorData {
46 	int _mode;
47 	int _mode2;
48 	uint32 _verbId1;
49 	uint32 _progResKeywordId;
50 	VerbState _verbState;
51 	uint32 _currOverlappedObjectId;
52 	uint32 _overlappedObjectId;
53 	uint32 _sequenceId;
54 	uint32 _sequenceId2;
55 	uint32 _holdingObjectId;
56 	uint32 _holdingObjectId2;
57 	int _visibleCtr;
58 	uint32 _causeThreadId1;
59 	uint32 _causeThreadId2;
60 	int16 _field90;
61 	uint _flags;
62 	uint32 _currCursorTrackingSequenceId;
63 	int16 _idleCtr;
64 };
65 
66 struct CursorSequence {
67 	uint32 _objectId;
68 	uint32 _sequenceId;
CursorSequenceCursorSequence69 	CursorSequence() : _objectId(0), _sequenceId(0) {}
70 };
71 
72 const uint kMaxCursorSequences = 100;
73 
74 class BbdouCursor {
75 public:
76 	BbdouCursor(IllusionsEngine_BBDOU *vm, BbdouSpecialCode *bbdou);
77 	~BbdouCursor();
78 	void init(uint32 objectId, uint32 progResKeywordId);
79 	void enable(uint32 objectId);
80 	void disable(uint32 objectId);
81 	void reset(uint32 objectId);
82 	void addCursorSequenceId(uint32 objectId, uint32 sequenceId);
83 	uint32 findCursorSequenceId(uint32 objectId);
84 	bool updateTrackingCursor(Control *control);
85 	void saveInfo();
86 	void restoreInfo();
87 	void saveBeforeTrackingCursor(Control *control, uint32 sequenceId);
88 	void restoreAfterTrackingCursor();
89 	uint32 getSequenceId1(int sequenceIndex);
90 	uint calcTrackingFlags(Common::Point actorPos, Common::Point trackingLimits);
91 	uint calcTrackingCursorIndex(uint trackingFlags);
92 	bool getTrackingCursorSequenceId(Control *control, uint32 &outSequenceId);
93 public:
94 	IllusionsEngine_BBDOU *_vm;
95 	BbdouSpecialCode *_bbdou;
96 	Control *_control;
97 	CursorData _data;
98 	CursorSequence _cursorSequences[kMaxCursorSequences];
99 	void resetActiveVerbs();
100 	void show(Control *control);
101 	void hide(uint32 objectId);
102 };
103 
104 } // End of namespace Illusions
105 
106 #endif // ILLUSIONS_BBDOU_BBDOU_CURSOR_H
107