Author: mir3x
Date: Tue Dec 27 22:06:06 2016
New Revision: 34740

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

See patch #8053


Modified:
    trunk/client/colors_common.h
    trunk/client/mapview_common.c
    trunk/client/mapview_common.h
    trunk/data/misc/colors.tilespec

Modified: trunk/client/colors_common.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/colors_common.h?rev=34740&r1=34739&r2=34740&view=diff
==============================================================================
--- trunk/client/colors_common.h        (original)
+++ trunk/client/colors_common.h        Tue Dec 27 22:06:06 2016
@@ -40,80 +40,82 @@
 #define SPECENUM_VALUE1NAME   "mapview_citytext"
 #define SPECENUM_VALUE2   COLOR_MAPVIEW_CITYTEXT_DARK           /* black */
 #define SPECENUM_VALUE2NAME   "mapview_citytext_dark"
-#define SPECENUM_VALUE3   COLOR_MAPVIEW_CITYGROWTH_BLOCKED      /* red */
-#define SPECENUM_VALUE3NAME   "mapview_cityblocked"
-#define SPECENUM_VALUE4   COLOR_MAPVIEW_GOTO                    /* cyan */
-#define SPECENUM_VALUE4NAME   "mapview_goto"
-#define SPECENUM_VALUE5   COLOR_MAPVIEW_SELECTION               /* yellow */
-#define SPECENUM_VALUE5NAME   "mapview_selection"
-#define SPECENUM_VALUE6   COLOR_MAPVIEW_TRADE_ROUTE_LINE
-#define SPECENUM_VALUE6NAME   "mapview_trade_route_line"
-#define SPECENUM_VALUE7   COLOR_MAPVIEW_TRADE_ROUTES_ALL_BUILT  /* green */
-#define SPECENUM_VALUE7NAME   "mapview_trade_routes_all_built"
-#define SPECENUM_VALUE8   COLOR_MAPVIEW_TRADE_ROUTES_SOME_BUILT /* yellow */
-#define SPECENUM_VALUE8NAME   "mapview_trade_routes_some_built"
-#define SPECENUM_VALUE9   COLOR_MAPVIEW_TRADE_ROUTES_NO_BUILT   /* red */
-#define SPECENUM_VALUE9NAME   "mapview_trade_routes_no_built"
-#define SPECENUM_VALUE10  COLOR_MAPVIEW_CITY_LINK               /* green */
-#define SPECENUM_VALUE10NAME  "mapview_city_link"
-#define SPECENUM_VALUE11  COLOR_MAPVIEW_TILE_LINK               /* red */
-#define SPECENUM_VALUE11NAME  "mapview_tile_link"
-#define SPECENUM_VALUE12  COLOR_MAPVIEW_UNIT_LINK               /* cyan */
-#define SPECENUM_VALUE12NAME  "mapview_unit_link"
+#define SPECENUM_VALUE3   COLOR_MAPVIEW_CITYPROD_NEGATIVE        /* red */
+#define SPECENUM_VALUE3NAME   "mapview_cityprod_negative"
+#define SPECENUM_VALUE4   COLOR_MAPVIEW_CITYGROWTH_BLOCKED      /* red */
+#define SPECENUM_VALUE4NAME   "mapview_cityblocked"
+#define SPECENUM_VALUE5   COLOR_MAPVIEW_GOTO                    /* cyan */
+#define SPECENUM_VALUE5NAME   "mapview_goto"
+#define SPECENUM_VALUE6   COLOR_MAPVIEW_SELECTION               /* yellow */
+#define SPECENUM_VALUE6NAME   "mapview_selection"
+#define SPECENUM_VALUE7   COLOR_MAPVIEW_TRADE_ROUTE_LINE
+#define SPECENUM_VALUE7NAME   "mapview_trade_route_line"
+#define SPECENUM_VALUE8   COLOR_MAPVIEW_TRADE_ROUTES_ALL_BUILT  /* green */
+#define SPECENUM_VALUE8NAME   "mapview_trade_routes_all_built"
+#define SPECENUM_VALUE9   COLOR_MAPVIEW_TRADE_ROUTES_SOME_BUILT /* yellow */
+#define SPECENUM_VALUE9NAME   "mapview_trade_routes_some_built"
+#define SPECENUM_VALUE10  COLOR_MAPVIEW_TRADE_ROUTES_NO_BUILT   /* red */
+#define SPECENUM_VALUE10NAME   "mapview_trade_routes_no_built"
+#define SPECENUM_VALUE11  COLOR_MAPVIEW_CITY_LINK               /* green */
+#define SPECENUM_VALUE11NAME  "mapview_city_link"
+#define SPECENUM_VALUE12  COLOR_MAPVIEW_TILE_LINK               /* red */
+#define SPECENUM_VALUE12NAME  "mapview_tile_link"
+#define SPECENUM_VALUE13  COLOR_MAPVIEW_UNIT_LINK               /* cyan */
+#define SPECENUM_VALUE13NAME  "mapview_unit_link"
 /* Spaceship colors */
