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 NUVIE_CORE_CURSOR_H
23#define NUVIE_CORE_CURSOR_H
24
25#include "common/str.h"
26
27
28namespace Ultima {
29namespace Nuvie {
30
31class Configuration;
32class Screen;
33class U6Shape;
34
35typedef struct {
36 uint16 point_x, point_y; // hotspot
37 unsigned char *shapedat;
38 uint16 w, h;
40
41
42/* Contains all mouse pointers, with hotspot and draw methods that work on the
43 * active cursor.
44 */
45class Cursor {
46 friend class Screen;
47 Screen *screen;
48 const Configuration *config;
49 sint32 cur_x, cur_y; // location on screen, unused normally
50 Common::Array<MousePointer *> cursors; // pointer list
51 uint8 cursor_id; // which pointer is active
52
53 unsigned char *cleanup; // restore image behind cursor
54 Common::Rect cleanup_area;
55 Common::Rect update_area; // clear & display are updated at once (avoid flicker)
56
57 bool hidden;
58
59 uint16 screen_w, screen_h;
60
61 void add_update(uint16 x, uint16 y, uint16 w, uint16 h);
62 inline void fix_position(MousePointer *ptr, int &px, int &py);
63 void save_backing(uint32 px, uint32 py, uint32 w, uint32 h);
64
65public:
66 Cursor();
67 ~Cursor() {
68 unload_all();
69 }
70 bool init(const Configuration *c, Screen *s, nuvie_game_t game_type);
71 uint32 load_all(const Common::Path &filename, nuvie_game_t game_type);
72 void unload_all();
73 bool set_pointer(uint8 ptr_num);
74
75 void reset_position() {
76 cur_x = -1;
77 cur_y = -1;
78 }
79 void move(uint32 px, uint32 py) {
80 cur_x = px;
81 cur_y = py;
82 }
83 void hide() {
84 hidden = true;
85 clear();
86 update();
87 }
88 void show() {
89 hidden = false;
90 }
91
92 void get_hotspot(uint16 &x, uint16 &y) const {
93 x = cursors[cursor_id]->point_x;
94 y = cursors[cursor_id]->point_y;
95 }
96 bool display() {
97 return display(cur_x, cur_y);
98 }
99 bool display(int px, int py);
100 void clear();
101 void update();
102
103 bool is_visible() const {
104 return !hidden;
105 }
106};
107
108} // End of namespace Nuvie
109} // End of namespace Ultima
110
111#endif
Definition: array.h:52
Definition: path.h:52
Definition: configuration.h:60
Definition: cursor.h:45
Definition: screen.h:41
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: rect.h:536
Definition: atari-screen.h:58
Definition: cursor.h:35