-
Notifications
You must be signed in to change notification settings - Fork 17
/
Cursor.h
67 lines (53 loc) · 1.92 KB
/
Cursor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __Cursor_h__
#define __Cursor_h__
#include <string>
#include <vector>
#include "SDL.h"
class Configuration;
class Screen;
class U6Shape;
typedef struct
{
uint16 point_x, point_y; // hotspot
unsigned char *shapedat;
uint16 w, h;
} MousePointer;
/* Contains all mouse pointers, with hotspot and draw methods that work on the
* active cursor.
*/
class Cursor
{
friend class Screen;
Screen *screen;
Configuration *config;
sint32 cur_x, cur_y; // location on screen, unused normally
std::vector<MousePointer *> cursors; // pointer list
uint8 cursor_id; // which pointer is active
unsigned char *cleanup; // restore image behind cursor
SDL_Rect cleanup_area;
SDL_Rect update_area; // clear & display are updated at once (avoid flicker)
bool hidden;
uint16 screen_w, screen_h;
void add_update(uint16 x, uint16 y, uint16 w, uint16 h);
inline void fix_position(MousePointer *ptr, sint32 &px, sint32 &py);
void save_backing(uint32 px, uint32 py, uint32 w, uint32 h);
public:
Cursor();
~Cursor() { unload_all(); }
bool init(Configuration *c, Screen *s, nuvie_game_t game_type);
uint32 load_all(std::string filename, nuvie_game_t game_type);
void unload_all();
bool set_pointer(uint8 ptr_num);
void reset_position() { cur_x = -1; cur_y = -1; }
void move(uint32 px, uint32 py) { cur_x = px; cur_y = py; }
void hide() { hidden = true; clear(); update(); }
void show() { hidden = false; }
void get_hotspot(uint16 &x, uint16 &y) { x = cursors[cursor_id]->point_x;
y = cursors[cursor_id]->point_y; }
bool display() { return(display(cur_x, cur_y)); }
bool display(sint32 px, sint32 py);
void clear();
void update();
bool is_visible() { return !hidden; }
};
#endif /* __Cursor_h__ */