-#define SPECENUM_VALUE13   COLOR_SPACESHIP_BACKGROUND            /* black */
-#define SPECENUM_VALUE13NAME  "spaceship_background"
+#define SPECENUM_VALUE14   COLOR_SPACESHIP_BACKGROUND            /* black */
+#define SPECENUM_VALUE14NAME  "spaceship_background"
 /* Overview colors */
-#define SPECENUM_VALUE14  COLOR_OVERVIEW_UNKNOWN      /* Black */
-#define SPECENUM_VALUE14NAME  "overview_unknown"
-#define SPECENUM_VALUE15  COLOR_OVERVIEW_MY_CITY      /* white */
-#define SPECENUM_VALUE15NAME  "overview_mycity"
-#define SPECENUM_VALUE16  COLOR_OVERVIEW_ALLIED_CITY
-#define SPECENUM_VALUE16NAME  "overview_alliedcity"
-#define SPECENUM_VALUE17  COLOR_OVERVIEW_ENEMY_CITY   /* cyan */
-#define SPECENUM_VALUE17NAME  "overview_enemycity"
-#define SPECENUM_VALUE18  COLOR_OVERVIEW_MY_UNIT      /* yellow */
-#define SPECENUM_VALUE18NAME  "overview_myunit"
-#define SPECENUM_VALUE19  COLOR_OVERVIEW_ALLIED_UNIT
-#define SPECENUM_VALUE19NAME  "overview_alliedunit"
-#define SPECENUM_VALUE20  COLOR_OVERVIEW_ENEMY_UNIT   /* red */
-#define SPECENUM_VALUE20NAME  "overview_enemyunit"
-#define SPECENUM_VALUE21  COLOR_OVERVIEW_OCEAN        /* ocean/blue */
-#define SPECENUM_VALUE21NAME  "overview_ocean"
-#define SPECENUM_VALUE22  COLOR_OVERVIEW_LAND         /* ground/green */
-#define SPECENUM_VALUE22NAME  "overview_ground"
-#define SPECENUM_VALUE23  COLOR_OVERVIEW_FROZEN       /* frozen/grey */
-#define SPECENUM_VALUE23NAME  "overview_frozen"
-#define SPECENUM_VALUE24  COLOR_OVERVIEW_VIEWRECT     /* white */
-#define SPECENUM_VALUE24NAME  "overview_viewrect"
+#define SPECENUM_VALUE15  COLOR_OVERVIEW_UNKNOWN      /* Black */
+#define SPECENUM_VALUE15NAME  "overview_unknown"
+#define SPECENUM_VALUE16  COLOR_OVERVIEW_MY_CITY      /* white */
+#define SPECENUM_VALUE16NAME  "overview_mycity"
+#define SPECENUM_VALUE17  COLOR_OVERVIEW_ALLIED_CITY
+#define SPECENUM_VALUE17NAME  "overview_alliedcity"
+#define SPECENUM_VALUE18  COLOR_OVERVIEW_ENEMY_CITY   /* cyan */
+#define SPECENUM_VALUE18NAME  "overview_enemycity"
+#define SPECENUM_VALUE19  COLOR_OVERVIEW_MY_UNIT      /* yellow */
+#define SPECENUM_VALUE19NAME  "overview_myunit"
+#define SPECENUM_VALUE20  COLOR_OVERVIEW_ALLIED_UNIT
+#define SPECENUM_VALUE20NAME  "overview_alliedunit"
+#define SPECENUM_VALUE21  COLOR_OVERVIEW_ENEMY_UNIT   /* red */
+#define SPECENUM_VALUE21NAME  "overview_enemyunit"
+#define SPECENUM_VALUE22  COLOR_OVERVIEW_OCEAN        /* ocean/blue */
+#define SPECENUM_VALUE22NAME  "overview_ocean"
+#define SPECENUM_VALUE23  COLOR_OVERVIEW_LAND         /* ground/green */
+#define SPECENUM_VALUE23NAME  "overview_ground"
+#define SPECENUM_VALUE24  COLOR_OVERVIEW_FROZEN       /* frozen/grey */
+#define SPECENUM_VALUE24NAME  "overview_frozen"
+#define SPECENUM_VALUE25  COLOR_OVERVIEW_VIEWRECT     /* white */
+#define SPECENUM_VALUE25NAME  "overview_viewrect"
 /* Reqtree colors */
