? civscore.log ? diff Index: client/climisc.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v retrieving revision 1.61 diff -u -r1.61 climisc.c --- client/climisc.c 2001/09/20 11:07:28 1.61 +++ client/climisc.c 2001/09/22 14:26:45 @@ -47,6 +47,7 @@ #include "mapview_g.h" #include "tilespec.h" #include "civclient.h" +#include "options.h" #include "climisc.h" @@ -469,7 +470,7 @@ Returns the color the grid should have between tile (x1,y1) and (x2,y2). **************************************************************************/ -enum color_std get_grid_color(int x1, int y1, int x2, int y2) +int get_grid_color(int x1, int y1, int x2, int y2, enum color_std *color) { enum city_tile_type city_tile_type1, city_tile_type2; struct city *dummy_pcity; @@ -478,13 +479,14 @@ int pos2_is_in_city_radius = 0; assert(is_real_tile(x1, y1)); + assert(map_get_tile(x1, y1)->known); if (is_real_tile(x2, y2)) { normalize_map_pos(&x2, &y2); assert(is_tiles_adjacent(x1, y1, x2, y2)); if (!map_get_tile(x2, y2)->known) { - return COLOR_STD_BLACK; + return 0; } pos2_is_in_city_radius = @@ -494,16 +496,36 @@ city_tile_type2 = C_TILE_UNAVAILABLE; } - if (!pos1_is_in_city_radius && !pos2_is_in_city_radius) { - return COLOR_STD_BLACK; - } - get_worker_on_map_position(x1, y1, &city_tile_type1, &dummy_pcity); - if (city_tile_type1 == C_TILE_WORKER || city_tile_type2 == C_TILE_WORKER) { - return COLOR_STD_RED; +#define NORMAL(a, b) ((a) || (b)) +#define MERGE(a, b) (((a) || (b)) && !((a) && (b))) +#define MATCH(merge, a, b) (((merge) && MERGE((a), (b))) || \ + (!(merge) && NORMAL((a), (b)))) + + if (draw_used_tiles && MATCH(draw_merge_grid_tiles, + city_tile_type1 == C_TILE_WORKER, + city_tile_type2 == C_TILE_WORKER)) { + *color = COLOR_STD_RED; + return 1; + } + + if (draw_city_outline && MATCH(draw_merge_grid_tiles, + pos1_is_in_city_radius, + pos2_is_in_city_radius)) { + *color = COLOR_STD_WHITE; + return 1; + } + +#undef NORMAL +#undef MERGE +#undef MATCH + + if (draw_base_map_grid) { + *color = COLOR_STD_BLACK; + return 1; } else { - return COLOR_STD_WHITE; + return 0; } } Index: client/climisc.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/climisc.h,v retrieving revision 1.23 diff -u -r1.23 climisc.h --- client/climisc.h 2001/09/19 18:48:46 1.23 +++ client/climisc.h 2001/09/22 14:26:45 @@ -13,6 +13,8 @@ #ifndef FC__CLIMISC_H #define FC__CLIMISC_H +#include "colors_g.h" + struct city; struct Clause; typedef int cid; @@ -36,7 +38,7 @@ int client_warming_sprite(void); int client_cooling_sprite(void); -enum color_std get_grid_color(int x1, int y1, int x2, int y2); +int get_grid_color(int x1, int y1, int x2, int y2, enum color_std *color); void center_on_something(void); Index: client/control.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/control.c,v retrieving revision 1.60 diff -u -r1.60 control.c --- client/control.c 2001/09/15 15:31:19 1.60 +++ client/control.c 2001/09/22 14:26:46 @@ -845,13 +845,50 @@ } /************************************************************************** - Toggle display of grid lines on the map + Toggle display of black grid lines on the map **************************************************************************/ -void request_toggle_map_grid(void) +void request_toggle_base_map_grid(void) { - if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) return; + if (get_client_state() != CLIENT_GAME_RUNNING_STATE) + return; + + draw_base_map_grid ^= 1; + update_map_canvas_visible(); +} + +/************************************************************************** + Toggle display of tiles which can be used by a city on the map +**************************************************************************/ +void request_toggle_city_outline(void) +{ + if (get_client_state() != CLIENT_GAME_RUNNING_STATE) + return; + + draw_city_outline ^= 1; + update_map_canvas_visible(); +} + +/************************************************************************** + Toggle display of tiles which are used by a city on the map +**************************************************************************/ +void request_toggle_used_tiles(void) +{ + if (get_client_state() != CLIENT_GAME_RUNNING_STATE) + return; + + draw_used_tiles ^= 1; + update_map_canvas_visible(); +} + +/************************************************************************** + Toggle the merging of tiles on the map +**************************************************************************/ +void request_toggle_merge_tiles(void) +{ + if (get_client_state() != CLIENT_GAME_RUNNING_STATE) + return; - draw_map_grid^=1; + draw_merge_grid_tiles ^= 1; update_map_canvas_visible(); } @@ -1464,12 +1501,37 @@ set_turn_done_button_state(FALSE); } } + +/************************************************************************** +... +**************************************************************************/ +void key_base_map_grid_toggle(void) +{ + request_toggle_base_map_grid(); +} + +/************************************************************************** +... +**************************************************************************/ +void key_show_city_outline_toggle(void) +{ + request_toggle_city_outline(); +} + +/************************************************************************** +... +**************************************************************************/ +void key_show_used_tiles_toggle(void) +{ + request_toggle_used_tiles(); +} + /************************************************************************** ... **************************************************************************/ -void key_map_grid_toggle(void) +void key_merge_grid_tiles_toggle(void) { - request_toggle_map_grid(); + request_toggle_merge_tiles(); } /************************************************************************** Index: client/control.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/control.h,v retrieving revision 1.23 diff -u -r1.23 control.h --- client/control.h 2001/06/23 20:33:35 1.23 +++ client/control.h 2001/09/22 14:26:46 @@ -63,7 +63,10 @@ void request_unit_upgrade(struct unit *punit); void request_unit_wait(struct unit *punit); void request_unit_wakeup(struct unit *punit); -void request_toggle_map_grid(void); +void request_toggle_base_map_grid(void); +void request_toggle_city_outline(void); +void request_toggle_used_tiles(void); +void request_toggle_merge_tiles(void); void request_toggle_city_names(void); void request_toggle_city_productions(void); void request_toggle_terrain(void); @@ -112,7 +115,10 @@ void key_focus_unit_toggle(void); void key_fog_of_war_toggle(void); void key_end_turn(void); -void key_map_grid_toggle(void); +void key_base_map_grid_toggle(void); +void key_show_city_outline_toggle(void); +void key_show_used_tiles_toggle(void); +void key_merge_grid_tiles_toggle(void); void key_move_north(void); void key_move_north_east(void); void key_move_east(void); Index: client/options.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/options.c,v retrieving revision 1.42 diff -u -r1.42 options.c --- client/options.c 2001/09/08 21:33:49 1.42 +++ client/options.c 2001/09/22 14:26:46 @@ -72,7 +72,10 @@ /** View Options: **/ -int draw_map_grid=0; +int draw_base_map_grid = 0; +int draw_city_outline = 0; +int draw_used_tiles = 0; +int draw_merge_grid_tiles = 0; int draw_city_names=1; int draw_city_productions=0; int draw_terrain=1; @@ -92,7 +95,10 @@ #define VIEW_OPTION_TERMINATOR { NULL, NULL } view_option view_options[] = { - VIEW_OPTION(draw_map_grid), + VIEW_OPTION(draw_base_map_grid), + VIEW_OPTION(draw_city_outline), + VIEW_OPTION(draw_used_tiles), + VIEW_OPTION(draw_merge_grid_tiles), VIEW_OPTION(draw_city_names), VIEW_OPTION(draw_city_productions), VIEW_OPTION(draw_terrain), Index: client/options.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/options.h,v retrieving revision 1.10 diff -u -r1.10 options.h --- client/options.h 2001/02/06 20:30:58 1.10 +++ client/options.h 2001/09/22 14:26:47 @@ -47,7 +47,10 @@ /** View Options: **/ -extern int draw_map_grid; +extern int draw_base_map_grid; +extern int draw_city_outline; +extern int draw_used_tiles; +extern int draw_merge_grid_tiles; extern int draw_city_names; extern int draw_city_productions; extern int draw_terrain; Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.191 diff -u -r1.191 packhand.c --- client/packhand.c 2001/09/16 18:49:44 1.191 +++ client/packhand.c 2001/09/22 14:26:49 @@ -453,8 +453,8 @@ } } - if(draw_map_grid && - is_new && get_client_state()==CLIENT_GAME_RUNNING_STATE) { + if ((draw_base_map_grid || draw_city_outline || draw_used_tiles) && + is_new && get_client_state() == CLIENT_GAME_RUNNING_STATE) { /* just to update grid; slow, but doesn't happen very often --jjm */ int r = ((CITY_MAP_SIZE + 1) / 2); int d = (2 * r) + 1; Index: client/gui-gtk/mapview.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v retrieving revision 1.98 diff -u -r1.98 mapview.c --- client/gui-gtk/mapview.c 2001/09/15 21:25:07 1.98 +++ client/gui-gtk/mapview.c 2001/09/22 14:26:51 @@ -181,20 +181,22 @@ } } - if (draw_map_grid && !citymode) { + if (!citymode) { + enum color_std color; + /* left side... */ - gdk_gc_set_foreground(civ_gc, - colors_standard[get_grid_color - (x, y, x - 1, y)]); - gdk_draw_line(pm, civ_gc, canvas_x, canvas_y, canvas_x, - canvas_y + NORMAL_TILE_HEIGHT); + if (get_grid_color(x, y, x - 1, y, &color)) { + gdk_gc_set_foreground(civ_gc, colors_standard[color]); + gdk_draw_line(pm, civ_gc, canvas_x, canvas_y, canvas_x, + canvas_y + NORMAL_TILE_HEIGHT); + } /* top side... */ - gdk_gc_set_foreground(civ_gc, - colors_standard[get_grid_color - (x, y, x, y - 1)]); - gdk_draw_line(pm, civ_gc, canvas_x, canvas_y, - canvas_x + NORMAL_TILE_WIDTH, canvas_y); + if (get_grid_color(x, y, x, y - 1, &color)) { + gdk_gc_set_foreground(civ_gc, colors_standard[color]); + gdk_draw_line(pm, civ_gc, canvas_x, canvas_y, + canvas_x + NORMAL_TILE_WIDTH, canvas_y); + } } if (draw_coastline && !draw_terrain) { @@ -2340,23 +2342,26 @@ } /*** Map grid ***/ - if (draw_map_grid) { - /* we draw the 2 lines on top of the tile; the buttom lines will be - drawn by the tiles underneath. */ - if (draw & D_M_R) { - gdk_gc_set_foreground(thin_line_gc, - colors_standard[get_grid_color - (x, y, x, y - 1)]); + + /* we draw the 2 lines on top of the tile; the buttom lines will be + drawn by the tiles underneath. */ + if (draw & D_M_R) { + enum color_std color; + + if (get_grid_color(x, y, x, y - 1, &color)) { + gdk_gc_set_foreground(thin_line_gc, colors_standard[color]); gdk_draw_line(pm, thin_line_gc, canvas_x + NORMAL_TILE_WIDTH / 2, canvas_y, canvas_x + NORMAL_TILE_WIDTH, canvas_y + NORMAL_TILE_HEIGHT / 2); } + } + + if (draw & D_M_L) { + enum color_std color; - if (draw & D_M_L) { - gdk_gc_set_foreground(thin_line_gc, - colors_standard[get_grid_color - (x, y, x - 1, y)]); + if (get_grid_color(x, y, x - 1, y, &color)) { + gdk_gc_set_foreground(thin_line_gc, colors_standard[color]); gdk_draw_line(pm, thin_line_gc, canvas_x, canvas_y + NORMAL_TILE_HEIGHT / 2, canvas_x + NORMAL_TILE_WIDTH / 2, canvas_y); Index: client/gui-gtk/menu.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/menu.c,v retrieving revision 1.58 diff -u -r1.58 menu.c --- client/gui-gtk/menu.c 2001/09/15 15:31:20 1.58 +++ client/gui-gtk/menu.c 2001/09/22 14:26:52 @@ -78,7 +78,10 @@ MENU_KINGDOM_WORKLISTS, MENU_KINGDOM_REVOLUTION, - MENU_VIEW_SHOW_MAP_GRID, + MENU_VIEW_SHOW_BASE_MAP_GRID, + MENU_VIEW_SHOW_CITY_OUTLINE, + MENU_VIEW_SHOW_USED_TILES, + MENU_VIEW_MERGE_GRID_TILES, MENU_VIEW_SHOW_CITY_NAMES, MENU_VIEW_SHOW_CITY_PRODUCTIONS, MENU_VIEW_SHOW_TERRAIN, @@ -221,9 +224,21 @@ GtkWidget *widget) { switch(callback_action) { - case MENU_VIEW_SHOW_MAP_GRID: - if (draw_map_grid ^ GTK_CHECK_MENU_ITEM(widget)->active) - key_map_grid_toggle(); + case MENU_VIEW_SHOW_BASE_MAP_GRID: + if (draw_base_map_grid ^ GTK_CHECK_MENU_ITEM(widget)->active) + key_base_map_grid_toggle(); + break; + case MENU_VIEW_SHOW_CITY_OUTLINE: + if (draw_city_outline ^ GTK_CHECK_MENU_ITEM(widget)->active) + key_show_city_outline_toggle(); + break; + case MENU_VIEW_SHOW_USED_TILES: + if (draw_used_tiles ^ GTK_CHECK_MENU_ITEM(widget)->active) + key_show_used_tiles_toggle(); + break; + case MENU_VIEW_MERGE_GRID_TILES: + if (draw_merge_grid_tiles ^ GTK_CHECK_MENU_ITEM(widget)->active) + key_merge_grid_tiles_toggle(); break; case MENU_VIEW_SHOW_CITY_NAMES: if (draw_city_names ^ GTK_CHECK_MENU_ITEM(widget)->active) @@ -588,8 +603,14 @@ NULL, 0, "" }, { "/" N_("View") "/tearoff1", NULL, NULL, 0, "" }, - { "/" N_("View") "/" N_("Map _Grid"), "g", - view_menu_callback, MENU_VIEW_SHOW_MAP_GRID, "" }, + { "/" N_("View") "/" N_("Base Map _Grid"), "g", + view_menu_callback, MENU_VIEW_SHOW_BASE_MAP_GRID, "" }, + { "/" N_("View") "/" N_("City Outlines"), NULL, + view_menu_callback, MENU_VIEW_SHOW_CITY_OUTLINE, "" }, + { "/" N_("View") "/" N_("Used Tiles"), NULL, + view_menu_callback, MENU_VIEW_SHOW_USED_TILES, "" }, + { "/" N_("View") "/" N_("Merge Map Tiles"), NULL, + view_menu_callback, MENU_VIEW_MERGE_GRID_TILES, "" }, { "/" N_("View") "/" N_("City _Names"), "n", view_menu_callback, MENU_VIEW_SHOW_CITY_NAMES, "" }, { "/" N_("View") "/" N_("City _Productions"), "p", @@ -964,7 +985,10 @@ menus_set_sensitive("
/_Reports/S_paceship", (game.player_ptr->spaceship.state!=SSHIP_NONE)); - menus_set_active("
/_View/Map _Grid", draw_map_grid); + menus_set_active("
/_View/Base Map _Grid", draw_base_map_grid); + menus_set_active("
/_View/City Outlines", draw_city_outline); + menus_set_active("
/_View/Used Tiles", draw_used_tiles); + menus_set_active("
/_View/Merge Map Tiles", draw_merge_grid_tiles); menus_set_active("
/_View/City _Names", draw_city_names); menus_set_active("
/_View/City _Productions", draw_city_productions); menus_set_active("
/_View/Terrain", draw_terrain);