/*************************************************************************** ... ***************************************************************************/ void create_overlay_unit(struct canvas *pcanvas, struct unit_type *punittype) { int x1, x2, y1, y2; int width, height; struct sprite *sprite = get_unittype_sprite(tileset, punittype); sprite_get_bounding_box(sprite, &x1, &y1, &x2, &y2); if (pcanvas->type == CANVAS_PIXBUF) { width = gdk_pixbuf_get_width(pcanvas->v.pixbuf); height = gdk_pixbuf_get_height(pcanvas->v.pixbuf); gdk_pixbuf_fill(pcanvas->v.pixbuf, 0x00000000); } else { if (pcanvas->type == CANVAS_PIXCOMM) { gtk_pixcomm_clear(pcanvas->v.pixcomm); } /* Guess */ width = tileset_full_tile_width(tileset); height = tileset_full_tile_height(tileset); } /* Finally, put a picture of the unit in the tile */ canvas_put_sprite(pcanvas, 0, 0, sprite, (x2 + x1 - width) / 2, (y1 + y2 - height) / 2, tileset_full_tile_width(tileset) - (x2 + x1 - width) / 2, tileset_full_tile_height(tileset) - (y1 + y2 - height) / 2); }
/************************************************************************** Fill pixcomm with unit gfx **************************************************************************/ void put_unit_gpixmap(struct unit *punit, GtkPixcomm *p) { struct canvas canvas_store = FC_STATIC_CANVAS_INIT; canvas_store.surface = gtk_pixcomm_get_surface(p); gtk_pixcomm_clear(p); put_unit(punit, &canvas_store, 1.0, 0, 0); }
/************************************************************************** ... **************************************************************************/ void put_unit_gpixmap(struct unit *punit, GtkPixcomm *p) { struct canvas canvas_store; canvas_store.type = CANVAS_PIXCOMM; canvas_store.v.pixcomm = p; gtk_pixcomm_freeze(p); gtk_pixcomm_clear(p); put_unit(punit, &canvas_store, 0, 0); gtk_pixcomm_thaw(p); }