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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 //=============================================================================
32 // Author: Arvind
33 // Purpose: Cursor object
34 //=============================================================================
35 #ifndef CRAB_CURSOR_H
36 #define CRAB_CURSOR_H
37 
38 #include "common/events.h"
39 #include "crab/vectors.h"
40 #include "crab/image/Image.h"
41 
42 namespace Crab {
43 
44 namespace pyrodactyl {
45 namespace input {
46 class Cursor {
47  // Mouse images
48  pyrodactyl::image::Image _img, _imgS, _imgHover, _imgHoverS;
49 
50  // The hover mouse cursor is drawn at a slight offset to the normal cursor
51  Vector2i _hoverOffset;
52 
53  // Mouse image changes slightly if left click button is pressed
54  bool _pressed;
55 
56  int8 _state;
57 
58 public:
59  // Various coordinates
60  Vector2i _motion, _button, _rel;
61 
62  // Is the mouse inside the HUD? Used to disable level mouse movement if true
63  bool _insideHud;
64 
65  // Was the last click on an NPC?
66  bool _hover;
67 
68  Cursor() {
69  _pressed = false;
70  _insideHud = false;
71  _hover = false;
72  reset();
73  }
74  ~Cursor() {}
75 
76  void quit() {
77  _img.deleteImage();
78  _imgS.deleteImage();
79  _imgHover.deleteImage();
80  _imgHoverS.deleteImage();
81  }
82 
83  void reset();
84 
85  void load(rapidxml::xml_node<char> *node);
86  void handleEvents(const Common::Event &event);
87 
88  void draw();
89  bool pressed() {
90  return _pressed;
91  }
92 };
93 
94 } // End of namespace input
95 } // End of namespace pyrodactyl
96 
97 } // End of namespace Crab
98 
99 #endif // CRAB_CURSOR_H
Definition: Image.h:51
Definition: events.h:199
Definition: moveeffect.h:37
Definition: cursor.h:46