1 /* ---------------------------------------------------------------------- *
2  * geometry.h
3  * This file is part of lincity.
4  * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2001.
5  * ---------------------------------------------------------------------- */
6 #ifndef __geometry_h__
7 #define __geometry_h__
8 
9 #include "lin-city.h"
10 
11 struct rect_struct
12 {
13     int x;
14     int y;
15     int w;
16     int h;
17 };
18 typedef struct rect_struct Rect;
19 
20 struct screen_geometry_struct
21 {
22     int border_x;
23     int border_y;
24     int client_w;
25     int client_h;
26 
27     /* Entire window */
28     Rect client_win;
29 
30     /* Main window */
31     Rect main_win;
32 
33     /* Speed buttons */
34     Rect pause_button;
35     Rect slow_button;
36     Rect med_button;
37     Rect fast_button;
38 
39     /* Menu buttons */
40     Rect menu_button;
41 
42     /* Load/Save buttons */
43     Rect load_button;
44     Rect save_button;
45     Rect quit_button;
46     Rect help_button;
47 
48     /* Misc buttons */
49     Rect results_button;
50     Rect tover_button;
51     Rect confine_button;
52 
53     /* Icon palette (a.k.a. "module buttons") */
54     Rect module_buttons;
55 
56     /* Progress bars */
57     Rect pbar_area;
58     Rect pbar_pop;
59     Rect pbar_tech;
60     Rect pbar_food;
61     Rect pbar_jobs;
62     Rect pbar_money;
63     Rect pbar_coal;
64     Rect pbar_goods;
65     Rect pbar_ore;
66     Rect pbar_steel;
67 
68     /* Info screens */
69     Rect sust;
70 
71     /* Strings */
72     Rect select_message;
73     Rect date;
74     Rect time_for_year;
75     Rect status_message_1;
76     Rect status_message_2;
77     Rect money;
78 
79     /* Mini map */
80     Rect mini_map;
81     Rect mini_map_aux;
82     Rect mini_map_area;    /* contains both mini_map and mini_map_aux */
83 #if defined (commentout)   /* GCS: keep these around for now */
84     Rect ms_normal_button;
85     Rect ms_pollution_button;
86     Rect ms_fire_cover_button;
87     Rect ms_ub40_button;
88     Rect ms_coal_button;
89     Rect ms_health_cover_button;
90     Rect ms_cricket_cover_button;
91     Rect ms_power_button;
92     Rect ms_starve_button;
93     Rect ms_ocost_button;
94 #endif
95 
96     /* Statistics */
97     Rect monthgraph;
98     Rect mappoint_stats;
99 
100     /* Market CB */
101     Rect market_cb;
102 };
103 typedef struct screen_geometry_struct Screen_Geometry;
104 
105 
106 
107 void initialize_geometry (Screen_Geometry* scr);
108 void resize_geometry (int new_width, int new_height);
109 int mouse_in_rect (Rect* b, int x, int y);
110 int pixel_to_mappoint(int px, int py, int *mpx, int *mpy);
111 int pixel_to_winpoint(int px, int py, int *wpx, int *wpy);
112 void adjust_main_origin (int new_origin_x, int new_origin_y, int refresh);
113 void draw_pause (int active);
114 void draw_slow (int active);
115 void draw_med (int active);
116 void draw_fast (int active);
117 void draw_menu (void);
118 void draw_load (void);
119 void draw_save (void);
120 void draw_quit (void);
121 void draw_help (void);
122 void draw_results (void);
123 void draw_select_button_graphic (int button, char *graphic);
124 void select_fast (void);
125 void select_medium (void);
126 void select_slow (void);
127 void select_pause (void);
128 void draw_ms_button (char* graphic);
129 void draw_ms_text (char* txt);
130 void draw_small_bezel (int x, int y, int w, int h, int colour);
131 void draw_bezel (Rect r, short width, int color);
132 
133 /* Text width */
134 #define CHAR_HEIGHT 8
135 #define CHAR_WIDTH 8
136 
137 /* Main window */
138 #define MAIN_WIN_W 432
139 #define MAIN_WIN_X 56+8+1
140 #define MAIN_WIN_Y 8
141 #define MAIN_WIN_H 400
142 
143 /* Speed buttons */
144 #define SPEED_BUTTONS_X 0 + MENU_BUTTON_W
145 #define SPEED_BUTTONS_Y 416
146 #define SPEED_BUTTONS_H 16
147 #define SPEED_BUTTONS_W 32
148 #define PAUSE_BUTTON_X SPEED_BUTTONS_X
149 #define PAUSE_BUTTON_Y SPEED_BUTTONS_Y
150 #define PAUSE_BUTTON_H 16
151 #define PAUSE_BUTTON_W 32
152 #define SLOW_BUTTON_X SPEED_BUTTONS_X
153 #define SLOW_BUTTON_Y SPEED_BUTTONS_Y + SPEED_BUTTONS_H
154 #define SLOW_BUTTON_H 16
155 #define SLOW_BUTTON_W 32
156 #define MED_BUTTON_X SPEED_BUTTONS_X
157 #define MED_BUTTON_Y SPEED_BUTTONS_Y + 2 * SPEED_BUTTONS_H
158 #define MED_BUTTON_H 16
159 #define MED_BUTTON_W 32
160 #define FAST_BUTTON_X SPEED_BUTTONS_X
161 #define FAST_BUTTON_Y SPEED_BUTTONS_Y + 3 * SPEED_BUTTONS_H
162 #define FAST_BUTTON_H 16
163 #define FAST_BUTTON_W 32
164 
165 
166 #define QUIT_BUTTON_X 608
167 #define QUIT_BUTTON_Y 416
168 #define QUIT_BUTTON_W 32
169 #define QUIT_BUTTON_H 32
170 #define LOAD_BUTTON_X 576
171 #define LOAD_BUTTON_Y 416
172 #define LOAD_BUTTON_W 32
173 #define LOAD_BUTTON_H 32
174 #define SAVE_BUTTON_X 576
175 #define SAVE_BUTTON_Y 448
176 #define SAVE_BUTTON_W 32
177 #define SAVE_BUTTON_H 32
178 
179 
180 /* Misc buttons */
181 #define MISC_BUTTONS_X 0
182 #define MISC_BUTTONS_Y 400
183 #define TOVER_BUTTON_X MISC_BUTTONS_X + 32
184 #define TOVER_BUTTON_Y MISC_BUTTONS_Y
185 #define TOVER_BUTTON_W 32
186 #define TOVER_BUTTON_H 16
187 #define CONFINE_BUTTON_X MISC_BUTTONS_X + 64
188 #define CONFINE_BUTTON_Y MISC_BUTTONS_Y
189 #define CONFINE_BUTTON_W 16
190 #define CONFINE_BUTTON_H 16
191 
192 #define MENU_BUTTON_X 0
193 #define MENU_BUTTON_Y 0
194 #define MENU_BUTTON_W 56
195 #define MENU_BUTTON_H 24
196 
197 /* Stats button */
198 #if defined(commentout)
199 #define HELP_BUTTON_X 640 - 56
200 #define HELP_BUTTON_Y 480 - 24
201 #define HELP_BUTTON_W 56
202 #define HELP_BUTTON_H 24
203 
204 #define RESULTS_BUTTON_X 640 - 2*56
205 #define RESULTS_BUTTON_Y 480 - 24
206 #define RESULTS_BUTTON_W 56
207 #define RESULTS_BUTTON_H 24
208 #else
209 #define HELP_BUTTON_X 0
210 #define HELP_BUTTON_Y 24
211 #define HELP_BUTTON_W 56
212 #define HELP_BUTTON_H 24
213 
214 #define RESULTS_BUTTON_X 0
215 #define RESULTS_BUTTON_Y 48
216 #define RESULTS_BUTTON_W 56
217 #define RESULTS_BUTTON_H 24
218 #endif
219 
220 
221 #define SELECT_BUTTON_WIN_X 0
222 #define SELECT_BUTTON_WIN_W 56
223 #define SELECT_BUTTON_WIN_Y 72
224 #define SELECT_BUTTON_WIN_H 392
225 #define SELECT_BUTTON_WIDTH 16
226 #define SELECT_BUTTON_DISTANCE 8
227 #define SELECT_BUTTON_INTERVAL (SELECT_BUTTON_WIDTH + SELECT_BUTTON_DISTANCE)
228 
229 /* Progress bars */
230 //#define PBAR_W 16
231 //#define PBAR_H 56
232 #define PBAR_W 56
233 #define PBAR_H 16
234 
235 #define PBAR_AREA_X     (56+MAIN_WIN_W+16+2)
236 #define PBAR_AREA_Y     0
237 #define PBAR_AREA_H     ((PBAR_H * 9) + 8 + 8)
238 #define PBAR_AREA_W     (640 - PBAR_AREA_X + 1)
239 
240 #define PBAR_TEXT_W     (PBAR_AREA_W - 8 - PBAR_W)
241 
242 
243 #ifdef commentout
244 
245 #define PBAR_POP_X      (PBAR_AREA_X + 4)
246 #define PBAR_POP_Y      (PBAR_AREA_Y + 4)
247 #define PBAR_TECH_X     PBAR_POP_X
248 #define PBAR_TECH_Y     PBAR_POP_Y+(PBAR_H+1)
249 #define PBAR_FOOD_X     PBAR_POP_X
250 #define PBAR_FOOD_Y     PBAR_POP_Y+(PBAR_H+1)*2
251 #define PBAR_JOBS_X     PBAR_POP_X
252 #define PBAR_JOBS_Y     PBAR_POP_Y+(PBAR_H+1)*3
253 #define PBAR_COAL_X     PBAR_POP_X
254 #define PBAR_COAL_Y     PBAR_POP_Y+(PBAR_H+1)*4
255 #define PBAR_GOODS_X    PBAR_POP_X
256 #define PBAR_GOODS_Y    PBAR_POP_Y+(PBAR_H+1)*5
257 #define PBAR_ORE_X      PBAR_POP_X
258 #define PBAR_ORE_Y      PBAR_POP_Y+(PBAR_H+1)*6
259 #define PBAR_STEEL_X    PBAR_POP_X
260 #define PBAR_STEEL_Y    PBAR_POP_Y+(PBAR_H+1)*7
261 #define PBAR_MONEY_X    PBAR_POP_X
262 #define PBAR_MONEY_Y    PBAR_POP_Y+(PBAR_H+1)*8
263 #endif /* commentout */
264 
265 #define STATUS_AREA_X             MAIN_WIN_X + SPEED_BUTTONS_W
266 #define DATE_W                    112
267 #define MONEY_W                   32 * CHAR_WIDTH
268 #define TIME_FOR_YEAR_X           STATUS_AREA_X
269 #define TIME_FOR_YEAR_Y           470
270 #define SELECT_BUTTON_MESSAGE_X   STATUS_AREA_X
271 #define SELECT_BUTTON_MESSAGE_Y   460
272 #define STATUS_MESSAGE_1_X        STATUS_AREA_X
273 #define STATUS_MESSAGE_1_Y        440
274 #define STATUS_MESSAGE_2_X        STATUS_AREA_X
275 #define STATUS_MESSAGE_2_Y        450
276 
277 #define SUST_SCREEN_X 96
278 #define SUST_SCREEN_Y 416
279 #define SUST_SCREEN_W (60+8)
280 #define SUST_SCREEN_H 20
281 
282 #if defined (MAPPOINT_STATS_X)
283 #undef MONTHGRAPH_X
284 #undef MONTHGRAPH_Y
285 #undef MAPPOINT_STATS_X
286 #undef MAPPOINT_STATS_Y
287 #undef MAPPOINT_STATS_W
288 #endif
289 #define MAPPOINT_STATS_LINES 14
290 #define MAPPOINT_STATS_X (PBAR_AREA_X + 4)
291 #define MAPPOINT_STATS_Y (PBAR_AREA_Y + PBAR_AREA_H + 4)
292 #define MAPPOINT_STATS_W (PBAR_AREA_W - 8)
293 #define MAPPOINT_STATS_H (MAPPOINT_STATS_LINES*8)
294 
295 
296 
297 #define MINI_MAP_AUX_X PBAR_AREA_X + 4
298 #define MINI_MAP_AUX_Y MAPPOINT_STATS_Y + MAPPOINT_STATS_H + 8
299 #define MINI_MAP_AUX_W PBAR_AREA_W - 8
300 #define MINI_MAP_AUX_H 16
301 
302 #define MONTHGRAPH_X PBAR_AREA_X + 4
303 #define MONTHGRAPH_Y MINI_MAP_AREA_Y + MINI_MAP_AREA_H + 8
304 /* MONTHGRAPH_W must match MAPPOINT_STATS_W as used in shrglobs.c */
305 #define MONTHGRAPH_W PBAR_AREA_W - 8
306 #define MONTHGRAPH_H 64
307 
308 #define MINI_SCREEN_W WORLD_SIDE_LEN
309 #define MINI_SCREEN_H WORLD_SIDE_LEN
310 #define MINI_SCREEN_X MINI_MAP_AUX_X + ((MINI_MAP_AUX_W - MINI_SCREEN_W) / 2)
311 #define MINI_SCREEN_Y MINI_MAP_AUX_Y + MINI_MAP_AUX_H + 2
312 
313 #define MINI_MAP_AREA_X PBAR_AREA_X + 4
314 #define MINI_MAP_AREA_Y MINI_MAP_AUX_Y
315 #define MINI_MAP_AREA_W PBAR_AREA_W - 8
316 #define MINI_MAP_AREA_H MINI_SCREEN_H + MINI_MAP_AUX_H + 2
317 
318 #define MS_BUTTON_H 16
319 #define MS_BUTTON_W 16
320 #define MS_NORMAL_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W)
321 #define MS_NORMAL_BUTTON_Y (MINI_SCREEN_Y)
322 #define MS_POLLUTION_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W)
323 #define MS_POLLUTION_BUTTON_Y (MINI_SCREEN_Y + 1*16)
324 #define MS_FIRE_COVER_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W)
325 #define MS_FIRE_COVER_BUTTON_Y (MINI_SCREEN_Y + 2*16)
326 #define MS_UB40_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W)
327 #define MS_UB40_BUTTON_Y (MINI_SCREEN_Y + 3*16)
328 #define MS_HEALTH_COVER_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W)
329 #define MS_HEALTH_COVER_BUTTON_Y (MINI_SCREEN_Y + 4*16)
330 #define MS_COAL_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W)
331 #define MS_COAL_BUTTON_Y (MINI_SCREEN_Y + 5*16)
332 #define MS_CRICKET_COVER_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W + 1*16)
333 #define MS_CRICKET_COVER_BUTTON_Y (MINI_SCREEN_Y + 1*16)
334 #define MS_POWER_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W + 1*16)
335 #define MS_POWER_BUTTON_Y (MINI_SCREEN_Y + 2*16)
336 #define MS_STARVE_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W + 1*16)
337 #define MS_STARVE_BUTTON_Y (MINI_SCREEN_Y + 3*16)
338 #define MS_OCOST_BUTTON_X (MINI_SCREEN_X + MINI_SCREEN_W + 1*16)
339 #define MS_OCOST_BUTTON_Y (MINI_SCREEN_Y + 4*16)
340 
341 #define MARKET_CB_X (PBAR_AREA_X)
342 #define MARKET_CB_Y (PBAR_AREA_Y)
343 
344 //#define MARKET_CB_H (23*8)
345 //#define MARKET_CB_W (18*8)
346 
347 #endif /* __geometry_h__ */
348