ScummVM API documentation
cursor.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NANCY_CURSOR_H
23 #define NANCY_CURSOR_H
24 
25 #include "common/array.h"
26 #include "common/stream.h"
27 
28 #include "graphics/managed_surface.h"
29 
30 namespace Nancy {
31 
32 class NancyEngine;
33 
35  friend class NancyEngine;
36 
37 public:
38  enum CursorType {
39  kNormal = 0, // Eyeglass (except in TVD), non-highlighted
40  kHotspot = 1, // Eyeglass (except in TVD), highlighted
41  kMove = 2, // Used for movement in early games
42  kExit = 3, // Used for movement, some games use it for exiting puzzles
43  kRotateCW = 4, // Used in puzzles only
44  kRotateCCW = 5, // Used in puzzles only
45  kMoveLeft = 6, // Used for movement, some games used it for turning in 360 scenes
46  kMoveRight = 7, // Used for movement, some games used it for turning in 360 scenes
47  kMoveForward = 8, // Used for movement
48  kMoveBackward = 9, // Used for movement, some games use it for exiting puzzles
49  kMoveUp = 10, // Used for movement
50  kMoveDown = 11, // Used for movement
51  kRotateLeft = 12, // Used in 360 scenes in nancy6 and up
52  kRotateRight = 13, // Used in 360 scenes in nancy6 and up
53  kInvertedRotateRight = 14, // Used in 360 scenes with inverted rotation; nancy6 and up
54  kInvertedRotateLeft = 15, // Used in 360 scenes with inverted rotation; nancy6 and up
55  kCustom1 = 16, // Custom cursors change between games; Likely used in puzzles
56  kCustom1Hotspot = 17,
57  kCustom2 = 18,
58  kCustom2Hotspot = 19,
59  kNormalArrow = 20,
60  kHotspotArrow = 21,
61 
62  // Cursors in Nancy10 and newer games
63  kNewNormal = 0, // Eyeglass, non-highlighted
64  kNewHotspot = 1, // Eyeglass, highlighted
65  kNewNormalArrow = 8,
66  kNewHotspotArrow = 9,
67  kNewExit = 10, // Used for movement and exiting puzzles
68  kNewRotateCW = 13, // Used in puzzles only
69  kNewRotateCCW = 14, // Used in puzzles only
70  kNewMoveLeft = 15, // Used for movement and turning in 360 scenes
71  kNewMoveRight = 16, // Used for movement and turning in 360 scenes
72  kNewMoveForward = 17, // Used for movement
73  kNewMoveBackward = 18, // Used for movement and exiting puzzles
74  kNewMoveUp = 19, // Used for movement
75  kNewMoveDown = 20, // Used for movement
76  kNewRotateRight = 21, // Used in 360 scenes
77  kNewRotateLeft = 22, // Used in 360 scenes
78  kNewInvertedRotateRight = 23, // Used in 360 scenes
79  kNewInvertedRotateLeft = 24, // Used in 360 scenes
80  };
81 
82  CursorManager();
83 
84  void init(Common::SeekableReadStream *chunkStream);
85 
86  // Change the current cursor ID. Does not change the graphic
87  void setCursor(CursorType type, int16 itemID);
88  void setCursorType(CursorType type);
89  void setCursorItemID(int16 itemID);
90 
91  void warpCursor(const Common::Point &pos);
92 
93  // Change the cursor graphic. Should be called right before drawing to screen
94  void applyCursor();
95 
96  const Common::Point &getCurrentCursorHotspot() { return _cursors[_curCursorID].hotspot;}
97  const Common::Rect &getPrimaryVideoInactiveZone() { return _primaryVideoInactiveZone; }
98  const Common::Point &getPrimaryVideoInitialPos() { return _primaryVideoInitialPos; }
99 
100  const CursorType _puzzleExitCursor;
101 
102 private:
103  void showCursor(bool shouldShow);
104 
105  void adjustCursorHotspot();
106 
107  struct Cursor {
108  Common::Rect bounds;
109  Common::Point hotspot;
110  };
111 
112  // CURS data
113  Common::Array<Cursor> _cursors;
114 
115  Common::Rect _primaryVideoInactiveZone;
116  Common::Point _primaryVideoInitialPos;
117 
118  Graphics::ManagedSurface _invCursorsSurface;
119 
120  Common::Point _warpedMousePos;
121  CursorType _curCursorType;
122  int16 _curItemID;
123  uint _curCursorID;
124  uint _lastCursorID;
125  bool _hasItem;
126  bool _isInitialized;
127  int _numCursorTypes;
128 };
129 
130 } // End of namespace Nancy
131 
132 #endif // NANCY_CURSOR_H
Definition: managed_surface.h:51
Definition: nancy.h:74
Definition: cursor.h:34
Definition: rect.h:524
Definition: stream.h:745
Definition: rect.h:144
Definition: actionmanager.h:32