00001
00002
00003
00004
00005
00006 #include "lcconfig.h"
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <math.h>
00010 #include <sys/types.h>
00011 #include <sys/stat.h>
00012 #if defined (HAVE_UNISTD_H)
00013 #include <unistd.h>
00014 #endif
00015 #include "lcstring.h"
00016 #include "common.h"
00017 #include "lctypes.h"
00018 #include "lin-city.h"
00019 #include "screen.h"
00020 #include "engglobs.h"
00021 #include "cliglobs.h"
00022 #include "pixmap.h"
00023 #include "lchelp.h"
00024 #include "mouse.h"
00025 #include "mps.h"
00026 #include "lcintl.h"
00027 #include "ldsvgui.h"
00028 #include "pbar.h"
00029 #include "dialbox.h"
00030 #include "lclib.h"
00031 #include "module_buttons.h"
00032 #include "stats.h"
00033 #include "engine.h"
00034 #include "fileutil.h"
00035
00036
00037
00038
00039 extern int network_game;
00040
00041
00042
00043
00044 unsigned char main_font[2048];
00045 unsigned char start_font1[2048];
00046 unsigned char start_font2[4096];
00047 unsigned char start_font3[4096];
00048 Update_Scoreboard update_scoreboard;
00049
00050 int monthgraph_style = MONTHGRAPH_STYLE_MIN;
00051 int mps_global_style = MPS_GLOBAL_STYLE_MIN;
00052
00053 char screen_refreshing = 0;
00054
00055
00056
00057
00058 static int monthgraph_style_timeout = 1;
00059 static int mps_global_style_timeout = 1;
00060 static float time_for_year;
00061
00062
00063
00064
00065 void draw_yellow_bezel (int x, int y, int h, int w);
00066 void draw_small_yellow_bezel (int x, int y, int h, int w);
00067 void print_time_for_year (void);
00068 void calculate_time_for_year (void);
00069 void clear_monthgraph (void);
00070 void draw_ms_buttons (void);
00071 static void do_monthgraph (int full_refresh);
00072 static void do_history_linegraph (int draw);
00073 static void do_sust_barchart (int draw);
00074 static void draw_sustline (int yoffset, int count, int max, int col);
00075 void monthgraph_full_refresh (void);
00076 void draw_mini_pol_in_main_win ();
00077 void mini_full_refresh (void);
00078 void update_main_screen_normal (int full_refresh);
00079 void update_main_screen_pollution (void);
00080 void update_main_screen_ub40 (void);
00081 void update_main_screen_starve (void);
00082 void update_main_screen_power (void);
00083 void update_main_screen_fire_cover (void);
00084 void update_main_screen_cricket_cover (void);
00085 void update_main_screen_health_cover (void);
00086 void update_main_screen_coal (void);
00087
00088
00089
00090
00091
00092
00093 void
00094 draw_background (void)
00095 {
00096
00097
00098
00099 #if defined (LC_X11) || defined (WIN32)
00100
00101 draw_border ();
00102
00103 Fgl_fillbox (0, 0, pixmap_width, pixmap_height, TEXT_BG_COLOUR);
00104 #else
00105 Fgl_fillbox (0, 0, display.winW, display.winH, TEXT_BG_COLOUR);
00106 #endif
00107 }
00108
00109 void
00110 connect_transport_main_screen (void)
00111 {
00112 Rect* b = &scr.main_win;
00113
00114 connect_transport (main_screen_originx, main_screen_originy,
00115 b->w / 16, b->h / 16);
00116 }
00117
00118 void
00119 refresh_main_screen (void)
00120 {
00121 connect_transport_main_screen ();
00122 update_main_screen (1);
00123 update_mini_screen ();
00124 dialog_refresh();
00125 }
00126
00127 void
00128 clip_main_window ()
00129 {
00130 Rect* b = &scr.main_win;
00131 Fgl_enableclipping ();
00132 Fgl_setclippingwindow (b->x, b->y, b->x + b->w - 1, b->y + b->h - 1);
00133 }
00134
00135 void
00136 unclip_main_window ()
00137 {
00138 Fgl_disableclipping ();
00139 }
00140
00141 void
00142 rotate_main_screen (void)
00143 {
00144 if (main_screen_flag == MAIN_SCREEN_NORMAL_FLAG) {
00145 main_screen_flag = MAIN_SCREEN_EQUALS_MINI;
00146 } else {
00147 main_screen_flag = MAIN_SCREEN_NORMAL_FLAG;
00148 }
00149 refresh_main_screen ();
00150 }
00151
00152 void
00153 update_main_screen (int full_refresh)
00154 {
00155 if (main_screen_flag == MAIN_SCREEN_NORMAL_FLAG) {
00156 update_main_screen_normal (full_refresh);
00157 } else {
00158 switch (mini_screen_flags) {
00159 case MINI_SCREEN_NORMAL_FLAG:
00160 update_main_screen_normal (full_refresh);
00161 break;
00162 case MINI_SCREEN_POL_FLAG:
00163 update_main_screen_pollution ();
00164 break;
00165 case MINI_SCREEN_UB40_FLAG:
00166 update_main_screen_ub40 ();
00167 break;
00168 case MINI_SCREEN_STARVE_FLAG:
00169 update_main_screen_starve ();
00170 break;
00171 case MINI_SCREEN_POWER_FLAG:
00172 update_main_screen_power ();
00173 break;
00174 case MINI_SCREEN_FIRE_COVER:
00175 update_main_screen_fire_cover ();
00176 break;
00177 case MINI_SCREEN_CRICKET_COVER:
00178 update_main_screen_cricket_cover ();
00179 break;
00180 case MINI_SCREEN_HEALTH_COVER:
00181 update_main_screen_health_cover ();
00182 break;
00183 case MINI_SCREEN_COAL_FLAG:
00184 if (coal_survey_done) {
00185 update_main_screen_coal ();
00186 } else {
00187 update_main_screen_normal (full_refresh);
00188 }
00189 break;
00190 }
00191 }
00192 #if defined (WIN32)
00193
00194 if (full_refresh) {
00195 UpdateWindow (display.hWnd);
00196 }
00197 #else
00198 if (mouse_type == MOUSE_TYPE_SQUARE)
00199 redraw_mouse ();
00200 #endif
00201 }
00202
00203 void
00204 update_main_screen_normal (int full_refresh)
00205 {
00206 Rect* mw = &scr.main_win;
00207 int x, y, xm, ym;
00208 short typ, grp;
00209 #ifdef USE_PIXMAPS
00210 int sx, sy, dx, dy, x1, y1;
00211 #endif
00212
00213 #ifdef DEBUG_MAIN_SCREEN
00214 printf ("Updating main screen\n");
00215 #endif
00216 if (help_flag || load_flag || save_flag)
00217 return;
00218
00219
00220
00221
00222 xm = main_screen_originx;
00223 if (xm > 3)
00224 xm = 3;
00225 ym = main_screen_originy;
00226 if (ym > 3)
00227 ym = 3;
00228 #if !defined (WIN32)
00229 if (mouse_type == MOUSE_TYPE_SQUARE)
00230 hide_mouse ();
00231 #endif
00232 clip_main_window ();
00233 for (y = main_screen_originy - ym; y < main_screen_originy
00234 + (mw->h / 16); y++)
00235 for (x = main_screen_originx - xm; x < main_screen_originx
00236 + (mw->w / 16); x++)
00237 {
00238 typ = MP_TYPE(x,y);
00239 if (typ != mappointoldtype[x][y] || full_refresh)
00240 {
00241 mappointoldtype[x][y] = typ;
00242 if (typ == CST_USED) {
00243 continue;
00244 }
00245 grp = get_group_of_type(typ);
00246 #ifdef USE_PIXMAPS
00247 if (icon_pixmap[typ] != 0)
00248 {
00249 x1 = y1 = 0;
00250 if (x < main_screen_originx)
00251 x1 = (main_screen_originx - x) * 16;
00252 if (y < main_screen_originy)
00253 y1 = (main_screen_originy - y) * 16;
00254 sx = sy = main_groups[grp].size;
00255 if ((sx + x) > (main_screen_originx + (mw->w / 16)))
00256 sx = (main_screen_originx + (mw->w / 16)) - x;
00257 if ((sy + y) > (main_screen_originy + (mw->h / 16)))
00258 sy = (main_screen_originy + (mw->h / 16)) - y;
00259 sx = (sx << 4) - x1;
00260 sy = (sy << 4) - y1;
00261 dx = mw->x + (x - main_screen_originx) * 16 + x1;
00262 dy = mw->y + (y - main_screen_originy) * 16 + y1;
00263 if (sx > 0 && sy > 0)
00264 {
00265 #if defined (LC_X11)
00266 #ifdef ALLOW_PIX_DOUBLING
00267 if (pix_double)
00268 XCopyArea (display.dpy
00269 ,icon_pixmap[typ]
00270 ,display.win
00271 ,display.pixcolour_gc[0]
00272 ,x1 * 2, y1 * 2, sx * 2, sy * 2
00273 ,dx * 2, dy * 2);
00274 else
00275 #endif
00276 XCopyArea (display.dpy
00277 ,icon_pixmap[typ]
00278 ,display.win
00279 ,display.pixcolour_gc[0]
00280 ,x1, y1, sx, sy
00281 ,dx + borderx, dy + bordery);
00282 #elif defined (WIN32)
00283 CopyPixmapToScreen (typ, x1, y1, sx, sy, dx, dy);
00284 #endif
00285 update_pixmap (x1, y1, sx, sy, dx, dy,
00286 main_groups[grp].size,
00287 main_types[typ].graphic);
00288
00289 }
00290 }
00291 else
00292 #endif
00293 Fgl_putbox (mw->x + (x - main_screen_originx) * 16,
00294 mw->y + (y - main_screen_originy) * 16,
00295 16 * main_groups[grp].size,
00296 16 * main_groups[grp].size,
00297 main_types[typ].graphic);
00298 }
00299 }
00300 unclip_main_window ();
00301 }
00302
00303 void
00304 update_main_screen_pollution (void)
00305 {
00306 Rect* mw = &scr.main_win;
00307 int x, y, col;
00308
00309 for (y = main_screen_originy;
00310 y < main_screen_originy + (mw->h / 16); y++) {
00311 for (x = main_screen_originx;
00312 x < main_screen_originx + (mw->w / 16); x++) {
00313 if (MP_POL(x,y) < 4) {
00314 col = green (24);
00315 } else if (MP_POL(x,y) < 600) {
00316 col = green (23 - (MP_POL(x,y) / 45));
00317 } else {
00318 col = (int) sqrt ((float) (MP_POL(x,y) - 600)) / 9;
00319 if (col > 20)
00320 col = 20;
00321 col += red (11);
00322 }
00323 Fgl_fillbox (mw->x + (x - main_screen_originx) * 16,
00324 mw->y + (y - main_screen_originy) * 16,
00325 16, 16, col);
00326 }
00327 }
00328 }
00329
00330 void
00331 update_main_screen_ub40 (void)
00332 {
00333 Rect* mw = &scr.main_win;
00334 int x, y, col;
00335
00336 for (y = main_screen_originy;
00337 y < main_screen_originy + (mw->h / 16); y++) {
00338 for (x = main_screen_originx;
00339 x < main_screen_originx + (mw->w / 16); x++) {
00340 int xx = x;
00341 int yy = y;
00342 if (MP_TYPE(x,y) == CST_USED) {
00343 xx = MP_INFO(x,y).int_1;
00344 yy = MP_INFO(x,y).int_2;
00345 }
00346 if (MP_GROUP_IS_RESIDENCE(xx,yy)) {
00347 if (MP_INFO(xx,yy).int_1 < -20)
00348 col = red (28);
00349 else if (MP_INFO(xx,yy).int_1 < 10)
00350 col = red (14);
00351 else
00352 col = green (20);
00353 } else {
00354 col = green (14);
00355 }
00356 Fgl_fillbox (mw->x + (x - main_screen_originx) * 16,
00357 mw->y + (y - main_screen_originy) * 16,
00358 16, 16, col);
00359 }
00360 }
00361 }
00362
00363 void
00364 update_main_screen_starve (void)
00365 {
00366 Rect* mw = &scr.main_win;
00367 int x, y, col;
00368
00369 for (y = main_screen_originy;
00370 y < main_screen_originy + (mw->h / 16); y++) {
00371 for (x = main_screen_originx;
00372 x < main_screen_originx + (mw->w / 16); x++) {
00373 int xx = x;
00374 int yy = y;
00375 if (MP_TYPE(x,y) == CST_USED) {
00376 xx = MP_INFO(x,y).int_1;
00377 yy = MP_INFO(x,y).int_2;
00378 }
00379 if (MP_GROUP_IS_RESIDENCE(xx,yy)) {
00380 if ((total_time - MP_INFO(x,y).int_2) < 20)
00381 col = red (28);
00382 else if ((total_time - MP_INFO(x,y).int_2) < 100)
00383 col = red (14);
00384 else
00385 col = green (20);
00386 } else {
00387 col = green (14);
00388 }
00389 Fgl_fillbox (mw->x + (x - main_screen_originx) * 16,
00390 mw->y + (y - main_screen_originy) * 16,
00391 16, 16, col);
00392 }
00393 }
00394 }
00395
00396 void
00397 update_main_screen_power (void)
00398 {
00399 Rect* mw = &scr.main_win;
00400 int x, y, col;
00401
00402 for (y = main_screen_originy;
00403 y < main_screen_originy + (mw->h / 16); y++) {
00404 for (x = main_screen_originx;
00405 x < main_screen_originx + (mw->w / 16); x++) {
00406 int xx = x;
00407 int yy = y;
00408 if (MP_TYPE(x,y) == CST_USED) {
00409 xx = MP_INFO(x,y).int_1;
00410 yy = MP_INFO(x,y).int_2;
00411 }
00412 if (get_power (xx, yy, 1, 1) != 0) {
00413 col = green (14);
00414 } else if (get_power (xx, yy, 1, 0) != 0) {
00415 col = green (10);
00416 } else {
00417
00418 col = green (20);
00419 }
00420 Fgl_fillbox (mw->x + (x - main_screen_originx) * 16,
00421 mw->y + (y - main_screen_originy) * 16,
00422 16, 16, col);
00423 }
00424 }
00425 }
00426
00427 void
00428 update_main_screen_fire_cover (void)
00429 {
00430 Rect* mw = &scr.main_win;
00431 int x, y, col;
00432
00433 for (y = main_screen_originy;
00434 y < main_screen_originy + (mw->h / 16); y++) {
00435 for (x = main_screen_originx;
00436 x < main_screen_originx + (mw->w / 16); x++) {
00437 int xx = x;
00438 int yy = y;
00439 if (MP_TYPE(x,y) == CST_USED) {
00440 xx = MP_INFO(x,y).int_1;
00441 yy = MP_INFO(x,y).int_2;
00442 }
00443
00444 if ((MP_INFO(xx,yy).flags & FLAG_FIRE_COVER) == 0)
00445
00446 col = green (20);
00447 else
00448 col = green (10);
00449 Fgl_fillbox (mw->x + (x - main_screen_originx) * 16,
00450 mw->y + (y - main_screen_originy) * 16,
00451 16, 16, col);
00452 }
00453 }
00454 }
00455
00456 void
00457 update_main_screen_health_cover (void)
00458 {
00459 Rect* mw = &scr.main_win;
00460 int x, y, col;
00461
00462 for (y = main_screen_originy;
00463 y < main_screen_originy + (mw->h / 16); y++) {
00464 for (x = main_screen_originx;
00465 x < main_screen_originx + (mw->w / 16); x++) {
00466 int xx = x;
00467 int yy = y;
00468 if (MP_TYPE(x,y) == CST_USED) {
00469 xx = MP_INFO(x,y).int_1;
00470 yy = MP_INFO(x,y).int_2;
00471 }
00472 if ((MP_INFO(xx,yy).flags & FLAG_HEALTH_COVER) == 0)
00473
00474 col = green (20);
00475 else
00476 col = green (10);
00477 Fgl_fillbox (mw->x + (x - main_screen_originx) * 16,
00478 mw->y + (y - main_screen_originy) * 16,
00479 16, 16, col);
00480 }
00481 }
00482 }
00483
00484 void
00485 update_main_screen_cricket_cover (void)
00486 {
00487 Rect* mw = &scr.main_win;
00488 int x, y, col;
00489
00490 for (y = main_screen_originy;
00491 y < main_screen_originy + (mw->h / 16); y++) {
00492 for (x = main_screen_originx;
00493 x < main_screen_originx + (mw->w / 16); x++) {
00494 int xx = x;
00495 int yy = y;
00496 if (MP_TYPE(x,y) == CST_USED) {
00497 xx = MP_INFO(x,y).int_1;
00498 yy = MP_INFO(x,y).int_2;
00499 }
00500 if ((MP_INFO(xx,yy).flags & FLAG_CRICKET_COVER) == 0)
00501
00502 col = green (20);
00503 else
00504 col = green (10);
00505 Fgl_fillbox (mw->x + (x - main_screen_originx) * 16,
00506 mw->y + (y - main_screen_originy) * 16,
00507 16, 16, col);
00508 }
00509 }
00510 }
00511
00512 void
00513 update_main_screen_coal (void)
00514 {
00515 Rect* mw = &scr.main_win;
00516 int x, y, col;
00517
00518 for (y = main_screen_originy;
00519 y < main_screen_originy + (mw->h / 16); y++) {
00520 for (x = main_screen_originx;
00521 x < main_screen_originx + (mw->w / 16); x++) {
00522 if (MP_INFO(x,y).coal_reserve == 0)
00523 col = white (4);
00524 else if (MP_INFO(x,y).coal_reserve >= COAL_RESERVE_SIZE / 2)
00525 col = white (18);
00526 else if (MP_INFO(x,y).coal_reserve < COAL_RESERVE_SIZE / 2)
00527 col = white (28);
00528 Fgl_fillbox (mw->x + (x - main_screen_originx) * 16,
00529 mw->y + (y - main_screen_originy) * 16,
00530 16, 16, col);
00531 }
00532 }
00533 }
00534
00535
00536
00537
00538
00539
00540
00541
00542 void
00543 screen_setup (void)
00544 {
00545
00546 monthgraph_full_refresh ();
00547 monthgraph_style_timeout = real_time + 10000;
00548 mps_full_refresh ();
00549 mps_global_style_timeout = real_time + 10000;
00550
00551
00552
00553 up_pbar1_graphic = load_graphic ("pbarup1.csi");
00554 up_pbar2_graphic = load_graphic ("pbarup2.csi");
00555 down_pbar1_graphic = load_graphic ("pbardown1.csi");
00556 down_pbar2_graphic = load_graphic ("pbardown2.csi");
00557 pop_pbar_graphic = load_graphic ("pbarpop.csi");
00558 tech_pbar_graphic = load_graphic ("pbartech.csi");
00559 food_pbar_graphic = load_graphic ("pbarfood.csi");
00560 jobs_pbar_graphic = load_graphic ("pbarjobs.csi");
00561 coal_pbar_graphic = load_graphic ("pbarcoal.csi");
00562 goods_pbar_graphic = load_graphic ("pbargoods.csi");
00563 ore_pbar_graphic = load_graphic ("pbarore.csi");
00564 steel_pbar_graphic = load_graphic ("pbarsteel.csi");
00565 money_pbar_graphic = load_graphic ("pbarmoney.csi");
00566 init_pbars ();
00567
00568
00569 draw_main_window_box (green (8));
00570
00571 checked_box_graphic = load_graphic ("checked_box.csi");
00572 unchecked_box_graphic = load_graphic ("unchecked_box.csi");
00573
00574
00575 ms_normal_button_graphic = load_graphic ("ms-normal-button.csi");
00576 ms_pollution_button_graphic = load_graphic ("ms-pollution-button.csi");
00577 ms_fire_cover_button_graphic = load_graphic ("ms-fire-cover-button.csi");
00578 ms_health_cover_button_graphic
00579 = load_graphic ("ms-health-cover-button.csi");
00580 ms_cricket_cover_button_graphic
00581 = load_graphic ("ms-cricket-cover-button.csi");
00582 ms_ub40_button_graphic = load_graphic ("ms-ub40-button.csi");
00583 ms_coal_button_graphic = load_graphic ("ms-coal-button.csi");
00584 ms_starve_button_graphic = load_graphic ("ms-starve-button.csi");
00585 ms_power_button_graphic = load_graphic ("ms-power-button.csi");
00586 ms_ocost_button_graphic = load_graphic ("ms-ocost-button.csi");
00587
00588
00589 pause_button1_off = load_graphic ("pause-offl.csi");
00590 pause_button2_off = load_graphic ("pause-offr.csi");
00591 pause_button1_on = load_graphic ("pause-onl.csi");
00592 pause_button2_on = load_graphic ("pause-onr.csi");
00593 draw_pause (0);
00594
00595
00596 slow_button1_off = load_graphic ("slow-offl.csi");
00597 slow_button2_off = load_graphic ("slow-offr.csi");
00598 slow_button1_on = load_graphic ("slow-onl.csi");
00599 slow_button2_on = load_graphic ("slow-onr.csi");
00600 draw_slow (0);
00601
00602
00603 med_button1_off = load_graphic ("norm-offl.csi");
00604 med_button2_off = load_graphic ("norm-offr.csi");
00605 med_button1_on = load_graphic ("norm-onl.csi");
00606 med_button2_on = load_graphic ("norm-onr.csi");
00607 draw_med (0);
00608
00609
00610 fast_button1_off = load_graphic ("fast-offl.csi");
00611 fast_button2_off = load_graphic ("fast-offr.csi");
00612 fast_button1_on = load_graphic ("fast-onl.csi");
00613 fast_button2_on = load_graphic ("fast-onr.csi");
00614 draw_fast (0);
00615
00616
00617 results_button1 = load_graphic ("results-l.csi");
00618 results_button2 = load_graphic ("results-r.csi");
00619 draw_results ();
00620
00621
00622 #if defined (commentout)
00623 toveron_button1 = load_graphic ("tover1-on.csi");
00624 toveroff_button1 = load_graphic ("tover1-off.csi");
00625 toveron_button2 = load_graphic ("tover2-on.csi");
00626 toveroff_button2 = load_graphic ("tover2-off.csi");
00627 draw_tover (0);
00628
00629 #ifdef LC_X11
00630
00631 confine_button = load_graphic ("mouse-confined.csi");
00632 unconfine_button = load_graphic ("mouse-free.csi");
00633 draw_confine (0);
00634 #endif
00635 #endif
00636
00637
00638 #if defined (commentout)
00639 menu_button_graphic = load_graphic ("menu-button.csi");
00640 #endif
00641 draw_menu ();
00642 draw_help ();
00643 #if defined (commentout)
00644 load_button_graphic = load_graphic ("load-button.csi");
00645 draw_load ();
00646 save_button_graphic = load_graphic ("save-button.csi");
00647 draw_save ();
00648 quit_button_graphic = load_graphic ("quit-button.csi");
00649 draw_quit ();
00650 help_button_graphic = load_graphic ("help-button.csi");
00651 draw_help ();
00652 #endif
00653
00654
00655 set_selected_module (CST_TRACK_LR);
00656
00657 #ifdef SCREEN_SETUP_DRAWS
00658 mini_full_refresh ();
00659
00660 redraw_mouse ();
00661
00662 update_main_screen ();
00663 #endif
00664
00665 }
00666
00667 void
00668 screen_full_refresh (void)
00669 {
00670 screen_refreshing++;
00671 draw_background ();
00672
00673 monthgraph_full_refresh ();
00674 mps_full_refresh ();
00675 pbars_full_refresh ();
00676 mini_full_refresh ();
00677
00678
00679 if (selected_module_type == CST_GREEN)
00680 draw_main_window_box (red (8));
00681 else
00682 draw_main_window_box (green (8));
00683
00684 draw_menu ();
00685 draw_help ();
00686 #if defined (commentout)
00687 draw_load ();
00688 draw_save ();
00689 draw_quit ();
00690 draw_help ();
00691 #endif
00692 draw_pause (pause_flag);
00693 draw_slow (slow_flag & !pause_flag);
00694 draw_med (med_flag & !pause_flag);
00695 draw_fast (fast_flag & !pause_flag);
00696 draw_results ();
00697
00698 draw_modules ();
00699
00700
00701
00702 if (help_flag) {
00703 refresh_help_page ();
00704 }
00705 refresh_main_screen ();
00706
00707
00708 print_date();
00709 print_time_for_year();
00710 print_total_money();
00711 draw_selected_module_cost();
00712
00713 refresh_pbars();
00714 redraw_mouse();
00715 screen_refreshing--;
00716 }
00717
00718 #if defined (commentout)
00719 void
00720 draw_ms_buttons (void)
00721 {
00722 draw_ms_button (&scr.ms_normal_button, ms_normal_button_graphic);
00723 draw_ms_button (&scr.ms_pollution_button, ms_pollution_button_graphic);
00724 draw_ms_button (&scr.ms_fire_cover_button, ms_fire_cover_button_graphic);
00725 draw_ms_button (&scr.ms_health_cover_button,
00726 ms_health_cover_button_graphic);
00727 draw_ms_button (&scr.ms_cricket_cover_button,
00728 ms_cricket_cover_button_graphic);
00729 draw_ms_button (&scr.ms_ub40_button, ms_ub40_button_graphic);
00730 draw_ms_button (&scr.ms_coal_button, ms_coal_button_graphic);
00731 draw_ms_button (&scr.ms_starve_button, ms_starve_button_graphic);
00732 draw_ms_button (&scr.ms_power_button, ms_power_button_graphic);
00733 draw_ms_button (&scr.ms_ocost_button, ms_ocost_button_graphic);
00734 }
00735 #endif
00736
00737 void
00738 draw_main_window_box (int colour)
00739 {
00740 Rect* b = &scr.main_win;
00741 int x;
00742 for (x = 0; x < 8; x++)
00743 {
00744 Fgl_hline (b->x - 1 - x, b->y - 1 - x,
00745 b->x + b->w + x, colour + x + x);
00746 Fgl_hline (b->x - 1 - x, b->y + b->h + x,
00747 b->x + b->w + x, colour + x + x);
00748 Fgl_line (b->x - 1 - x, b->y - x, b->x - 1 - x,
00749 b->y + b->h + x, colour + x + x);
00750 Fgl_line (b->x + b->w + x, b->y - x,
00751 b->x + b->w + x, b->y + b->h + x,
00752 colour + x + x);
00753 }
00754 }
00755
00756 void
00757 draw_yellow_bezel (int x, int y, int h, int w)
00758 {
00759 int i;
00760 for (i = 1; i < 8; i++) {
00761 Fgl_hline (x - 1 - i, y - 1 - i, x + w + 1 + i, yellow (16));
00762 Fgl_line (x - 1 - i, y - 1 - i, x - 1 - i, y + h + 1 + i, yellow (14));
00763 Fgl_hline (x - 1 - i, y + h + 1 + i, x + w + 1 + i, yellow (22));
00764 Fgl_line (x + w + 1 + i, y - 1 - i, x + w + 1 + i, y + h + 1 + i,
00765 yellow (24));
00766 }
00767 }
00768
00769 void
00770 draw_small_yellow_bezel (int x, int y, int h, int w)
00771 {
00772 #if defined (commentout)
00773 int i;
00774 for (i = 1; i < 4; i++) {
00775 Fgl_hline (x - 1 - i, y - 1 - i, x + w + 1 + i, yellow (16));
00776 Fgl_line (x - 1 - i, y - 1 - i, x - 1 - i, y + h + 1 + i, yellow (14));
00777 Fgl_hline (x - 1 - i, y + h + 1 + i, x + w + 1 + i, yellow (22));
00778 Fgl_line (x + w + 1 + i, y - 1 - i, x + w + 1 + i, y + h + 1 + i,
00779 yellow (24));
00780 }
00781 #endif
00782 int i;
00783 for (i = 1; i < 4; i++) {
00784 Fgl_hline (x - 1 - i, y - 1 - i, x + w + i, yellow (16));
00785 Fgl_line (x - 1 - i, y - 1 - i, x - 1 - i, y + h + i, yellow (14));
00786 Fgl_hline (x - 1 - i, y + h + i, x + w + i, yellow (22));
00787 Fgl_line (x + w + i, y - 1 - i, x + w + i, y + h + i,
00788 yellow (24));
00789 }
00790 }
00791
00792 void
00793 load_fonts()
00794 {
00795 char s[LC_PATH_MAX];
00796 int i;
00797 FILE *inf;
00798
00799 if ((inf = fopen (fontfile, "r")) == 0)
00800 HandleError ("Can't open the font file", FATAL);
00801 for (i = 0; i < 256 * 8; i++)
00802 main_font[i] = fgetc (inf);
00803 fclose (inf);
00804
00805 sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "8x8thin");
00806 if ((inf = fopen (s, "rb")) == NULL)
00807 do_error ("Can't open opening screen font 8x8thin");
00808 for (i = 0; i < 2048; i++)
00809 start_font1[i] = fgetc (inf);
00810 fclose (inf);
00811
00812 sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "scrawl_w.fnt");
00813 if ((inf = fopen (s, "rb")) == NULL)
00814 do_error ("Can't open opening screen font scrawl_w.fnt");
00815 for (i = 0; i < 4096; i++)
00816 start_font2[i] = fgetc (inf);
00817 fclose (inf);
00818
00819 sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "scrawl_s.fnt");
00820 if ((inf = fopen (s, "rb")) == NULL)
00821 do_error ("Can't open opening screen font scrawl_s.fnt");
00822 for (i = 0; i < 4096; i++)
00823 start_font3[i] = fgetc (inf);
00824 fclose (inf);
00825 }
00826
00827 void
00828 init_fonts (void)
00829 {
00830 #if defined (WIN32)
00831 init_windows_font();
00832 #endif
00833 load_fonts();
00834 #if defined (SVGALIB)
00835 gl_setwritemode (FONT_COMPRESSED);
00836 #endif
00837 Fgl_setfont (8, 8, main_font);
00838 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00839 }
00840
00841
00842
00843 static Mouse_Handle * mini_map_handle;
00844 static Mouse_Handle * mini_aux_handle;
00845
00846 void
00847 init_mini_map_mouse (void)
00848 {
00849 mini_map_handle = mouse_register(&scr.mini_map,&mini_map_handler);
00850 mini_aux_handle = mouse_register(&scr.mini_map_aux,&mini_aux_handler);
00851 }
00852
00853
00854 void
00855 mini_map_handler(int x, int y, int button)
00856 {
00857 Rect* b = &scr.mini_map;
00858
00859 if (button == LC_MOUSE_RIGHTBUTTON) {
00860 mini_screen_help ();
00861 return;
00862 }
00863 if (mini_screen_flags == MINI_SCREEN_COAL_FLAG && !coal_survey_done) {
00864 if (yn_dial_box (_("Coal survey"),
00865 _("This will cost you 1 million"),
00866 _("After that it's is free to call again"),
00867 _("Do coal survey?")) == 0)
00868 {
00869 return;
00870 }
00871 do_coal_survey ();
00872 print_total_money ();
00873 return;
00874 }
00875 adjust_main_origin (x - scr.main_win.w / 32,
00876 y - scr.main_win.h / 32, 1);
00877
00878 if (mini_screen_flags == MINI_SCREEN_PORT_FLAG)
00879 draw_mini_screen ();
00880 }
00881
00882 void
00883 mini_aux_handler(int x, int y, int button)
00884 {
00885 if (button == LC_MOUSE_MIDDLEBUTTON) {
00886 rotate_main_screen ();
00887 return;
00888 } else if (button == LC_MOUSE_RIGHTBUTTON) {
00889 mini_screen_help ();
00890 return;
00891 }
00892 rotate_mini_screen ();
00893 }
00894
00895 void
00896 rotate_mini_screen (void)
00897 {
00898 switch (mini_screen_flags)
00899 {
00900 case MINI_SCREEN_NORMAL_FLAG:
00901 mini_screen_flags = MINI_SCREEN_POL_FLAG;
00902 break;
00903 case MINI_SCREEN_POL_FLAG:
00904 mini_screen_flags = MINI_SCREEN_UB40_FLAG;
00905 break;
00906 case MINI_SCREEN_UB40_FLAG:
00907 mini_screen_flags = MINI_SCREEN_STARVE_FLAG;
00908 break;
00909 case MINI_SCREEN_STARVE_FLAG:
00910 mini_screen_flags = MINI_SCREEN_POWER_FLAG;
00911 break;
00912 #if defined (commentout)
00913 case MINI_SCREEN_PORT_FLAG:
00914
00915 #endif
00916 case MINI_SCREEN_POWER_FLAG:
00917 mini_screen_flags = MINI_SCREEN_FIRE_COVER;
00918 break;
00919 case MINI_SCREEN_FIRE_COVER:
00920 mini_screen_flags = MINI_SCREEN_CRICKET_COVER;
00921 break;
00922 case MINI_SCREEN_CRICKET_COVER:
00923 mini_screen_flags = MINI_SCREEN_HEALTH_COVER;
00924 break;
00925 case MINI_SCREEN_HEALTH_COVER:
00926 mini_screen_flags = MINI_SCREEN_COAL_FLAG;
00927 break;
00928 case MINI_SCREEN_COAL_FLAG:
00929 mini_screen_flags = MINI_SCREEN_NORMAL_FLAG;
00930 break;
00931 }
00932 update_mini_screen ();
00933
00934 if (main_screen_flag == MAIN_SCREEN_EQUALS_MINI) {
00935 refresh_main_screen ();
00936 }
00937 }
00938
00939 void
00940 update_mini_screen (void)
00941 {
00942 switch (mini_screen_flags)
00943 {
00944 case MINI_SCREEN_NORMAL_FLAG:
00945 draw_mini_screen ();
00946 break;
00947 case MINI_SCREEN_POL_FLAG:
00948 draw_mini_screen_pollution ();
00949 break;
00950 case MINI_SCREEN_UB40_FLAG:
00951 draw_mini_screen_ub40 ();
00952 break;
00953 case MINI_SCREEN_STARVE_FLAG:
00954 draw_mini_screen_starve ();
00955 break;
00956 #if defined (commentout)
00957 case MINI_SCREEN_PORT_FLAG:
00958 draw_mini_screen_port ();
00959 break;
00960 #endif
00961 case MINI_SCREEN_POWER_FLAG:
00962 draw_mini_screen_power ();
00963 break;
00964 case MINI_SCREEN_FIRE_COVER:
00965 draw_mini_screen_fire_cover ();
00966 break;
00967 case MINI_SCREEN_CRICKET_COVER:
00968 draw_mini_screen_cricket_cover ();
00969 break;
00970 case MINI_SCREEN_HEALTH_COVER:
00971 draw_mini_screen_health_cover ();
00972 break;
00973 case MINI_SCREEN_COAL_FLAG:
00974 draw_mini_screen_coal ();
00975 break;
00976 }
00977 }
00978
00979 void
00980 mini_screen_help (void)
00981 {
00982 switch (mini_screen_flags)
00983 {
00984 case MINI_SCREEN_NORMAL_FLAG:
00985 activate_help ("msb-normal.hlp");
00986 break;
00987 case MINI_SCREEN_POL_FLAG:
00988 activate_help ("msb-pol.hlp");
00989 break;
00990 case MINI_SCREEN_UB40_FLAG:
00991 activate_help ("msb-ub40.hlp");
00992 break;
00993 case MINI_SCREEN_STARVE_FLAG:
00994 activate_help ("msb-starve.hlp");
00995 break;
00996 case MINI_SCREEN_POWER_FLAG:
00997 activate_help ("msb-power.hlp");
00998 break;
00999 case MINI_SCREEN_FIRE_COVER:
01000 activate_help ("msb-fire.hlp");
01001 break;
01002 case MINI_SCREEN_CRICKET_COVER:
01003 activate_help ("msb-cricket.hlp");
01004 break;
01005 case MINI_SCREEN_HEALTH_COVER:
01006 activate_help ("msb-health.hlp");
01007 break;
01008 case MINI_SCREEN_COAL_FLAG:
01009 activate_help ("msb-coal.hlp");
01010 break;
01011 }
01012 }
01013
01014 void
01015 mini_full_refresh (void)
01016 {
01017 Rect* mm = &scr.mini_map;
01018 Rect* mmaux = &scr.mini_map_aux;
01019 Rect* mmarea = &scr.mini_map_area;
01020
01021
01022 draw_small_yellow_bezel (mmarea->x, mmarea->y, mmarea->h, mmarea->w);
01023
01024 Fgl_hline (mmaux->x, mmaux->y + mmaux->h, mmaux->x + mmaux->w,
01025 yellow (16));
01026 Fgl_hline (mmaux->x, mmaux->y + mmaux->h + 1, mmaux->x + mmaux->w,
01027 yellow (16));
01028
01029 Fgl_fillbox (mmarea->x, mm->y, mm->x - mmarea->x, mm->h,
01030 GRAPHS_B_COLOUR);
01031 Fgl_fillbox (mm->x + mm->w, mm->y, mmarea->x + mmarea->w - mm->x - mm->w,
01032 mm->h, GRAPHS_B_COLOUR);
01033
01034
01035 draw_mini_screen ();
01036 }
01037
01038 void
01039 draw_mini_screen (void)
01040 {
01041 int x, y, xx, yy;
01042 Rect* mm = &scr.mini_map;
01043
01044 mini_screen_flags = MINI_SCREEN_NORMAL_FLAG;
01045 draw_ms_button (ms_normal_button_graphic);
01046 draw_ms_text (_("Land Use "));
01047 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01048 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01049 if (MP_TYPE(x,y) == CST_USED) {
01050 xx = MP_INFO(x,y).int_1;
01051 yy = MP_INFO(x,y).int_2;
01052
01053
01054 if ((xx < 0 || xx > WORLD_SIDE_LEN) ||
01055 (yy < 0 || yy > WORLD_SIDE_LEN)) {
01056 printf("Argh! mini_screen out of range on CST_USED!\n");
01057 printf("xx=%d,yy=%d. Continuing\n",xx,yy);
01058 }
01059
01060 Fgl_setpixel (mm->x + x, mm->y + y, main_groups[MP_GROUP(xx,yy)].colour);
01061 } else {
01062 Fgl_setpixel (mm->x + x, mm->y + y, main_groups[MP_GROUP(x,y)].colour);
01063 }
01064 }
01065 }
01066 draw_mini_screen_cursor ();
01067
01068 #if defined (WIN32)
01069 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01070 #endif
01071 }
01072
01073 void
01074 draw_big_mini_screen (void)
01075 {
01076 Rect* b = &scr.main_win;
01077 int x, y, xx, yy;
01078 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01079 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01080 if (MP_TYPE(x,y) == CST_USED) {
01081 xx = MP_INFO(x,y).int_1;
01082 yy = MP_INFO(x,y).int_2;
01083 Fgl_fillbox (b->x + x * 4, b->y + y * 4, 4, 4
01084 ,main_groups[MP_GROUP(xx,yy)].colour);
01085 } else {
01086 Fgl_fillbox (b->x + x * 4, b->y + y * 4, 4, 4
01087 ,main_groups[MP_GROUP(x,y)].colour);
01088 }
01089 }
01090 }
01091 }
01092
01093
01094 void
01095 draw_mini_screen_pollution (void)
01096 {
01097 int x, y, col;
01098 Rect* mm = &scr.mini_map;
01099
01100 mini_screen_flags = MINI_SCREEN_POL_FLAG;
01101 draw_ms_text (_("Pollution "));
01102 draw_ms_button (ms_pollution_button_graphic);
01103 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01104 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01105 if (MP_POL(x,y) < 4) {
01106 col = green (24);
01107 } else if (MP_POL(x,y) < 600) {
01108 col = green (23 - (MP_POL(x,y) / 45));
01109 } else {
01110 col = (int) sqrt ((float) (MP_POL(x,y) - 600)) / 9;
01111 if (col > 20)
01112 col = 20;
01113 col += red (11);
01114 }
01115 Fgl_setpixel (mm->x + x, mm->y + y, col);
01116 }
01117 }
01118 draw_mini_screen_cursor ();
01119 #if defined (WIN32)
01120 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01121 #endif
01122 }
01123
01124 void
01125 draw_mini_screen_fire_cover (void)
01126 {
01127 int x, y, xx, yy, col;
01128 Rect* mm = &scr.mini_map;
01129
01130
01131
01132 mini_screen_flags = MINI_SCREEN_FIRE_COVER;
01133 draw_ms_text (_("Fire cover "));
01134 draw_ms_button (ms_fire_cover_button_graphic);
01135 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01136 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01137 if (MP_TYPE(x,y) == CST_USED)
01138 {
01139 xx = MP_INFO(x,y).int_1;
01140 yy = MP_INFO(x,y).int_2;
01141 if ((MP_INFO(xx,yy).flags & FLAG_FIRE_COVER) == 0)
01142 col = main_groups[MP_GROUP(xx,yy)].colour;
01143 else
01144 col = green (10);
01145 }
01146 else
01147 {
01148 if ((MP_INFO(x,y).flags & FLAG_FIRE_COVER) == 0)
01149 col = main_groups[MP_GROUP(x,y)].colour;
01150 else
01151 col = green (10);
01152 }
01153 Fgl_setpixel (mm->x + x, mm->y + y, col);
01154 }
01155 }
01156 draw_mini_screen_cursor ();
01157 #if defined (WIN32)
01158 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01159 #endif
01160 }
01161
01162 void
01163 draw_mini_screen_cricket_cover (void)
01164 {
01165 int x, y, xx, yy, col;
01166 Rect* mm = &scr.mini_map;
01167
01168 mini_screen_flags = MINI_SCREEN_CRICKET_COVER;
01169 draw_ms_text (_("Crickt cover"));
01170 draw_ms_button (ms_cricket_cover_button_graphic);
01171 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01172 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01173 if (MP_TYPE(x,y) == CST_USED)
01174 {
01175 xx = MP_INFO(x,y).int_1;
01176 yy = MP_INFO(x,y).int_2;
01177 if ((MP_INFO(xx,yy).flags & FLAG_CRICKET_COVER) == 0)
01178 col = main_groups[MP_GROUP(xx,yy)].colour;
01179 else
01180 col = green (10);
01181 }
01182 else
01183 {
01184 if ((MP_INFO(x,y).flags & FLAG_CRICKET_COVER) == 0)
01185 col = main_groups[MP_GROUP(x,y)].colour;
01186 else
01187 col = green (10);
01188 }
01189 Fgl_setpixel (mm->x + x, mm->y + y, col);
01190 }
01191 }
01192 draw_mini_screen_cursor ();
01193 #if defined (WIN32)
01194 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01195 #endif
01196 }
01197
01198 void
01199 draw_mini_screen_health_cover (void)
01200 {
01201 int x, y, xx, yy, col;
01202 Rect* mm = &scr.mini_map;
01203
01204 mini_screen_flags = MINI_SCREEN_HEALTH_COVER;
01205 draw_ms_text (_("Health cover"));
01206 draw_ms_button (ms_health_cover_button_graphic);
01207 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01208 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01209 if (MP_TYPE(x,y) == CST_USED)
01210 {
01211 xx = MP_INFO(x,y).int_1;
01212 yy = MP_INFO(x,y).int_2;
01213 if ((MP_INFO(xx,yy).flags & FLAG_HEALTH_COVER) == 0)
01214 col = main_groups[MP_GROUP(xx,yy)].colour;
01215 else
01216 col = green (10);
01217 }
01218 else
01219 {
01220 if ((MP_INFO(x,y).flags & FLAG_HEALTH_COVER) == 0)
01221 col = main_groups[MP_GROUP(x,y)].colour;
01222 else
01223 col = green (10);
01224 }
01225 Fgl_setpixel (mm->x + x, mm->y + y, col);
01226 }
01227 }
01228 draw_mini_screen_cursor ();
01229 #if defined (WIN32)
01230 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01231 #endif
01232 }
01233
01234 void
01235 draw_mini_screen_ub40 (void)
01236 {
01237 int x, y, col;
01238 Rect* mm = &scr.mini_map;
01239
01240 mini_screen_flags = MINI_SCREEN_UB40_FLAG;
01241 draw_ms_text (_("Unemployment"));
01242 draw_ms_button (ms_ub40_button_graphic);
01243 Fgl_fillbox (mm->x, mm->y, WORLD_SIDE_LEN, WORLD_SIDE_LEN, green (14));
01244 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01245 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01246 if (MP_GROUP_IS_RESIDENCE(x,y)) {
01247 if (MP_INFO(x,y).int_1 < -20)
01248 col = red (28);
01249 else if (MP_INFO(x,y).int_1 < 10)
01250 col = red (14);
01251 else
01252 col = green (20);
01253 Fgl_fillbox (mm->x + x, mm->y + y, 3, 3, col);
01254 }
01255 }
01256 }
01257 draw_mini_screen_cursor ();
01258 #if defined (WIN32)
01259 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01260 #endif
01261 }
01262
01263 void
01264 draw_mini_screen_starve (void)
01265 {
01266 int x, y, col;
01267 Rect* mm = &scr.mini_map;
01268
01269 mini_screen_flags = MINI_SCREEN_STARVE_FLAG;
01270 draw_ms_text (_("Starvation "));
01271 draw_ms_button (ms_starve_button_graphic);
01272 Fgl_fillbox (mm->x, mm->y,
01273 WORLD_SIDE_LEN, WORLD_SIDE_LEN, green (14));
01274 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01275 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01276 if (MP_GROUP_IS_RESIDENCE(x,y)) {
01277 if ((total_time - MP_INFO(x,y).int_2) < 20)
01278 col = red (28);
01279 else if ((total_time - MP_INFO(x,y).int_2) < 100)
01280 col = red (14);
01281 else
01282 col = green (20);
01283 Fgl_fillbox (mm->x + x, mm->y + y, 3, 3, col);
01284 }
01285 }
01286 }
01287 draw_mini_screen_cursor ();
01288 #if defined (WIN32)
01289 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01290 #endif
01291 }
01292
01293 void
01294 draw_mini_screen_coal (void)
01295 {
01296 int x, y, col;
01297 Rect* mm = &scr.mini_map;
01298
01299 mini_screen_flags = MINI_SCREEN_COAL_FLAG;
01300 draw_ms_text (_("Coal Reserve"));
01301 draw_ms_button (ms_coal_button_graphic);
01302 if (coal_survey_done) {
01303 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01304 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01305 if (MP_INFO(x,y).coal_reserve == 0)
01306 col = white (4);
01307 else if (MP_INFO(x,y).coal_reserve >= COAL_RESERVE_SIZE / 2)
01308 col = white (18);
01309 else if (MP_INFO(x,y).coal_reserve < COAL_RESERVE_SIZE / 2)
01310 col = white (28);
01311 Fgl_setpixel (mm->x + x, mm->y + y, col);
01312 }
01313 }
01314 draw_mini_screen_cursor ();
01315 } else {
01316 Fgl_setfontcolors (white(4), white(28));
01317 Fgl_fillbox (mm->x, mm->y, WORLD_SIDE_LEN, WORLD_SIDE_LEN, white(4));
01318 Fgl_write (mm->x + 4, mm->y + 20, _("Click here"));
01319 Fgl_write (mm->x + 4, mm->y + 32, _(" to do "));
01320 Fgl_write (mm->x + 4, mm->y + 44, _("coal survey"));
01321 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
01322 }
01323 #if defined (WIN32)
01324 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01325 #endif
01326 }
01327
01328 void
01329 draw_mini_screen_power (void)
01330 {
01331 int x, y, xx, yy, col;
01332 int have_power = 0;
01333 Rect* mm = &scr.mini_map;
01334
01335 mini_screen_flags = MINI_SCREEN_POWER_FLAG;
01336 draw_ms_button (ms_power_button_graphic);
01337 for (y = 0; y < WORLD_SIDE_LEN; y++) {
01338 for (x = 0; x < WORLD_SIDE_LEN; x++) {
01339 short grp = MP_GROUP(x,y);
01340 if (grp == GROUP_USED) {
01341 xx = MP_INFO(x,y).int_1;
01342 yy = MP_INFO(x,y).int_2;
01343 grp = MP_GROUP(xx,yy);
01344 } else {
01345 xx = x;
01346 yy = y;
01347 }
01348 if (get_power (xx, yy, 1, 1) != 0) {
01349 have_power = 1;
01350 col = green (14);
01351 } else if (get_power (xx, yy, 1, 0) != 0) {
01352 have_power = 1;
01353 col = green (10);
01354 } else {
01355 col = main_groups[grp].colour;
01356 }
01357 Fgl_setpixel (mm->x + x, mm->y + y, col);
01358 }
01359 }
01360 if (have_power) {
01361 draw_ms_text (_("Power "));
01362 } else {
01363 draw_ms_text (_("Power (none)"));
01364 }
01365 draw_mini_screen_cursor ();
01366 #if defined (WIN32)
01367 RefreshArea (mm->x, mm->y, mm->x + x, mm->y + y);
01368 #endif
01369 }
01370
01371
01372 void
01373 draw_mini_screen_ocost (void)
01374 {
01375 char s[100];
01376 Rect* b = &scr.mini_map;
01377 mini_screen_flags = MINI_SCREEN_NORMAL_FLAG;
01378 draw_ms_text ("Other Costs");
01379 draw_ms_button (ms_ocost_button_graphic);
01380 Fgl_fillbox (b->x, b->y,
01381 WORLD_SIDE_LEN, WORLD_SIDE_LEN, green (12));
01382 Fgl_setfontcolors (green (12), TEXT_FG_COLOUR);
01383 sprintf (s, "OC yr %04d", (total_time / NUMOF_DAYS_IN_YEAR) - 1);
01384 Fgl_write (b->x + 10, b->y + 2, s);
01385
01386 if (ly_interest > 19999)
01387 {
01388 sprintf (s, "Int %4dK", ly_interest / 1000);
01389 }
01390 else
01391 sprintf (s, "Int %5d", ly_interest);
01392 Fgl_write (b->x + 10, b->y + 16, s);
01393
01394 if (ly_school_cost > 19999)
01395 {
01396 if (ly_school_cost > 1999999)
01397 sprintf (s, "Scl %4dM", ly_school_cost / 1000000);
01398 else
01399 sprintf (s, "Scl %4dK", ly_school_cost / 1000);
01400 }
01401 else
01402 sprintf (s, "Scl %5d", ly_school_cost);
01403 Fgl_write (b->x + 10, b->y + 24, s);
01404
01405 if (ly_university_cost > 19999)
01406 {
01407 if (ly_university_cost > 1999999)
01408 sprintf (s, "Uni %4dM", ly_university_cost / 1000000);
01409 else
01410 sprintf (s, "Uni %4dK", ly_university_cost / 1000);
01411 }
01412 else
01413 sprintf (s, "Uni %5d", ly_university_cost);
01414 Fgl_write (b->x + 10, b->y + 32, s);
01415
01416 if (ly_deaths_cost > 19999)
01417 {
01418 if (ly_deaths_cost > 1999999)
01419 sprintf (s, "UnD %4dM", ly_deaths_cost / 1000000);
01420 else
01421 sprintf (s, "UnD %4dK", ly_deaths_cost / 1000);
01422 }
01423 else
01424 sprintf (s, "UnD %5d", ly_deaths_cost);
01425 Fgl_write (b->x + 10, b->y + 40, s);
01426
01427 if (ly_windmill_cost > 19999)
01428 {
01429 if (ly_windmill_cost > 1999999)
01430 sprintf (s, "WiM %4dM", ly_windmill_cost / 1000000);
01431 else
01432 sprintf (s, "WiM %4dK", ly_windmill_cost / 1000);
01433 }
01434 else
01435 sprintf (s, "WiM %5d", ly_windmill_cost);
01436 Fgl_write (b->x + 10, b->y + 48, s);
01437
01438 if (ly_recycle_cost > 19999)
01439 {
01440 if (ly_recycle_cost > 1999999)
01441 sprintf (s, "Rcy %4dM", ly_recycle_cost / 1000000);
01442 else
01443 sprintf (s, "Rcy %4dK", ly_recycle_cost / 1000);
01444 }
01445 else
01446 sprintf (s, "Rcy %5d", ly_recycle_cost);
01447 Fgl_write (b->x + 10, b->y + 56, s);
01448
01449 if (ly_health_cost > 19999)
01450 {
01451 if (ly_health_cost > 1999999)
01452 sprintf (s, "Hth %4dM", ly_health_cost / 1000000);
01453 else
01454 sprintf (s, "Hth %4dK", ly_health_cost / 1000);
01455 }
01456 else
01457 sprintf (s, "Hth %5d", ly_health_cost);
01458 Fgl_write (b->x + 10, b->y + 64, s);
01459
01460 if (ly_rocket_pad_cost > 19999)
01461 {
01462 if (ly_rocket_pad_cost > 1999999)
01463 sprintf (s, "Rok %4dM", ly_rocket_pad_cost / 1000000);
01464 else
01465 sprintf (s, "Rok %4dK", ly_rocket_pad_cost / 1000);
01466 }
01467 else
01468 sprintf (s, "Rok %5d", ly_rocket_pad_cost);
01469 Fgl_write (b->x + 10, b->y + 72, s);
01470
01471 if (ly_fire_cost > 19999)
01472 {
01473 if (ly_fire_cost > 1999999)
01474 sprintf (s, "Fst %4dM", ly_fire_cost / 1000000);
01475 else
01476 sprintf (s, "Fst %4dK", ly_fire_cost / 1000);
01477 }
01478 else
01479 sprintf (s, "Fst %5d", ly_fire_cost);
01480 Fgl_write (b->x + 10, b->y + 80, s);
01481
01482 if (ly_cricket_cost > 19999)
01483 {
01484 if (ly_cricket_cost > 1999999)
01485 sprintf (s, "Ckt %4dM", ly_cricket_cost / 1000000);
01486 else
01487 sprintf (s, "Ckt %4dK", ly_cricket_cost / 1000);
01488 }
01489 else
01490 sprintf (s, "Ckt %5d", ly_cricket_cost);
01491 Fgl_write (b->x + 10, b->y + 88, s);
01492
01493 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
01494 }
01495
01496 #if defined (commentout)
01497 void
01498 draw_mini_screen_port (void)
01499 {
01500 char buy[256], sell[256], s[256];
01501 int l, i, *p1, *p2;
01502 Rect* b = &scr.mini_map;
01503 mini_screen_flags = MINI_SCREEN_PORT_FLAG;
01504
01505
01506
01507 Fgl_fillbox (b->x, b->y, WORLD_SIDE_LEN, WORLD_SIDE_LEN, green (12));
01508 Fgl_setfontcolors (green (12), TEXT_FG_COLOUR);
01509 sprintf (s, " Port %2d %2d", mini_screen_port_x, mini_screen_port_y);
01510 Fgl_write (b->x + 4, b->y + 2, s);
01511 Fgl_write (b->x + 4, b->y + 16, " F C O G S");
01512 Fgl_write (b->x + 4, b->y + 26, " Buy Sell");
01513
01514 p1 = &(MP_INFO(mini_screen_port_x,mini_screen_port_y + 1).int_3);
01515 p2 = &(MP_INFO(mini_screen_port_x,mini_screen_port_y + 2).int_3);
01516 for (i = 0; i < 5; i++)
01517 {
01518 l = *(p1++) / 100;
01519 if (l > 19999)
01520 {
01521 if (l > 1999999)
01522 sprintf (buy, "%4dM", l / 1000000);
01523 else
01524 sprintf (buy, "%4dK", l / 1000);
01525 }
01526 else
01527 sprintf (buy, "%5d", l);
01528 l = *(p2++) / 100;
01529 if (l > 19999)
01530 {
01531 if (l > 1999999)
01532 sprintf (sell, "%4dM", l / 1000000);
01533 else
01534 sprintf (sell, "%4dK", l / 1000);
01535 }
01536 else
01537 sprintf (sell, "%5d", l);
01538 sprintf (s, "%s %s", buy, sell);
01539 Fgl_write (b->x + 10, b->y + 40 + i * 8, s);
01540 }
01541
01542 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
01543 }
01544 #endif
01545
01546 void
01547 draw_mini_screen_cursor (void)
01548 {
01549 Rect* mini = &scr.mini_map;
01550 Rect* mw = &scr.main_win;
01551 Fgl_hline (mini->x + main_screen_originx
01552 ,mini->y + main_screen_originy
01553 ,mini->x + main_screen_originx + mw->w / 16 - 1
01554 ,255);
01555 Fgl_hline (mini->x + main_screen_originx
01556 ,mini->y + main_screen_originy + mw->h / 16 - 1
01557 ,mini->x + main_screen_originx + mw->w / 16 - 1
01558 ,255);
01559 Fgl_line (mini->x + main_screen_originx
01560 ,mini->y + main_screen_originy
01561 ,mini->x + main_screen_originx
01562 ,mini->y + main_screen_originy + mw->h / 16 - 1
01563 ,255);
01564 Fgl_line (mini->x + main_screen_originx + mw->w / 16 - 1
01565 ,mini->y + main_screen_originy
01566 ,mini->x + main_screen_originx + mw->w / 16 - 1
01567 ,mini->y + main_screen_originy + mw->h / 16 - 1
01568 ,255);
01569
01570 }
01571
01572 void
01573 initialize_print_stats (void)
01574 {
01575 #if !defined (WIN32)
01576 hide_mouse ();
01577 #endif
01578 update_scoreboard.mps = 0;
01579 update_scoreboard.mini = 0;
01580 update_scoreboard.date = 0;
01581 update_scoreboard.money = 0;
01582 update_scoreboard.monthly = 0;
01583 update_scoreboard.yearly_1 = 0;
01584 update_scoreboard.yearly_2 = 0;
01585 update_scoreboard.message_area = 0;
01586
01587 #if defined (STATS_WINDOW)
01588 draw_yellow_bezel (STATS_X, STATS_Y, STATS_H, STATS_W);
01589 Fgl_write (STATS_X, STATS_Y, "Population ");
01590 Fgl_write (STATS_X, STATS_Y + 8, "% Starving ");
01591 Fgl_write (STATS_X, STATS_Y + 16, "Foodstore ");
01592 Fgl_write (STATS_X, STATS_Y + 24, "% u-ployed ");
01593 Fgl_write (STATS_X + 18 * 8, STATS_Y, "Tech level ");
01594 Fgl_write (STATS_X + 18 * 8, STATS_Y + 8, "Un-nat deaths ");
01595 Fgl_write (STATS_X + 18 * 8, STATS_Y + 16, "Rockets ");
01596 Fgl_write (STATS_X + 18 * 8, STATS_Y + 24, "Shanty towns");
01597 #endif
01598
01599 #if defined (FINANCE_WINDOW)
01600 draw_yellow_bezel (FINANCE_X, FINANCE_Y, FINANCE_H, FINANCE_W);
01601 Fgl_write (FINANCE_X, FINANCE_Y, "Income Expend");
01602 Fgl_write (FINANCE_X, FINANCE_Y + 8, "IT");
01603 Fgl_write (FINANCE_X, FINANCE_Y + 16, "CT");
01604 Fgl_write (FINANCE_X, FINANCE_Y + 24, "GT");
01605 Fgl_write (FINANCE_X, FINANCE_Y + 32, "XP");
01606 Fgl_write (FINANCE_X + 64, FINANCE_Y + 8, "OC");
01607 Fgl_write (FINANCE_X + 64, FINANCE_Y + 16, "UC");
01608 Fgl_write (FINANCE_X + 64, FINANCE_Y + 24, "TC");
01609 Fgl_write (FINANCE_X + 64, FINANCE_Y + 32, "IP");
01610 Fgl_write (FINANCE_X, FINANCE_Y + 48, "Tot");
01611 #endif
01612
01613 #if !defined (WIN32)
01614 redraw_mouse ();
01615 #endif
01616 }
01617
01618 void
01619 advance_mps_style (void)
01620 {
01621 mps_global_style = mps_global_style++;
01622 if (mps_global_style > MPS_GLOBAL_STYLE_MAX) {
01623 mps_global_style = MPS_GLOBAL_STYLE_MIN;
01624 }
01625 mps_global_style_timeout = real_time + 6000;
01626 }
01627
01628 void
01629 refresh_mps (void)
01630 {
01631 mappoint_stats (-2, -2, mps_global_style);
01632 }
01633
01634 void
01635 advance_monthgraph_style (void)
01636 {
01637 monthgraph_style = (monthgraph_style % 2) + 1;
01638 if (monthgraph_style == MONTHGRAPH_STYLE_ECONOMY) {
01639 monthgraph_style_timeout = real_time + 10000;
01640 } else {
01641 monthgraph_style_timeout = real_time + 4000;
01642 }
01643 }
01644
01645 void
01646 refresh_monthgraph (void)
01647 {
01648 do_monthgraph (1);
01649 }
01650
01651 void
01652 monthgraph_full_refresh (void)
01653 {
01654 Rect* mg = &scr.monthgraph;
01655 draw_small_yellow_bezel (mg->x, mg->y, mg->h, mg->w);
01656 do_monthgraph (1);
01657 }
01658
01659 void
01660 print_stats (void)
01661 {
01662 static int flag = 0;
01663 int monthgraph_full_update = 0;
01664
01665 if (flag == 0) {
01666 initialize_print_stats ();
01667 flag = 1;
01668 }
01669
01670 #if !defined (WIN32)
01671 hide_mouse ();
01672 #endif
01673
01674 if (total_time % NUMOF_DAYS_IN_MONTH == (NUMOF_DAYS_IN_MONTH - 1)) {
01675 update_scoreboard.monthly = 1;
01676 }
01677 if (total_time % NUMOF_DAYS_IN_YEAR == (NUMOF_DAYS_IN_YEAR - 1)) {
01678 update_scoreboard.yearly_1 = 1;
01679 update_scoreboard.money = 1;
01680 }
01681 if ((total_time % NUMOF_DAYS_IN_YEAR) == 0) {
01682 update_scoreboard.yearly_2 = 1;
01683 }
01684 if (real_time > mappoint_stats_time) {
01685 update_scoreboard.mps = 1;
01686 mappoint_stats_time = real_time + 1000;
01687 }
01688 if (mini_screen_flags != MINI_SCREEN_NORMAL_FLAG
01689 && real_time > mini_screen_time) {
01690 update_scoreboard.mini = 1;
01691 mini_screen_time = real_time + 1000;
01692 }
01693 if ((total_time % NUMOF_DAYS_IN_YEAR) == 0) {
01694 calculate_time_for_year ();
01695 print_time_for_year ();
01696 }
01697 if (total_time % NUMOF_DAYS_IN_MONTH == 1) {
01698 update_scoreboard.date = 1;
01699 }
01700
01701
01702 if (update_scoreboard.mps) {
01703 update_scoreboard.mps = 0;
01704
01705 if (help_flag || load_flag || save_flag || mappoint_stats_flag) {
01706 mps_global_style_timeout = real_time + 6000;
01707 }
01708 if (real_time > mps_global_style_timeout) {
01709 if (time_multiplex_stats) {
01710 advance_mps_style ();
01711 }
01712 }
01713 if (!mappoint_stats_flag) {
01714 mappoint_stats (-2, -2, mps_global_style);
01715 } else {
01716 mappoint_stats (-1, -1, -1);
01717 }
01718 }
01719
01720 if (update_scoreboard.mini) {
01721 update_scoreboard.mini = 0;
01722 update_mini_screen ();
01723 }
01724
01725 if (update_scoreboard.date) {
01726 update_scoreboard.date = 0;
01727 print_date ();
01728 }
01729
01730 if (update_scoreboard.money) {
01731 update_scoreboard.money = 0;
01732 print_total_money ();
01733 }
01734
01735 if (update_scoreboard.monthly) {
01736 update_scoreboard.monthly = 0;
01737
01738
01739 if (help_flag || load_flag || save_flag) {
01740 if (monthgraph_style == MONTHGRAPH_STYLE_ECONOMY) {
01741 monthgraph_style_timeout = real_time + 10000;
01742 } else {
01743 monthgraph_style_timeout = real_time + 4000;
01744 }
01745 }
01746 if (real_time > monthgraph_style_timeout) {
01747 if (time_multiplex_stats) {
01748 monthgraph_full_update = 1;
01749 monthgraph_style = (monthgraph_style % 2) + 1;
01750 }
01751 if (monthgraph_style == MONTHGRAPH_STYLE_ECONOMY) {
01752 monthgraph_style_timeout = real_time + 10000;
01753 } else {
01754 monthgraph_style_timeout = real_time + 4000;
01755 }
01756 }
01757
01758 do_monthgraph (monthgraph_full_update);
01759
01760 #if defined (STATS_WINDOW)
01761 sprintf (s, "%5d ", housed_population + people_pool);
01762 Fgl_write (STATS_X + 8 * 11, STATS_Y, s);
01763 i = ((tstarving_population / NUMOF_DAYS_IN_MONTH)
01764 * 1000) / ((tpopulation / NUMOF_DAYS_IN_MONTH) + 1);
01765 sprintf (s, "%3d.%1d ", i / 10, i % 10);
01766 Fgl_write (STATS_X + 8 * 11, STATS_Y + 8, s);
01767 sprintf (s, "%5d ", tfood_in_markets / NUMOF_DAYS_IN_MONTH);
01768 Fgl_write (STATS_X + 8 * 11, STATS_Y + 16, s);
01769 i = ((tunemployed_population / NUMOF_DAYS_IN_MONTH)
01770 * 1000) / ((tpopulation / NUMOF_DAYS_IN_MONTH) + 1);
01771 sprintf (s, "%3d.%1d ", i / 10, i % 10);
01772 Fgl_write (STATS_X + 8 * 11, STATS_Y + 24, s);
01773 sprintf (s, "%5d ", numof_shanties);
01774 Fgl_write (STATS_X + 8 * (12 + 20), STATS_Y + 24, s);
01775 sprintf (s, "%5.1f ", (float) tech_level * 100.0 / MAX_TECH_LEVEL);
01776 Fgl_write (STATS_X + (20 + 12) * 8, STATS_Y, s);
01777 sprintf (s, "%5d ", unnat_deaths);
01778 Fgl_write (STATS_X + (20 + 12) * 8, STATS_Y + 8, s);
01779 #endif
01780
01781 update_pbars_monthly();
01782
01783 refresh_pbars();
01784
01785
01786
01787
01788
01789 #if !defined (WIN32)
01790 redraw_mouse ();
01791 #endif
01792 update_avail_modules (1);
01793 #if !defined (WIN32)
01794 hide_mouse ();
01795 #endif
01796 }
01797
01798 if (update_scoreboard.yearly_1) {
01799 update_scoreboard.yearly_1 = 0;
01800 }
01801
01802 if (update_scoreboard.message_area > 0
01803 && real_time > update_scoreboard.message_area) {
01804 reset_status_message ();
01805 }
01806
01807 #if defined (WIN32)
01808 UpdateWindow (display.hWnd);
01809 #else
01810 redraw_mouse ();
01811 #endif
01812 }
01813
01814 void
01815 print_total_money (void)
01816 {
01817 Rect* b = &scr.money;
01818 char str[MONEY_W / CHAR_WIDTH + 1];
01819 size_t count;
01820
01821 count = sprintf(str, _("Money: "));
01822 count += commify(str + count, (MONEY_W / CHAR_WIDTH) - count, total_money);
01823 count += snprintf(str + count, (MONEY_W / CHAR_WIDTH) - count,
01824 " ");
01825 str[MONEY_W / CHAR_WIDTH] = '\0';
01826
01827 if (total_money < 0)
01828 Fgl_setfontcolors (TEXT_BG_COLOUR, red (30));
01829
01830
01831
01832 Fgl_write (b->x + 32, b->y, str);
01833
01834 if (total_money < 0)
01835 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
01836 }
01837
01838 void
01839 print_date (void)
01840 {
01841 char s[50];
01842 Rect* b = &scr.date;
01843 sprintf (s, _("Date %s %04d "), current_month(total_time),
01844 current_year(total_time));
01845 Fgl_write (b->x, b->y, s);
01846 #if defined (WIN32)
01847 UpdateWindow (display.hWnd);
01848 #endif
01849 }
01850
01851 void
01852 print_population (void)
01853 {
01854 draw_pbar (&scr.pbar_pop, pop_pbar_graphic);
01855 }
01856
01857 void
01858 calculate_time_for_year (void)
01859 {
01860 static int time_last_year = 0;
01861
01862 time_for_year = (float) (real_time - time_last_year) / 1000.0;
01863
01864 time_last_year = real_time;
01865 }
01866
01867 void
01868 print_time_for_year (void)
01869 {
01870 char s[100];
01871 Rect* b = &scr.time_for_year;
01872
01873
01874 if (time_for_year > 3600.0)
01875 sprintf (s, _("%s%5.1f MINS/year V %s"),
01876 cheat_flag ? _("TEST MODE") : "",
01877 time_for_year / 60.0, VERSION);
01878 else
01879 sprintf (s, _("%s%5.1f secs/year V %s "),
01880 cheat_flag ? _("TEST MODE") : "",
01881 time_for_year, VERSION);
01882 Fgl_write (b->x, b->y, s);
01883 }
01884
01885
01886 void
01887 status_message_1 (char * message)
01888 {
01889 Rect* b = &scr.status_message_1;
01890
01891 Fgl_fillbox(b->x, b->y, b->w, b->h, TEXT_BG_COLOUR);
01892 if (message == NULL)
01893 return;
01894 Fgl_write (b->x, b->y, message);
01895 }
01896
01897 void
01898 status_message_2 (char * message)
01899 {
01900 Rect* b = &scr.status_message_2;
01901
01902 Fgl_fillbox(b->x, b->y, b->w, b->h, TEXT_BG_COLOUR);
01903 if (message == NULL)
01904 return;
01905 Fgl_write (b->x, b->y, message);
01906 }
01907
01908 void
01909 status_message (char* m1, char* m2)
01910 {
01911 status_message_1(m1);
01912 status_message_2(m2);
01913 #if defined (WIN32)
01914 UpdateWindow (display.hWnd);
01915 #endif
01916 update_scoreboard.message_area = real_time + 10000;
01917 }
01918
01919 void
01920 reset_status_message (void)
01921 {
01922 status_message_1(0);
01923 status_message_2(0);
01924 #if defined (WIN32)
01925 UpdateWindow (display.hWnd);
01926 #endif
01927 update_scoreboard.message_area = 0;
01928 }
01929
01930 void
01931 init_monthgraph (void)
01932 {
01933 Rect* mg = &scr.monthgraph;
01934 Fgl_fillbox (mg->x, mg->y, mg->w + 1, mg->h + 1, GRAPHS_B_COLOUR);
01935 }
01936
01937 void
01938 clear_monthgraph (void)
01939 {
01940 Rect* mg = &scr.monthgraph;
01941 Fgl_fillbox (mg->x, mg->y, mg->w + 1, mg->h + 1, GRAPHS_B_COLOUR);
01942 }
01943
01944 static void
01945 do_monthgraph (int full_refresh)
01946 {
01947 if (full_refresh) {
01948 clear_monthgraph();
01949 }
01950 do_history_linegraph (monthgraph_style == MONTHGRAPH_STYLE_ECONOMY);
01951 do_sust_barchart (monthgraph_style == MONTHGRAPH_STYLE_SUSTAIN);
01952
01953 #if defined (WIN32)
01954 {
01955 Rect* mg = &scr.monthgraph;
01956 RefreshArea (mg->x, mg->y, mg->x + mg->w,
01957 mg->y + mg->h);
01958 }
01959 #endif
01960 }
01961
01962
01963 void
01964 initialize_monthgraph (void)
01965 {
01966 int i;
01967
01968 monthgraph_size = scr.monthgraph.w;
01969
01970 monthgraph_pop = (int*) malloc (sizeof(int) * monthgraph_size);
01971 if (monthgraph_pop == 0) {
01972 malloc_failure ();
01973 }
01974 monthgraph_starve = (int*) malloc (sizeof(int) * monthgraph_size);
01975 if (monthgraph_starve == 0) {
01976 malloc_failure ();
01977 }
01978 monthgraph_nojobs = (int*) malloc (sizeof(int) * monthgraph_size);
01979 if (monthgraph_nojobs == 0) {
01980 malloc_failure ();
01981 }
01982 monthgraph_ppool = (int*) malloc (sizeof(int) * monthgraph_size);
01983 if (monthgraph_ppool == 0) {
01984 malloc_failure ();
01985 }
01986 for (i = 0; i < monthgraph_size; i++) {
01987 monthgraph_pop[i] = 0;
01988 monthgraph_starve[i] = 0;
01989 monthgraph_nojobs[i] = 0;
01990 monthgraph_ppool[i] = 0;
01991 }
01992 }
01993
01994 static void
01995 do_history_linegraph (int draw)
01996 {
01997 Rect* mg = &scr.monthgraph;
01998 int i;
01999 float f;
02000
02001 for (i = mg->w - 1; i > 0; i--) {
02002 if (draw) {
02003 Fgl_line (mg->x + mg->w - i,
02004 mg->y + mg->h - monthgraph_nojobs[i],
02005 mg->x + mg->w - i,
02006 mg->y + mg->h,
02007 GRAPHS_B_COLOUR);
02008 Fgl_line (mg->x + mg->w - i,
02009 mg->y + mg->h - monthgraph_nojobs[i-1],
02010 mg->x + mg->w - i,
02011 mg->y + mg->h,
02012 yellow (24));
02013
02014 Fgl_line (mg->x + mg->w - i,
02015 mg->y + mg->h - monthgraph_starve[i],
02016 mg->x + mg->w - i,
02017 mg->y + mg->h,
02018 GRAPHS_B_COLOUR);
02019 Fgl_line (mg->x + mg->w - i,
02020 mg->y + mg->h - monthgraph_starve[i-1],
02021 mg->x + mg->w - i,
02022 mg->y + mg->h,
02023 red (24));
02024
02025 Fgl_setpixel (mg->x + mg->w - i,
02026 mg->y + mg->h - monthgraph_pop[i],
02027 GRAPHS_B_COLOUR);
02028 Fgl_setpixel (mg->x + mg->w - i,
02029 mg->y + mg->h - monthgraph_pop[i-1], 7);
02030
02031 Fgl_setpixel (mg->x + mg->w - i,
02032 mg->y + mg->h - monthgraph_ppool[i],
02033 GRAPHS_B_COLOUR);
02034 Fgl_setpixel (mg->x + mg->w - i,
02035 mg->y + mg->h - monthgraph_ppool[i-1],
02036 cyan (24));
02037 }
02038 monthgraph_pop[i] = monthgraph_pop[i-1];
02039 monthgraph_ppool[i] = monthgraph_ppool[i-1];
02040 monthgraph_nojobs[i] = monthgraph_nojobs[i-1];
02041 monthgraph_starve[i] = monthgraph_starve[i-1];
02042 }
02043 if (tpopulation > 0)
02044 {
02045
02046 if (draw) {
02047 Fgl_setpixel (mg->x + mg->w,
02048 mg->y + mg->h - monthgraph_pop[0],
02049 GRAPHS_B_COLOUR);
02050 Fgl_setpixel (mg->x + mg->w,
02051 mg->y + mg->h - monthgraph_starve[0],
02052 GRAPHS_B_COLOUR);
02053 Fgl_setpixel (mg->x + mg->w,
02054 mg->y + mg->h - monthgraph_nojobs[0],
02055 GRAPHS_B_COLOUR);
02056 Fgl_setpixel (mg->x + mg->w,
02057 mg->y + mg->h - monthgraph_ppool[0],
02058 GRAPHS_B_COLOUR);
02059 }
02060 monthgraph_pop[0] = ((int) (log ((tpopulation / NUMOF_DAYS_IN_MONTH)
02061 + 1) * mg->h / 15)) - 5;
02062 if (monthgraph_pop[0] < 0)
02063 monthgraph_pop[0] = 0;
02064 f = ((float) tstarving_population
02065 / ((float) tpopulation + 1.0)) * 100.0;
02066 if (tpopulation > 3000)
02067 f += f;
02068 if (tpopulation > 6000)
02069 f += f;
02070 monthgraph_starve[0] = (int) f;
02071
02072 if (monthgraph_starve[0] >= mg->h)
02073 monthgraph_starve[0] = mg->h - 1;
02074 f = ((float) tunemployed_population
02075 / ((float) tpopulation + 1.0)) * 100.0;
02076 if (tpopulation > 3000)
02077 f += f;
02078 if (tpopulation > 6000)
02079 f += f;
02080 monthgraph_nojobs[0] = (int) f;
02081
02082 if (monthgraph_nojobs[0] >= mg->h)
02083 monthgraph_nojobs[0] = mg->h - 1;
02084 monthgraph_ppool[0] = ((int) (sqrt (people_pool + 1) * mg->h) / 35);
02085 if (monthgraph_ppool[0] < 0)
02086 monthgraph_ppool[0] = 0;
02087 if (monthgraph_ppool[0] >= mg->h)
02088 monthgraph_ppool[0] = mg->h - 1;
02089 if (draw) {
02090 Fgl_setpixel (mg->x + mg->w,
02091 mg->y + mg->h - monthgraph_pop[0], 7);
02092 Fgl_setpixel (mg->x + mg->w,
02093 mg->y + mg->h - monthgraph_starve[0], red (24));
02094 Fgl_setpixel (mg->x + mg->w,
02095 mg->y + mg->h - monthgraph_nojobs[0], yellow (24));
02096 Fgl_setpixel (mg->x + mg->w,
02097 mg->y + mg->h - monthgraph_ppool[0], cyan (24));
02098 }
02099 }
02100 }
02101
02102 void
02103 clicked_market_cb (int x, int y)
02104 {
02105 market_cb_flag = 1;
02106 mcbx = x;
02107 mcby = y;
02108 }
02109
02110
02111 void
02112 draw_cb_box (int row, int col, int checked)
02113 {
02114 int x, y;
02115 char* graphic;
02116 Rect* mcb = &scr.market_cb;
02117
02118 y = mcb->y + 4 + (4 * 8) + (row * CB_SPACE);
02119 x = mcb->x + 12 + (col * 12) * 8;
02120 graphic = checked ? checked_box_graphic : unchecked_box_graphic;
02121 Fgl_putbox (x, y, 16, 16, graphic);
02122 }
02123
02124 void
02125 draw_cb_template (int is_market_cb)
02126 {
02127 int x, y, flags;
02128 char s[100];
02129 Rect* mcb = &scr.market_cb;
02130
02131 debug_printf ("In draw_cb_template...\n");
02132 debug_printf ("Coords are %d %d %d %d\n",mcb->x,mcb->y,mcb->w,mcb->h);
02133 x = mcbx;
02134 y = mcby;
02135 flags = MP_INFO(x,y).flags;
02136 Fgl_getbox (mcb->x, mcb->y, mcb->w, mcb->h, market_cb_gbuf);
02137 Fgl_fillbox (mcb->x, mcb->y, mcb->w, mcb->h, 28);
02138 draw_small_bezel(mcb->x+4, mcb->y+4, mcb->w-8, mcb->h-8, blue(0));
02139 Fgl_setfontcolors (28,TEXT_FG_COLOUR);
02140 #ifdef USE_EXPANDED_FONT
02141 gl_setwritemode (WRITEMODE_MASKED | FONT_EXPANDED);
02142 #endif
02143
02144 if (is_market_cb) {
02145 Fgl_write (mcb->x + 1 * 8, mcb->y + 8, _("Market"));
02146 } else {
02147 Fgl_write (mcb->x + 3 * 8, mcb->y + 8, _("Port"));
02148 }
02149 sprintf (s, "%3d,%3d", x, y);
02150 Fgl_write (mcb->x + 7 * 8, mcb->y + 8, s);
02151 Fgl_hline (mcb->x + 2, mcb->y + 20, mcb->x + mcb->w - 2,
02152 TEXT_FG_COLOUR);
02153
02154 Fgl_write (mcb->x + 1 * 8, mcb->y + 3 * 8, _("Buy"));
02155 Fgl_write (mcb->x + 12 * 8 + 4, mcb->y + 3 * 8 + 1, _("Sell"));
02156 if (is_market_cb) {
02157 Fgl_write (mcb->x + 6 * 8 + 4, mcb->y + 40 +(CB_SPACE * 0), _("JOBS"));
02158 }
02159 Fgl_write (mcb->x + 6 * 8 + 4, mcb->y + 40 + (CB_SPACE * 1), _("FOOD"));
02160 Fgl_write (mcb->x + 6 * 8 + 4, mcb->y + 40 + (CB_SPACE * 2), _("COAL"));
02161 Fgl_write (mcb->x + 7 * 8, mcb->y + 40 + (CB_SPACE * 3), _("ORE"));
02162 Fgl_write (mcb->x + 6 * 8, mcb->y + 40 + (CB_SPACE * 4), _("GOODS"));
02163 Fgl_write (mcb->x + 6 * 8, mcb->y + 40 + (CB_SPACE * 5), _("STEEL"));
02164
02165 #ifdef USE_EXPANDED_FONT
02166 gl_setwritemode (WRITEMODE_OVERWRITE | FONT_EXPANDED);
02167 #endif
02168
02169 if (is_market_cb) {
02170 draw_cb_box (0, 0, MP_INFO(mcbx,mcby).flags & FLAG_MB_JOBS);
02171 draw_cb_box (0, 1, MP_INFO(mcbx,mcby).flags & FLAG_MS_JOBS);
02172 }
02173 draw_cb_box (1, 0, MP_INFO(mcbx,mcby).flags & FLAG_MB_FOOD);
02174 draw_cb_box (1, 1, MP_INFO(mcbx,mcby).flags & FLAG_MS_FOOD);
02175 draw_cb_box (2, 0, MP_INFO(mcbx,mcby).flags & FLAG_MB_COAL);
02176 draw_cb_box (2, 1, MP_INFO(mcbx,mcby).flags & FLAG_MS_COAL);
02177 draw_cb_box (3, 0, MP_INFO(mcbx,mcby).flags & FLAG_MB_ORE);
02178 draw_cb_box (3, 1, MP_INFO(mcbx,mcby).flags & FLAG_MS_ORE);
02179 draw_cb_box (4, 0, MP_INFO(mcbx,mcby).flags & FLAG_MB_GOODS);
02180 draw_cb_box (4, 1, MP_INFO(mcbx,mcby).flags & FLAG_MS_GOODS);
02181 draw_cb_box (5, 0, MP_INFO(mcbx,mcby).flags & FLAG_MB_STEEL);
02182 draw_cb_box (5, 1, MP_INFO(mcbx,mcby).flags & FLAG_MS_STEEL);
02183 }
02184
02185 void
02186 draw_market_cb (void)
02187 {
02188 market_cb_drawn_flag = 1;
02189 draw_cb_template (1);
02190 }
02191
02192 void
02193 close_market_cb (void)
02194 {
02195 Rect* mcb = &scr.market_cb;
02196
02197 market_cb_flag = 0;
02198 market_cb_drawn_flag = 0;
02199
02200 Fgl_putbox (mcb->x, mcb->y, mcb->w, mcb->h
02201 ,market_cb_gbuf);
02202 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
02203
02204
02205 cs_mouse_button = LC_MOUSE_LEFTBUTTON;
02206 }
02207
02208 void
02209 clicked_port_cb (int x, int y)
02210 {
02211 port_cb_flag = 1;
02212 mcbx = x;
02213 mcby = y;
02214 }
02215
02216 void
02217 draw_port_cb (void)
02218 {
02219 port_cb_drawn_flag = 1;
02220 draw_cb_template (0);
02221 }
02222
02223
02224 void
02225 close_port_cb (void)
02226 {
02227 Rect* mcb = &scr.market_cb;
02228
02229 port_cb_flag = 0;
02230 port_cb_drawn_flag = 0;
02231
02232 Fgl_putbox (mcb->x, mcb->y, mcb->w, mcb->h, market_cb_gbuf);
02233
02234 cs_mouse_button = LC_MOUSE_LEFTBUTTON;
02235 }
02236
02237 int
02238 yn_dial_box (char * s1, char * s2, char * s3, char *s4)
02239 {
02240 int result;
02241 result = dialog_box(red(10),7,
02242 0,0,s1,
02243 0,0,"",
02244 0,0,s2,
02245 0,0,s3,
02246 0,0,s4,
02247 1,'y',_("Yes"),
02248 1,'n',_("No"));
02249
02250 return (result == 'y') ? 1 : 0;
02251 }
02252
02253 void
02254 ok_dial_box (char *fn, int good_bad, char *xs)
02255 {
02256 FILE *inf;
02257 struct stat statbuf;
02258 int colour;
02259 char * ss;
02260 char s[LC_PATH_MAX];
02261 int retval;
02262
02263 if (suppress_ok_buttons != 0)
02264 return;
02265 if (good_bad == GOOD || good_bad == RESULTS)
02266 colour = green (14);
02267 else if (good_bad == BAD)
02268 colour = red (12);
02269 else
02270 colour = white (12);
02271 if (good_bad == RESULTS)
02272 strcpy (s, fn);
02273 else
02274 {
02275 strcpy (s, message_path);
02276 strcat (s, fn);
02277 }
02278
02279 if ((inf = fopen (s, "rb")) == NULL)
02280 {
02281 printf ("Can't open message <%s> for OK dialog box\n", s);
02282 strcpy (s, message_path);
02283 strcat (s, "error.mes");
02284 if ((inf = fopen (s, "rb")) == NULL)
02285 {
02286 fprintf (stderr,
02287 "Can't open default message <%s> either\n", s);
02288 fprintf (stderr, " ...it was not displayed");
02289 return;
02290 }
02291 }
02292 stat(s,&statbuf);
02293
02294 ss = (char *)lcalloc(statbuf.st_size + 1);
02295 retval = fread(ss,sizeof(char),statbuf.st_size,inf);
02296 ss[statbuf.st_size] = '\0';
02297
02298 undosify_string (ss);
02299
02300 #if defined (commentout)
02301 if (xs != 0)
02302 dialog_box(colour,3,
02303 0,0,ss,
02304 0,0,xs,
02305 2,' ',_("OK"));
02306 else
02307 dialog_box(colour,2,
02308 0,0,ss,
02309 2,' ',_("OK"));
02310 #endif
02311 fclose(inf);
02312
02313 display_info_message (colour, ss, xs);
02314 }
02315
02316 void
02317 format_status_message (char* sm1, char* sm2, int num_char, char* ss, char* xs)
02318 {
02319 char* src = ss;
02320 char* tgt = sm1;
02321 int did_xs = 0;
02322 int did_sm2 = 0;
02323 int chars_done = 0;
02324 *sm2 = *sm1 = '\0';\
02325
02326 while (src) {
02327 char src_c = *src++;
02328
02329 switch (src_c) {
02330 case '\0':
02331 if (did_xs || !xs) {
02332 *tgt = '\0';
02333 return;
02334 } else {
02335 src = xs;
02336 did_xs = 1;
02337 }
02338
02339 case '\n':
02340 *tgt++ = ' ';
02341 break;
02342 default:
02343 *tgt++ = src_c;
02344 }
02345 if (++chars_done == num_char) {
02346 *tgt = '\0';
02347 if (did_sm2) return;
02348 tgt = sm2;
02349 did_sm2 = 1;
02350 chars_done = 0;
02351 }
02352 }
02353 }
02354
02355
02356 void
02357 display_info_message (int colour, char* ss, char* xs)
02358 {
02359 if (suppress_popups) {
02360
02361 Rect* b = &scr.status_message_1;
02362 int num_char = b->w / 9 - 1;
02363 char *sm1, *sm2;
02364 if ((sm1 = (char *) malloc (num_char+1)) == 0)
02365 malloc_failure ();
02366 if ((sm2 = (char *) malloc (num_char+1)) == 0)
02367 malloc_failure ();
02368
02369 format_status_message (sm1,sm2,num_char,ss,xs);
02370 status_message(sm1,sm2);
02371 free (sm1);
02372 free (sm2);
02373 } else {
02374
02375 if (xs) {
02376 dialog_box(colour,3,
02377 0,0,ss,
02378 0,0,xs,
02379 2,' ',_("OK"));
02380 } else {
02381 dialog_box(colour,2,
02382 0,0,ss,
02383 2,' ',_("OK"));
02384 }
02385 }
02386 }
02387
02388 void
02389 prog_box (char *title, int percent)
02390 {
02391 static int flag = 0, oldpercent = 0;
02392 char s[100];
02393 int i;
02394 if (flag == 0) {
02395 hide_mouse ();
02396 Fgl_getbox (PROGBOXX - 8, PROGBOXY - 8, PROGBOXW + 16,
02397 PROGBOXH + 16, progbox);
02398 Fgl_fillbox (PROGBOXX, PROGBOXY,
02399 PROGBOXW, PROGBOXH, PROGBOX_BG_COLOUR);
02400 for (i = 1; i < 8; i++) {
02401 Fgl_hline (PROGBOXX - i, PROGBOXY - i,
02402 PROGBOXX + PROGBOXW + i - 1,
02403 PROGBOX_BG_COLOUR + i + i);
02404 Fgl_hline (PROGBOXX - i, PROGBOXY + PROGBOXH + i - 1,
02405 PROGBOXX + PROGBOXW + i - 1,
02406 PROGBOX_BG_COLOUR + i + i);
02407 Fgl_line (PROGBOXX - i, PROGBOXY - i,
02408 PROGBOXX - i, PROGBOXY + PROGBOXH + i - 1,
02409 PROGBOX_BG_COLOUR + i + i);
02410 Fgl_line (PROGBOXX + PROGBOXW + i - 1, PROGBOXY - i,
02411 PROGBOXX + PROGBOXW + i - 1,
02412 PROGBOXY + PROGBOXH + i - 1,
02413 PROGBOX_BG_COLOUR + i + i);
02414 }
02415
02416
02417 Fgl_setfontcolors (PROGBOX_BG_COLOUR, TEXT_FG_COLOUR);
02418 Fgl_write ((PROGBOXX + PROGBOXW / 2)
02419 - (strlen (title) * 4), PROGBOXY + 8, title);
02420 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
02421
02422 flag = 1;
02423 }
02424 if (percent != oldpercent)
02425 {
02426 Fgl_fillbox (PROGBOXX + 20, PROGBOXY + 60,
02427 ((PROGBOXW - 40) * percent) / 100,
02428 20, PROGBOX_DONE_COL);
02429 Fgl_fillbox (PROGBOXX + 20 + (((PROGBOXW - 40) * percent) / 100),
02430 PROGBOXY + 60,
02431 PROGBOXW - 40 - (((PROGBOXW - 40) * percent) / 100),
02432 20, PROGBOX_NOTDONE_COL);
02433 oldpercent = percent;
02434 Fgl_fillbox (PROGBOXX + (PROGBOXW / 2) - 20,
02435 PROGBOXY + 24, 40, 16, PROGBOX_BG_COLOUR);
02436 sprintf (s, "%3d%%", percent);
02437 Fgl_setfontcolors (PROGBOX_BG_COLOUR, TEXT_FG_COLOUR);
02438 Fgl_write (PROGBOXX + (PROGBOXW / 2) - 20, PROGBOXY + 24, s);
02439 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
02440 }
02441 #ifdef LC_X11
02442 XSync (display.dpy, FALSE);
02443 #endif
02444 if (percent < 100)
02445 {
02446 #if defined (WIN32)
02447
02448 RefreshArea (PROGBOXX - 8, PROGBOXY - 8, PROGBOXW + 16, PROGBOXH + 16);
02449 #endif
02450 return;
02451 }
02452
02453 Fgl_putbox (PROGBOXX - 8, PROGBOXY - 8, PROGBOXW + 16, PROGBOXH + 16, progbox);
02454 redraw_mouse ();
02455 flag = 0;
02456 }
02457
02458
02459 static void
02460 do_sust_barchart (int draw)
02461 {
02462 #define SUST_BAR_H 5
02463 #define SUST_BAR_GAP_Y 5
02464 Rect* mg = &scr.monthgraph;
02465 static int flag = 0;
02466 if (flag == 0)
02467 {
02468
02469
02470 #if defined (commentout)
02471 draw_small_yellow_bezel (mg->x, mg->y, mg->h, mg->w);
02472 #endif
02473 if (draw) {
02474
02475 Fgl_fillbox (mg->x, mg->y, mg->w, mg->h, 0);
02476
02477 Fgl_setfontcolors (0, TEXT_FG_COLOUR);
02478 Fgl_write (mg->x+3,
02479 mg->y + SUST_BAR_GAP_Y - 1,
02480
02481
02482
02483
02484
02485 _("MIN"));
02486 Fgl_write (mg->x+3,
02487 mg->y + SUST_BAR_GAP_Y + (SUST_BAR_H + SUST_BAR_GAP_Y) - 1,
02488 _("PRT"));
02489 Fgl_write (mg->x+3,
02490 mg->y + SUST_BAR_GAP_Y + 2 * (SUST_BAR_H + SUST_BAR_GAP_Y) - 1,
02491 _("MNY"));
02492 Fgl_write (mg->x+3,
02493 mg->y + SUST_BAR_GAP_Y + 3 * (SUST_BAR_H + SUST_BAR_GAP_Y) - 1,
02494 _("POP"));
02495 Fgl_write (mg->x+3,
02496 mg->y + SUST_BAR_GAP_Y + 4 * (SUST_BAR_H + SUST_BAR_GAP_Y) - 1,
02497 _("TEC"));
02498 Fgl_write (mg->x+3,
02499 mg->y + SUST_BAR_GAP_Y + 5 * (SUST_BAR_H + SUST_BAR_GAP_Y) - 1,
02500 _("FIR"));
02501 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
02502
02503 Fgl_line (mg->x + 38, mg->y, mg->x + 38, mg->y + mg->h,
02504 yellow (24));
02505
02506 Fgl_fillbox (mg->x + 36, mg->y + SUST_BAR_GAP_Y,
02507 3, SUST_BAR_H, SUST_ORE_COAL_COL);
02508
02509 Fgl_fillbox (mg->x + 36,
02510 mg->y + SUST_BAR_GAP_Y + (SUST_BAR_H + SUST_BAR_GAP_Y),
02511 3, SUST_BAR_H, SUST_PORT_COL);
02512
02513 Fgl_fillbox (mg->x + 36,
02514 mg->y + SUST_BAR_GAP_Y + 2 * (SUST_BAR_H + SUST_BAR_GAP_Y),
02515 3, SUST_BAR_H, SUST_MONEY_COL);
02516
02517 Fgl_fillbox (mg->x + 36,
02518 mg->y + SUST_BAR_GAP_Y + 3 * (SUST_BAR_H + SUST_BAR_GAP_Y),
02519 3, SUST_BAR_H, SUST_POP_COL);
02520
02521 Fgl_fillbox (mg->x + 36,
02522 mg->y + SUST_BAR_GAP_Y + 4 * (SUST_BAR_H + SUST_BAR_GAP_Y),
02523 3, SUST_BAR_H, SUST_TECH_COL);
02524
02525 Fgl_fillbox (mg->x + 36,
02526 mg->y + SUST_BAR_GAP_Y + 5 * (SUST_BAR_H + SUST_BAR_GAP_Y),
02527 3, SUST_BAR_H, SUST_FIRE_COL);
02528 }
02529 }
02530 if (sust_dig_ore_coal_count >= SUST_ORE_COAL_YEARS_NEEDED
02531 && sust_port_count >= SUST_PORT_YEARS_NEEDED
02532 && sust_old_money_count >= SUST_MONEY_YEARS_NEEDED
02533 && sust_old_population_count >= SUST_POP_YEARS_NEEDED
02534 && sust_old_tech_count >= SUST_TECH_YEARS_NEEDED
02535 && sust_fire_count >= SUST_FIRE_YEARS_NEEDED)
02536 {
02537 if (sustain_flag == 0)
02538 ok_dial_box ("sustain.mes", GOOD, 0L);
02539 sustain_flag = 1;
02540 }
02541 else
02542 sustain_flag = 0;
02543 if (draw) {
02544 draw_sustline (0, sust_dig_ore_coal_count,
02545 SUST_ORE_COAL_YEARS_NEEDED, SUST_ORE_COAL_COL);
02546 draw_sustline ((SUST_BAR_H + SUST_BAR_GAP_Y),
02547 sust_port_count,
02548 SUST_PORT_YEARS_NEEDED, SUST_PORT_COL);
02549 draw_sustline (2*(SUST_BAR_H + SUST_BAR_GAP_Y),
02550 sust_old_money_count,
02551 SUST_MONEY_YEARS_NEEDED, SUST_MONEY_COL);
02552 draw_sustline (3*(SUST_BAR_H + SUST_BAR_GAP_Y),
02553 sust_old_population_count,
02554 SUST_POP_YEARS_NEEDED, SUST_POP_COL);
02555 draw_sustline (4*(SUST_BAR_H + SUST_BAR_GAP_Y),
02556 sust_old_tech_count,
02557 SUST_TECH_YEARS_NEEDED, SUST_TECH_COL);
02558 draw_sustline (5*(SUST_BAR_H + SUST_BAR_GAP_Y),
02559 sust_fire_count,
02560 SUST_FIRE_YEARS_NEEDED, SUST_FIRE_COL);
02561 }
02562
02563 }
02564
02565 static void
02566 draw_sustline (int yoffset, int count, int max, int col)
02567 {
02568 Rect* mg = &scr.monthgraph;
02569 int split;
02570 if (count >= max)
02571 split = 60;
02572 else
02573 split = 60 * count / max;
02574 Fgl_fillbox (mg->x + 38,
02575 mg->y + SUST_BAR_GAP_Y + yoffset, split, SUST_BAR_H, col);
02576 if (split < 60)
02577 Fgl_fillbox (mg->x + 38 + split + 1,
02578 mg->y + SUST_BAR_GAP_Y + yoffset, 60 - split,
02579 SUST_BAR_H, 0);
02580 }
02581
02582 void
02583 dump_screen (void)
02584 {
02585 #if !defined (LC_X11) && !defined (WIN32)
02586 int x, y, r, g, b;
02587 FILE *outf;
02588 if ((outf = fopen ("screendump.raw", "wb")) == NULL)
02589 do_error ("Can't open screendump.raw");
02590 for (y = 0; y < 480; y++)
02591 for (x = 0; x < 640; x++)
02592 {
02593 gl_getpixelrgb (x, y, &r, &g, &b);
02594 fputc (r, outf);
02595 fputc (g, outf);
02596 fputc (b, outf);
02597 }
02598 fclose (outf);
02599 #endif
02600 }
02601
02602 void
02603 debug_writeval (int v)
02604 {
02605 char s[100];
02606 sprintf (s, "%d ", v);
02607 Fgl_write (280, 471, s);
02608 }
02609
02610 int
02611 ask_launch_rocket_click (int x, int y)
02612 {
02613 return yn_dial_box (_("ROCKET LAUNCH"),
02614 _("You can launch the rocket now or wait until later."),
02615 _("If you wait, it costs you *only* money to keep the"),
02616 _("rocket ready. Launch?"));
02617 }
02618
02619 int
02620 ask_launch_rocket_now (int x, int y)
02621 {
02622 return yn_dial_box (_("Rocket ready to launch"),
02623 _("You can launch it now or wait until later."),
02624 _("If you wait it will continue costing you money."),
02625 _("Launch it later by clicking on the rocket area."));
02626 }
02627
02628 void
02629 display_rocket_result_dialog (int result)
02630 {
02631 switch (result) {
02632 case ROCKET_LAUNCH_BAD:
02633 ok_dial_box ("launch-fail.mes", BAD, 0L);
02634 break;
02635 case ROCKET_LAUNCH_GOOD:
02636 ok_dial_box ("launch-good.mes", GOOD, 0L);
02637 break;
02638 case ROCKET_LAUNCH_EVAC:
02639 ok_dial_box ("launch-evac.mes", GOOD, 0L);
02640 break;
02641 }
02642 }
02643
02644 void
02645 Fgl_getrect(Rect * r, void * buffer)
02646 {
02647 Fgl_getbox(r->x,r->y,r->w,r->h,buffer);
02648 }
02649
02650 void
02651 Fgl_putrect(Rect *r, void * buffer)
02652 {
02653 Fgl_putbox(r->x,r->y,r->w,r->h,buffer);
02654 }
02655