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 ASYLUM_SYSTEM_CURSOR_H
23 #define ASYLUM_SYSTEM_CURSOR_H
24 
25 #include "common/events.h"
26 #include "common/rect.h"
27 
28 #include "asylum/shared.h"
29 
30 namespace Asylum {
31 
32 class AsylumEngine;
33 class GraphicResource;
34 
35 enum CursorState {
36  kCursorStateLeft = 1,
37  kCursorStateRight = 2,
38  kCursorMiddle = 3
39 };
40 
41 enum CursorAnimation {
42  kCursorAnimationNone = 0,
43  kCursorAnimationLinear = 1,
44  kCursorAnimationMirror = 2
45 };
46 
51 class Cursor {
52 public:
53  Cursor(AsylumEngine *engine);
54  virtual ~Cursor();
55 
59  void show() const;
60 
64  void hide() const;
65 
71  bool isHidden() const;
72 
82  void set(ResourceId resourceId, int32 cnt = 0, CursorAnimation anim = kCursorAnimationMirror, int32 frames = -1);
83 
88  void animate();
89 
90  // Accessors
91  void setState(const Common::Event &evt);
92  byte getState() { return _state; }
93  void setForceHide(bool state) { _forceHide = state; }
94  ResourceId getResourceId() { return _graphicResourceId; }
95  CursorAnimation getAnimation() { return _animation; }
96 
100  const Common::Point position() const;
101 
102 private:
103  AsylumEngine *_vm;
104 
105  byte _state;
106 
107  // Cursor resource
108  GraphicResource *_cursorRes;
109 
111  Common::Point _pos;
112 
114  Common::Point _hotspot;
115 
116  // The number of milliseconds between cursor gfx updates
117  uint32 _nextTick;
118 
119  int32 _frameStep;
120 
121  // NOTE: The original engine contains a function that assigns global variables to a
122  // struct associated with cursor graphics info. Since this functionality only
123  // ever seems to be used to reference cursor info, the struct members
124  // may as well be class members in order to simplify the logic a bit
125  ResourceId _graphicResourceId;
126  uint32 _currentFrame;
127  uint32 _lastFrameIndex;
128  int32 _counter;
129  CursorAnimation _animation;
130 
141  bool _forceHide;
142 
146  void update();
147 
151  void updateFrame();
152 
160  Common::Point getHotspot(uint32 frameIndex);
161 };
162 
163 } // end of namespace Asylum
164 
165 #endif // ASYLUM_SYSTEM_CURSOR_H
Definition: asylum.h:53
const Common::Point position() const
Definition: cursor.h:51
Definition: events.h:198
Definition: rect.h:45
Definition: asylum.h:70
bool isHidden() const
void show() const
void hide() const
Definition: graphics.h:58