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 
33 
34 public:
35  enum CursorType {
36  kNormal = 0, // Eyeglass (except in TVD), non-highlighted
37  kHotspot = 1, // Eyeglass (except in TVD), highlighted
38  kMove = 2, // Used for movement in early games
39  kExit = 3, // Used for movement, some games use it for exiting puzzles
40  kRotateCW = 4, // Used in puzzles only
41  kRotateCCW = 5, // Used in puzzles only
42  kMoveLeft = 6, // Used for movement, some games used it for turning in 360 scenes
43  kMoveRight = 7, // Used for movement, some games used it for turning in 360 scenes
44  kMoveForward = 8, // Used for movement
45  kMoveBackward = 9, // Used for movement, some games use it for exiting puzzles
46  kMoveUp = 10, // Used for movement
47  kMoveDown = 11, // Used for movement
48  kRotateLeft = 12, // Used in 360 scenes in nancy6 and up
49  kRotateRight = 13, // Used in 360 scenes in nancy6 and up
50  kInvertedRotateRight = 14, // Used in 360 scenes with inverted rotation; nancy6 and up
51  kInvertedRotateLeft = 15, // Used in 360 scenes with inverted rotation; nancy6 and up
52  kCustom1 = 16, // Custom cursors change between games; Likely used in puzzles
53  kCustom1Hotspot = 17,
54  kCustom2 = 18,
55  kCustom2Hotspot = 19,
56  kNormalArrow = 20,
57  kHotspotArrow = 21,
58  kHotspotTalk = 22, // Speech-bubble hover cursor (Nancy 10+)
59  kDragHand = 23, // Hand cursor used when dragging an item (Nancy 10+)
60 
61  // Cursors in Nancy10 and newer games. The CURS chunk holds 37 system
62  // cursor types in pairs; type T's idle slot is (T*2) and its hotspot
63  // slot is (T*2 + 1). Types 0–4 and 18–26 have visually distinct idle
64  // vs. hotspot sprites; types 5–17 and 27–36 use the same sprite for
65  // both. Types 18+ are Nancy 10-specific puzzle/inventory cursors.
66  kNewNormal = 0, // Type 0 — Eyeglass
67  kNewHotspot = 1, // Type 0 hotspot — Eyeglass highlighted
68  kNewUse = 2, // Type 1 — Open-hand "use" cursor (interact with characters/objects)
69  kNewHotspotUse = 3, // Type 1 hotspot
70  kNewLockedUse = 4, // Type 2 — Locked variant of the use hand
71  kNewHotspotLockedUse = 5, // Type 2 hotspot
72  kNewTalk = 6, // Type 3 — Speech-bubble (talking to characters)
73  kNewHotspotTalk = 7, // Type 3 hotspot
74  kNewNormalArrow = 8, // Type 4 — Taskbar arrow
75  kNewHotspotArrow = 9, // Type 4 hotspot
76  kNewExit = 10, // Type 5 — Exit / back movement
77  kNewRotateCW = 12, // Type 6 — Puzzle rotation
78  kNewRotateCCW = 14, // Type 7 — Puzzle rotation
79  kNewMoveLeft = 16, // Type 8 — Movement / 360 turn
80  kNewMoveRight = 18, // Type 9 — Movement / 360 turn
81  kNewMoveForward = 20, // Type 10 — Movement
82  kNewMoveBackward = 22, // Type 11 — Movement / exit puzzles
83  kNewMoveUp = 24, // Type 12 — Movement
84  kNewMoveDown = 26, // Type 13 — Movement
85  kNewRotateRight = 28, // Type 14 — 360 scenes
86  kNewRotateLeft = 30, // Type 15 — 360 scenes
87  kNewInvertedRotateRight = 32, // Type 16 — Inverted 360 rotation
88  kNewInvertedRotateLeft = 34, // Type 17 — Inverted 360 rotation
89  kNewDragHand = 38, // Type 19 — Hand used while dragging puzzle pieces (e.g. SortPuzzle pickup action sets this)
90  kNewDropHand = 64, // Type 32 — Hand shown when a held piece is dropped (briefly set on the drop action)
91  };
92 
93  CursorManager();
94 
95  void init(Common::SeekableReadStream *chunkStream);
96 
97  // Change the current cursor ID. Does not change the graphic
98  void setCursor(CursorType type, int16 itemID);
99  void setCursorType(CursorType type);
100  void setCursorItemID(int16 itemID);
101  void showCursor(bool shouldShow);
102 
103  void warpCursor(const Common::Point &pos);
104 
105  // Change the cursor graphic. Should be called right before drawing to screen
106  void applyCursor();
107 
108  const Common::Point &getCurrentCursorHotspot() { return _cursors[_curCursorID].hotspot;}
109  const Common::Rect &getPrimaryVideoInactiveZone() { return _primaryVideoInactiveZone; }
110  const Common::Point &getPrimaryVideoInitialPos() { return _primaryVideoInitialPos; }
111 
112  const CursorType _puzzleExitCursor;
113 
114 private:
115  void adjustCursorHotspot();
116 
117  // Resolve a CursorType + held-item pair to a Nancy 10+ cursor ID.
118  uint resolveNancy10CursorID(CursorType type, int16 itemID);
119 
120  struct Cursor {
121  Common::Rect bounds;
122  Common::Point hotspot;
123  };
124 
125  // CURS data
126  Common::Array<Cursor> _cursors;
127 
128  Common::Rect _primaryVideoInactiveZone;
129  Common::Point _primaryVideoInitialPos;
130 
131  Graphics::ManagedSurface _invCursorsSurface;
132  Graphics::ManagedSurface _uiCursorsSurface; // Nancy13+
133 
134  Common::Point _warpedMousePos;
135  CursorType _curCursorType;
136  int16 _curItemID;
137  uint _curCursorID;
138  uint _lastCursorID;
139  bool _hasItem;
140  bool _isInitialized;
141  int _numCursorTypes;
142 };
143 
144 } // End of namespace Nancy
145 
146 #endif // NANCY_CURSOR_H
Definition: managed_surface.h:51
Definition: cursor.h:32
Definition: rect.h:524
Definition: stream.h:745
Definition: rect.h:144
Definition: actionmanager.h:32