[Freeciv-Dev] (PR#12248) use refresh_xxx_mapcanvas for more drawing
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12248 >
Wherever possible when doing updates we should call
refresh_xxx_mapcanvas, which does "efficient" drawing, rather than a
direct call to update_map_canvas. It's prettier too.
This patch fixes some simple cases.
-jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.189
diff -u -r1.189 mapview_common.c
--- client/mapview_common.c 14 Feb 2005 17:52:56 -0000 1.189
+++ client/mapview_common.c 14 Feb 2005 18:47:09 -0000
@@ -1070,10 +1070,6 @@
****************************************************************************/
void toggle_city_color(struct city *pcity)
{
- int canvas_x, canvas_y;
- int width = get_citydlg_canvas_width();
- int height = get_citydlg_canvas_height();
-
if (pcity->client.colored) {
pcity->client.colored = FALSE;
} else {
@@ -1082,10 +1078,7 @@
color_index = (color_index + 1) % NUM_CITY_COLORS;
}
- tile_to_canvas_pos(&canvas_x, &canvas_y, pcity->tile);
- update_map_canvas(canvas_x - (width - NORMAL_TILE_WIDTH) / 2,
- canvas_y - (height - NORMAL_TILE_HEIGHT) / 2,
- width, height);
+ refresh_city_mapcanvas(pcity, pcity->tile, TRUE, FALSE);
}
/****************************************************************************
@@ -1095,10 +1088,6 @@
****************************************************************************/
void toggle_unit_color(struct unit *punit)
{
- int canvas_x, canvas_y;
- int width = get_citydlg_canvas_width();
- int height = get_citydlg_canvas_height();
-
if (punit->client.colored) {
punit->client.colored = FALSE;
} else {
@@ -1107,10 +1096,7 @@
color_index = (color_index + 1) % NUM_CITY_COLORS;
}
- tile_to_canvas_pos(&canvas_x, &canvas_y, punit->tile);
- update_map_canvas(canvas_x - (width - NORMAL_TILE_WIDTH) / 2,
- canvas_y - (height - NORMAL_TILE_HEIGHT) / 2,
- width, height);
+ refresh_unit_mapcanvas(punit, punit->tile, FALSE);
}
/****************************************************************************
@@ -1871,21 +1857,14 @@
**************************************************************************/
void undraw_segment(struct tile *src_tile, enum direction8 dir)
{
- int canvas_x, canvas_y, canvas_dx, canvas_dy;
-
- assert(!is_drawn_line(src_tile, dir));
+ struct tile *dst_tile = mapstep(src_tile, dir);
- /* Note that if source and dest tiles are not adjacent (because the
- * mapview wraps around) this will not give the correct behavior. This is
- * consistent with the current design which fails when the size of the
- * mapview approaches the size of the map. */
- (void) tile_to_canvas_pos(&canvas_x, &canvas_y, src_tile);
- map_to_gui_vector(&canvas_dx, &canvas_dy, DIR_DX[dir], DIR_DY[dir]);
-
- update_map_canvas(MIN(canvas_x, canvas_x + canvas_dx),
- MIN(canvas_y, canvas_y + canvas_dy),
- ABS(canvas_dx) + NORMAL_TILE_WIDTH,
- ABS(canvas_dy) + NORMAL_TILE_HEIGHT);
+ if (is_drawn_line(src_tile, dir) || !dst_tile) {
+ assert(0);
+ return;
+ }
+ refresh_tile_mapcanvas(src_tile, FALSE);
+ refresh_tile_mapcanvas(dst_tile, FALSE);
}
/****************************************************************************
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12248) use refresh_xxx_mapcanvas for more drawing,
Jason Short <=
|
|