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 CursorAnimation {
36  kCursorAnimationNone = 0,
37  kCursorAnimationLinear = 1,
38  kCursorAnimationMirror = 2
39 };
40 
45 class Cursor {
46 public:
47  Cursor(AsylumEngine *engine);
48  virtual ~Cursor();
49 
53  void show() const;
54 
58  void hide() const;
59 
65  bool isHidden() const;
66 
76  void set(ResourceId resourceId, int32 cnt = 0, CursorAnimation anim = kCursorAnimationMirror, int32 frames = -1);
77 
82  void animate();
83 
84  // Accessors
85  void setForceHide(bool state) { _forceHide = state; }
86  ResourceId getResourceId() { return _graphicResourceId; }
87  CursorAnimation getAnimation() { return _animation; }
88 
92  const Common::Point position() const;
93 
94 private:
95  AsylumEngine *_vm;
96 
97  // Cursor resource
98  GraphicResource *_cursorRes;
99 
101  Common::Point _pos;
102 
104  Common::Point _hotspot;
105 
106  // The number of milliseconds between cursor gfx updates
107  uint32 _nextTick;
108 
109  int32 _frameStep;
110 
111  // NOTE: The original engine contains a function that assigns global variables to a
112  // struct associated with cursor graphics info. Since this functionality only
113  // ever seems to be used to reference cursor info, the struct members
114  // may as well be class members in order to simplify the logic a bit
115  ResourceId _graphicResourceId;
116  uint32 _currentFrame;
117  uint32 _lastFrameIndex;
118  int32 _counter;
119  CursorAnimation _animation;
120 
131  bool _forceHide;
132 
136  void update();
137 
141  void updateFrame();
142 
150  Common::Point getHotspot(uint32 frameIndex);
151 };
152 
153 } // end of namespace Asylum
154 
155 #endif // ASYLUM_SYSTEM_CURSOR_H
Definition: asylum.h:53
const Common::Point position() const
Definition: cursor.h:45
Definition: rect.h:45
Definition: asylum.h:73
bool isHidden() const
void show() const
void hide() const
Definition: graphics.h:58