示例#1
0
文件: plrdlg.cpp 项目: valisc/freeciv
/**************************************************************************
  Returns data from item
**************************************************************************/
QVariant plr_item::data(int column, int role) const
{
  QPixmap *pix;
  struct player_dlg_column *pdc;

  if (role == Qt::UserRole) {
    return QVariant::fromValue((void *)ipplayer);
  }
  if (role != Qt::DisplayRole) {
    return QVariant();
  }
  pdc = &player_dlg_columns[column];
  switch (player_dlg_columns[column].type) {
  case COL_FLAG:
    pix = get_nation_flag_sprite(tileset, nation_of_player(ipplayer))->pm;
    return *pix;
    break;
  case COL_COLOR:
    return get_player_color(tileset, ipplayer)->qcolor;
    break;
  case COL_BOOLEAN:
    return pdc->bool_func(ipplayer);
    break;
  case COL_TEXT:
  case COL_RIGHT_TEXT:
    return pdc->func(ipplayer);
  default:
    return QVariant();
  }
  return QVariant();
}
示例#2
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);
}