Main Page | Data Structures | Directories | File List | Data Fields | Globals

geometry.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------- *
00002  * geometry.c
00003  * This file is part of lincity.
00004  * Lincity is copyright (c) I J Peters 1995-1997, (c) Greg Sharp 1997-2001.
00005  * ---------------------------------------------------------------------- */
00006 #include "lcconfig.h"
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <math.h>
00010 #include "lcstring.h"
00011 #include "lin-city.h"
00012 #include "common.h"
00013 #include "geometry.h"
00014 #include "cliglobs.h"
00015 #include "pixmap.h"
00016 #include "screen.h"
00017 #include "lcintl.h"
00018 #include "pbar.h"
00019 #include "mouse.h"
00020 
00021 
00022 /* ---------------------------------------------------------------------- *
00023  * Private function prototypes
00024  * ---------------------------------------------------------------------- */
00025 void resize_main_win (int new_width, int new_height);
00026 
00027 
00028 /* ---------------------------------------------------------------------- *
00029  * General functions
00030  * ---------------------------------------------------------------------- */
00031 void 
00032 initialize_geometry (Screen_Geometry* scr)
00033 {
00034     scr->border_x = 0;
00035     scr->border_y = 0;
00036 
00037     scr->client_w = 640;
00038     scr->client_h = 480;
00039 
00040     scr->client_win.x = 0;
00041     scr->client_win.y = 0;
00042     scr->client_win.w = 640;
00043     scr->client_win.h = 480;
00044 
00045     scr->main_win.x = MAIN_WIN_X;
00046     scr->main_win.y = MAIN_WIN_Y;
00047     scr->main_win.h = MAIN_WIN_H;
00048     scr->main_win.w = MAIN_WIN_W;
00049 
00050     scr->pause_button.x = PAUSE_BUTTON_X;
00051     scr->pause_button.y = PAUSE_BUTTON_Y;
00052     scr->pause_button.h = PAUSE_BUTTON_H;
00053     scr->pause_button.w = PAUSE_BUTTON_W;
00054 
00055     scr->slow_button.x = SLOW_BUTTON_X;
00056     scr->slow_button.y = SLOW_BUTTON_Y;
00057     scr->slow_button.h = SLOW_BUTTON_H;
00058     scr->slow_button.w = SLOW_BUTTON_W;
00059 
00060     scr->med_button.x = MED_BUTTON_X;
00061     scr->med_button.y = MED_BUTTON_Y;
00062     scr->med_button.h = MED_BUTTON_H;
00063     scr->med_button.w = MED_BUTTON_W;
00064 
00065     scr->fast_button.x = FAST_BUTTON_X;
00066     scr->fast_button.y = FAST_BUTTON_Y;
00067     scr->fast_button.h = FAST_BUTTON_H;
00068     scr->fast_button.w = FAST_BUTTON_W;
00069 
00070     scr->menu_button.x = MENU_BUTTON_X;
00071     scr->menu_button.y = MENU_BUTTON_Y;
00072     scr->menu_button.h = MENU_BUTTON_H;
00073     scr->menu_button.w = MENU_BUTTON_W;
00074 
00075     scr->load_button.x = LOAD_BUTTON_X;
00076     scr->load_button.y = LOAD_BUTTON_Y;
00077     scr->load_button.h = LOAD_BUTTON_H;
00078     scr->load_button.w = LOAD_BUTTON_W;
00079 
00080     scr->save_button.x = SAVE_BUTTON_X;
00081     scr->save_button.y = SAVE_BUTTON_Y;
00082     scr->save_button.h = SAVE_BUTTON_H;
00083     scr->save_button.w = SAVE_BUTTON_W;
00084 
00085     scr->quit_button.x = QUIT_BUTTON_X;
00086     scr->quit_button.y = QUIT_BUTTON_Y;
00087     scr->quit_button.h = QUIT_BUTTON_H;
00088     scr->quit_button.w = QUIT_BUTTON_W;
00089 
00090     scr->help_button.x = HELP_BUTTON_X;
00091     scr->help_button.y = HELP_BUTTON_Y;
00092     scr->help_button.h = HELP_BUTTON_H;
00093     scr->help_button.w = HELP_BUTTON_W;
00094 
00095     scr->results_button.x = RESULTS_BUTTON_X;
00096     scr->results_button.y = RESULTS_BUTTON_Y;
00097     scr->results_button.h = RESULTS_BUTTON_H;
00098     scr->results_button.w = RESULTS_BUTTON_W;
00099 
00100     scr->tover_button.x = TOVER_BUTTON_X;
00101     scr->tover_button.y = TOVER_BUTTON_Y;
00102     scr->tover_button.h = TOVER_BUTTON_H;
00103     scr->tover_button.w = TOVER_BUTTON_W;
00104 
00105     scr->confine_button.x = CONFINE_BUTTON_X;
00106     scr->confine_button.y = CONFINE_BUTTON_Y;
00107     scr->confine_button.h = CONFINE_BUTTON_H;
00108     scr->confine_button.w = CONFINE_BUTTON_W;
00109 
00110     scr->module_buttons.x = SELECT_BUTTON_WIN_X;
00111     scr->module_buttons.y = SELECT_BUTTON_WIN_Y;
00112     scr->module_buttons.h = SELECT_BUTTON_WIN_H;
00113     scr->module_buttons.w = SELECT_BUTTON_WIN_W;
00114 
00115     scr->pbar_area.x = PBAR_AREA_X;
00116     scr->pbar_area.y = PBAR_AREA_Y;
00117     scr->pbar_area.h = PBAR_AREA_H;
00118     scr->pbar_area.w = PBAR_AREA_W;
00119 
00120     scr->pbar_pop.x = PBAR_POP_X;
00121     scr->pbar_pop.y = PBAR_POP_Y;
00122     scr->pbar_pop.h = PBAR_H;
00123     scr->pbar_pop.w = PBAR_W;
00124 
00125     scr->pbar_tech.x = PBAR_TECH_X;
00126     scr->pbar_tech.y = PBAR_TECH_Y;
00127     scr->pbar_tech.h = PBAR_H;
00128     scr->pbar_tech.w = PBAR_W;
00129 
00130     scr->pbar_food.x = PBAR_FOOD_X;
00131     scr->pbar_food.y = PBAR_FOOD_Y;
00132     scr->pbar_food.h = PBAR_H;
00133     scr->pbar_food.w = PBAR_W;
00134 
00135     scr->pbar_jobs.x = PBAR_JOBS_X;
00136     scr->pbar_jobs.y = PBAR_JOBS_Y;
00137     scr->pbar_jobs.h = PBAR_H;
00138     scr->pbar_jobs.w = PBAR_W;
00139 
00140     scr->pbar_money.x = PBAR_MONEY_X;
00141     scr->pbar_money.y = PBAR_MONEY_Y;
00142     scr->pbar_money.h = PBAR_H;
00143     scr->pbar_money.w = PBAR_W;
00144 
00145     scr->pbar_coal.x = PBAR_COAL_X;
00146     scr->pbar_coal.y = PBAR_COAL_Y;
00147     scr->pbar_coal.h = PBAR_H;
00148     scr->pbar_coal.w = PBAR_W;
00149 
00150     scr->pbar_goods.x = PBAR_GOODS_X;
00151     scr->pbar_goods.y = PBAR_GOODS_Y;
00152     scr->pbar_goods.h = PBAR_H;
00153     scr->pbar_goods.w = PBAR_W;
00154 
00155     scr->pbar_ore.x = PBAR_ORE_X;
00156     scr->pbar_ore.y = PBAR_ORE_Y;
00157     scr->pbar_ore.h = PBAR_H;
00158     scr->pbar_ore.w = PBAR_W;
00159 
00160     scr->pbar_steel.x = PBAR_STEEL_X;
00161     scr->pbar_steel.y = PBAR_STEEL_Y;
00162     scr->pbar_steel.h = PBAR_H;
00163     scr->pbar_steel.w = PBAR_W;
00164 
00165     scr->sust.x = SUST_SCREEN_X;
00166     scr->sust.y = SUST_SCREEN_Y;
00167     scr->sust.h = SUST_SCREEN_H;
00168     scr->sust.w = SUST_SCREEN_W;
00169 
00170     scr->select_message.x = SELECT_BUTTON_MESSAGE_X;
00171     scr->select_message.y = SELECT_BUTTON_MESSAGE_Y;
00172     scr->select_message.h = 0;  /* unused */
00173     scr->select_message.w = 0;  /* unused */
00174 
00175     scr->date.w = DATE_W;  
00176     scr->date.x = scr->main_win.x + scr->main_win.w - scr->date.w;
00177     scr->date.y = scr->main_win.y + scr->main_win.h + 16;
00178     scr->date.h = 16; 
00179 
00180     scr->money.w = MONEY_W;
00181     scr->money.x = scr->main_win.x;
00182     scr->money.y = scr->main_win.y + scr->main_win.h + 16;
00183     scr->money.h = 16;
00184 
00185     scr->time_for_year.x = scr->main_win.x;
00186     scr->time_for_year.y = TIME_FOR_YEAR_Y;
00187     scr->time_for_year.h = 0;  /* unused */
00188     scr->time_for_year.w = 0;  /* unused */
00189 
00190     scr->status_message_1.x = scr->main_win.x;
00191     scr->status_message_1.y = STATUS_MESSAGE_1_Y;
00192     scr->status_message_1.h = 8;
00193     scr->status_message_1.w = scr->main_win.w;
00194 
00195     scr->status_message_2.x = scr->main_win.x;
00196     scr->status_message_2.y = STATUS_MESSAGE_2_Y;
00197     scr->status_message_2.h = 8;
00198     scr->status_message_2.w = scr->main_win.w;
00199 
00200     scr->mini_map.x = MINI_SCREEN_X;
00201     scr->mini_map.y = MINI_SCREEN_Y;
00202     scr->mini_map.h = MINI_SCREEN_H;
00203     scr->mini_map.w = MINI_SCREEN_W;
00204 
00205     scr->mini_map_aux.x = MINI_MAP_AUX_X;
00206     scr->mini_map_aux.y = MINI_MAP_AUX_Y;
00207     scr->mini_map_aux.h = MINI_MAP_AUX_H;
00208     scr->mini_map_aux.w = MINI_MAP_AUX_W;
00209 
00210     scr->mini_map_area.x = MINI_MAP_AREA_X;
00211     scr->mini_map_area.y = MINI_MAP_AREA_Y;
00212     scr->mini_map_area.h = MINI_MAP_AREA_H;
00213     scr->mini_map_area.w = MINI_MAP_AREA_W;
00214 
00215 #if defined (commentout)
00216     scr->ms_normal_button.x = MS_NORMAL_BUTTON_X;
00217     scr->ms_normal_button.y = MS_NORMAL_BUTTON_Y;
00218     scr->ms_normal_button.h = MS_BUTTON_H;
00219     scr->ms_normal_button.w = MS_BUTTON_W;
00220 
00221     scr->ms_pollution_button.x = MS_POLLUTION_BUTTON_X;
00222     scr->ms_pollution_button.y = MS_POLLUTION_BUTTON_Y;
00223     scr->ms_pollution_button.h = MS_BUTTON_H;
00224     scr->ms_pollution_button.w = MS_BUTTON_W;
00225 
00226     scr->ms_fire_cover_button.x = MS_FIRE_COVER_BUTTON_X;
00227     scr->ms_fire_cover_button.y = MS_FIRE_COVER_BUTTON_Y;
00228     scr->ms_fire_cover_button.h = MS_BUTTON_H;
00229     scr->ms_fire_cover_button.w = MS_BUTTON_W;
00230 
00231     scr->ms_ub40_button.x = MS_UB40_BUTTON_X;
00232     scr->ms_ub40_button.y = MS_UB40_BUTTON_Y;
00233     scr->ms_ub40_button.h = MS_BUTTON_H;
00234     scr->ms_ub40_button.w = MS_BUTTON_W;
00235 
00236     scr->ms_coal_button.x = MS_COAL_BUTTON_X;
00237     scr->ms_coal_button.y = MS_COAL_BUTTON_Y;
00238     scr->ms_coal_button.h = MS_BUTTON_H;
00239     scr->ms_coal_button.w = MS_BUTTON_W;
00240 
00241     scr->ms_health_cover_button.x = MS_HEALTH_COVER_BUTTON_X;
00242     scr->ms_health_cover_button.y = MS_HEALTH_COVER_BUTTON_Y;
00243     scr->ms_health_cover_button.h = MS_BUTTON_H;
00244     scr->ms_health_cover_button.w = MS_BUTTON_W;
00245 
00246     scr->ms_cricket_cover_button.x = MS_CRICKET_COVER_BUTTON_X;
00247     scr->ms_cricket_cover_button.y = MS_CRICKET_COVER_BUTTON_Y;
00248     scr->ms_cricket_cover_button.h = MS_BUTTON_H;
00249     scr->ms_cricket_cover_button.w = MS_BUTTON_W;
00250 
00251     scr->ms_power_button.x = MS_POWER_BUTTON_X;
00252     scr->ms_power_button.y = MS_POWER_BUTTON_Y;
00253     scr->ms_power_button.h = MS_BUTTON_H;
00254     scr->ms_power_button.w = MS_BUTTON_W;
00255 
00256     scr->ms_starve_button.x = MS_STARVE_BUTTON_X;
00257     scr->ms_starve_button.y = MS_STARVE_BUTTON_Y;
00258     scr->ms_starve_button.h = MS_BUTTON_H;
00259     scr->ms_starve_button.w = MS_BUTTON_W;
00260 
00261     scr->ms_ocost_button.x = MS_OCOST_BUTTON_X;
00262     scr->ms_ocost_button.y = MS_OCOST_BUTTON_Y;
00263     scr->ms_ocost_button.h = MS_BUTTON_H;
00264     scr->ms_ocost_button.w = MS_BUTTON_W;
00265 #endif
00266 
00267     scr->monthgraph.x = MONTHGRAPH_X;
00268     scr->monthgraph.y = MONTHGRAPH_Y;
00269     scr->monthgraph.h = MONTHGRAPH_H;
00270     scr->monthgraph.w = MONTHGRAPH_W;
00271 
00272     scr->mappoint_stats.x = MAPPOINT_STATS_X;
00273     scr->mappoint_stats.y = MAPPOINT_STATS_Y;
00274     scr->mappoint_stats.h = MAPPOINT_STATS_H;
00275     scr->mappoint_stats.w = MAPPOINT_STATS_W;
00276 
00277     scr->market_cb = scr->pbar_area;
00278     /*    scr->market_cb.x = MARKET_CB_X;
00279     scr->market_cb.y = MARKET_CB_Y;
00280     scr->market_cb.h = MARKET_CB_H;
00281     scr->market_cb.w = MARKET_CB_W; */
00282 }
00283 
00284 void 
00285 resize_geometry (int new_width, int new_height)
00286 {
00287     if (display.winW == new_width && display.winH == new_height) {
00288         /* Not a resize event. */
00289         return;
00290     }
00291 
00292     /* Reset geometry back to default */
00293     initialize_geometry (&scr);
00294 
00295     scr.client_win.w = new_width;
00296     scr.client_win.h = new_height;
00297 
00298     if (pix_double) {
00299         new_width = new_width / 2;
00300         new_height = new_height / 2;
00301     }
00302 
00303     /* Update display info */
00304     display.winW = new_width;
00305     display.winH = new_height;
00306 
00307     /* Expand pixmap if necessary */
00308     scr.client_w = new_width - 2*borderx;
00309     scr.client_h = new_height - 2*bordery;
00310 #if !defined (SVGALIB)
00311     resize_pixmap (scr.client_w, scr.client_h);
00312 #endif
00313 
00314     /* Adjust items that need adjusting */
00315 
00316     resize_main_win (scr.client_w, scr.client_h);
00317 
00318     scr.select_message.y = SELECT_BUTTON_MESSAGE_Y + (scr.client_h - 480);
00319     scr.time_for_year.y = TIME_FOR_YEAR_Y + (scr.client_h - 480);
00320     scr.status_message_1.y = STATUS_MESSAGE_1_Y + (scr.client_h - 480);
00321     scr.status_message_1.w = scr.main_win.w;
00322     scr.status_message_2.y = STATUS_MESSAGE_2_Y + (scr.client_h - 480);
00323     scr.status_message_2.w = scr.main_win.w;
00324 
00325     scr.date.y = scr.main_win.y + scr.main_win.h + 16;
00326     scr.date.x = scr.main_win.x + scr.main_win.w - scr.date.w;
00327 
00328     scr.pbar_area.x = 56 + scr.main_win.w + 16 + 2;
00329     scr.pbar_pop.x = scr.pbar_area.x + 4;
00330     scr.pbar_tech.x = scr.pbar_area.x + 4;
00331     scr.pbar_food.x = scr.pbar_area.x + 4;
00332     scr.pbar_jobs.x = scr.pbar_area.x + 4;
00333     scr.pbar_money.x = scr.pbar_area.x + 4;
00334     scr.pbar_coal.x = scr.pbar_area.x + 4;
00335     scr.pbar_goods.x = scr.pbar_area.x + 4;
00336     scr.pbar_ore.x = scr.pbar_area.x + 4;
00337     scr.pbar_steel.x = scr.pbar_area.x + 4;
00338 
00339     scr.monthgraph.x = scr.pbar_area.x + 4;
00340     scr.mappoint_stats.x = scr.pbar_area.x + 4;
00341     scr.market_cb.x = scr.pbar_area.x;
00342 
00343     scr.mini_map_aux.x = scr.pbar_area.x + 4;
00344     scr.mini_map_area.x = scr.pbar_area.x + 4;
00345     scr.mini_map.x = scr.mini_map_aux.x 
00346             + ((scr.mini_map_aux.w - scr.mini_map.w) / 2);
00347 
00348     scr.money.x = scr.main_win.x;
00349     scr.money.y = scr.main_win.y + scr.main_win.h + 16;
00350 
00351     scr.help_button.x = scr.client_w - 56;
00352     scr.help_button.y = scr.client_h - 24;
00353     scr.results_button.x = scr.client_w - 2*56;
00354     scr.results_button.y = scr.client_h - 24;
00355 
00356 #if defined (SVGALIB)
00357     mouse_set_range (new_width,new_height);
00358 #endif
00359 
00360     /* Complete refresh of the screen required here */
00361 #if !defined (SVGALIB)
00362     screen_full_refresh ();
00363 #endif
00364 }
00365 
00366 int 
00367 mouse_in_rect (Rect* b, int x, int y)
00368 {
00369     return ((x > b->x) && (x < b->x + b->w) && 
00370             (y > b->y) && (y < b->y + b->h));
00371 }
00372 
00373 
00374 /* ---------------------------------------------------------------------- *
00375  * Main win functions
00376  * ---------------------------------------------------------------------- */
00377 void
00378 resize_main_win (int new_width, int new_height)
00379 {
00380     Rect* mw = &scr.main_win;
00381     mw->w = new_width - 640 + MAIN_WIN_W;
00382     mw->w = (mw->w/16)*16;
00383     mw->h = new_height - 480 + MAIN_WIN_H;
00384     mw->h = (mw->h/16)*16;
00385     adjust_main_origin (main_screen_originx, main_screen_originy,0);
00386 }
00387 
00388 
00389 /* pixel_to_mappoint: convert a pixel value into a mappoint value.
00390    beware, values for mpx _can_ be negative */
00391 int
00392 pixel_to_mappoint(int px, int py, int *mpx, int *mpy)
00393 {
00394     Rect* mw = &scr.main_win;
00395     *mpx = (px - mw->x) / 16;
00396     *mpy = (py - mw->y) / 16;
00397     *mpx += main_screen_originx;
00398     *mpy += main_screen_originy; 
00399 
00400     if ((px > (mw->x + mw->w)) || (py > (mw->y + mw->h)) 
00401         || (px < mw->x) || (py < mw->y)) {
00402         return 0;
00403     }
00404   
00405     return 1;
00406 }
00407 
00408 /* same as above, only with the upper left corner of the visible map being
00409    1,1 */
00410 int
00411 pixel_to_winpoint(int px, int py, int *wpx, int *wpy)
00412 {
00413     Rect* mw = &scr.main_win;
00414     *wpx = (px - mw->x) / 16;
00415     *wpy = (py - mw->y) / 16;
00416 
00417 
00418     if ((px > (mw->x + mw->w)) || (py > (mw->y + mw->h)) 
00419         || (px < mw->x) || (py < mw->y)) {
00420         return 0;
00421     }
00422   
00423     return 1;
00424 }
00425 
00426 /* Adjust the main window origin, and refresh if necessary */
00427 void
00428 adjust_main_origin (int new_origin_x, int new_origin_y, int refresh)
00429 {
00430     Rect* mw = &scr.main_win;
00431 
00432     if (new_origin_x < 1) {
00433         new_origin_x = 1;
00434     } else if (new_origin_x > WORLD_SIDE_LEN - mw->w / 16 - 1) {
00435         new_origin_x = WORLD_SIDE_LEN - mw->w / 16 - 1;
00436     }
00437     if (new_origin_y < 1) {
00438         new_origin_y = 1;
00439     } else if (new_origin_y > WORLD_SIDE_LEN - mw->h / 16 - 1) {
00440         new_origin_y = WORLD_SIDE_LEN - mw->h / 16 - 1;
00441     }
00442 
00443     if (new_origin_x == main_screen_originx
00444         && new_origin_y == main_screen_originy)
00445     {
00446         return;
00447     }
00448 
00449     main_screen_originx = new_origin_x;
00450     main_screen_originy = new_origin_y;
00451 
00452     if (refresh) {
00453         hide_mouse ();
00454         refresh_main_screen ();
00455         redraw_mouse ();
00456     }
00457 }
00458 
00459 /* ---------------------------------------------------------------------- *
00460  * Button drawing functions
00461  * ---------------------------------------------------------------------- */
00462 void 
00463 draw_pause (int active)
00464 {
00465     Rect* b = &scr.pause_button;
00466     if (active) {
00467         Fgl_putbox (b->x, b->y, 16, 16, pause_button1_on);
00468         Fgl_putbox (b->x + 16, b->y, 16, 16, pause_button2_on);
00469     } else {
00470         Fgl_putbox (b->x, b->y, 16, 16, pause_button1_off);
00471         Fgl_putbox (b->x + 16, b->y, 16, 16, pause_button2_off);
00472     }
00473 }
00474 
00475 void 
00476 draw_slow (int active)
00477 {
00478     Rect* b = &scr.slow_button;
00479     if (active) {
00480         Fgl_putbox (b->x, b->y, 16, 16, slow_button1_on);
00481         Fgl_putbox (b->x + 16, b->y, 16, 16, slow_button2_on);
00482     } else {
00483         Fgl_putbox (b->x, b->y, 16, 16, slow_button1_off);
00484         Fgl_putbox (b->x + 16, b->y, 16, 16, slow_button2_off);
00485     }
00486 }
00487 
00488 void 
00489 draw_med (int active)
00490 {
00491     Rect* b = &scr.med_button;
00492     if (active) {
00493         Fgl_putbox (b->x, b->y, 16, 16, med_button1_on);
00494         Fgl_putbox (b->x + 16, b->y, 16, 16, med_button2_on);
00495     } else {
00496         Fgl_putbox (b->x, b->y, 16, 16, med_button1_off);
00497         Fgl_putbox (b->x + 16, b->y, 16, 16, med_button2_off);
00498     }
00499 }
00500 
00501 void 
00502 draw_fast (int active)
00503 {
00504     Rect* b = &scr.fast_button;
00505     if (active) {
00506         Fgl_putbox (b->x, b->y, 16, 16, fast_button1_on);
00507         Fgl_putbox (b->x + 16, b->y, 16, 16, fast_button2_on);
00508     } else {
00509         Fgl_putbox (b->x, b->y, 16, 16, fast_button1_off);
00510         Fgl_putbox (b->x + 16, b->y, 16, 16, fast_button2_off);
00511     }
00512 }
00513 
00514 void 
00515 draw_menu (void)
00516 {
00517     /*    int menu_bg_color = white(20);*/
00518     /*    int menu_bg_color = TEXT_BG_COLOUR; */
00519     /*    int menu_bg_color = 14;*/
00520     /*    int menu_fg_color = TEXT_FG_COLOUR;*/
00521     int menu_bg_color = 80;
00522     int menu_fg_color = 226;
00523 
00524     Rect* b = &scr.menu_button;
00525 
00526     Fgl_fillbox (b->x, b->y, b->w, b->h, white(20));
00527     Fgl_fillbox (b->x+5, b->y+4, b->w-10, b->h-5, menu_bg_color);
00528     
00529     Fgl_hline (b->x+5, b->y+4, b->x + b->w-5, white(8));
00530     Fgl_line (b->x+5, b->y+4, b->x+5, b->y + b->h-2, white(8));
00531     Fgl_hline (b->x+5, b->y + b->h-2, b->x + b->w-5, white(8));
00532     Fgl_line (b->x + b->w-5, b->y+4, b->x + b->w-5, b->y + b->h-2, white(8));
00533 
00534     Fgl_setfontcolors (menu_bg_color,menu_fg_color);
00535     Fgl_write (b->x + 12, b->y + 10, _("Menu"));
00536     Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00537 }
00538 
00539 void 
00540 draw_help (void)
00541 {
00542     /*    int menu_bg_color = white(20);*/
00543     /*    int menu_bg_color = TEXT_BG_COLOUR; */
00544     /*    int menu_bg_color = 14;*/
00545     /*    int menu_fg_color = TEXT_FG_COLOUR;*/
00546     int menu_bg_color = 80;
00547     int menu_fg_color = 226;
00548 
00549     Rect* b = &scr.help_button;
00550 
00551     Fgl_fillbox (b->x, b->y, b->w, b->h, white(20));
00552     Fgl_fillbox (b->x+5, b->y+4, b->w-10, b->h-8, menu_bg_color);
00553     
00554     Fgl_hline (b->x+5, b->y+4, b->x + b->w-5, white(8));
00555     Fgl_line (b->x+5, b->y+4, b->x+5, b->y + b->h-4, white(8));
00556     Fgl_hline (b->x+5, b->y + b->h-4, b->x + b->w-5, white(8));
00557     Fgl_line (b->x + b->w-5, b->y+4, b->x + b->w-5, b->y + b->h-4, white(8));
00558 
00559     Fgl_setfontcolors (menu_bg_color,menu_fg_color);
00560     Fgl_write (b->x + 13, b->y + 9, _("Help"));
00561     Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00562 }
00563 
00564 void 
00565 draw_results (void)
00566 {
00567     /*    int menu_bg_color = white(20);*/
00568     /*    int menu_bg_color = TEXT_BG_COLOUR; */
00569     /*    int menu_bg_color = 14;*/
00570     /*    int menu_fg_color = TEXT_FG_COLOUR;*/
00571     int menu_bg_color = 80;
00572     int menu_fg_color = 226;
00573 
00574     Rect* b = &scr.results_button;
00575 
00576     Fgl_fillbox (b->x, b->y, b->w, b->h, white(20));
00577     Fgl_fillbox (b->x+5, b->y+4, b->w-10, b->h-8, menu_bg_color);
00578     
00579     Fgl_hline (b->x+5, b->y+4, b->x + b->w-5, white(8));
00580     Fgl_line (b->x+5, b->y+4, b->x+5, b->y + b->h-4, white(8));
00581     Fgl_hline (b->x+5, b->y + b->h-4, b->x + b->w-5, white(8));
00582     Fgl_line (b->x + b->w-5, b->y+4, b->x + b->w-5, b->y + b->h-4, white(8));
00583 
00584     Fgl_setfontcolors (menu_bg_color,menu_fg_color);
00585     Fgl_write (b->x + 9, b->y + 9, _("Stats"));
00586     Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00587 }
00588 
00589 #if defined (commentout)
00590 void 
00591 draw_load (void)
00592 {
00593     Rect* b = &scr.load_button;
00594     Fgl_putbox (b->x, b->y, 32, 32, load_button_graphic);
00595 }
00596 
00597 void 
00598 draw_save (void)
00599 {
00600     Rect* b = &scr.save_button;
00601     Fgl_putbox (b->x, b->y, 32, 32, save_button_graphic);
00602 }
00603 
00604 void 
00605 draw_quit (void)
00606 {
00607     Rect* b = &scr.quit_button;
00608     Fgl_putbox (b->x, b->y, 32, 32, quit_button_graphic);
00609 }
00610 
00611 void 
00612 draw_help (void)
00613 {
00614     Rect* b = &scr.help_button;
00615     Fgl_putbox (b->x, b->y, 32, 32, help_button_graphic);
00616 }
00617 
00618 void 
00619 draw_results (void)
00620 {
00621     Rect* b = &scr.results_button;
00622     Fgl_putbox (b->x, b->y, 16, 16, results_button1);
00623     Fgl_putbox (b->x + 16, b->y, 16, 16, results_button2);
00624 }
00625 #endif
00626 
00627 
00628 /* ---------------------------------------------------------------------- *
00629  * Button click functions
00630  * ---------------------------------------------------------------------- */
00631 
00632 
00633 /* ---------------------------------------------------------------------- *
00634  * Mini map button functions
00635  * ---------------------------------------------------------------------- */
00636 #if defined (commentout)
00637 void
00638 draw_ms_button (Rect* b, char* graphic)
00639 {
00640     Fgl_putbox (b->x, b->y, 16, 16, graphic);
00641 }
00642 #endif
00643 void
00644 draw_ms_button (char* graphic)
00645 {
00646     Rect* mma = &scr.mini_map_aux;
00647     Fgl_putbox (mma->x + 4, mma->y, 16, 16, graphic);
00648 }
00649 
00650 void
00651 draw_ms_text (char* txt)
00652 {
00653     Rect* mma = &scr.mini_map_aux;
00654     Fgl_write (mma->x + 28, mma->y + 4, txt);
00655 }
00656 
00657 void
00658 draw_small_bezel (int x, int y, int w, int h, int colour)
00659 {
00660     int i;
00661     for (i = 1; i < 4; i++) {
00662         Fgl_hline (x - 1 - i, y - 1 - i, x + w + i, colour + 16);
00663         Fgl_line (x - 1 - i, y - 1 - i, x - 1 - i, y + h + i, colour + 14);
00664         Fgl_hline (x - 1 - i, y + h + i, x + w + i, colour + 22);
00665         Fgl_line (x + w + i, y - 1 - i, x + w + i, y + h + i, colour + 24);
00666     }
00667 }
00668 
00669 void 
00670 draw_bezel (Rect r, short width, int color)
00671 {
00672   int i;
00673   int c;
00674   for (i = 0; i < width; i++)
00675     {
00676       c = color + (width - i) * 2;
00677       Fgl_hline (r.x + i, r.y + i, r.x + r.w - i - 1, c);
00678       Fgl_hline (r.x + i, r.y + r.h - i - 1, r.x + r.w - i - 1, c);
00679       Fgl_line (r.x + i, r.y + i, r.x + i, r.y + r.h - i - 1, c);
00680       Fgl_line (r.x + r.w - i - 1, r.y + i, r.x + r.w - i - 1, 
00681                 r.y + r.h - i - 1, c);
00682     }
00683 }

Generated on Sun Dec 26 11:23:24 2004 for lincity by  doxygen 1.3.9.1