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