[Freeciv-Dev] (PR#7859) remove draw_unit_animation_frame
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7859 >
> [jdorje - Fri Mar 12 07:31:50 2004]:
>
> This patch removes the GUI function draw_unit_animation_frame. This
> drawing is now done straight from within the calling function in
> mapview_common.
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.89
diff -u -r1.89 mapview_common.c
--- client/mapview_common.c 12 Mar 2004 04:57:51 -0000 1.89
+++ client/mapview_common.c 12 Mar 2004 07:29:13 -0000
@@ -1630,13 +1630,10 @@
assert(0);
}
- flush_dirty();
-
if (tile_visible_mapcanvas(map_x, map_y)
|| tile_visible_mapcanvas(dest_x, dest_y)) {
int i, steps;
int start_x, start_y;
- int this_x, this_y;
int canvas_dx, canvas_dy;
if (is_isometric) {
@@ -1685,26 +1682,33 @@
start_y -= NORMAL_TILE_HEIGHT / 2;
}
- this_x = start_x;
- this_y = start_y;
-
for (i = 1; i <= steps; i++) {
- int new_x, new_y;
+ int this_x, this_y;
anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
- new_x = start_x + (i * canvas_dx) / steps;
- new_y = start_y + (i * canvas_dy) / steps;
+ this_x = start_x + (i * canvas_dx) / steps;
+ this_y = start_y + (i * canvas_dy) / steps;
- draw_unit_animation_frame(punit, i == 1, i == steps,
- this_x, this_y, new_x, new_y);
-
- this_x = new_x;
- this_y = new_y;
+ /* Backup the canvas store to the single_tile canvas. */
+ canvas_copy(mapview_canvas.single_tile, mapview_canvas.store,
+ this_x, this_y, 0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
+
+ /* Draw */
+ put_unit_full(punit, mapview_canvas.store, this_x, this_y);
+ dirty_rect(this_x, this_y, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
+
+ /* Flush. */
+ flush_dirty();
+ gui_flush();
if (i < steps) {
usleep_since_timer_start(anim_timer, 10000);
}
+
+ /* Restore the backup. */
+ canvas_copy(mapview_canvas.store, mapview_canvas.single_tile,
+ 0, 0, this_x, this_y, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
}
}
}
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.205
diff -u -r1.205 mapview.c
--- client/gui-gtk/mapview.c 12 Mar 2004 04:57:51 -0000 1.205
+++ client/gui-gtk/mapview.c 12 Mar 2004 07:29:13 -0000
@@ -270,36 +270,6 @@
}
/**************************************************************************
- Draw a single frame of animation. This function needs to clear the old
- image and draw the new one. It must flush output to the display.
-**************************************************************************/
-void draw_unit_animation_frame(struct unit *punit,
- bool first_frame, bool last_frame,
- int old_canvas_x, int old_canvas_y,
- int new_canvas_x, int new_canvas_y)
-{
- struct canvas store = {single_tile_pixmap};
-
- /* Clear old sprite. */
- gdk_draw_pixmap(map_canvas->window, civ_gc, map_canvas_store, old_canvas_x,
- old_canvas_y, old_canvas_x, old_canvas_y, UNIT_TILE_WIDTH,
- UNIT_TILE_HEIGHT);
-
- /* Draw the new sprite. */
- gdk_draw_pixmap(single_tile_pixmap, civ_gc, map_canvas_store, new_canvas_x,
- new_canvas_y, 0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
- put_unit_full(punit, &store, 0, 0);
-
- /* Write to screen. */
- gdk_draw_pixmap(map_canvas->window, civ_gc, single_tile_pixmap, 0, 0,
- new_canvas_x, new_canvas_y, UNIT_TILE_WIDTH,
- UNIT_TILE_HEIGHT);
-
- /* Flush. */
- gdk_flush();
-}
-
-/**************************************************************************
...
**************************************************************************/
void map_size_changed(void)
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.105
diff -u -r1.105 mapview.c
--- client/gui-gtk-2.0/mapview.c 12 Mar 2004 04:57:51 -0000 1.105
+++ client/gui-gtk-2.0/mapview.c 12 Mar 2004 07:29:13 -0000
@@ -314,36 +314,6 @@
}
/**************************************************************************
- Draw a single frame of animation. This function needs to clear the old
- image and draw the new one. It must flush output to the display.
-**************************************************************************/
-void draw_unit_animation_frame(struct unit *punit,
- bool first_frame, bool last_frame,
- int old_canvas_x, int old_canvas_y,
- int new_canvas_x, int new_canvas_y)
-{
- struct canvas store = {single_tile_pixmap};
-
- /* Clear old sprite. */
- gdk_draw_drawable(map_canvas->window, civ_gc, map_canvas_store, old_canvas_x,
- old_canvas_y, old_canvas_x, old_canvas_y, UNIT_TILE_WIDTH,
- UNIT_TILE_HEIGHT);
-
- /* Draw the new sprite. */
- gdk_draw_drawable(single_tile_pixmap, civ_gc, map_canvas_store, new_canvas_x,
- new_canvas_y, 0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
- put_unit_full(punit, &store, 0, 0);
-
- /* Write to screen. */
- gdk_draw_drawable(map_canvas->window, civ_gc, single_tile_pixmap, 0, 0,
- new_canvas_x, new_canvas_y, UNIT_TILE_WIDTH,
- UNIT_TILE_HEIGHT);
-
- /* Flush. */
- gdk_flush();
-}
-
-/**************************************************************************
...
**************************************************************************/
void map_size_changed(void)
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.67
diff -u -r1.67 mapview.c
--- client/gui-sdl/mapview.c 9 Mar 2004 19:10:41 -0000 1.67
+++ client/gui-sdl/mapview.c 12 Mar 2004 07:29:14 -0000
@@ -2562,79 +2562,6 @@
}
/**************************************************************************
- Draw a single frame of animation. This function needs to clear the old
- image and draw the new one. It must flush output to the display.
-**************************************************************************/
-void draw_unit_animation_frame(struct unit *punit,
- bool first_frame, bool last_frame,
- int old_canvas_x, int old_canvas_y,
- int new_canvas_x, int new_canvas_y)
-{
- static SDL_Rect dst, dest;
- static SDL_Surface *pMap_Copy, *pUnit_Surf;
-
- if (first_frame) {
- /* Create extra backing stores. */
- pMap_Copy =
- create_surf(UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, SDL_SWSURFACE);
- pUnit_Surf =
- create_surf(UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, SDL_SWSURFACE);
- SDL_FillRect(pUnit_Surf, NULL, SDL_MapRGB(pUnit_Surf->format, 255, 0,
255));
- SDL_SetColorKey(pUnit_Surf, SDL_SRCCOLORKEY|SDL_RLEACCEL,
- SDL_MapRGB(pUnit_Surf->format, 255, 0, 255));
- put_unit_pixmap_draw(punit, pUnit_Surf, 0, 0);
- if (punit->owner != game.player_idx) {
- rebuild_focus_anim_frames();
- }
- }
- else
- {
- /* Clear old sprite area. */
- dst.x = old_canvas_x;
- dst.y = old_canvas_y;
- dst.w = UNIT_TILE_WIDTH;
- dst.h = UNIT_TILE_HEIGHT;
- SDL_BlitSurface(pMap_Copy, NULL, Main.map, &dst);
- sdl_dirty_rect(dst);
- }
-
- dest.x = new_canvas_x;
- dest.y = new_canvas_y;
- dest.w = UNIT_TILE_WIDTH;
- dest.h = UNIT_TILE_HEIGHT;
- dst = dest;
-
- /* Save new background. */
- SDL_BlitSurface(Main.map, &dst, pMap_Copy, NULL);
-
- /* draw focus animation frame */
- if(is_isometric && (SDL_Client_Flags & CF_FOCUS_ANIMATION) &&
- pAnim->num_tiles_focused_unit) {
- dest.y += HALF_NORMAL_TILE_HEIGHT;
- dst = dest;
- SDL_BlitSurface(pAnim->Focus[frame++], NULL, Main.map, &dst);
- dest.y -= HALF_NORMAL_TILE_HEIGHT;
-
- if(!(frame < pAnim->num_tiles_focused_unit)) {
- frame = 0;
- }
- }
-
- /* Draw the new sprite. */
- dst = dest;
- SDL_BlitSurface(pUnit_Surf, NULL, Main.map, &dst);
- sdl_dirty_rect(dst);
-
- /* Write to screen. */
- flush_dirty();
-
- if (last_frame) {
- FREESURFACE(pMap_Copy);
- FREESURFACE(pUnit_Surf);
- }
-}
-
-/**************************************************************************
This function is called to decrease a unit's HP smoothly in battle when
combat_animation is turned on.
**************************************************************************/
Index: client/gui-stub/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/mapview.c,v
retrieving revision 1.39
diff -u -r1.39 mapview.c
--- client/gui-stub/mapview.c 9 Mar 2004 19:10:41 -0000 1.39
+++ client/gui-stub/mapview.c 12 Mar 2004 07:29:14 -0000
@@ -306,18 +306,6 @@
}
/**************************************************************************
- Draw a single frame of animation. This function needs to clear the old
- image and draw the new one. It must flush output to the display.
-**************************************************************************/
-void draw_unit_animation_frame(struct unit *punit,
- bool first_frame, bool last_frame,
- int old_canvas_x, int old_canvas_y,
- int new_canvas_x, int new_canvas_y)
-{
- /* PORTME */
-}
-
-/**************************************************************************
This function is called to decrease a unit's HP smoothly in battle when
combat_animation is turned on.
**************************************************************************/
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.103
diff -u -r1.103 mapview.c
--- client/gui-win32/mapview.c 12 Mar 2004 04:57:52 -0000 1.103
+++ client/gui-win32/mapview.c 12 Mar 2004 07:29:14 -0000
@@ -671,54 +671,6 @@
}
/**************************************************************************
- Draw a single frame of animation. This function needs to clear the old
- image and draw the new one. It must flush output to the display.
-**************************************************************************/
-void draw_unit_animation_frame(struct unit *punit,
- bool first_frame, bool last_frame,
- int old_canvas_x, int old_canvas_y,
- int new_canvas_x, int new_canvas_y)
-{
- static HDC mapstoredc, hdc, hdcwin;
- static HBITMAP old, oldbmp;
- static struct canvas canvas_store;
- /* Create extra backing store. This should be done statically. */
- if (first_frame) {
- mapstoredc = CreateCompatibleDC(NULL);
- old = SelectObject(mapstoredc, mapstorebitmap);
- hdc = CreateCompatibleDC(NULL);
- oldbmp = SelectObject(hdc, single_tile_pixmap);
- hdcwin = GetDC(map_window);
- canvas_store.hdc = hdc;
- canvas_store.bitmap = NULL;
- }
-
- /* Clear old sprite. */
- BitBlt(hdcwin, old_canvas_x, old_canvas_y, UNIT_TILE_WIDTH,
- UNIT_TILE_HEIGHT, mapstoredc, old_canvas_x, old_canvas_y, SRCCOPY);
-
- /* Draw the new sprite. */
- BitBlt(hdc, 0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, mapstoredc,
- new_canvas_x, new_canvas_y, SRCCOPY);
- put_unit_full(punit, &canvas_store, 0, 0);
-
- /* Write to screen. */
- BitBlt(hdcwin, new_canvas_x, new_canvas_y, UNIT_TILE_WIDTH,
- UNIT_TILE_HEIGHT, hdc, 0, 0, SRCCOPY);
-
- /* Flush. */
- GdiFlush();
-
- if (last_frame) {
- SelectObject(hdc, oldbmp);
- DeleteDC(hdc);
- ReleaseDC(map_window, hdcwin);
- SelectObject(mapstoredc, old);
- DeleteDC(mapstoredc);
- }
-}
-
-/**************************************************************************
**************************************************************************/
void overview_expose(HDC hdc)
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.168
diff -u -r1.168 mapview.c
--- client/gui-xaw/mapview.c 12 Mar 2004 04:57:52 -0000 1.168
+++ client/gui-xaw/mapview.c 12 Mar 2004 07:29:14 -0000
@@ -293,36 +293,6 @@
}
/**************************************************************************
- Draw a single frame of animation. This function needs to clear the old
- image and draw the new one. It must flush output to the display.
-**************************************************************************/
-void draw_unit_animation_frame(struct unit *punit,
- bool first_frame, bool last_frame,
- int old_canvas_x, int old_canvas_y,
- int new_canvas_x, int new_canvas_y)
-{
- struct canvas store = {single_tile_pixmap};
-
- /* Clear old sprite. */
- XCopyArea(display, map_canvas_store, XtWindow(map_canvas), civ_gc,
- old_canvas_x, old_canvas_y, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
- old_canvas_x, old_canvas_y);
-
- /* Draw the new sprite. */
- XCopyArea(display, map_canvas_store, single_tile_pixmap, civ_gc,
- new_canvas_x, new_canvas_y, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, 0,
- 0);
- put_unit_full(punit, &store, 0, 0);
-
- /* Write to screen. */
- XCopyArea(display, single_tile_pixmap, XtWindow(map_canvas), civ_gc, 0, 0,
- UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, new_canvas_x, new_canvas_y);
-
- /* Flush. */
- XSync(display, 0);
-}
-
-/**************************************************************************
...
**************************************************************************/
void overview_canvas_expose(Widget w, XEvent *event, Region exposed,
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.50
diff -u -r1.50 mapview_g.h
--- client/include/mapview_g.h 12 Mar 2004 04:57:52 -0000 1.50
+++ client/include/mapview_g.h 12 Mar 2004 07:29:14 -0000
@@ -72,11 +72,6 @@
void put_cross_overlay_tile(int x,int y);
void put_city_workers(struct city *pcity, int color);
-void draw_unit_animation_frame(struct unit *punit,
- bool first_frame, bool last_frame,
- int old_canvas_x, int old_canvas_y,
- int new_canvas_x, int new_canvas_y);
-
void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h);
void tileset_changed(void);
|
|