1 /*
2  * Seven Kingdoms: Ancient Adversaries
3  *
4  * Copyright 1997,1998 Enlight Software Ltd.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 //Filename    : OMOUSECR.H
22 //Description : Header file of Object Cursor resource
23 
24 #ifndef __OMOUSECR_H
25 #define __OMOUSECR_H
26 
27 #ifndef __ALL_H
28 #include <ALL.h>
29 #endif
30 
31 #ifndef __OVGA_H
32 #include <OVGA.h>
33 #endif
34 
35 #ifndef __ORESDB_H
36 #include <ORESDB.h>
37 #endif
38 
39 //------------ Define cursor id. ----------//
40 
41 enum { CURSOR_NORMAL =1,      // nothing selected,
42        CURSOR_NORMAL_C,			// nothing selected, pointing a friend object
43 		 CURSOR_NORMAL_O,			// nothing selected, pointing an enemy object
44 
45 		 CURSOR_UNIT,				// selected a friend unit  (walk)
46 		 CURSOR_UNIT_C,			// selected a friend unit, pointing a friend object
47 		 CURSOR_UNIT_O,			// selected a friend unit, pointing an enemy object (attack!)
48 
49 		 CURSOR_C_TOWN,			// selected a friend town
50 		 CURSOR_C_TOWN_C,			// selected a friend town, pointing a friend object
51 		 CURSOR_C_TOWN_O,			// selected a friend town, pointing an enemy object
52 		 CURSOR_O_TOWN,			// selected an enemy town
53 		 CURSOR_O_TOWN_C,			// selected an enemy town, pointing a friend object
54 		 CURSOR_O_TOWN_O,			// selected an enemy town, pointing an enemy object
55 
56 		 CURSOR_C_FIRM,			// selected a friend firm
57 		 CURSOR_C_FIRM_C,			// selected a friend firm, pointing a friend object
58 		 CURSOR_C_FIRM_O,			// selected a friend firm, pointing an enemy object
59 		 CURSOR_O_FIRM,			// selected an enemy firm
60 		 CURSOR_O_FIRM_C,			// selected an enemy firm, pointing a friend object
61 		 CURSOR_O_FIRM_O,			// selected an enemy firm, pointing an enemy object
62 
63 		 CURSOR_WAITING,
64 		 CURSOR_BUILD,
65 		 CURSOR_DESTRUCT,
66 		 CURSOR_ASSIGN,
67 		 CURSOR_SET_STOP,
68 		 CURSOR_CANT_SET_STOP,
69 		 CURSOR_SHIP_STOP,
70 		 CURSOR_CANT_SHIP_STOP,
71 		 CURSOR_BURN,
72 		 CURSOR_SETTLE,
73 		 CURSOR_SETTLE_1,			// settle cursor for different color_scheme_id
74 		 CURSOR_SETTLE_2,
75 		 CURSOR_SETTLE_3,
76 		 CURSOR_SETTLE_4,
77 		 CURSOR_SETTLE_5,
78 		 CURSOR_SETTLE_6,
79 		 CURSOR_SETTLE_7,
80 		 CURSOR_ON_LINK,			// when pointing town/firm link
81 		 CURSOR_TRIGGER_EXPLODE,	// special of CURSOR_UNIT_C, when pointing at an explosive cart
82 		 CURSOR_CAPTURE_FIRM,
83 		 CURSOR_ENCYC,
84      };
85 
86 enum { STRETCH_NW, STRETCH_NE, STRETCH_SW, STRECH_SE };	// mouse_stretch_dir
87 
88 
89 //------------ Define struct CursorRec ---------------//
90 
91 struct CursorRec
92 {
93 	enum { HOT_SPOT_LEN=3, FILE_NAME_LEN=8, BITMAP_PTR_LEN=4 };
94 
95 	char file_name[FILE_NAME_LEN];
96 
97 	char hot_spot_x[HOT_SPOT_LEN];
98 	char hot_spot_y[HOT_SPOT_LEN];
99 
100 	char bitmap_ptr[BITMAP_PTR_LEN];
101 };
102 
103 //------------- Define struct CursorInfo --------------//
104 
105 struct CursorInfo
106 {
107 	short hot_spot_x;
108 	short hot_spot_y;
109 
110 	char* bitmap_ptr;
111 };
112 
113 //--------- Define class MouseCursor --------//
114 
115 class MouseCursor
116 {
117 public:
118 	char  init_flag;
119 	char  hide_all_flag;
120 	char  hide_area_flag;
121 
122 	// ###### begin Gilbert 18/8 #####//
123 	short	cur_icon;
124 	// ###### end Gilbert 18/8 #####//
125 
126 	int   hide_x1, hide_y1, hide_x2, hide_y2;
127 	int   cur_x1, cur_y1, cur_x2, cur_y2;
128 
129 	int	hot_spot_x, hot_spot_y;
130 
131 	int   icon_width;
132 	int   icon_height;
133 
134 	char  cursor_shown;     // whether the cursor has been shown on the screen
135 	char  processing_flag;  // whether process() is being run or not, prevent nested call by interrupt
136 	char  wait_mode_count;  // allow nested wait cursor
137 
138 	char 	*icon_ptr, *icon_data_ptr;
139 	char 	*save_scr, *save_back_scr, *merge_buf;
140 
141 	//------- nation selection frame --------//
142 
143 	char  frame_flag;			// whether nation selection frame is on
144 	char  frame_shown;
145 
146 	int	frame_x1, frame_y1, frame_x2, frame_y2;
147 	int	frame_origin_x, frame_origin_y;
148 	int	frame_border_x1, frame_border_y1, frame_border_x2, frame_border_y2;
149 
150 	char  frame_top_save_scr[VGA_WIDTH+4];		// for saving the nation selection frame
151 	char  frame_bottom_save_scr[VGA_WIDTH+4];	// +4 is for the width & height info
152 	char  frame_left_save_scr[VGA_HEIGHT+4];
153 	char  frame_right_save_scr[VGA_HEIGHT+4];
154 
155 	//------- cursor bitmap resource --------//
156 
157 private:
158 	short    	 cursor_count;
159 	CursorInfo*  cursor_info_array;
160 
161 	ResourceDb	 res_bitmap;
162 
163 public:
164 	MouseCursor();
165 	~MouseCursor();
166 
167 	void 	init();
168 	void 	deinit();
169 
170 	void 	set_icon(int);
171 	void  set_frame(char,char=0);
172 	void  set_frame_border(int,int,int,int);
173 
174 	void 	process(int,int);
175 	void	disp_back_buf(int,int,int,int);
176 
177 	// ####### begin Gilbert 18/8 ########//
get_icon()178 	int	get_icon()				{ return cur_icon; }
179 	void	restore_icon(int);
180 	// ####### end Gilbert 18/8 ########//
181 
182 private:
183 	void	process_frame(int,int);
184 	void 	disp_frame(VgaBuf*);
185 	int	is_touch(int,int,int,int);
186 
187 	void  load_cursor_info();
188 };
189 
190 extern MouseCursor mouse_cursor;
191 
192 //----------------------------------------------//
193 
194 #endif
195 
196