#include "lcconfig.h"#include <stdio.h>#include <stdlib.h>#include "lcstring.h"#include "ldsvgui.h"#include "lcintl.h"#include "screen.h"#include "pbar.h"#include "module_buttons.h"#include "fileutil.h"#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <time.h>#include <ctype.h>#include "common.h"#include "lctypes.h"#include "lin-city.h"#include "cliglobs.h"#include "engglobs.h"#include "ldsvguts.h"#include "mouse.h"#include "stats.h"Go to the source code of this file.
Defines | |
| #define | dirent direct |
| #define | NAMLEN(dirent) (dirent)->d_namlen |
Functions | |
| int | verify_city (char *cname) |
| void | input_network_host (char *s) |
| void | input_network_port (char *s) |
| void | draw_prefs_cb (void) |
| void | do_prefs_buttons (int x, int y) |
| void | do_prefs_mouse (int x, int y, int mbutton) |
| void | do_prefs_screen (void) |
| void | close_prefs_screen (void) |
| void | do_save_city () |
| void | load_opening_city (char *s) |
| void | do_load_city (void) |
| void | draw_save_dir (int bg_colour) |
| void | edit_string (char *s, unsigned int maxlen, int xpos, int ypos) |
| void | input_save_filename (char *s) |
| void | do_get_nw_server (void) |
Variables | |
| char * | lc_save_dir |
| char | save_names [10][42] |
|
|
|
|
|
|
|
|
Definition at line 231 of file ldsvgui.c. 00232 {
00233 save_lincityrc();
00234
00235 prefs_flag = 0;
00236 prefs_drawn_flag = 0;
00237 #ifdef USE_EXPANDED_FONT
00238 Fgl_setwritemode (WRITEMODE_OVERWRITE | FONT_EXPANDED);
00239 #else
00240 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00241 #endif
00242 }
|
|
|
Definition at line 643 of file ldsvgui.c. 00644 {
00645 Rect* mw = &scr.main_win;
00646 char c;
00647 hide_mouse ();
00648 Fgl_fillbox (mw->x, mw->y, mw->w, mw->h, NW_BG_COLOUR);
00649 Fgl_setfontcolors (LOAD_BG_COLOUR, TEXT_FG_COLOUR);
00650 Fgl_write (mw->x + 140, mw->y + 15, _("Choose network server"));
00651 Fgl_write (mw->x + 40, mw->y + 35
00652 ,_("Please enter the address and port of the server"));
00653 Fgl_write (mw->x + 110, mw->y + 210
00654 ,_("Press space to cancel."));
00655 draw_save_dir (NW_BG_COLOUR);
00656 do
00657 {
00658 #ifdef LC_X11
00659 db_flag = 1;
00660 redraw_mouse ();
00661 cs_mouse_handler (0, -1, 0);
00662 cs_mouse_handler (0, 1, 0);
00663 do
00664 {
00665 call_event ();
00666 c = x_key_value;
00667 }
00668 while (c == 0);
00669 x_key_value = 0;
00670 #elif defined (WIN32)
00671 while (0 == (c = GetKeystroke ())); /* Wait for keystroke */
00672 #else
00673 c = getchar ();
00674 #endif
00675 if (c > '0' && c <= '9')
00676 if (strlen (save_names[c - '0']) < 1)
00677 {
00678 redraw_mouse ();
00679 if (yn_dial_box (_("No scene.")
00680 ,_("There is no save scene with this number.")
00681 ,_("Do you want to")
00682 ,_("try again?")) != 0)
00683 c = 0;
00684 else
00685 c = ' ';
00686 hide_mouse ();
00687 }
00688 }
00689 while ((c <= '0' || c > '9') && c != ' ');
00690 redraw_mouse ();
00691 if (c > '0' && c <= '9')
00692 {
00693 if (yn_dial_box (_("Loading Scene")
00694 ,_("Do you want to load the scene")
00695 ,save_names[c - '0']
00696 ,_("and forget the current game?")) != 0)
00697 {
00698 Fgl_write (mw->x + 70, mw->y + 310
00699 ,_("Loading scene... please wait"));
00700 load_saved_city (save_names[c - '0']);
00701 }
00702 }
00703 db_flag = 0;
00704 cs_mouse_handler (0, -1, 0);
00705 cs_mouse_handler (0, 1, 0);
00706 hide_mouse ();
00707 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00708 refresh_main_screen ();
00709 suppress_ok_buttons = 1;
00710 update_avail_modules (0);
00711 suppress_ok_buttons = 0;
00712 redraw_mouse ();
00713 }
|
|
|
Definition at line 366 of file ldsvgui.c. 00367 {
00368 Rect* mw = &scr.main_win;
00369 char c;
00370 hide_mouse ();
00371 Fgl_fillbox (mw->x, mw->y, mw->w, mw->h
00372 ,LOAD_BG_COLOUR);
00373 Fgl_setfontcolors (LOAD_BG_COLOUR, TEXT_FG_COLOUR);
00374 Fgl_write (mw->x + 140, mw->y + 15, _("Load a file"));
00375 Fgl_write (mw->x + 40, mw->y + 35
00376 ,_("Choose the number of the scene you want"));
00377 Fgl_write (mw->x + 40, mw->y + 50
00378 ,_("Entries coloured red are either not there,"));
00379 Fgl_write (mw->x + 44, mw->y + 60
00380 ,_("or they are from an earlier version, they"));
00381 Fgl_write (mw->x + 110, mw->y + 70
00382 ,_("might not load properly."));
00383 Fgl_write (mw->x + 110, mw->y + 210
00384 ,_("Press space to cancel."));
00385 draw_save_dir (LOAD_BG_COLOUR);
00386 db_flag = 1;
00387
00388 do {
00389 #ifdef LC_X11
00390 redraw_mouse ();
00391 cs_mouse_handler (0, -1, 0);
00392 cs_mouse_handler (0, 1, 0);
00393 do {
00394 call_event ();
00395 c = x_key_value;
00396 } while (c == 0);
00397 x_key_value = 0;
00398 #elif defined (WIN32)
00399 while (0 == (c = GetKeystroke ())); /* Wait for keystroke */
00400 redraw_mouse ();
00401 #else
00402 c = getchar ();
00403 redraw_mouse ();
00404 #endif
00405 if (c > '0' && c <= '9') {
00406 if (strlen (save_names[c - '0']) < 1) {
00407 redraw_mouse ();
00408 if (yn_dial_box (_("No scene."),
00409 _("There is no save scene with this number."),
00410 _("Do you want to"),
00411 _("try again?")) != 0)
00412 c = 0;
00413 else
00414 c = ' ';
00415 hide_mouse ();
00416 }
00417 }
00418 } while (c==0);
00419
00420 redraw_mouse ();
00421 if (c > '0' && c <= '9') {
00422 if (yn_dial_box (_("Loading Scene")
00423 ,_("Do you want to load the scene")
00424 ,save_names[c - '0']
00425 ,_("and forget the current game?")) != 0)
00426 {
00427 Fgl_write (mw->x + 70, mw->y + 310
00428 ,_("Loading scene... please wait"));
00429 load_saved_city (save_names[c - '0']);
00430 refresh_pbars();
00431 }
00432 }
00433 db_flag = 0;
00434 cs_mouse_handler (0, -1, 0);
00435 cs_mouse_handler (0, 1, 0);
00436 hide_mouse ();
00437 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00438 load_flag = 0;
00439 refresh_main_screen ();
00440 suppress_ok_buttons = 1;
00441 update_avail_modules (0);
00442 suppress_ok_buttons = 0;
00443 redraw_mouse ();
00444 }
|
|
||||||||||||
|
Definition at line 138 of file ldsvgui.c. 00139 {
00140 int outx, outy, outh, outw;
00141 Rect* mw = &scr.main_win;
00142 if (x > mw->x + 50 && x < mw->x + 50 + 16) {
00143 if (y > mw->y + 30 && y < mw->y + 30 + 16) {
00144 hide_mouse ();
00145 overwrite_transport_flag = !overwrite_transport_flag;
00146 draw_prefs_cb ();
00147 redraw_mouse ();
00148 } else if (y > mw->y + 30 + 16 && y < mw->y + 30 + 2*16) {
00149 hide_mouse ();
00150 suppress_popups = !suppress_popups;
00151 draw_prefs_cb ();
00152 redraw_mouse ();
00153 } else if (y > mw->y + 30 + 2*16 && y < mw->y + 30 + 3*16) {
00154 hide_mouse ();
00155 time_multiplex_stats = !time_multiplex_stats;
00156 draw_prefs_cb ();
00157 redraw_mouse ();
00158 #if defined (LC_X11)
00159 } else if (y > mw->y + 30 + 3*16 && y < mw->y + 30 + 4*16) {
00160 hide_mouse ();
00161 confine_flag = !confine_flag;
00162 draw_prefs_cb ();
00163 set_pointer_confinement ();
00164 redraw_mouse ();
00165 #endif
00166 }
00167 }
00168 outx = 370;
00169 outy = 387;
00170 outh = 12;
00171 outw = 3*8 + 4;
00172 if (x > mw->x + outx && x < mw->x + outx + outw &&
00173 y > mw->y + outy && y < mw->y + outy + outh)
00174 {
00175 close_prefs_screen ();
00176 refresh_main_screen ();
00177 }
00178 }
|
|
||||||||||||||||
|
Definition at line 181 of file ldsvgui.c. 00182 {
00183 Rect* mw = &scr.main_win;
00184 if (mouse_in_rect(mw, x, y)) {
00185 do_prefs_buttons (x, y);
00186 return;
00187 }
00188 /* If the user clicks outside of main window, cancel prefs?? */
00189 close_prefs_screen ();
00190 refresh_main_screen ();
00191 }
|
|
|
Definition at line 194 of file ldsvgui.c. 00195 {
00196 int x,y,w,h;
00197 Rect* mw = &scr.main_win;
00198
00199 prefs_drawn_flag = 1;
00200
00201 hide_mouse ();
00202 Fgl_fillbox (mw->x, mw->y, mw->w, mw->h, LOAD_BG_COLOUR);
00203 Fgl_setfontcolors (LOAD_BG_COLOUR, TEXT_FG_COLOUR);
00204 Fgl_write (mw->x + 80, mw->y + 4*8, _("Transport overwrite"));
00205 Fgl_write (mw->x + 80, mw->y + 6*8, _("Popup info to dialog boxes"));
00206 Fgl_write (mw->x + 80, mw->y + 8*8, _("Time multiplexed stats windows"));
00207 #if defined (LC_X11)
00208 Fgl_write (mw->x + 80, mw->y + 10*8, _("Confine X pointer"));
00209 #endif
00210
00211 x = 370;
00212 y = 387;
00213 h = 12;
00214 w = 3*8 + 4;
00215 Fgl_hline (mw->x + x, mw->y + y,
00216 mw->x + x + w, HELPBUTTON_COLOUR);
00217 Fgl_hline (mw->x + x, mw->y + y + h,
00218 mw->x + x + w, HELPBUTTON_COLOUR);
00219 Fgl_line (mw->x + x, mw->y + y,
00220 mw->x + x, mw->y + y + h, HELPBUTTON_COLOUR);
00221 Fgl_line (mw->x + x + w, mw->y + y,
00222 mw->x + x + w, mw->y + y + h, HELPBUTTON_COLOUR);
00223 Fgl_write (mw->x + x + 2, mw->y + y + 2, _("OUT"));
00224
00225 draw_prefs_cb ();
00226
00227 redraw_mouse ();
00228 }
|
|
|
Definition at line 280 of file ldsvgui.c. 00281 {
00282 Rect* mw = &scr.main_win;
00283 char s[200], c;
00284 hide_mouse ();
00285 Fgl_fillbox (mw->x, mw->y, mw->w, mw->h
00286 ,SAVE_BG_COLOUR);
00287 Fgl_setfontcolors (SAVE_BG_COLOUR, TEXT_FG_COLOUR);
00288 Fgl_write (mw->x + 100, mw->y + 15, _("Save a scene"));
00289 Fgl_write (mw->x + 8, mw->y + 35
00290 ,_("Choose the number of the scene you want to save"));
00291 Fgl_write (mw->x + 110, mw->y + 210
00292 ,_("Press space to cancel."));
00293 draw_save_dir (SAVE_BG_COLOUR);
00294 db_flag = 1;
00295 #ifdef LC_X11
00296 redraw_mouse ();
00297 cs_mouse_handler (0, -1, 0);
00298 cs_mouse_handler (0, 1, 0);
00299 do
00300 {
00301 call_event ();
00302 c = x_key_value;
00303 }
00304 while (c == 0);
00305 x_key_value = 0;
00306 #elif defined (WIN32)
00307 while (0 == (c = GetKeystroke ())); /* Wait for keystroke */
00308 redraw_mouse ();
00309 #else
00310 c = getchar ();
00311 redraw_mouse ();
00312 #endif
00313 if (c > '0' && c <= '9')
00314 {
00315 Fgl_write (mw->x + 40, mw->y + 300
00316 ,_("Type comment for the saved scene"));
00317 Fgl_write (mw->x + 16, mw->y + 310
00318 ,_("The comment may be up to 40 characters"));
00319 Fgl_write (mw->x + 40, mw->y + 320
00320 ,_("and may contain spaces or % . - + ,"));
00321 strcpy (s, &(save_names[c - '0'][2]));
00322 input_save_filename (s);
00323 remove_scene (save_names[c - '0']);
00324 sprintf (save_names[c - '0'], "%d_", c - '0');
00325 strcat (save_names[c - '0'], s);
00326 Fgl_fillbox (mw->x + 5, mw->y + 300
00327 ,360, 30, SAVE_BG_COLOUR);
00328 Fgl_write (mw->x + 70, mw->y + 310
00329 ,_("Saving city scene... please wait"));
00330 save_city (save_names[c - '0']);
00331 }
00332 db_flag = 0;
00333 cs_mouse_handler (0, -1, 0);
00334 cs_mouse_handler (0, 1, 0);
00335 hide_mouse ();
00336 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00337 save_flag = 0;
00338 refresh_main_screen ();
00339 redraw_mouse ();
00340 }
|
|
|
Definition at line 109 of file ldsvgui.c. 00110 {
00111 Rect* mw = &scr.main_win;
00112 int x, y;
00113 char* graphic;
00114
00115 x = mw->x + 50;
00116 y = mw->y + 30;
00117 graphic = overwrite_transport_flag ?
00118 checked_box_graphic : unchecked_box_graphic;
00119 Fgl_putbox (x, y, 16, 16, graphic);
00120
00121 y += 16;
00122 graphic = suppress_popups ? unchecked_box_graphic : checked_box_graphic;
00123 Fgl_putbox (x, y, 16, 16, graphic);
00124
00125 y += 16;
00126 graphic = time_multiplex_stats ?
00127 checked_box_graphic : unchecked_box_graphic;
00128 Fgl_putbox (x, y, 16, 16, graphic);
00129
00130 #if defined (LC_X11)
00131 y += 16;
00132 graphic = confine_flag ? checked_box_graphic : unchecked_box_graphic;
00133 Fgl_putbox (x, y, 16, 16, graphic);
00134 #endif
00135 }
|
|
|
Definition at line 447 of file ldsvgui.c. 00448 {
00449 Rect* mw = &scr.main_win;
00450 char *s, s2[200];
00451 int i, j, l;
00452 #if defined (WIN32)
00453 char filespec[4];
00454 #if defined(_MSC_VER)
00455 struct _finddata_t fileinfo;
00456 #elif defined (__BORLANDC__)
00457 struct ffblk fileinfo;
00458 #endif
00459 long fh;
00460 #else
00461 struct dirent *ep;
00462 DIR *dp;
00463 #endif
00464 if ((s = (char *) malloc (lc_save_dir_len + strlen (LC_SAVE_DIR) + 64)) == 0)
00465 malloc_failure ();
00466 strcpy (s, lc_save_dir);
00467 if (!directory_exists (s))
00468 {
00469 printf (_("Couldn't find the save directory %s\n"), s);
00470 free (s);
00471 return;
00472 }
00473 /* GCS FIX: Technically speaking, there is a race condition here. */
00474 #if defined (WIN32)
00475 _chdir (s);
00476 #else
00477 dp = opendir (s);
00478 #endif
00479 for (i = 1; i < 10; i++)
00480 {
00481 save_names[i][0] = 0;
00482 #if defined (WIN32)
00483 sprintf (filespec, "%d_*", i);
00484 #if defined (_MSC_VER)
00485 fh = _findfirst (filespec, &fileinfo);
00486 #elif defined (__BORLANDC__)
00487 fh = findfirst (filespec, &fileinfo, FA_ARCH);
00488 #endif
00489 if (fh != -1)
00490 {
00491 #else
00492 while ((ep = readdir (dp))) /* extra brackets to stop warning */
00493
00494 {
00495 if (*(ep->d_name) == (i + '0')
00496 && *((ep->d_name) + 1) == '_')
00497 {
00498 #endif
00499 sprintf (s2, "%2d ", i);
00500 #if defined (WIN32)
00501 #if defined (_MSC_VER)
00502 strncpy (save_names[i], fileinfo.name, 40);
00503 #elif defined (__BORLANDC__)
00504 strncpy (save_names[i], fileinfo.ff_name, 40);
00505 #endif
00506 #else /* UNIX */
00507 strncpy (save_names[i], ep->d_name, 40);
00508 #endif
00509 if (strlen (save_names[i]) > 2)
00510 strncat (s2, &(save_names[i][2]), 40);
00511 else
00512 strcat (s2, "???");
00513 #if defined (WIN32)
00514 #if defined (_MSC_VER)
00515 _findclose (fh);
00516 #elif defined (__BORLANDC__)
00517 findclose(&fileinfo);
00518 #endif
00519 }
00520 #else
00521 }
00522 }
00523 #endif
00524 if (strlen (save_names[i]) < 1)
00525 sprintf (s2, " %d .....", i);
00526 else
00527 {
00528 l = strlen (s2);
00529 for (j = 0; j < l; j++)
00530 if (s2[j] == '_')
00531 s2[j] = ' ';
00532 }
00533 if (verify_city (save_names[i]) == 0)
00534 Fgl_setfontcolors (bg_colour, red (28));
00535 else
00536 Fgl_setfontcolors (bg_colour, green (28));
00537 Fgl_write (mw->x + 24, mw->y + 10 * (10 + i), s2);
00538 #if !defined (WIN32)
00539 rewinddir (dp);
00540 #endif
00541 }
00542 #if defined (WIN32)
00543 _chdir (LIBDIR); /* go back... */
00544 #else
00545 closedir (dp);
00546 #endif
00547 Fgl_setfontcolors (bg_colour, TEXT_FG_COLOUR);
00548 free (s);
00549 }
|
|
||||||||||||||||||||
|
Definition at line 552 of file ldsvgui.c. 00553 {
00554 char c;
00555 int i, t, on;
00556 c = 0;
00557 s[maxlen+1] = 0;
00558 t = strlen (s);
00559 for (i = 0; i < t; i++)
00560 if (s[i] == '_')
00561 s[i] = ' ';
00562 while (c != 0xd && c != 0xa)
00563 {
00564 Fgl_write (xpos, ypos, s);
00565 Fgl_write (xpos + (strlen (s) * 8), ypos, "_");
00566 on = 1;
00567 get_real_time ();
00568 t = real_time;
00569 #ifdef LC_X11
00570 call_event ();
00571 while ((c = x_key_value) == 0)
00572 #elif defined (WIN32)
00573 while ((c = GetKeystroke ()) == 0)
00574 #else
00575 while ((c = vga_getkey ()) == 0)
00576 #endif
00577 {
00578 #ifdef LC_X11
00579 call_event ();
00580 #endif
00581 get_real_time ();
00582 if (real_time > t + 200) {
00583 if (on == 1) {
00584 Fgl_write (xpos + (strlen (s) * 8),
00585 ypos, " ");
00586 on = 0;
00587 } else {
00588 Fgl_write (xpos + (strlen (s) * 8),
00589 ypos, "_");
00590 on = 1;
00591 }
00592 get_real_time ();
00593 t = real_time;
00594 }
00595 }
00596 #ifdef LC_X11
00597 x_key_value = 0;
00598 #endif
00599 if ((isalnum (c) || c == ' ' || c == '.' || c == '%' || c == ','
00600 || c == '-' || c == '+') && strlen (s) < maxlen)
00601 {
00602 t = strlen (s);
00603 s[t] = c;
00604 s[t + 1] = 0;
00605 }
00606 else if (c == 0x7f && strlen (s) > 0)
00607 {
00608 Fgl_write (xpos + (strlen (s) * 8), ypos, " ");
00609 s[strlen (s) - 1] = 0;
00610 }
00611 }
00612 t = strlen (s);
00613 for (i = 0; i < t; i++)
00614 if (s[i] == ' ')
00615 s[i] = '_';
00616 }
|
|
|
Definition at line 626 of file ldsvgui.c. 00627 {
00628 Rect* mw = &scr.main_win;
00629 Fgl_write (mw->x + 50, mw->y + 240, "Host:");
00630 edit_string (s, 40, mw->x + 124, mw->y + 240);
00631 }
|
|
|
Definition at line 634 of file ldsvgui.c. 00635 {
00636 Rect* mw = &scr.main_win;
00637 Fgl_write (mw->x + 50, mw->y + 280, "Port:");
00638 edit_string (s, 40, mw->x + 124, mw->y + 280);
00639 }
|
|
|
Definition at line 619 of file ldsvgui.c.
|
|
|
Definition at line 343 of file ldsvgui.c. 00344 {
00345 char *cname = (char *) malloc (strlen (opening_path) + strlen (s) + 2);
00346 sprintf (cname, "%s%c%s", opening_path, PATH_SLASH, s);
00347 load_city (cname);
00348 free (cname);
00349
00350 strcpy (given_scene, s);
00351 db_flag = 0;
00352 cs_mouse_handler (0, -1, 0);
00353 cs_mouse_handler (0, 1, 0);
00354 /* GCS: Should I hide_mouse() here, as is done in do_load_city above? */
00355 hide_mouse ();
00356 Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);
00357 refresh_main_screen ();
00358 suppress_ok_buttons = 1;
00359 update_avail_modules (0);
00360 suppress_ok_buttons = 0;
00361 /* GCS: ?? */
00362 redraw_mouse ();
00363 }
|
|
|
Definition at line 688 of file ldsvguts.c. 00689 {
00690 FILE* fp;
00691 char* s;
00692 int v;
00693
00694 if (strlen(cname) == 0) {
00695 return 0;
00696 }
00697 if ((s = (char *) malloc (lc_save_dir_len + strlen(cname) + 2)) == 0)
00698 malloc_failure ();
00699 sprintf (s, "%s%c%s", lc_save_dir, PATH_SLASH, cname);
00700 if (!file_exists(s)) {
00701 free (s);
00702 return 0;
00703 }
00704 fp = fopen_read_gzipped (s);
00705 if (fp == NULL) {
00706 v = 0;
00707 } else if (1 != fscanf (fp, "%d", &v)) {
00708 v = 0;
00709 }
00710 fclose_read_gzipped (fp);
00711 free (s);
00712 return v == VERSION_INT;
00713 }
|
|
|
|
|
|
|
1.3.9.1