1 /* ---------------------------------------------------------------------- *
2 * geometry.c
3 * This file is part of lincity.
4 * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2001.
5 * ---------------------------------------------------------------------- */
6 #include "lcconfig.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <math.h>
10 #include "lcstring.h"
11 #include "lin-city.h"
12 #include "common.h"
13 #include "geometry.h"
14 #include "cliglobs.h"
15 #include "pixmap.h"
16 #include "screen.h"
17 #include "lcintl.h"
18 #include "pbar.h"
19 #include "mouse.h"
20
21
22 /* ---------------------------------------------------------------------- *
23 * Private function prototypes
24 * ---------------------------------------------------------------------- */
25 void resize_main_win (int new_width, int new_height);
26
27
28 /* ---------------------------------------------------------------------- *
29 * General functions
30 * ---------------------------------------------------------------------- */
31 void
initialize_geometry(Screen_Geometry * scr)32 initialize_geometry (Screen_Geometry* scr)
33 {
34 scr->border_x = 0;
35 scr->border_y = 0;
36
37 scr->client_w = 640;
38 scr->client_h = 480;
39
40 scr->client_win.x = 0;
41 scr->client_win.y = 0;
42 scr->client_win.w = 640;
43 scr->client_win.h = 480;
44
45 scr->main_win.x = MAIN_WIN_X;
46 scr->main_win.y = MAIN_WIN_Y;
47 scr->main_win.h = MAIN_WIN_H;
48 scr->main_win.w = MAIN_WIN_W;
49
50 scr->pause_button.x = PAUSE_BUTTON_X;
51 scr->pause_button.y = PAUSE_BUTTON_Y;
52 scr->pause_button.h = PAUSE_BUTTON_H;
53 scr->pause_button.w = PAUSE_BUTTON_W;
54
55 scr->slow_button.x = SLOW_BUTTON_X;
56 scr->slow_button.y = SLOW_BUTTON_Y;
57 scr->slow_button.h = SLOW_BUTTON_H;
58 scr->slow_button.w = SLOW_BUTTON_W;
59
60 scr->med_button.x = MED_BUTTON_X;
61 scr->med_button.y = MED_BUTTON_Y;
62 scr->med_button.h = MED_BUTTON_H;
63 scr->med_button.w = MED_BUTTON_W;
64
65 scr->fast_button.x = FAST_BUTTON_X;
66 scr->fast_button.y = FAST_BUTTON_Y;
67 scr->fast_button.h = FAST_BUTTON_H;
68 scr->fast_button.w = FAST_BUTTON_W;
69
70 scr->menu_button.x = MENU_BUTTON_X;
71 scr->menu_button.y = MENU_BUTTON_Y;
72 scr->menu_button.h = MENU_BUTTON_H;
73 scr->menu_button.w = MENU_BUTTON_W;
74
75 scr->load_button.x = LOAD_BUTTON_X;
76 scr->load_button.y = LOAD_BUTTON_Y;
77 scr->load_button.h = LOAD_BUTTON_H;
78 scr->load_button.w = LOAD_BUTTON_W;
79
80 scr->save_button.x = SAVE_BUTTON_X;
81 scr->save_button.y = SAVE_BUTTON_Y;
82 scr->save_button.h = SAVE_BUTTON_H;
83 scr->save_button.w = SAVE_BUTTON_W;
84
85 scr->quit_button.x = QUIT_BUTTON_X;
86 scr->quit_button.y = QUIT_BUTTON_Y;
87 scr->quit_button.h = QUIT_BUTTON_H;
88 scr->quit_button.w = QUIT_BUTTON_W;
89
90 scr->help_button.x = HELP_BUTTON_X;
91 scr->help_button.y = HELP_BUTTON_Y;
92 scr->help_button.h = HELP_BUTTON_H;
93 scr->help_button.w = HELP_BUTTON_W;
94
95 scr->results_button.x = RESULTS_BUTTON_X;
96 scr->results_button.y = RESULTS_BUTTON_Y;
97 scr->results_button.h = RESULTS_BUTTON_H;
98 scr->results_button.w = RESULTS_BUTTON_W;
99
100 scr->tover_button.x = TOVER_BUTTON_X;
101 scr->tover_button.y = TOVER_BUTTON_Y;
102 scr->tover_button.h = TOVER_BUTTON_H;
103 scr->tover_button.w = TOVER_BUTTON_W;
104
105 scr->confine_button.x = CONFINE_BUTTON_X;
106 scr->confine_button.y = CONFINE_BUTTON_Y;
107 scr->confine_button.h = CONFINE_BUTTON_H;
108 scr->confine_button.w = CONFINE_BUTTON_W;
109
110 scr->module_buttons.x = SELECT_BUTTON_WIN_X;
111 scr->module_buttons.y = SELECT_BUTTON_WIN_Y;
112 scr->module_buttons.h = SELECT_BUTTON_WIN_H;
113 scr->module_buttons.w = SELECT_BUTTON_WIN_W;
114
115 scr->pbar_area.x = PBAR_AREA_X;
116 scr->pbar_area.y = PBAR_AREA_Y;
117 scr->pbar_area.h = PBAR_AREA_H;
118 scr->pbar_area.w = PBAR_AREA_W;
119
120 scr->pbar_pop.x = PBAR_POP_X;
121 scr->pbar_pop.y = PBAR_POP_Y;
122 scr->pbar_pop.h = PBAR_H;
123 scr->pbar_pop.w = PBAR_W;
124
125 scr->pbar_tech.x = PBAR_TECH_X;
126 scr->pbar_tech.y = PBAR_TECH_Y;
127 scr->pbar_tech.h = PBAR_H;
128 scr->pbar_tech.w = PBAR_W;
129
130 scr->pbar_food.x = PBAR_FOOD_X;
131 scr->pbar_food.y = PBAR_FOOD_Y;
132 scr->pbar_food.h = PBAR_H;
133 scr->pbar_food.w = PBAR_W;
134
135 scr->pbar_jobs.x = PBAR_JOBS_X;
136 scr->pbar_jobs.y = PBAR_JOBS_Y;
137 scr->pbar_jobs.h = PBAR_H;
138 scr->pbar_jobs.w = PBAR_W;
139
140 scr->pbar_money.x = PBAR_MONEY_X;
141 scr->pbar_money.y = PBAR_MONEY_Y;
142 scr->pbar_money.h = PBAR_H;
143 scr->pbar_money.w = PBAR_W;
144
145 scr->pbar_coal.x = PBAR_COAL_X;
146 scr->pbar_coal.y = PBAR_COAL_Y;
147 scr->pbar_coal.h = PBAR_H;
148 scr->pbar_coal.w = PBAR_W;
149
150 scr->pbar_goods.x = PBAR_GOODS_X;
151 scr->pbar_goods.y = PBAR_GOODS_Y;
152 scr->pbar_goods.h = PBAR_H;
153 scr->pbar_goods.w = PBAR_W;
154
155 scr->pbar_ore.x = PBAR_ORE_X;
156 scr->pbar_ore.y = PBAR_ORE_Y;
157 scr->pbar_ore.h = PBAR_H;
158 scr->pbar_ore.w = PBAR_W;
159
160 scr->pbar_steel.x = PBAR_STEEL_X;
161 scr->pbar_steel.y = PBAR_STEEL_Y;
162 scr->pbar_steel.h = PBAR_H;
163 scr->pbar_steel.w = PBAR_W;
164
165 scr->sust.x = SUST_SCREEN_X;
166 scr->sust.y = SUST_SCREEN_Y;
167 scr->sust.h = SUST_SCREEN_H;
168 scr->sust.w = SUST_SCREEN_W;
169
170 scr->select_message.x = SELECT_BUTTON_MESSAGE_X;
171 scr->select_message.y = SELECT_BUTTON_MESSAGE_Y;
172 scr->select_message.h = 0; /* unused */
173 scr->select_message.w = 0; /* unused */
174
175 scr->date.w = DATE_W;
176 scr->date.x = scr->main_win.x + scr->main_win.w - scr->date.w;
177 scr->date.y = scr->main_win.y + scr->main_win.h + 16;
178 scr->date.h = 16;
179
180 scr->money.w = MONEY_W;
181 scr->money.x = scr->main_win.x;
182 scr->money.y = scr->main_win.y + scr->main_win.h + 16;
183 scr->money.h = 16;
184
185 scr->time_for_year.x = TIME_FOR_YEAR_X;
186 scr->time_for_year.y = TIME_FOR_YEAR_Y;
187 scr->time_for_year.h = 0; /* unused */
188 scr->time_for_year.w = 0; /* unused */
189
190 scr->status_message_1.x = scr->main_win.x;
191 scr->status_message_1.y = STATUS_MESSAGE_1_Y;
192 scr->status_message_1.h = 8;
193 scr->status_message_1.w = scr->main_win.w;
194
195 scr->status_message_2.x = scr->main_win.x;
196 scr->status_message_2.y = STATUS_MESSAGE_2_Y;
197 scr->status_message_2.h = 8;
198 scr->status_message_2.w = scr->main_win.w;
199
200 scr->mini_map.x = MINI_SCREEN_X;
201 scr->mini_map.y = MINI_SCREEN_Y;
202 scr->mini_map.h = MINI_SCREEN_H;
203 scr->mini_map.w = MINI_SCREEN_W;
204
205 scr->mini_map_aux.x = MINI_MAP_AUX_X;
206 scr->mini_map_aux.y = MINI_MAP_AUX_Y;
207 scr->mini_map_aux.h = MINI_MAP_AUX_H;
208 scr->mini_map_aux.w = MINI_MAP_AUX_W;
209
210 scr->mini_map_area.x = MINI_MAP_AREA_X;
211 scr->mini_map_area.y = MINI_MAP_AREA_Y;
212 scr->mini_map_area.h = MINI_MAP_AREA_H;
213 scr->mini_map_area.w = MINI_MAP_AREA_W;
214
215 #if defined (commentout)
216 scr->ms_normal_button.x = MS_NORMAL_BUTTON_X;
217 scr->ms_normal_button.y = MS_NORMAL_BUTTON_Y;
218 scr->ms_normal_button.h = MS_BUTTON_H;
219 scr->ms_normal_button.w = MS_BUTTON_W;
220
221 scr->ms_pollution_button.x = MS_POLLUTION_BUTTON_X;
222 scr->ms_pollution_button.y = MS_POLLUTION_BUTTON_Y;
223 scr->ms_pollution_button.h = MS_BUTTON_H;
224 scr->ms_pollution_button.w = MS_BUTTON_W;
225
226 scr->ms_fire_cover_button.x = MS_FIRE_COVER_BUTTON_X;
227 scr->ms_fire_cover_button.y = MS_FIRE_COVER_BUTTON_Y;
228 scr->ms_fire_cover_button.h = MS_BUTTON_H;
229 scr->ms_fire_cover_button.w = MS_BUTTON_W;
230
231 scr->ms_ub40_button.x = MS_UB40_BUTTON_X;
232 scr->ms_ub40_button.y = MS_UB40_BUTTON_Y;
233 scr->ms_ub40_button.h = MS_BUTTON_H;
234 scr->ms_ub40_button.w = MS_BUTTON_W;
235
236 scr->ms_coal_button.x = MS_COAL_BUTTON_X;
237 scr->ms_coal_button.y = MS_COAL_BUTTON_Y;
238 scr->ms_coal_button.h = MS_BUTTON_H;
239 scr->ms_coal_button.w = MS_BUTTON_W;
240
241 scr->ms_health_cover_button.x = MS_HEALTH_COVER_BUTTON_X;
242 scr->ms_health_cover_button.y = MS_HEALTH_COVER_BUTTON_Y;
243 scr->ms_health_cover_button.h = MS_BUTTON_H;
244 scr->ms_health_cover_button.w = MS_BUTTON_W;
245
246 scr->ms_cricket_cover_button.x = MS_CRICKET_COVER_BUTTON_X;
247 scr->ms_cricket_cover_button.y = MS_CRICKET_COVER_BUTTON_Y;
248 scr->ms_cricket_cover_button.h = MS_BUTTON_H;
249 scr->ms_cricket_cover_button.w = MS_BUTTON_W;
250
251 scr->ms_power_button.x = MS_POWER_BUTTON_X;
252 scr->ms_power_button.y = MS_POWER_BUTTON_Y;
253 scr->ms_power_button.h = MS_BUTTON_H;
254 scr->ms_power_button.w = MS_BUTTON_W;
255
256 scr->ms_starve_button.x = MS_STARVE_BUTTON_X;
257 scr->ms_starve_button.y = MS_STARVE_BUTTON_Y;
258 scr->ms_starve_button.h = MS_BUTTON_H;
259 scr->ms_starve_button.w = MS_BUTTON_W;
260
261 scr->ms_ocost_button.x = MS_OCOST_BUTTON_X;
262 scr->ms_ocost_button.y = MS_OCOST_BUTTON_Y;
263 scr->ms_ocost_button.h = MS_BUTTON_H;
264 scr->ms_ocost_button.w = MS_BUTTON_W;
265 #endif
266
267 scr->monthgraph.x = MONTHGRAPH_X;
268 scr->monthgraph.y = MONTHGRAPH_Y;
269 scr->monthgraph.h = MONTHGRAPH_H;
270 scr->monthgraph.w = MONTHGRAPH_W;
271
272 scr->mappoint_stats.x = MAPPOINT_STATS_X;
273 scr->mappoint_stats.y = MAPPOINT_STATS_Y;
274 scr->mappoint_stats.h = MAPPOINT_STATS_H;
275 scr->mappoint_stats.w = MAPPOINT_STATS_W;
276
277 scr->market_cb = scr->pbar_area;
278 /* scr->market_cb.x = MARKET_CB_X;
279 scr->market_cb.y = MARKET_CB_Y;
280 scr->market_cb.h = MARKET_CB_H;
281 scr->market_cb.w = MARKET_CB_W; */
282 }
283
284 void
resize_geometry(int new_width,int new_height)285 resize_geometry (int new_width, int new_height)
286 {
287 if (display.winW == new_width && display.winH == new_height) {
288 /* Not a resize event. */
289 return;
290 }
291
292 /* Reset geometry back to default */
293 initialize_geometry (&scr);
294
295 scr.client_win.w = new_width;
296 scr.client_win.h = new_height;
297
298 if (pix_double) {
299 new_width = new_width / 2;
300 new_height = new_height / 2;
301 }
302
303 /* Update display info */
304 display.winW = new_width;
305 display.winH = new_height;
306
307 /* Expand pixmap if necessary */
308 scr.client_w = new_width - 2*borderx;
309 scr.client_h = new_height - 2*bordery;
310 #if !defined (SVGALIB)
311 resize_pixmap (scr.client_w, scr.client_h);
312 #endif
313
314 /* Adjust items that need adjusting */
315
316 resize_main_win (scr.client_w, scr.client_h);
317
318 scr.select_message.y = SELECT_BUTTON_MESSAGE_Y + (scr.client_h - 480);
319 scr.time_for_year.y = TIME_FOR_YEAR_Y + (scr.client_h - 480);
320 scr.status_message_1.y = STATUS_MESSAGE_1_Y + (scr.client_h - 480);
321 scr.status_message_1.w = scr.main_win.w;
322 scr.status_message_2.y = STATUS_MESSAGE_2_Y + (scr.client_h - 480);
323 scr.status_message_2.w = scr.main_win.w;
324
325 scr.date.y = scr.main_win.y + scr.main_win.h + 16;
326 scr.date.x = scr.main_win.x + scr.main_win.w - scr.date.w;
327
328 scr.pbar_area.x = 56 + scr.main_win.w + 16 + 2;
329 scr.pbar_pop.x = scr.pbar_area.x + 4;
330 scr.pbar_tech.x = scr.pbar_area.x + 4;
331 scr.pbar_food.x = scr.pbar_area.x + 4;
332 scr.pbar_jobs.x = scr.pbar_area.x + 4;
333 scr.pbar_money.x = scr.pbar_area.x + 4;
334 scr.pbar_coal.x = scr.pbar_area.x + 4;
335 scr.pbar_goods.x = scr.pbar_area.x + 4;
336 scr.pbar_ore.x = scr.pbar_area.x + 4;
337 scr.pbar_steel.x = scr.pbar_area.x + 4;
338
339 scr.monthgraph.x = scr.pbar_area.x + 4;
340 scr.mappoint_stats.x = scr.pbar_area.x + 4;
341 scr.market_cb.x = scr.pbar_area.x;
342
343 scr.mini_map_aux.x = scr.pbar_area.x + 4;
344 scr.mini_map_area.x = scr.pbar_area.x + 4;
345 scr.mini_map.x = scr.mini_map_aux.x
346 + ((scr.mini_map_aux.w - scr.mini_map.w) / 2);
347
348 scr.money.x = scr.main_win.x;
349 scr.money.y = scr.main_win.y + scr.main_win.h + 16;
350
351
352 scr.pause_button.y = PAUSE_BUTTON_Y + (scr.main_win.h - MAIN_WIN_H);
353 scr.slow_button.y = SLOW_BUTTON_Y + (scr.main_win.h - MAIN_WIN_H);
354 scr.med_button.y = MED_BUTTON_Y + (scr.main_win.h - MAIN_WIN_H);
355 scr.fast_button.y = FAST_BUTTON_Y + (scr.main_win.h - MAIN_WIN_H);
356
357 #if defined (SVGALIB)
358 mouse_set_range (new_width,new_height);
359 #endif
360
361 /* Complete refresh of the screen required here */
362 #if !defined (SVGALIB)
363 screen_full_refresh ();
364 #endif
365 }
366
367 int
mouse_in_rect(Rect * b,int x,int y)368 mouse_in_rect (Rect* b, int x, int y)
369 {
370 return ((x > b->x) && (x < b->x + b->w) &&
371 (y > b->y) && (y < b->y + b->h));
372 }
373
374
375 /* ---------------------------------------------------------------------- *
376 * Main win functions
377 * ---------------------------------------------------------------------- */
378 void
resize_main_win(int new_width,int new_height)379 resize_main_win (int new_width, int new_height)
380 {
381 Rect* mw = &scr.main_win;
382 mw->w = new_width - 640 + MAIN_WIN_W;
383 mw->w = (mw->w/16)*16;
384 mw->h = new_height - 480 + MAIN_WIN_H;
385 mw->h = (mw->h/16)*16;
386 adjust_main_origin (main_screen_originx, main_screen_originy,0);
387 }
388
389
390 /* pixel_to_mappoint: convert a pixel value into a mappoint value.
391 beware, values for mpx _can_ be negative */
392 int
pixel_to_mappoint(int px,int py,int * mpx,int * mpy)393 pixel_to_mappoint(int px, int py, int *mpx, int *mpy)
394 {
395 Rect* mw = &scr.main_win;
396 *mpx = (px - mw->x) / 16;
397 *mpy = (py - mw->y) / 16;
398 *mpx += main_screen_originx;
399 *mpy += main_screen_originy;
400
401 if ((px > (mw->x + mw->w)) || (py > (mw->y + mw->h))
402 || (px < mw->x) || (py < mw->y)) {
403 return 0;
404 }
405
406 return 1;
407 }
408
409 /* same as above, only with the upper left corner of the visible map being
410 1,1 */
411 int
pixel_to_winpoint(int px,int py,int * wpx,int * wpy)412 pixel_to_winpoint(int px, int py, int *wpx, int *wpy)
413 {
414 Rect* mw = &scr.main_win;
415 *wpx = (px - mw->x) / 16;
416 *wpy = (py - mw->y) / 16;
417
418
419 if ((px > (mw->x + mw->w)) || (py > (mw->y + mw->h))
420 || (px < mw->x) || (py < mw->y)) {
421 return 0;
422 }
423
424 return 1;
425 }
426
427 /* Adjust the main window origin, and refresh if necessary */
428 void
adjust_main_origin(int new_origin_x,int new_origin_y,int refresh)429 adjust_main_origin (int new_origin_x, int new_origin_y, int refresh)
430 {
431 Rect* mw = &scr.main_win;
432
433 if (new_origin_x < 1) {
434 new_origin_x = 1;
435 } else if (new_origin_x > WORLD_SIDE_LEN - mw->w / 16 - 1) {
436 new_origin_x = WORLD_SIDE_LEN - mw->w / 16 - 1;
437 }
438 if (new_origin_y < 1) {
439 new_origin_y = 1;
440 } else if (new_origin_y > WORLD_SIDE_LEN - mw->h / 16 - 1) {
441 new_origin_y = WORLD_SIDE_LEN - mw->h / 16 - 1;
442 }
443
444 if (new_origin_x == main_screen_originx
445 && new_origin_y == main_screen_originy)
446 {
447 return;
448 }
449
450 main_screen_originx = new_origin_x;
451 main_screen_originy = new_origin_y;
452
453 if (refresh) {
454 hide_mouse ();
455 refresh_main_screen ();
456 redraw_mouse ();
457 }
458 }
459
460 /* ---------------------------------------------------------------------- *
461 * Button drawing functions
462 * ---------------------------------------------------------------------- */
463 void
draw_pause(int active)464 draw_pause (int active)
465 {
466 Rect* b = &scr.pause_button;
467 if (active) {
468 Fgl_putbox (b->x, b->y, 16, 16, pause_button1_on);
469 Fgl_putbox (b->x + 16, b->y, 16, 16, pause_button2_on);
470 } else {
471 Fgl_putbox (b->x, b->y, 16, 16, pause_button1_off);
472 Fgl_putbox (b->x + 16, b->y, 16, 16, pause_button2_off);
473 }
474 }
475
476 void
draw_slow(int active)477 draw_slow (int active)
478 {
479 Rect* b = &scr.slow_button;
480 if (active) {
481 Fgl_putbox (b->x, b->y, 16, 16, slow_button1_on);
482 Fgl_putbox (b->x + 16, b->y, 16, 16, slow_button2_on);
483 } else {
484 Fgl_putbox (b->x, b->y, 16, 16, slow_button1_off);
485 Fgl_putbox (b->x + 16, b->y, 16, 16, slow_button2_off);
486 }
487 }
488
489 void
draw_med(int active)490 draw_med (int active)
491 {
492 Rect* b = &scr.med_button;
493 if (active) {
494 Fgl_putbox (b->x, b->y, 16, 16, med_button1_on);
495 Fgl_putbox (b->x + 16, b->y, 16, 16, med_button2_on);
496 } else {
497 Fgl_putbox (b->x, b->y, 16, 16, med_button1_off);
498 Fgl_putbox (b->x + 16, b->y, 16, 16, med_button2_off);
499 }
500 }
501
502 void
draw_fast(int active)503 draw_fast (int active)
504 {
505 Rect* b = &scr.fast_button;
506 if (active) {
507 Fgl_putbox (b->x, b->y, 16, 16, fast_button1_on);
508 Fgl_putbox (b->x + 16, b->y, 16, 16, fast_button2_on);
509 } else {
510 Fgl_putbox (b->x, b->y, 16, 16, fast_button1_off);
511 Fgl_putbox (b->x + 16, b->y, 16, 16, fast_button2_off);
512 }
513 }
514
515 void
draw_menu(void)516 draw_menu (void)
517 {
518 /* int menu_bg_color = white(20);*/
519 /* int menu_bg_color = TEXT_BG_COLOUR; */
520 /* int menu_bg_color = 14;*/
521 /* int menu_fg_color = TEXT_FG_COLOUR;*/
522 int menu_bg_color = 80;
523 int menu_fg_color = 226;
524
525 Rect* b = &scr.menu_button;
526
527 Fgl_fillbox (b->x, b->y, b->w, b->h, white(20));
528 Fgl_fillbox (b->x+5, b->y+4, b->w-10, b->h-5, menu_bg_color);
529
530 Fgl_hline (b->x+5, b->y+4, b->x + b->w-5, white(8));
531 Fgl_line (b->x+5, b->y+4, b->x+5, b->y + b->h-2, white(8));
532 Fgl_hline (b->x+5, b->y + b->h-2, b->x + b->w-5, white(8));
533 Fgl_line (b->x + b->w-5, b->y+4, b->x + b->w-5, b->y + b->h-2, white(8));
534
535 Fgl_setfontcolors (menu_bg_color,menu_fg_color);
536 Fgl_write (b->x + 12, b->y + 10, _("Menu"));
537 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
538 }
539
540 void
draw_help(void)541 draw_help (void)
542 {
543 /* int menu_bg_color = white(20);*/
544 /* int menu_bg_color = TEXT_BG_COLOUR; */
545 /* int menu_bg_color = 14;*/
546 /* int menu_fg_color = TEXT_FG_COLOUR;*/
547 int menu_bg_color = 80;
548 int menu_fg_color = 226;
549
550 Rect* b = &scr.help_button;
551
552 Fgl_fillbox (b->x, b->y, b->w, b->h, white(20));
553 Fgl_fillbox (b->x+5, b->y+4, b->w-10, b->h-8, menu_bg_color);
554
555 Fgl_hline (b->x+5, b->y+4, b->x + b->w-5, white(8));
556 Fgl_line (b->x+5, b->y+4, b->x+5, b->y + b->h-4, white(8));
557 Fgl_hline (b->x+5, b->y + b->h-4, b->x + b->w-5, white(8));
558 Fgl_line (b->x + b->w-5, b->y+4, b->x + b->w-5, b->y + b->h-4, white(8));
559
560 Fgl_setfontcolors (menu_bg_color,menu_fg_color);
561 Fgl_write (b->x + 13, b->y + 9, _("Help"));
562 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
563 }
564
565 void
draw_results(void)566 draw_results (void)
567 {
568 /* int menu_bg_color = white(20);*/
569 /* int menu_bg_color = TEXT_BG_COLOUR; */
570 /* int menu_bg_color = 14;*/
571 /* int menu_fg_color = TEXT_FG_COLOUR;*/
572 int menu_bg_color = 80;
573 int menu_fg_color = 226;
574
575 Rect* b = &scr.results_button;
576
577 Fgl_fillbox (b->x, b->y, b->w, b->h, white(20));
578 Fgl_fillbox (b->x+5, b->y+4, b->w-10, b->h-8, menu_bg_color);
579
580 Fgl_hline (b->x+5, b->y+4, b->x + b->w-5, white(8));
581 Fgl_line (b->x+5, b->y+4, b->x+5, b->y + b->h-4, white(8));
582 Fgl_hline (b->x+5, b->y + b->h-4, b->x + b->w-5, white(8));
583 Fgl_line (b->x + b->w-5, b->y+4, b->x + b->w-5, b->y + b->h-4, white(8));
584
585 Fgl_setfontcolors (menu_bg_color,menu_fg_color);
586 Fgl_write (b->x + 9, b->y + 9, _("Stats"));
587 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
588 }
589
590 #if defined (commentout)
591 void
draw_load(void)592 draw_load (void)
593 {
594 Rect* b = &scr.load_button;
595 Fgl_putbox (b->x, b->y, 32, 32, load_button_graphic);
596 }
597
598 void
draw_save(void)599 draw_save (void)
600 {
601 Rect* b = &scr.save_button;
602 Fgl_putbox (b->x, b->y, 32, 32, save_button_graphic);
603 }
604
605 void
draw_quit(void)606 draw_quit (void)
607 {
608 Rect* b = &scr.quit_button;
609 Fgl_putbox (b->x, b->y, 32, 32, quit_button_graphic);
610 }
611
612 void
draw_help(void)613 draw_help (void)
614 {
615 Rect* b = &scr.help_button;
616 Fgl_putbox (b->x, b->y, 32, 32, help_button_graphic);
617 }
618
619 void
draw_results(void)620 draw_results (void)
621 {
622 Rect* b = &scr.results_button;
623 Fgl_putbox (b->x, b->y, 16, 16, results_button1);
624 Fgl_putbox (b->x + 16, b->y, 16, 16, results_button2);
625 }
626 #endif
627
628
629 /* ---------------------------------------------------------------------- *
630 * Button click functions
631 * ---------------------------------------------------------------------- */
632
633
634 /* ---------------------------------------------------------------------- *
635 * Mini map button functions
636 * ---------------------------------------------------------------------- */
637 #if defined (commentout)
638 void
draw_ms_button(Rect * b,char * graphic)639 draw_ms_button (Rect* b, char* graphic)
640 {
641 Fgl_putbox (b->x, b->y, 16, 16, graphic);
642 }
643 #endif
644 void
draw_ms_button(char * graphic)645 draw_ms_button (char* graphic)
646 {
647 Rect* mma = &scr.mini_map_aux;
648 Fgl_putbox (mma->x + 4, mma->y, 16, 16, graphic);
649 }
650
651 void
draw_ms_text(char * txt)652 draw_ms_text (char* txt)
653 {
654 Rect* mma = &scr.mini_map_aux;
655 Fgl_write (mma->x + 28, mma->y + 4, txt);
656 }
657
658 void
draw_small_bezel(int x,int y,int w,int h,int colour)659 draw_small_bezel (int x, int y, int w, int h, int colour)
660 {
661 int i;
662 for (i = 1; i < 4; i++) {
663 Fgl_hline (x - 1 - i, y - 1 - i, x + w + i, colour + 16);
664 Fgl_line (x - 1 - i, y - 1 - i, x - 1 - i, y + h + i, colour + 14);
665 Fgl_hline (x - 1 - i, y + h + i, x + w + i, colour + 22);
666 Fgl_line (x + w + i, y - 1 - i, x + w + i, y + h + i, colour + 24);
667 }
668 }
669
670 void
draw_bezel(Rect r,short width,int color)671 draw_bezel (Rect r, short width, int color)
672 {
673 int i;
674 int c;
675 for (i = 0; i < width; i++)
676 {
677 c = color + (width - i) * 2;
678 Fgl_hline (r.x + i, r.y + i, r.x + r.w - i - 1, c);
679 Fgl_hline (r.x + i, r.y + r.h - i - 1, r.x + r.w - i - 1, c);
680 Fgl_line (r.x + i, r.y + i, r.x + i, r.y + r.h - i - 1, c);
681 Fgl_line (r.x + r.w - i - 1, r.y + i, r.x + r.w - i - 1,
682 r.y + r.h - i - 1, c);
683 }
684 }
685