-#define SPECENUM_VALUE25  COLOR_REQTREE_RESEARCHING         /* cyan */
-#define SPECENUM_VALUE25NAME  "reqtree_researching"
-#define SPECENUM_VALUE26  COLOR_REQTREE_KNOWN               /* green */
-#define SPECENUM_VALUE26NAME  "reqtree_known"
-#define SPECENUM_VALUE27  COLOR_REQTREE_GOAL_PREREQS_KNOWN
-#define SPECENUM_VALUE27NAME  "reqtree_goal_prereqs_known"
-#define SPECENUM_VALUE28  COLOR_REQTREE_GOAL_UNKNOWN
-#define SPECENUM_VALUE28NAME  "reqtree_goal_unknown"
-#define SPECENUM_VALUE29  COLOR_REQTREE_PREREQS_KNOWN       /* yellow */
-#define SPECENUM_VALUE29NAME  "reqtree_prereqs_known"
-#define SPECENUM_VALUE30  COLOR_REQTREE_UNKNOWN             /* red */
-#define SPECENUM_VALUE30NAME  "reqtree_unknown"
-#define SPECENUM_VALUE31  COLOR_REQTREE_UNREACHABLE
-#define SPECENUM_VALUE31NAME  "reqtree_unreachable"
-#define SPECENUM_VALUE32  COLOR_REQTREE_NOT_GETTABLE
-#define SPECENUM_VALUE32NAME  "reqtree_not_gettable"
-#define SPECENUM_VALUE33  COLOR_REQTREE_GOAL_NOT_GETTABLE
-#define SPECENUM_VALUE33NAME  "reqtree_goal_not_gettable"
-#define SPECENUM_VALUE34  COLOR_REQTREE_BACKGROUND          /* black */
-#define SPECENUM_VALUE34NAME  "reqtree_background"
-#define SPECENUM_VALUE35  COLOR_REQTREE_TEXT                /* black */
-#define SPECENUM_VALUE35NAME  "reqtree_text"
-#define SPECENUM_VALUE36  COLOR_REQTREE_EDGE                /* gray */
-#define SPECENUM_VALUE36NAME  "reqtree_edge"
+#define SPECENUM_VALUE26  COLOR_REQTREE_RESEARCHING         /* cyan */
+#define SPECENUM_VALUE26NAME  "reqtree_researching"
+#define SPECENUM_VALUE27  COLOR_REQTREE_KNOWN               /* green */
+#define SPECENUM_VALUE27NAME  "reqtree_known"
+#define SPECENUM_VALUE28  COLOR_REQTREE_GOAL_PREREQS_KNOWN
+#define SPECENUM_VALUE28NAME  "reqtree_goal_prereqs_known"
+#define SPECENUM_VALUE29  COLOR_REQTREE_GOAL_UNKNOWN
+#define SPECENUM_VALUE29NAME  "reqtree_goal_unknown"
+#define SPECENUM_VALUE30  COLOR_REQTREE_PREREQS_KNOWN       /* yellow */
+#define SPECENUM_VALUE30NAME  "reqtree_prereqs_known"
+#define SPECENUM_VALUE31  COLOR_REQTREE_UNKNOWN             /* red */
+#define SPECENUM_VALUE31NAME  "reqtree_unknown"
+#define SPECENUM_VALUE32  COLOR_REQTREE_UNREACHABLE
+#define SPECENUM_VALUE32NAME  "reqtree_unreachable"
+#define SPECENUM_VALUE33  COLOR_REQTREE_NOT_GETTABLE
+#define SPECENUM_VALUE33NAME  "reqtree_not_gettable"
+#define SPECENUM_VALUE34  COLOR_REQTREE_GOAL_NOT_GETTABLE
+#define SPECENUM_VALUE34NAME  "reqtree_goal_not_gettable"
+#define SPECENUM_VALUE35  COLOR_REQTREE_BACKGROUND          /* black */
+#define SPECENUM_VALUE35NAME  "reqtree_background"
+#define SPECENUM_VALUE36  COLOR_REQTREE_TEXT                /* black */
+#define SPECENUM_VALUE36NAME  "reqtree_text"
+#define SPECENUM_VALUE37  COLOR_REQTREE_EDGE                /* gray */
+#define SPECENUM_VALUE37NAME  "reqtree_edge"
 /* Player dialog */
-#define SPECENUM_VALUE37  COLOR_PLAYER_COLOR_BACKGROUND     /* black */
-#define SPECENUM_VALUE37NAME  "playerdlg_background"
+#define SPECENUM_VALUE38  COLOR_PLAYER_COLOR_BACKGROUND     /* black */
+#define SPECENUM_VALUE38NAME  "playerdlg_background"
 
 #define SPECENUM_COUNT    COLOR_LAST
 #include "specenum_gen.h"

Modified: trunk/client/mapview_common.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/mapview_common.c?rev=34740&r1=34739&r2=34740&view=diff
==============================================================================
--- trunk/client/mapview_common.c       (original)
+++ trunk/client/mapview_common.c       Tue Dec 27 22:06:06 2016
@@ -1471,6 +1471,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
@@ -1525,7 +1526,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));
@@ -1670,10 +1671,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,
@@ -1701,7 +1700,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) {
@@ -1761,6 +1760,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
@@ -1792,7 +1792,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;
@@ -1854,7 +1855,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);
@@ -2693,10 +2694,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);
@@ -2716,6 +2719,10 @@
       *growth_color = COLOR_MAPVIEW_CITYGROWTH_BLOCKED;
     } else {
       *growth_color = COLOR_MAPVIEW_CITYTEXT;
+    }
+
+    if (pcity->surplus[O_SHIELD] < 0) {
+      *production_color = COLOR_MAPVIEW_CITYPROD_NEGATIVE;
     }
   } else {
     growth_buffer[0] = '\0';

Modified: trunk/client/mapview_common.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/mapview_common.h?rev=34740&r1=34739&r2=34740&view=diff
==============================================================================
--- trunk/client/mapview_common.h       (original)
+++ trunk/client/mapview_common.h       Tue Dec 27 22:06:06 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,

Modified: trunk/data/misc/colors.tilespec
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/misc/colors.tilespec?rev=34740&r1=34739&r2=34740&view=diff
==============================================================================
--- trunk/data/misc/colors.tilespec     (original)
+++ trunk/data/misc/colors.tilespec     Tue Dec 27 22:06:06 2016
@@ -9,6 +9,9 @@
 }
 mapview_citytext_dark = {"r", "g", "b"
     0,     0,   0
+}
+mapview_cityprod_negative = {"r", "g", "b"
+    255,     0,   0
 }
 mapview_cityblocked = {"r", "g", "b"
     255,   0,   0


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

Reply via email to