1 #ifndef _levelwin_h_
2 #define _levelwin_h_
3 
4 #include "vulture_tile.h"
5 #include "vulture_types.h"
6 #include "window.h"
7 #include "mapdata.h"
8 
9 /*
10  * Tile drawing: pixel coordinate difference from a square to
11  * the one next to it in the map. Because of isometry,
12  * this is not the same as the width/height of a tile!
13  */
14 #define V_MAP_XMOD 56
15 #define V_MAP_YMOD 22
16 
17 #define V_FILENAME_TOOLBAR1             "tb1"
18 #define V_FILENAME_TOOLBAR2             "tb2"
19 
20 
21 
22 class levelwin : public window, public mapviewer
23 {
24 public:
25 	levelwin(mapdata *data);
26 	~levelwin();
27 	void init();
28 	virtual bool draw();
29 	virtual eventresult handle_timer_event(window* target, void* result, int time);
30 	virtual eventresult handle_mousemotion_event(window* target, void* result,
31 	                                             int mouse_x, int mouse_y, int state);
32 	virtual eventresult handle_mousebuttonup_event(window* target, void* result,
33 	                                       int mouse_x, int mouse_y, int button, int state);
34 	virtual eventresult handle_keydown_event(window* target, void* result, int sym, int mod, int unicode);
35 	virtual eventresult handle_resize_event(window* target, void* result, int res_w, int res_h);
36 
37 	point mouse_to_map(point mouse);
38 	point map_to_mouse(point mappos);
39 
40 	void toggle_uiwin(int menuid, bool enabled);
41 	void set_view(int x, int y);
42 	bool need_recenter(int map_x, int map_y);
43 	void force_redraw(void);
44 	void set_wall_style(int style);
45 
46 	void map_update(glyph_type type, int prev_glyph, int new_glyph, int x, int y);
47 	void map_clear();
48 
49 private:
50 	mapdata *map_data;
51 
52 	void add_to_clipregion(int tl_x, int tl_y, int br_x, int br_y);
53 	int get_room_index(int x, int y);
54 	int get_wall_decor(int floortype, int wally, int wallx, int floory, int floorx);
55 	int get_floor_decor(int floorstyle, int floory, int floorx);
56 	void init_floor_decors(int num_decors);
57 	void get_wall_tiles(int y, int x);
58 	int get_floor_tile(int tile, int y, int x);
59 	void get_floor_edges(int y, int x);
60 	void clear_walls(int y, int x);
61 	void clear_floor_edges(int y, int x);
62 	int get_map_cursor(point mappos);
63 
64 	int view_x, view_y;  /* Center of displayed map area */
65 
66 	unsigned char map_deco[ROWNO][COLNO];     /* positions of murals and carpets */
67 	point map_highlight;
68 
69 	/* pointer to full height, half height or transparent walltile array */
70 	struct walls *walltiles;
71 
72 	struct walls maptile_wall[ROWNO][COLNO]; /* Custom (combination) wall style for each square */
73 	struct fedges maptile_floor_edge[ROWNO][COLNO]; /* Custom floor edge style for each square */
74 
75 	char room_indices[ROWNO][COLNO]; /* packed room numbers and deco ids */
76 
77 	int clip_tl_x;
78 	int clip_tl_y ;
79 	int clip_br_x;
80 	int clip_br_y;
81 };
82 
83 
84 extern levelwin *levwin;
85 extern int vulture_map_draw_lastmove;
86 extern int vulture_map_draw_msecs;
87 extern int vulture_map_highlight_objects;
88 
89 #endif
90