<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40213 >
[EMAIL PROTECTED] - So 20. Jul 2008, 18:15:03] Since there hasn't been done anything here for a month I assumed that this would be an ideal training ground for newbies. ;) I tried to supply an option for the view menu in the same manner as all the other options have been coded before. However, I don't really understand the necessarity for the key_x_toggle() wrapper function, when you could just use directly the request_toggle_x() function in control.c. Yet I still used the same way arround for I may be too stupid to understand this. :D Also I used the key combo "<ctrl> + t" instead of only "t", since all the other view options are also using the <ctrl> modifier. This patch only works for the GTK client, but should be addaptable for other clients.
diff -NurX.diff_ignore trunk/client/control.c changed/client/control.c --- trunk/client/control.c 2008-07-20 13:05:16.000000000 +0200 +++ changed/client/control.c 2008-07-20 20:01:06.000000000 +0200 @@ -1598,6 +1598,19 @@ } /************************************************************************** + Toggle display of worker output of cities on the map +**************************************************************************/ +void request_toggle_city_output(void) +{ + if (!can_client_change_view()) { + return; + } + + draw_city_output = !draw_city_output; + update_map_canvas_visible(); +} + +/************************************************************************** Toggle display of grid lines on the map **************************************************************************/ void request_toggle_map_grid(void) @@ -2691,6 +2704,14 @@ } /************************************************************************** + Toggle drawing of city output produced by workers of the city. +**************************************************************************/ +void key_city_output_toggle(void) +{ + request_toggle_city_output(); +} + +/************************************************************************** ... **************************************************************************/ void key_map_grid_toggle(void) diff -NurX.diff_ignore trunk/client/control.h changed/client/control.h --- trunk/client/control.h 2008-07-20 13:05:16.000000000 +0200 +++ changed/client/control.h 2008-07-20 19:59:17.000000000 +0200 @@ -92,6 +92,7 @@ void request_diplomat_action(enum diplomat_actions action, int dipl_id, int target_id, int value); void request_toggle_city_outlines(void); +void request_toggle_city_output(void); void request_toggle_map_grid(void); void request_toggle_map_borders(void); void request_toggle_city_names(void); @@ -155,6 +156,7 @@ void key_fog_of_war_toggle(void); void key_end_turn(void); void key_city_outlines_toggle(void); +void key_city_output_toggle(void); void key_map_grid_toggle(void); void key_map_borders_toggle(void); void key_recall_previous_focus_unit(void); diff -NurX.diff_ignore trunk/client/gui-gtk-2.0/menu.c changed/client/gui-gtk-2.0/menu.c --- trunk/client/gui-gtk-2.0/menu.c 2008-07-20 13:05:05.000000000 +0200 +++ changed/client/gui-gtk-2.0/menu.c 2008-07-20 20:06:34.000000000 +0200 @@ -100,6 +100,7 @@ MENU_GOVERNMENT_REVOLUTION, MENU_VIEW_SHOW_CITY_OUTLINES, + MENU_VIEW_SHOW_CITY_OUTPUT, MENU_VIEW_SHOW_MAP_GRID, MENU_VIEW_SHOW_NATIONAL_BORDERS, MENU_VIEW_SHOW_CITY_NAMES, @@ -310,6 +311,11 @@ key_city_outlines_toggle(); } break; + case MENU_VIEW_SHOW_CITY_OUTPUT: + if(draw_city_output ^ GTK_CHECK_MENU_ITEM(widget)->active) { + key_city_output_toggle(); + } + break; case MENU_VIEW_SHOW_MAP_GRID: if (draw_map_grid ^ GTK_CHECK_MENU_ITEM(widget)->active) key_map_grid_toggle(); @@ -816,6 +822,8 @@ NULL, 0, "<Tearoff>" }, { "/" N_("View") "/" N_("City Outlines"), "<control>y", view_menu_callback, MENU_VIEW_SHOW_CITY_OUTLINES, "<CheckItem>"}, + { "/" N_("View") "/" N_("City Output"), "<control>t", + view_menu_callback, MENU_VIEW_SHOW_CITY_OUTPUT, "<CheckItem>"}, { "/" N_("View") "/" N_("Map _Grid"), "<control>g", view_menu_callback, MENU_VIEW_SHOW_MAP_GRID, "<CheckItem>" }, { "/" N_("View") "/" N_("National _Borders"), "<control>b", @@ -1423,6 +1431,7 @@ && SSHIP_NONE != client.conn.playing->spaceship.state)); menus_set_active("<main>/_View/City Outlines", draw_city_outlines); + menus_set_active("<main>/_View/City Output", draw_city_output); menus_set_active("<main>/_View/Map _Grid", draw_map_grid); menus_set_sensitive("<main>/_View/National _Borders", game.info.borders > 0); menus_set_active("<main>/_View/National _Borders", draw_borders); diff -NurX.diff_ignore trunk/client/options.c changed/client/options.c --- trunk/client/options.c 2008-07-20 13:05:16.000000000 +0200 +++ changed/client/options.c 2008-07-20 20:09:28.000000000 +0200 @@ -281,6 +281,7 @@ /** View Options: **/ bool draw_city_outlines = TRUE; +bool draw_city_output = FALSE; bool draw_map_grid = FALSE; bool draw_city_names = TRUE; bool draw_city_growth = TRUE; @@ -308,6 +309,7 @@ view_option view_options[] = { VIEW_OPTION(draw_city_outlines), + VIEW_OPTION(draw_city_output), VIEW_OPTION(draw_map_grid), VIEW_OPTION(draw_city_names), VIEW_OPTION(draw_city_growth), diff -NurX.diff_ignore trunk/client/options.h changed/client/options.h --- trunk/client/options.h 2008-07-20 13:05:16.000000000 +0200 +++ changed/client/options.h 2008-07-20 20:07:19.000000000 +0200 @@ -143,6 +143,7 @@ /** View Options: **/ extern bool draw_city_outlines; +extern bool draw_city_output; extern bool draw_map_grid; extern bool draw_city_names; extern bool draw_city_growth; diff -NurX.diff_ignore trunk/client/tilespec.c changed/client/tilespec.c --- trunk/client/tilespec.c 2008-07-20 13:05:16.000000000 +0200 +++ changed/client/tilespec.c 2008-07-20 20:02:44.000000000 +0200 @@ -3653,7 +3653,8 @@ } else if (city_can_work_tile(pcity, ptile)) { ADD_SPRITE_SIMPLE(t->sprites.city.unworked_tile_overlay.p[index]); } - } else if (NULL != pwork && pwork == pcity) { + } else if (NULL != pwork && pwork == pcity + && (citymode || draw_city_output)) { /* Add on the tile output sprites. */ int food = city_tile_output_now(pcity, ptile, O_FOOD); int shields = city_tile_output_now(pcity, ptile, O_SHIELD);
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev