[Freeciv-Dev] (PR#8756) new function update_city_description
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#8756) new function update_city_description |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Wed, 19 May 2004 10:10:31 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8756 >
> [jdorje - Mon May 17 08:03:56 2004]:
>
> This patch adds a new function, update_city_description(). This updates
> a single description for a single city.
Here's a fixed version of the patch.
jason
? eff
? flags
? data/flags
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.117
diff -u -r1.117 mapview_common.c
--- client/mapview_common.c 17 May 2004 07:16:42 -0000 1.117
+++ client/mapview_common.c 19 May 2004 17:10:01 -0000
@@ -1364,13 +1364,37 @@
update_map_canvas(0, 0, mapview_canvas.width, mapview_canvas.height);
}
+/* The maximum city description width and height. This gives the dimensions
+ * of a rectangle centered directly beneath the tile a city is on, that
+ * contains the city description.
+ *
+ * These values are increased when drawing is done. This may mean that
+ * the change (from increasing the value) won't take place until the
+ * next redraw. */
+static int max_desc_width = 0, max_desc_height = 0;
+
+/**************************************************************************
+ Update the city description for the given city.
+**************************************************************************/
+void update_city_description(struct city *pcity)
+{
+ int canvas_x, canvas_y;
+
+ /* We update the entire map canvas area that this city description
+ * might be covering. This may, for instance, redraw other city
+ * descriptions that overlap with this one. */
+ (void) map_to_canvas_pos(&canvas_x, &canvas_y, pcity->x, pcity->y);
+ update_map_canvas(canvas_x - (max_desc_width - NORMAL_TILE_WIDTH) / 2,
+ canvas_y + NORMAL_TILE_HEIGHT,
+ max_desc_width, max_desc_height);
+}
+
/**************************************************************************
Show descriptions for all cities visible on the map canvas.
**************************************************************************/
void show_city_descriptions(int canvas_x, int canvas_y,
int width, int height)
{
- static int max_desc_width = 0, max_desc_height = 0;
const int dx = max_desc_width - NORMAL_TILE_WIDTH, dy = max_desc_height;
if (!draw_city_names && !draw_city_productions) {
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.62
diff -u -r1.62 mapview_common.h
--- client/mapview_common.h 14 May 2004 02:23:42 -0000 1.62
+++ client/mapview_common.h 19 May 2004 17:10:01 -0000
@@ -270,6 +270,7 @@
void update_map_canvas(int canvas_x, int canvas_y, int width, int height);
void update_map_canvas_visible(void);
+void update_city_description(struct city *pcity);
void show_city_descriptions(int canvas_x, int canvas_y,
int width, int height);
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.365
diff -u -r1.365 packhand.c
--- client/packhand.c 15 May 2004 16:33:42 -0000 1.365
+++ client/packhand.c 19 May 2004 17:10:02 -0000
@@ -422,14 +422,6 @@
assert(pcity->id == packet->id);
}
- /* Update the descriptions if necessary. We only draw the description
- * if the *city* is visible on the mapview, which is a bit inaccurate -
- * it's possible the city is off the mapview but the description is
- * visible. See all show_city_descriptions(). */
- if (update_descriptions && tile_visible_mapcanvas(packet->x, packet->y)) {
- queue_mapview_update(UPDATE_CITY_DESCRIPTIONS);
- }
-
pcity->owner=packet->owner;
pcity->x=packet->x;
pcity->y=packet->y;
@@ -544,6 +536,14 @@
handle_city_packet_common(pcity, city_is_new, popup,
packet->diplomat_investigate);
+ /* Update the descriptions if necessary. We only draw the description
+ * if the *city* is visible on the mapview, which is a bit inaccurate -
+ * it's possible the city is off the mapview but the description is
+ * visible. See all show_city_descriptions(). */
+ if (update_descriptions && tile_visible_mapcanvas(packet->x, packet->y)) {
+ update_city_description(pcity);
+ }
+
try_update_effects(need_effect_update);
}
@@ -753,7 +753,7 @@
/* update the descriptions if necessary */
if (update_descriptions && tile_visible_mapcanvas(pcity->x,pcity->y)) {
- queue_mapview_update(UPDATE_CITY_DESCRIPTIONS);
+ update_city_description(pcity);
}
try_update_effects(need_effect_update);
|
|