Exemplo n.º 1
0
/**************************************************************************
  Convert text describing direction into direction
**************************************************************************/
Direction api_utilities_str2dir(lua_State *L, const char *dir)
{
  LUASCRIPT_CHECK_STATE(L, direction8_invalid());
  LUASCRIPT_CHECK_ARG_NIL(L, dir, 2, string, direction8_invalid());

  return direction8_by_name(dir, fc_strcasecmp);
}
Exemplo n.º 2
0
/***************************************************************************
  Put unit sprite to canvas
***************************************************************************/
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,
                                              direction8_invalid());

  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);
}
Exemplo n.º 3
0
/***************************************************************************
...
***************************************************************************/
Pixmap create_overlay_unit(const struct unit_type *punittype)
{
  Pixmap pm;
  enum color_std bg_color;
  
  pm=XCreatePixmap(display, root_window, 
		   tileset_full_tile_width(tileset), tileset_full_tile_height(tileset), display_depth);

  /* Give tile a background color, based on the type of unit */
  /* Should there be colors like COLOR_MAPVIEW_LAND etc? -ev */
  switch (unit_color_type(punittype)) {
    case UNIT_BG_LAND:
      bg_color = COLOR_OVERVIEW_LAND;
      break;
    case UNIT_BG_SEA:
      bg_color = COLOR_OVERVIEW_OCEAN;
      break;
    case UNIT_BG_HP_LOSS:
    case UNIT_BG_AMPHIBIOUS:
      bg_color = COLOR_OVERVIEW_MY_UNIT;
      break;
    case UNIT_BG_FLYING:
      bg_color = COLOR_OVERVIEW_ENEMY_CITY;
      break;
    default:
      bg_color = COLOR_OVERVIEW_UNKNOWN;
      break;
  }
  XSetForeground(display, fill_bg_gc,
		 get_color(tileset, bg_color)->color.pixel);
  XFillRectangle(display, pm, fill_bg_gc, 0,0, 
		 tileset_full_tile_width(tileset), tileset_full_tile_height(tileset));

  /* If we're using flags, put one on the tile */
  if(!solid_color_behind_units)  {
    struct sprite *flag = get_nation_flag_sprite(tileset, nation_of_player(client.conn.playing));

    XSetClipOrigin(display, civ_gc, 0,0);
    XSetClipMask(display, civ_gc, flag->mask);
    XCopyArea(display, flag->pixmap, pm, civ_gc, 0,0, 
    	      flag->width,flag->height, 0,0);
    XSetClipMask(display, civ_gc, None);
  }

  /* Finally, put a picture of the unit in the tile */
/*  if(i<utype_count()) */ {
    struct sprite *s = get_unittype_sprite(tileset, punittype,
                                           direction8_invalid());

    XSetClipOrigin(display,civ_gc,0,0);
    XSetClipMask(display,civ_gc,s->mask);
    XCopyArea(display, s->pixmap, pm, civ_gc,
	      0,0, s->width,s->height, 0,0 );
    XSetClipMask(display,civ_gc,None);
  }
  return(pm);
}
Exemplo n.º 4
0
/****************************************************************
  Setup max unit sprite size.
*****************************************************************/
static void update_max_unit_size(void)
{
  max_unit_height = 0;
  max_unit_width = 0;

  unit_type_iterate(i) {
    int x1, x2, y1, y2;
    struct sprite *sprite = get_unittype_sprite(tileset, i,
                                                direction8_invalid(), TRUE);

    sprite_get_bounding_box(sprite, &x1, &y1, &x2, &y2);
    max_unit_width = MAX(max_unit_width, x2 - x1);
    max_unit_height = MAX(max_unit_height, y2 - y1);
  } unit_type_iterate_end;
}