Author: mir3x
Date: Tue Dec 27 22:02:35 2016
New Revision: 34739

URL: http://svn.gna.org/viewcvs/freeciv?rev=34739&view=rev
Log:
Draw negative city production on map with red color

See patch #8053


Modified:
    branches/S2_6/client/mapview_common.c
    branches/S2_6/client/mapview_common.h

Modified: branches/S2_6/client/mapview_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/mapview_common.c?rev=34739&r1=34738&r2=34739&view=diff
==============================================================================
--- branches/S2_6/client/mapview_common.c       (original)
+++ branches/S2_6/client/mapview_common.c       Tue Dec 27 22:02:35 2016
@@ -1472,6 +1472,7 @@
   const struct citybar_sprites *citybar = get_citybar_sprites(tileset);
   static char name[512], growth[32], prod[512], size[32], trade_routes[32];
   enum color_std growth_color;
+  enum color_std production_color;
   /* trade_routes_color initialized just to get rid off gcc warning
    * on optimization level 3 when it misdiagnoses that it would be used
    * uninitialized otherwise. Funny thing here is that warning would
@@ -1526,7 +1527,7 @@
 
   get_sprite_dimensions(bg, &bg_w, &bg_h);
   get_city_mapview_name_and_growth(pcity, name, sizeof(name),
-                                  growth, sizeof(growth), &growth_color);
+                                  growth, sizeof(growth), &growth_color, 
&production_color);
 
   if (gui_options.draw_city_names) {
     fc_snprintf(size, sizeof(size), "%d", city_size_get(pcity));
@@ -1671,10 +1672,8 @@
                            occupy_rect.x / map_zoom, occupy_rect.y / map_zoom,
                            occupy);
     canvas_put_text(pcanvas, name_rect.x / map_zoom, name_rect.y / map_zoom,
-                   FONT_CITY_NAME,
-                   get_color(tileset, COLOR_MAPVIEW_CITYTEXT),
-                   name);
-
+                    FONT_CITY_NAME,
+                    get_color(tileset, COLOR_MAPVIEW_CITYTEXT), name);
     canvas_put_rectangle(pcanvas, owner_color,
                         (size_rect.x - border / 2) / map_zoom,
                          canvas_y / map_zoom,
@@ -1702,7 +1701,7 @@
                              citybar->shields);
       canvas_put_text(pcanvas, prod_rect.x / map_zoom, prod_rect.y / map_zoom,
                       FONT_CITY_PROD,
-                      get_color(tileset, COLOR_MAPVIEW_CITYTEXT), prod);
+                      get_color(tileset, production_color), prod);
     }
 
     if (should_draw_trade_routes) {
@@ -1762,6 +1761,7 @@
 {
   static char name[512], growth[32], prod[512], trade_routes[32];
   enum color_std growth_color;
+  enum color_std production_color;
  /* trade_routes_color initialized just to get rid off gcc warning
    * on optimization level 3 when it misdiagnoses that it would be used
    * uninitialized otherwise. Funny thing here is that warning would
@@ -1793,7 +1793,8 @@
     total_height = 0;
 
     get_city_mapview_name_and_growth(pcity, name, sizeof(name),
-                                    growth, sizeof(growth), &growth_color);
+                                    growth, sizeof(growth), &growth_color,
+                                    &production_color);
 
     get_text_size(&name_rect.w, &name_rect.h, FONT_CITY_NAME, name);
     total_width += name_rect.w;
@@ -1855,7 +1856,7 @@
     canvas_put_text(pcanvas, (canvas_x - total_width / 2) / map_zoom,
                     canvas_y / map_zoom,
                    FONT_CITY_PROD,
-                   get_color(tileset, COLOR_MAPVIEW_CITYTEXT), prod);
+                   get_color(tileset, production_color), prod);
 
     canvas_y += total_height;
     *width = MAX(*width, total_width);
@@ -2701,10 +2702,12 @@
                                       size_t name_buffer_len,
                                       char *growth_buffer,
                                       size_t growth_buffer_len,
-                                      enum color_std *growth_color)
+                                      enum color_std *growth_color,
+                                      enum color_std *production_color)
 {
   fc_strlcpy(name_buffer, city_name_get(pcity), name_buffer_len);
 
+  *production_color = COLOR_MAPVIEW_CITYTEXT;
   if (NULL == client.conn.playing
       || city_owner(pcity) == client.conn.playing) {
     int turns = city_turns_to_grow(pcity);
@@ -2724,6 +2727,10 @@
       *growth_color = COLOR_MAPVIEW_CITYGROWTH_BLOCKED;
     } else {
       *growth_color = COLOR_MAPVIEW_CITYTEXT;
+    }
+
+    if (pcity->surplus[O_SHIELD] < 0) {
+      *production_color = COLOR_MAPVIEW_CITYGROWTH_BLOCKED;
     }
   } else {
     growth_buffer[0] = '\0';

Modified: branches/S2_6/client/mapview_common.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/mapview_common.h?rev=34739&r1=34738&r2=34739&view=diff
==============================================================================
--- branches/S2_6/client/mapview_common.h       (original)
+++ branches/S2_6/client/mapview_common.h       Tue Dec 27 22:02:35 2016
@@ -329,7 +329,8 @@
                                      size_t name_buffer_len,
                                      char *growth_buffer,
                                      size_t growth_buffer_len,
-                                     enum color_std *grwoth_color);
+                                     enum color_std *growth_color,
+                      enum color_std *production_color);
 void get_city_mapview_trade_routes(struct city *pcity,
                                    char *trade_routes_buffer,
                                    size_t trade_routes_buffer_len,


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to