<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40447 >
> [nicorwadh - Fri Aug 29 00:20:14 2008]: > > Attached patch incorporates the previous patches of > this ticket and adds an extra checkbox entry to the "map > options" dialog for this option. Additionally I made a > minor update to the doc referring to the different shortcut > key combos of this and #40458. There was a minor mistake in the SDL shortcut code (RCTRL instead of RSHIFT) which I have fixed in the attached version 3. Also, the citybar is now updated when traderoute information arrives (such as when a traderoute is established). > Am Sonntag, 24. August 2008 20:33:06 schrieb Madeline Book: > > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=40447 > > > > Maybe there is a list of shortcuts > > > mandatory for all clients available in the documentation? > > > > None that I know of. It would be a good idea to create such > > a page in the wiki though. It should be according to the gtk > > client, and the other guis made to follow it. > > Well. I can't find any such list on the wikia as well, just > I dunno how to create a new page for this. Maybe you need > to have an account on wikia for this? I don't really have a > sensible explenation for not signing up there except that > I just hate the idea of giving my (yet still spam free) > e- mail address to a comercial web host. Maybe you would > be so kind to create such a page? I'd add my input there > later as anonymus guest account seems to be enabled. I created http://freeciv.wikia.com/wiki/Keyboard_Reference but it is almost completely empty at the moment. Nor could I think of a pleasing format for such a table(s) of keyboard shortcuts. How does one create tables in the wiki? Hmm :| ---------------------------------------------------------------------- そういう話だった。
client/control.c | 22 ++++++ client/control.h | 2 + client/gui-gtk-2.0/menu.c | 14 ++++- client/gui-sdl/gui_id.h | 2 + client/gui-sdl/mapctrl.c | 9 ++- client/gui-sdl/optiondlg.c | 95 ++++++++++++++++++------- client/mapview_common.c | 166 ++++++++++++++++++++++++++++++++++++++------ client/mapview_common.h | 4 + client/options.c | 2 + client/options.h | 1 + client/packhand.c | 12 +++- client/tilespec.c | 1 + client/tilespec.h | 1 + data/misc/citybar.png | Bin 2852 -> 2721 bytes data/misc/citybar.spec | 2 + doc/README.SDLClient | 6 +- 16 files changed, 284 insertions(+), 55 deletions(-) diff --git a/client/control.c b/client/control.c index e2f7c92..c655548 100644 --- a/client/control.c +++ b/client/control.c @@ -1697,6 +1697,19 @@ void request_toggle_city_productions(void) } /************************************************************************** + Toggle display of city traderoutes +**************************************************************************/ +void request_toggle_city_traderoutes(void) +{ + if (!can_client_change_view()) { + return; + } + + draw_city_traderoutes ^= 1; + update_map_canvas_visible(); +} + +/************************************************************************** Toggle display of terrain **************************************************************************/ void request_toggle_terrain(void) @@ -2774,6 +2787,15 @@ void key_city_productions_toggle(void) } /************************************************************************** + Handle client request to toggle drawing of traderoute information + by the city name for cities visible on the main map view. +**************************************************************************/ +void key_city_traderoutes_toggle(void) +{ + request_toggle_city_traderoutes(); +} + +/************************************************************************** ... **************************************************************************/ void key_terrain_toggle(void) diff --git a/client/control.h b/client/control.h index ffc6257..59e7d8c 100644 --- a/client/control.h +++ b/client/control.h @@ -100,6 +100,7 @@ void request_toggle_map_borders(void); void request_toggle_city_names(void); void request_toggle_city_growth(void); void request_toggle_city_productions(void); +void request_toggle_city_traderoutes(void); void request_toggle_terrain(void); void request_toggle_coastline(void); void request_toggle_roads_rails(void); @@ -144,6 +145,7 @@ void key_center_capital(void); void key_city_names_toggle(void); void key_city_growth_toggle(void); void key_city_productions_toggle(void); +void key_city_traderoutes_toggle(void); void key_terrain_toggle(void); void key_coastline_toggle(void); void key_roads_rails_toggle(void); diff --git a/client/gui-gtk-2.0/menu.c b/client/gui-gtk-2.0/menu.c index 1db317c..e111f1d 100644 --- a/client/gui-gtk-2.0/menu.c +++ b/client/gui-gtk-2.0/menu.c @@ -106,6 +106,7 @@ enum MenuID { MENU_VIEW_SHOW_CITY_NAMES, MENU_VIEW_SHOW_CITY_GROWTH_TURNS, MENU_VIEW_SHOW_CITY_PRODUCTIONS, + MENU_VIEW_SHOW_CITY_TRADEROUTES, MENU_VIEW_SHOW_TERRAIN, MENU_VIEW_SHOW_COASTLINE, MENU_VIEW_SHOW_ROADS_RAILS, @@ -334,6 +335,7 @@ static void view_menu_callback(gpointer callback_data, guint callback_action, * city name), can draw the city growth even without drawing * the city name. But the old method cannot. */ menus_set_sensitive("<main>/_View/City G_rowth", draw_city_names); + menus_set_sensitive("<main>/_View/City _Traderoutes", draw_city_names); } } break; @@ -345,6 +347,11 @@ static void view_menu_callback(gpointer callback_data, guint callback_action, if (draw_city_productions ^ GTK_CHECK_MENU_ITEM(widget)->active) key_city_productions_toggle(); break; + case MENU_VIEW_SHOW_CITY_TRADEROUTES: + if (draw_city_traderoutes ^ GTK_CHECK_MENU_ITEM(widget)->active) { + key_city_traderoutes_toggle(); + } + break; case MENU_VIEW_SHOW_TERRAIN: if (draw_terrain ^ GTK_CHECK_MENU_ITEM(widget)->active) { key_terrain_toggle(); @@ -822,7 +829,7 @@ static GtkItemFactoryEntry menu_items[] = 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", + { "/" N_("View") "/" N_("City Output"), "<control>w", 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>" }, @@ -835,6 +842,8 @@ static GtkItemFactoryEntry menu_items[] = "<CheckItem>" }, { "/" N_("View") "/" N_("City _Productions"), "<control>p", view_menu_callback, MENU_VIEW_SHOW_CITY_PRODUCTIONS, "<CheckItem>" }, + { "/" N_("View") "/" N_("City _Traderoutes"), "<control>t", + view_menu_callback, MENU_VIEW_SHOW_CITY_TRADEROUTES, "<CheckItem>" }, { "/" N_("View") "/sep1", NULL, NULL, 0, "<Separator>" }, { "/" N_("View") "/" N_("Terrain"), NULL, @@ -1443,12 +1452,15 @@ void update_menus(void) * the city name. But the old method cannot. */ if (draw_full_citybar) { menus_set_sensitive("<main>/_View/City G_rowth", TRUE); + menus_set_sensitive("<main>/_View/City _Traderoutes", TRUE); } else { menus_set_sensitive("<main>/_View/City G_rowth", draw_city_names); + menus_set_sensitive("<main>/_View/City _Traderoutes", draw_city_names); } menus_set_active("<main>/_View/City G_rowth", draw_city_growth); menus_set_active("<main>/_View/City _Productions", draw_city_productions); + menus_set_active("<main>/_View/City _Traderoutes", draw_city_traderoutes); menus_set_active("<main>/_View/Terrain", draw_terrain); menus_set_active("<main>/_View/Coastline", draw_coastline); menus_set_sensitive("<main>/_View/Coastline", !draw_terrain); diff --git a/client/gui-sdl/gui_id.h b/client/gui-sdl/gui_id.h index 2e4268e..fca878f 100644 --- a/client/gui-sdl/gui_id.h +++ b/client/gui-sdl/gui_id.h @@ -98,6 +98,8 @@ enum GUI_ID { ID_OPTIONS_MAP_CITY_PROD_CHECKBOX, ID_OPTIONS_MAP_CITY_OUTPUT_CHECKBOX, ID_OPTIONS_MAP_CITY_OUTPUT_LABEL, + ID_OPTIONS_MAP_CITY_TRADEROUTES_CHECKBOX, + ID_OPTIONS_MAP_CITY_TRADEROUTES_LABEL, ID_OPTIONS_MAP_BORDERS_CHECKBOX, ID_OPTIONS_MAP_BORDERS_LABEL, ID_OPTIONS_MAP_CITY_CIV3_TEXT_STYLE_LABEL, diff --git a/client/gui-sdl/mapctrl.c b/client/gui-sdl/mapctrl.c index 75f3bfb..45232b3 100644 --- a/client/gui-sdl/mapctrl.c +++ b/client/gui-sdl/mapctrl.c @@ -2375,10 +2375,15 @@ bool map_event_handler(SDL_keysym Key) /* *** some additional shortcuts that work in the SDL client only *** */ - /* show terrain - Ctrl+t */ + /* show city traderoutes - Ctrl+t + * show terrain - Ctrl+Shift+t */ case SDLK_t: if (LCTRL || RCTRL) { - key_terrain_toggle(); + if (LSHIFT || RSHIFT) { + key_terrain_toggle(); + } else { + key_city_traderoutes_toggle(); + } } return FALSE; diff --git a/client/gui-sdl/optiondlg.c b/client/gui-sdl/optiondlg.c index c470bd9..4f04066 100644 --- a/client/gui-sdl/optiondlg.c +++ b/client/gui-sdl/optiondlg.c @@ -1316,6 +1316,20 @@ static int draw_city_output_callback(struct widget *pWidget) /************************************************************************** ... **************************************************************************/ +static int draw_city_traderoutes_callback(struct widget *pWidget) +{ + if (Main.event.button.button == SDL_BUTTON_LEFT) { + widget_redraw(pWidget); + widget_flush(pWidget); + draw_city_traderoutes ^= 1; + update_map_canvas_visible(); + } + return -1; +} + +/************************************************************************** + ... +**************************************************************************/ static int borders_callback(struct widget *pWidget) { if (Main.event.button.button == SDL_BUTTON_LEFT) { @@ -1632,6 +1646,33 @@ static int map_setting_callback(struct widget *pWidget) ((pTmpGui->next->size.h - pTmpGui->size.h) / 2); + /* 'show city traderoutes' */ + /* check box */ + pTmpGui = create_checkbox(pWindow->dst, draw_city_traderoutes, + WF_RESTORE_BACKGROUND); + + pTmpGui->action = draw_city_traderoutes_callback; + set_wstate(pTmpGui, FC_WS_NORMAL); + + pTmpGui->size.x = pWindow->size.x + adj_size(15); + + add_to_gui_list(ID_OPTIONS_MAP_CITY_TRADEROUTES_CHECKBOX, pTmpGui); + pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + adj_size(4); + + /* label */ + pStr = create_str16_from_char(_("City Traderoutes"), adj_font(10)); + pStr->style |= TTF_STYLE_BOLD; + pStr->fgcol = text_color; + pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0); + + pTmpGui->size.x = pWindow->size.x + adj_size(55); + + add_to_gui_list(ID_OPTIONS_MAP_CITY_TRADEROUTES_LABEL, pTmpGui); + + pTmpGui->size.y = pTmpGui->next->size.y + + ((pTmpGui->next->size.h - pTmpGui->size.h) / 2); + + /* 'draw borders' */ /* check box */ pTmpGui = create_checkbox(pWindow->dst, draw_borders, @@ -1875,33 +1916,7 @@ static int map_setting_callback(struct widget *pWidget) pTmpGui->size.y = pTmpGui->next->size.y + (pTmpGui->next->size.h - pTmpGui->size.h) / 2; - - /* 'draw fog of war' */ - - /* check box */ - pTmpGui = create_checkbox(pWindow->dst, - draw_fog_of_war, WF_RESTORE_BACKGROUND); - - pTmpGui->action = draw_fog_of_war_callback; - set_wstate(pTmpGui, FC_WS_NORMAL); - - pTmpGui->size.x = pWindow->size.x + adj_size(15); - - add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_FOG_CHECKBOX, pTmpGui); - pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + adj_size(3); - - /* label */ - pStr = create_str16_from_char(_("Fog of War"), adj_font(10)); - pStr->style |= TTF_STYLE_BOLD; - pStr->fgcol = text_color; - pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0); - pTmpGui->size.x = pWindow->size.x + adj_size(55); - - add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_FOG_LABEL, pTmpGui); - - pTmpGui->size.y = pTmpGui->next->size.y + - (pTmpGui->next->size.h - pTmpGui->size.h) / 2; /* 'draw road / rails' */ /* check box */ @@ -2007,6 +2022,34 @@ static int map_setting_callback(struct widget *pWidget) pTmpGui->size.y = pTmpGui->next->size.y + (pTmpGui->next->size.h - pTmpGui->size.h) / 2; + + /* 'draw fog of war' */ + + /* check box */ + pTmpGui = create_checkbox(pWindow->dst, + draw_fog_of_war, WF_RESTORE_BACKGROUND); + + pTmpGui->action = draw_fog_of_war_callback; + set_wstate(pTmpGui, FC_WS_NORMAL); + + pTmpGui->size.x = pWindow->size.x + adj_size(170); + + add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_FOG_CHECKBOX, pTmpGui); + pTmpGui->size.y = pTmpGui->next->next->size.y + pTmpGui->size.h + adj_size(4); + + /* label */ + pStr = create_str16_from_char(_("Fog of War"), adj_font(10)); + pStr->style |= TTF_STYLE_BOLD; + pStr->fgcol = text_color; + pTmpGui = create_iconlabel(NULL, pWindow->dst, pStr, 0); + + pTmpGui->size.x = pWindow->size.x + adj_size(210); + + add_to_gui_list(ID_OPTIONS_MAP_TERRAIN_FOG_LABEL, pTmpGui); + + pTmpGui->size.y = pTmpGui->next->size.y + + (pTmpGui->next->size.h - pTmpGui->size.h) / 2; + #if 0 /* Civ3 / Classic CITY Text Style */ diff --git a/client/mapview_common.c b/client/mapview_common.c index 52857f3..475dce1 100644 --- a/client/mapview_common.c +++ b/client/mapview_common.c @@ -1223,15 +1223,16 @@ static void show_full_citybar(struct canvas *pcanvas, struct city *pcity, int *width, int *height) { const struct citybar_sprites *citybar = get_citybar_sprites(tileset); - static char name[512], growth[32], prod[512], size[32]; - enum color_std growth_color; + static char name[512], growth[32], prod[512], size[32], traderoutes[32]; + enum color_std growth_color, traderoutes_color; struct color *owner_color; struct { int x, y, w, h; } name_rect = {0, 0, 0, 0}, growth_rect = {0, 0, 0, 0}, prod_rect = {0, 0, 0, 0}, size_rect = {0, 0, 0, 0}, flag_rect = {0, 0, 0, 0}, occupy_rect = {0, 0, 0, 0}, - food_rect = {0, 0, 0, 0}, shield_rect = {0, 0, 0, 0}; + food_rect = {0, 0, 0, 0}, shield_rect = {0, 0, 0, 0}, + traderoutes_rect = {0,}, trade_rect = {0,}; int width1 = 0, width2 = 0, height1 = 0, height2 = 0; struct sprite *bg = citybar->background; struct sprite *flag = get_city_flag_sprite(tileset, pcity); @@ -1250,8 +1251,11 @@ static void show_full_citybar(struct canvas *pcanvas, const bool should_draw_productions = can_see_inside && draw_city_productions; const bool should_draw_growth = can_see_inside && draw_city_growth; + const bool should_draw_traderoutes = can_see_inside + && draw_city_traderoutes; const bool should_draw_lower_bar - = should_draw_productions || should_draw_growth; + = should_draw_productions || should_draw_growth + || should_draw_traderoutes; if (width != NULL) { @@ -1303,25 +1307,38 @@ static void show_full_citybar(struct canvas *pcanvas, } if (should_draw_lower_bar) { + width2 = 0; + height2 = 0; if (should_draw_productions) { get_city_mapview_production(pcity, prod, sizeof(prod)); get_text_size(&prod_rect.w, &prod_rect.h, FONT_CITY_PROD, prod); get_sprite_dimensions(citybar->shields, &shield_rect.w, &shield_rect.h); + width2 += shield_rect.w + prod_rect.w + border; + height2 = MAX(height2, shield_rect.h); + height2 = MAX(height2, prod_rect.h + border); } if (should_draw_growth) { get_text_size(&growth_rect.w, &growth_rect.h, FONT_CITY_PROD, growth); get_sprite_dimensions(citybar->food, &food_rect.w, &food_rect.h); + width2 += food_rect.w + growth_rect.w + border; + height2 = MAX(height2, food_rect.h); + height2 = MAX(height2, growth_rect.h + border); } - width2 = (prod_rect.w + growth_rect.w + shield_rect.w + food_rect.w - + 2 * border); - height2 = MAX(shield_rect.h, - MAX(prod_rect.h + border, - MAX(growth_rect.h + border, - food_rect.h))); + if (should_draw_traderoutes) { + get_city_mapview_traderoutes(pcity, traderoutes, + sizeof(traderoutes), + &traderoutes_color); + get_text_size(&traderoutes_rect.w, &traderoutes_rect.h, + FONT_CITY_PROD, traderoutes); + get_sprite_dimensions(citybar->trade, &trade_rect.w, &trade_rect.h); + width2 += trade_rect.w + traderoutes_rect.w + border; + height2 = MAX(height2, trade_rect.h); + height2 = MAX(height2, traderoutes_rect.h + border); + } } *width = MAX(width1, width2); @@ -1354,8 +1371,23 @@ static void show_full_citybar(struct canvas *pcanvas, prod_rect.y = canvas_y + height1 + (height2 - prod_rect.h) / 2; } + if (should_draw_traderoutes) { + traderoutes_rect.x = canvas_x + (*width + 1) / 2 + - traderoutes_rect.w - border / 2; + traderoutes_rect.y = canvas_y + height1 + + (height2 - traderoutes_rect.h) / 2; + + trade_rect.x = traderoutes_rect.x - border / 2 - trade_rect.w; + trade_rect.y = canvas_y + height1 + (height2 - trade_rect.h) / 2; + } + if (should_draw_growth) { - growth_rect.x = canvas_x + (*width + 1) / 2 - growth_rect.w - border / 2; + growth_rect.x = canvas_x + (*width + 1) / 2 + - growth_rect.w - border / 2; + if (traderoutes_rect.w > 0) { + growth_rect.x = growth_rect.x + - traderoutes_rect.w - border / 2 - trade_rect.w - border / 2; + } growth_rect.y = canvas_y + height1 + (height2 - growth_rect.h) / 2; food_rect.x = growth_rect.x - border / 2 - food_rect.w; @@ -1405,6 +1437,14 @@ static void show_full_citybar(struct canvas *pcanvas, get_color(tileset, COLOR_MAPVIEW_CITYTEXT), prod); } + if (should_draw_traderoutes) { + canvas_put_sprite_full(pcanvas, trade_rect.x, trade_rect.y, + citybar->trade); + canvas_put_text(pcanvas, traderoutes_rect.x, traderoutes_rect.y, + FONT_CITY_PROD, + get_color(tileset, traderoutes_color), traderoutes); + } + if (should_draw_growth) { canvas_put_sprite_full(pcanvas, food_rect.x, food_rect.y, citybar->food); canvas_put_text(pcanvas, growth_rect.x, growth_rect.y, @@ -1445,13 +1485,14 @@ static void show_small_citybar(struct canvas *pcanvas, int canvas_x, int canvas_y, struct city *pcity, int *width, int *height) { - static char name[512], growth[32], prod[512]; - enum color_std growth_color; + static char name[512], growth[32], prod[512], traderoutes[32]; + enum color_std growth_color, traderoutes_color; struct { int x, y, w, h; } name_rect = {0, 0, 0, 0}, growth_rect = {0, 0, 0, 0}, - prod_rect = {0, 0, 0, 0}; - int extra_width = 0, total_width, total_height; + prod_rect = {0, 0, 0, 0}, traderoutes_rect = {0,}; + int total_width, total_height; + int spacer_width = 0; *width = *height = 0; @@ -1459,29 +1500,63 @@ static void show_small_citybar(struct canvas *pcanvas, canvas_y += tileset_citybar_offset_y(tileset); if (draw_city_names) { + int drawposx; + + /* HACK: put a character's worth of space between the two + * strings if needed. */ + get_text_size(&spacer_width, NULL, FONT_CITY_NAME, "M"); + + total_width = 0; + total_height = 0; + get_city_mapview_name_and_growth(pcity, name, sizeof(name), growth, sizeof(growth), &growth_color); get_text_size(&name_rect.w, &name_rect.h, FONT_CITY_NAME, name); + total_width += name_rect.w; + total_height = MAX(total_height, name_rect.h); if (draw_city_growth) { get_text_size(&growth_rect.w, &growth_rect.h, FONT_CITY_PROD, growth); - /* HACK: put a character's worth of space between the two strings. */ - get_text_size(&extra_width, NULL, FONT_CITY_NAME, "M"); + total_width += spacer_width + growth_rect.w; + total_height = MAX(total_height, growth_rect.h); + } + + if (draw_city_traderoutes) { + get_city_mapview_traderoutes(pcity, traderoutes, + sizeof(traderoutes), + &traderoutes_color); + get_text_size(&traderoutes_rect.w, &traderoutes_rect.h, + FONT_CITY_PROD, traderoutes); + total_width += spacer_width + traderoutes_rect.w; + total_height = MAX(total_height, traderoutes_rect.h); } - total_width = name_rect.w + extra_width + growth_rect.w; - total_height = MAX(name_rect.h, growth_rect.h); - canvas_put_text(pcanvas, - canvas_x - total_width / 2, canvas_y, + + drawposx = canvas_x; + drawposx -= total_width / 2; + canvas_put_text(pcanvas, drawposx, canvas_y, FONT_CITY_NAME, get_color(tileset, COLOR_MAPVIEW_CITYTEXT), name); + drawposx += name_rect.w; + if (draw_city_growth) { - canvas_put_text(pcanvas, - canvas_x - total_width / 2 + name_rect.w + extra_width, + drawposx += spacer_width; + canvas_put_text(pcanvas, drawposx, canvas_y + total_height - growth_rect.h, FONT_CITY_PROD, get_color(tileset, growth_color), growth); + drawposx += growth_rect.w; } + + if (draw_city_traderoutes) { + drawposx += spacer_width; + canvas_put_text(pcanvas, drawposx, + canvas_y + total_height - traderoutes_rect.h, + FONT_CITY_PROD, + get_color(tileset, traderoutes_color), traderoutes); + drawposx += traderoutes_rect.w; + } + canvas_y += total_height + 3; *width = MAX(*width, total_width); @@ -1986,6 +2061,51 @@ void get_city_mapview_production(struct city *pcity, } } +/************************************************************************** + Find the mapview city traderoutes text for the given city, and place it + into the buffer. Sets 'pcolor' to the preferred color the text should + be drawn in if it is non-NULL. +**************************************************************************/ +void get_city_mapview_traderoutes(struct city *pcity, + char *traderoutes_buffer, + size_t traderoutes_buffer_len, + enum color_std *pcolor) +{ + int num_traderoutes = 0, i; + + if (!traderoutes_buffer || traderoutes_buffer_len <= 0) { + return; + } + + if (!pcity) { + traderoutes_buffer[0] = '\0'; + if (pcolor) { + *pcolor = COLOR_MAPVIEW_CITYTEXT; + } + return; + } + + for (i = 0; i < NUM_TRADEROUTES; i++) { + if (pcity->trade[i] <= 0 && pcity->trade_value[i] <= 0) { + continue; + } + num_traderoutes++; + } + + my_snprintf(traderoutes_buffer, traderoutes_buffer_len, + "%d/%d", num_traderoutes, NUM_TRADEROUTES); + + if (pcolor) { + if (num_traderoutes == NUM_TRADEROUTES) { + *pcolor = COLOR_OVERVIEW_LAND; /* green */ + } else if (num_traderoutes == 0) { + *pcolor = COLOR_MAPVIEW_CITYGROWTH_BLOCKED; /* red */ + } else { + *pcolor = COLOR_MAPVIEW_SELECTION; /* yellow */ + } + } +} + /***************************************************************************/ static enum update_type needed_updates = UPDATE_NONE; static bool callback_queued = FALSE; diff --git a/client/mapview_common.h b/client/mapview_common.h index 6299a97..afee919 100644 --- a/client/mapview_common.h +++ b/client/mapview_common.h @@ -298,6 +298,10 @@ void get_city_mapview_name_and_growth(struct city *pcity, char *growth_buffer, size_t growth_buffer_len, enum color_std *grwoth_color); +void get_city_mapview_traderoutes(struct city *pcity, + char *traderoutes_buffer, + size_t traderoutes_buffer_len, + enum color_std *traderoutes_color); void init_mapview_decorations(void); bool map_canvas_resized(int width, int height); diff --git a/client/options.c b/client/options.c index bff38c8..55f44ae 100644 --- a/client/options.c +++ b/client/options.c @@ -300,6 +300,7 @@ bool draw_map_grid = FALSE; bool draw_city_names = TRUE; bool draw_city_growth = TRUE; bool draw_city_productions = FALSE; +bool draw_city_traderoutes = FALSE; bool draw_terrain = TRUE; bool draw_coastline = FALSE; bool draw_roads_rails = TRUE; @@ -329,6 +330,7 @@ view_option view_options[] = { VIEW_OPTION(draw_city_names), VIEW_OPTION(draw_city_growth), VIEW_OPTION(draw_city_productions), + VIEW_OPTION(draw_city_traderoutes), VIEW_OPTION(draw_terrain), VIEW_OPTION(draw_coastline), VIEW_OPTION(draw_roads_rails), diff --git a/client/options.h b/client/options.h index ce3c8d7..610d61a 100644 --- a/client/options.h +++ b/client/options.h @@ -148,6 +148,7 @@ extern bool draw_map_grid; extern bool draw_city_names; extern bool draw_city_growth; extern bool draw_city_productions; +extern bool draw_city_traderoutes; extern bool draw_terrain; extern bool draw_coastline; extern bool draw_roads_rails; diff --git a/client/packhand.c b/client/packhand.c index 9b24389..66fdaf7 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -536,9 +536,18 @@ void handle_city_info(struct packet_city_info *packet) TILE_XY(packet)); return; } else { + bool traderoutes_changed = FALSE; name_changed = (0 != strncmp(packet->name, pcity->name, sizeof(pcity->name))); + if (draw_city_traderoutes + && (0 != memcmp(pcity->trade, packet->trade, + sizeof(pcity->trade)) + || 0 != memcmp(pcity->trade_value, packet->trade_value, + sizeof(pcity->trade_value)))) { + traderoutes_changed = TRUE; + } + /* Descriptions should probably be updated if the * city name, production or time-to-grow changes. * Note that if either the food stock or surplus @@ -551,7 +560,8 @@ void handle_city_info(struct packet_city_info *packet) || pcity->shield_stock != packet->shield_stock)) || (draw_city_growth && (pcity->food_stock != packet->food_stock - || pcity->surplus[O_FOOD] != packet->surplus[O_FOOD])); + || pcity->surplus[O_FOOD] != packet->surplus[O_FOOD])) + || (draw_city_traderoutes && traderoutes_changed); } sz_strlcpy(pcity->name, packet->name); diff --git a/client/tilespec.c b/client/tilespec.c index edcb420..f8c5309 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -2284,6 +2284,7 @@ static void tileset_lookup_sprite_tags(struct tileset *t) SET_SPRITE(citybar.shields, "citybar.shields"); SET_SPRITE(citybar.food, "citybar.food"); + SET_SPRITE(citybar.trade, "citybar.trade"); SET_SPRITE(citybar.occupied, "citybar.occupied"); SET_SPRITE(citybar.background, "citybar.background"); sprite_vector_init(&t->sprites.citybar.occupancy); diff --git a/client/tilespec.h b/client/tilespec.h index 794e5f0..e96f406 100644 --- a/client/tilespec.h +++ b/client/tilespec.h @@ -215,6 +215,7 @@ struct citybar_sprites { struct sprite *shields, *food, + *trade, *occupied, *background; struct sprite_vector occupancy; diff --git a/data/misc/citybar.png b/data/misc/citybar.png index 382ab6b..9b2861e 100644 Binary files a/data/misc/citybar.png and b/data/misc/citybar.png differ diff --git a/data/misc/citybar.spec b/data/misc/citybar.spec index 229789a..e0dd114 100644 --- a/data/misc/citybar.spec +++ b/data/misc/citybar.spec @@ -8,6 +8,7 @@ options = "+spec3" artists = " Freim <...> + Madeline Book <[EMAIL PROTECTED]> (citybar.trade) " [file] @@ -25,6 +26,7 @@ tiles = { "row", "column", "tag" 0, 0, "citybar.shields" 0, 1, "citybar.food" + 0, 2, "citybar.trade" } diff --git a/doc/README.SDLClient b/doc/README.SDLClient index f7cf798..2f5203b 100644 --- a/doc/README.SDLClient +++ b/doc/README.SDLClient @@ -50,9 +50,11 @@ In-game controls: ----------------- - <Tab> to show input dialog (chatline) - - <ctrl - w> hide/show fog of war + - <ctrl - shift - w> hide/show fog of war + - <ctrl - w> hide/show city worker output on map - <ctrl - r> hide/show road/railroad - - <ctrl - t> hide/show terrain + - <ctrl - shift - t> hide/show terrain + - <ctrl - t> hide/show city traderoutes - <ctrl - i> hide/show irrigation/farmlands - <ctrl - u> hide/show units - <ctrl - o> hide/show pollution
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev