Exemplo n.º 1
0
/**********************************************************************
  Set city icons sprite value; should only happen after
  tileset_load_tiles(tileset).
***********************************************************************/
void tilespec_setup_city_icons(void)
{

  struct sprite *pSpr = NULL;
  
  pIcons = ( struct City_Icon *)fc_calloc(1,  sizeof( struct City_Icon ));
  
  load_city_icon_surface(pSpr, pBIG_Food_Corr, "city.food_waste");
  load_city_icon_surface(pSpr, pBIG_Shield_Corr, "city.shield_waste");
  load_city_icon_surface(pSpr, pBIG_Trade_Corr, "city.trade_waste");
  load_city_icon_surface(pSpr, pBIG_Food, "city.food");
      
  pIcons->pBIG_Food_Surplus = crop_rect_from_surface(pIcons->pBIG_Food, NULL);
  SDL_SetAlpha(pIcons->pBIG_Food_Surplus, SDL_SRCALPHA, 128);
    
  load_city_icon_surface(pSpr, pBIG_Shield, "city.shield");
  
  pIcons->pBIG_Shield_Surplus = crop_rect_from_surface(pIcons->pBIG_Shield, NULL);
  SDL_SetAlpha(pIcons->pBIG_Shield_Surplus, SDL_SRCALPHA, 128);
  
  load_city_icon_surface(pSpr, pBIG_Trade, "city.trade");
  load_city_icon_surface(pSpr, pBIG_Luxury, "city.lux");
  load_city_icon_surface(pSpr, pBIG_Coin, "city.coin");
  load_city_icon_surface(pSpr, pBIG_Colb, "city.colb");
  load_city_icon_surface(pSpr, pBIG_Face, "city.red_face");
  load_city_icon_surface(pSpr, pBIG_Coin_Corr, "city.dark_coin");
  load_city_icon_surface(pSpr, pBIG_Coin_UpKeep, "city.unkeep_coin");
  		  
  /* small icon */
  load_city_icon_surface(pSpr, pFood, "city.small_food");
  load_city_icon_surface(pSpr, pShield, "city.small_shield");
  load_city_icon_surface(pSpr, pTrade, "city.small_trade");
  load_city_icon_surface(pSpr, pFace, "city.small_red_face");
  load_city_icon_surface(pSpr, pLuxury, "city.small_lux");
  load_city_icon_surface(pSpr, pCoin, "city.small_coin");		  
  load_city_icon_surface(pSpr, pColb, "city.small_colb");		  
    
  load_city_icon_surface(pSpr, pPollution, "city.pollution");
  /* ================================================================= */
  
  load_city_icon_surface(pSpr, pPolice, "city.police");
  /* ================================================================= */
  pIcons->pWorklist = create_surf_alpha(9,9, SDL_SWSURFACE);
  SDL_FillRect(pIcons->pWorklist, NULL,
		  SDL_MapRGB(pIcons->pWorklist->format, 255, 255,255));
  putframe(pIcons->pWorklist, 0,0, pIcons->pWorklist->w - 1, pIcons->pWorklist->h - 1,
    map_rgba(pIcons->pWorklist->format, *get_game_colorRGB(COLOR_THEME_CITYREP_FRAME)));
  putline(pIcons->pWorklist, 3, 2, 5, 2,
    map_rgba(pIcons->pWorklist->format, *get_game_colorRGB(COLOR_THEME_CITYREP_FRAME)));
  putline(pIcons->pWorklist, 3, 4, 7, 4, 
    map_rgba(pIcons->pWorklist->format, *get_game_colorRGB(COLOR_THEME_CITYREP_FRAME)));
  putline(pIcons->pWorklist, 3, 6, 6, 6,
    map_rgba(pIcons->pWorklist->format, *get_game_colorRGB(COLOR_THEME_CITYREP_FRAME)));
  
  /* ================================================================= */
  
  /* force reload citizens icons */
  pIcons->style = 999;
}
Exemplo n.º 2
0
Arquivo: level.c Projeto: callaa/luola
/* Initialize level subsystem */
void init_level (void)
{
    int r,red, green, blue;
    lev_watercol = map_rgba(0x64,0x64,0xff,0xff);
    level_effects = NULL;
    lev_lastfx = NULL;
    for (r = 0; r < FIRE_FRAMES; r++) {
        if (r == 0)
            red = 0;
        else
            red = 128 + (255.0 / FIRE_FRAMES) * r;
        green = (255.0 / FIRE_FRAMES) * r;
        blue = 0;
        if (red > 255)
            red = 255;
        burncolor[r] = map_rgba(red,green,blue,0xff);
    }
}
Exemplo n.º 3
0
/* Draw a single weapon selection bar */
static SDL_Rect draw_weapon_bar(SDL_Surface *surface,int plr) {
    SDL_Rect rect;
    Uint32 color;
    int i,plrs=0;
    switch(plr) {
        case 0: color = map_rgba(156,0,0,255); break;
        case 1: color = map_rgba(0,0,156,255); break;
        case 2: color = map_rgba(0,156,0,255); break;
        case 3: color = map_rgba(156,156,0,255); break;
        default: color = 0;
    }

    rect.x = 0; rect.w = screen->w/4-WEAPON_SEP;
    rect.h = font_height(Bigfont);

    rect.y = 0;
    for(i=0;i<4;i++) {
        if(players[i].state != INACTIVE) {
            plrs++;
            if(i<plr) rect.y += rect.h + WEAPON_SEP;
        }
    }

    rect.y += screen->h/2 - ((rect.h + WEAPON_SEP) * plrs)/2;

    fill_box(surface,rect.x,rect.y,rect.w,rect.h,color);

    putstring_direct(surface, Bigfont, rect.x + 10, rect.y,
            normal_weapon[players[plr].standardWeapon].name, font_color_white);

    rect.x = rect.w + WEAPON_SEP;
    rect.w = screen->w - rect.x;

    fill_box(surface,rect.x,rect.y,rect.w,rect.h,color);

    putstring_direct(surface, Bigfont, rect.x + 10, rect.y,
            special_weapon[players[plr].specialWeapon].name, font_color_white);

    rect.x = 0;
    rect.w = screen->w;

    return rect;
}
Exemplo n.º 4
0
/**************************************************************************
  ...
**************************************************************************/
void setup_auxiliary_tech_icons(void)
{
  SDL_Color bg_color = {255, 255, 255, 136};

  SDL_Surface *pSurf;
  SDL_String16 *pStr = create_str16_from_char(_("None"), adj_font(10));
  
  pStr->style |= (TTF_STYLE_BOLD | SF_CENTER);
    
  /* create icons */
  pSurf = create_surf_alpha(adj_size(50), adj_size(50), SDL_SWSURFACE);
  SDL_FillRect(pSurf, NULL, map_rgba(pSurf->format, bg_color));
  putframe(pSurf, 0 , 0, pSurf->w - 1, pSurf->h - 1,
         map_rgba(pSurf->format, *get_game_colorRGB(COLOR_THEME_SCIENCEDLG_FRAME)));

  pNeutral_Tech_Icon = SDL_DisplayFormatAlpha(pSurf);
  pNone_Tech_Icon = SDL_DisplayFormatAlpha(pSurf);    
  pFuture_Tech_Icon = SDL_DisplayFormatAlpha(pSurf);
  
  FREESURFACE(pSurf);
    
  /* None */
  pSurf = create_text_surf_from_str16(pStr);
  blit_entire_src(pSurf, pNone_Tech_Icon ,
	  (adj_size(50) - pSurf->w) / 2 , (adj_size(50) - pSurf->h) / 2);
  
  FREESURFACE(pSurf);
  
  /* TRANS: Future Technology */ 
  copy_chars_to_string16(pStr, _("FT"));
  pSurf = create_text_surf_from_str16(pStr);
  blit_entire_src(pSurf, pFuture_Tech_Icon,
	  (adj_size(50) - pSurf->w) / 2 , (adj_size(50) - pSurf->h) / 2);
  
  FREESURFACE(pSurf);
  
  FREESTRING16(pStr);
    
}
Exemplo n.º 5
0
/****************************************************************************
  Create a sprite with the given height, width and color.
****************************************************************************/
struct sprite *create_sprite(int width, int height, struct color *pcolor)
{
  SDL_Surface *mypixbuf = NULL;
  SDL_Surface *pmask = NULL;

  fc_assert_ret_val(width > 0, NULL);
  fc_assert_ret_val(height > 0, NULL);
  fc_assert_ret_val(pcolor != NULL, NULL);

  mypixbuf = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
                                  0x00ff0000, 0x0000ff00, 0x000000ff,
                                  0xff000000);
  pmask = SDL_DisplayFormatAlpha(mypixbuf);
  SDL_FillRect(mypixbuf, NULL, map_rgba(pmask->format, *pcolor->color));

  return ctor_sprite(mypixbuf);
}
Exemplo n.º 6
0
/* Returns the width of the thumbnail */
static int draw_level(SDL_Surface *surface, struct LevelThumbnail *level,
        int x,int y,int visibility,int selected)
{
    int thwidth;
    SDL_Rect rect;
    Uint8 alpha;
    rect.x = x;
    rect.y = y;
    if(level->thumbnail) {
        SDL_Rect src = {0,0,level->thumbnail->w,level->thumbnail->h};
        thwidth = level->thumbnail->w;
        if(rect.x<0) {
            src.x = -rect.x;
            src.w -= src.x;
            rect.x = 0;
        }
        if(visibility > level->thumbnail->w)
            alpha = SDL_ALPHA_OPAQUE;
        else
            alpha = visibility/(double)level->thumbnail->w*SDL_ALPHA_OPAQUE;
        SDL_SetAlpha(level->thumbnail,SDL_SRCALPHA,alpha);
        SDL_BlitSurface(level->thumbnail,&src,surface,&rect);
    } else {
        rect.w = THUMBNAIL_HEIGHT;
        rect.h = THUMBNAIL_HEIGHT;
        thwidth = rect.w;
        if(visibility > THUMBNAIL_HEIGHT)
            alpha = SDL_ALPHA_OPAQUE;
        else
            alpha = visibility/(double)THUMBNAIL_HEIGHT*SDL_ALPHA_OPAQUE;
        fill_box(surface,rect.x,rect.y,rect.w,rect.h,map_rgba(0,0,0,alpha));
    }
    if(selected) {
        draw_box(rect.x-3, rect.y-3, rect.w+6, rect.h+6, 3, col_cyan);
        rect.y += rect.h + 4;
        rect.x += rect.w/2 - level->name->w/2;
        SDL_BlitSurface(level->name,NULL,surface,&rect);
    }

    return thwidth;
}
Exemplo n.º 7
0
/** Initialize video **/
void init_video () {
    int swidth,sheight;
    switch(luola_options.videomode) {
    case VID_640:
        swidth = 640;
        sheight = 480;
        break;
    case VID_800:
        swidth = 800;
        sheight = 600;
        break;
    case VID_1024:
        swidth = 1024;
        sheight = 768;
        break;
    default:
        fprintf(stderr,"Bug! init_video(): unknown video mode %d!\n",luola_options.videomode);
        exit(1);
    }
    screen =
        SDL_SetVideoMode (swidth, sheight, SCREEN_DEPTH,
                          (luola_options.fullscreen?SDL_FULLSCREEN:0)|SDL_SWSURFACE);
    if (screen == NULL) {
        fprintf (stderr,"Unable to set video mode: %s\n", SDL_GetError ());
        exit (1);
    }
    if (luola_options.hidemouse)
        SDL_ShowCursor (SDL_DISABLE);
    /* Set window caption */
    SDL_WM_SetCaption (PACKAGE_STRING, PACKAGE);
    /* Initialize colours */
    col_black = map_rgba (0, 0, 0, 255);
    col_gray = map_rgba (128, 128, 128, 255);
    col_grenade = map_rgba (160, 160, 160, 255);
    col_snow = map_rgba (176, 193, 255, 255);
    col_clay = map_rgba (255, 200, 128, 255);
    col_default = map_rgba (255, 100, 100, 255);
    col_yellow = map_rgba (255, 255, 100, 255);
    col_red = map_rgba (255, 0, 0, 255);
    col_blue = map_rgba (0, 0, 255, 255);
    col_cyan = map_rgba (0, 128, 255, 255);
    col_white = map_rgba (255, 255, 255, 255);
    col_rope = map_rgba (178, 159, 103, 255);
    col_plrs[0] = map_rgba (255, 0, 0, 255);
    col_plrs[1] = map_rgba (0, 0, 255, 255);
    col_plrs[2] = map_rgba (0, 255, 0, 255);
    col_plrs[3] = map_rgba (255, 255, 0, 255);
    col_pause_backg = map_rgba (128, 128, 128, 128);
    col_green = map_rgba (0, 158, 0, 255);
    col_translucent = map_rgba(255,255,255,128);
}
Exemplo n.º 8
0
Arquivo: intro.c Projeto: callaa/luola
/* Load some graphics and create menus */
void init_intro (LDAT *miscfile) {
    struct MenuDrawingOptions mainmenu, optionsmenu;
    struct MenuValue optsval;
    int logoy=10;
    int yoffset=250;
    int optionsy=80;
    /* Load the input device icons */
    keyb_icon = load_image_ldat (miscfile, 1, T_ALPHA, "KEYBOARD", 0);
    pad_icon = load_image_ldat (miscfile, 1, T_ALPHA, "PAD", 0);

    switch(luola_options.videomode) {
        case VID_640:
            yoffset = 250;
            logoy = 10;
            optionsy = 80;
            break;
        case VID_800:
            yoffset = 280;
            logoy = 40;
            optionsy = 120;
            break;
        case VID_1024:
            yoffset = 380;
            logoy = 90;
            optionsy = 220;
            break;
    }

    /* Menu drawing options */
    mainmenu.area.x = 0;
    mainmenu.area.y = yoffset;
    mainmenu.area.w = screen->w;
    mainmenu.area.h = screen->h-yoffset;
    mainmenu.spacing = MENU_SPACING;
    mainmenu.selection_color = map_rgba(0,128,255,255);
    mainmenu.left_offset = screen->h/2;

    optionsmenu = mainmenu;
    optionsmenu.area.y = optionsy;
    optionsmenu.left_offset = 130;

    /* Load graphics */
    intr_logo = load_image_ldat (miscfile, 1, 2, "LOGO", 0);
    if (intr_logo) {
        intr_logo_rect.x = screen->w / 2 - intr_logo->w / 2;
        intr_logo_rect.y = logoy;
        centered_string (intr_logo, Smallfont, intr_logo->h - 20, VERSION,
                         font_color_red);
    }

    /* Build main menu */
    intro_menu = create_menu(0,NULL,&mainmenu,
            "enabled","disabled",INTRO_RVAL_EXIT);
    add_menu_item(intro_menu,MNU_ITEM_RETURN,INTRO_RVAL_STARTGAME,
            menu_txt_label("Start game"),MnuNullValue);
    optsval.value = (int*)make_options_menu(intro_menu,&optionsmenu);
    add_menu_item(intro_menu,MNU_ITEM_SUBMENU,0,
            menu_txt_label("Settings"),optsval);
    add_menu_item(intro_menu,MNU_ITEM_RETURN,INTRO_RVAL_EXIT,
            menu_txt_label("Exit"),MnuNullValue);

    intro_menu->predraw = draw_logo;

    /* Misc. variable initialization */
    intr_message.show = 0;
    intr_message.text = NULL;
    intr_message.setkey = NULL;
    intr_message.framecolor = map_rgba(200,80,80,220);
    intr_message.fillcolor = map_rgba(0,0,0,220);
}
Exemplo n.º 9
0
Arquivo: level.c Projeto: callaa/luola
/* Load level and prepare for new game */
void load_level (struct LevelFile *lev) {
    SDL_Surface *collmap;
    int x, y, p, r;
    int freepix, otherpix;
    SDL_Color *tmpcol, defaultwater;
    Uint8 *bits;
    int basebufsize;

    defaultwater.r = 0;
    defaultwater.g = 0;
    defaultwater.b = 255;

    /* Load level artwork */
    lev_level.terrain = load_level_art (lev);
    lev_level.width = lev_level.terrain->w;
    lev_level.height = lev_level.terrain->h;
    /* Load level collisionmap */
    collmap = load_level_coll (lev);
    if (!collmap) {
        printf ("An error occured while loading collisionmap\n");
        exit (1);
    }
    if (collmap->w != lev_level.width || collmap->h != lev_level.height) {
        printf
            ("Error Collision map image \"%s\" has incorrect size (%dx%d), should be %dx%d!\n",
             lev->settings->mainblock.collmap, collmap->w, collmap->h,
             lev_level.width, lev_level.height);
        exit (1);
    }
    /* Get palette entries */
    /* Get water colour */
    tmpcol = &defaultwater;
    find_color(TER_WATER,lev->settings->palette.entries,
            collmap->format->palette,&tmpcol);
    lev_watercol = map_rgba(tmpcol->r, tmpcol->g, tmpcol->b,0xff);
    /* Calculate underwater clay colour */
    col_clay_uw = map_rgba((tmpcol->r+255)/2, (tmpcol->r+200)/2, (tmpcol->r+128)/2, 0xff);
    /* Get snow colour */
    tmpcol = NULL;
    find_color(TER_SNOW,lev->settings->palette.entries,
            collmap->format->palette,&tmpcol);
    if (tmpcol) {
        col_snow = map_rgba(tmpcol->r, tmpcol->g, tmpcol->b,0xff);
    }
    /* Prepare base regeneration array */
    if(game_settings.base_regen) {
        basebufsize=512;   /* Some arbitary size */
        lev_level.base = malloc(sizeof(RegenCoord)*basebufsize);
    } else {
        basebufsize=0;
        lev_level.base = NULL;
    }
    /* Load data map */
    lev_level.base_area = 0;
    lev_level.regen_area = 0;
    lev_level.solid = malloc (sizeof (char *) * lev_level.width);
    freepix = 0;
    otherpix = 0;
    for (x = 0; x < lev_level.width; x++) {
        bits = ((Uint8 *) collmap->pixels)+x;
        lev_level.solid[x] = malloc (lev_level.height);
        for (y = 0; y < lev_level.height; y++,bits+=collmap->pitch) {
            lev_level.solid[x][y] = lev->settings->palette.entries[*bits];
            if (lev_level.solid[x][y] == TER_FREE
                || lev_level.solid[x][y] == TER_WATER)
                freepix++;
            else {
                otherpix++;
                if (lev_level.solid[x][y] == TER_BASE) {
                    if(lev_level.base) {
                        Uint8 r,g,b;
                        lev_level.base[lev_level.base_area].x=x;
                        lev_level.base[lev_level.base_area].y=y;
                        SDL_GetRGB(getpixel(lev_level.terrain,x,y),
                                screen->format,
                                &r,
                                &g,
                                &b);
                        lev_level.base[lev_level.base_area].c=
                            map_rgba(r, g, b, 0xff);

                        if(lev_level.base_area==basebufsize-1) {
                            basebufsize+=512;
                            lev_level.base=realloc(lev_level.base,
                                    sizeof(RegenCoord)*basebufsize);
                        }
                    }
                    lev_level.base_area++;
                }
            }
        }
    }
    SDL_FreeSurface (collmap);
    /* Finalize the base regeneration buffer */
    if(lev_level.base) {
        lev_level.regen_timer = 0;
        lev_level.regen_area = lev_level.base_area;
        if(lev_level.base_area<basebufsize) {
            basebufsize=lev_level.base_area;
            lev_level.base=realloc(lev_level.base,
                    sizeof(RegenCoord)*basebufsize);
        }
        qsort(lev_level.base,lev_level.base_area,sizeof(RegenCoord),sort_regen);
    }
    /* Position players */
    if (game_settings.playmode == OutsideShip
        || game_settings.playmode == OutsideShip1)
        y = 2;
    else
        y = 1;
    for (p = 0; p < 4; p++)
        if (players[p].state != INACTIVE) {
            for (x = 0; x < y; x++) {
                r = 0;
                do {
                    lev_level.player_def_x[x][p] = rand () % lev_level.width;
                    lev_level.player_def_y[x][p] = rand () % lev_level.height;
                    r++;
                    if (r > 100000) {
                        fprintf(stderr,
                                "Warning: while searching for player %d startup position, loop counter reached 100000!\n",
                             p);
                        fprintf(stderr,
                            "Number of free space (including water) pixels: %d, number of other pixels: %d\n",
                             freepix, otherpix);
                        fprintf (stderr,
                                "%0.3f%% of the surface area is available\n",
                                ((double) freepix / (double) otherpix) * 100);
                        exit (0);
                    }
                } while (lev_level.
                         solid[lev_level.player_def_x[x][p]][lev_level.
                                                             player_def_y[x]
                                                             [p]] !=
                         TER_FREE);
            }
        }
}
Exemplo n.º 10
0
/****************************************************************
 Pops-up the Spy sabotage dialog, upon return of list of
 available improvements requested by the above function.
*****************************************************************/
void popup_sabotage_dialog(struct city *pCity)
{
  struct widget *pWindow = NULL, *pBuf = NULL , *pLast = NULL;
  struct CONTAINER *pCont;
  struct unit *pUnit = head_of_units_in_focus();
  SDL_String16 *pStr;
  SDL_Rect area, area2;
  int n, w = 0, h, imp_h = 0;
  
  if (pDiplomat_Dlg || !pUnit || !unit_has_type_flag(pUnit, F_SPY)) {
    return;
  }
  
  is_unit_move_blocked = TRUE;
    
  pDiplomat_Dlg = fc_calloc(1, sizeof(struct diplomat_dialog));
  pDiplomat_Dlg->diplomat_id = pUnit->id;
  pDiplomat_Dlg->diplomat_target_id = pCity->id;
  pDiplomat_Dlg->pdialog = fc_calloc(1, sizeof(struct ADVANCED_DLG));
  
  pCont = fc_calloc(1, sizeof(struct CONTAINER));
  pCont->id0 = pCity->id;
  pCont->id1 = pUnit->id;/* spy id */
    
  pStr = create_str16_from_char(_("Select Improvement to Sabotage") , adj_font(12));
  pStr->style |= TTF_STYLE_BOLD;
  
  pWindow = create_window_skeleton(NULL, pStr, 0);
    
  pWindow->action = diplomat_dlg_window_callback;
  set_wstate(pWindow, FC_WS_NORMAL);
  
  add_to_gui_list(ID_TERRAIN_ADV_DLG_WINDOW, pWindow);
  pDiplomat_Dlg->pdialog->pEndWidgetList = pWindow;
  
  area = pWindow->area;
  area.h = MAX(area.h, adj_size(2));
  
  /* ---------- */
  /* exit button */
  pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst,
                          WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND);
  pBuf->info_label = create_str16_from_char(_("Close Dialog (Esc)"),
                                            adj_font(12));
  area.w += pBuf->size.w + adj_size(10);
  pBuf->action = diplomat_close_callback;
  set_wstate(pBuf, FC_WS_NORMAL);
  pBuf->key = SDLK_ESCAPE;
  
  add_to_gui_list(ID_TERRAIN_ADV_DLG_EXIT_BUTTON, pBuf);
  /* ---------- */
  
  create_active_iconlabel(pBuf, pWindow->dst, pStr,
	    _("City Production"), sabotage_impr_callback);
  pBuf->data.cont = pCont;  
  set_wstate(pBuf, FC_WS_NORMAL);
  set_wflag(pBuf, WF_FREE_DATA);
  add_to_gui_list(MAX_ID - 1000, pBuf);
    
  area.w = MAX(area.w, pBuf->size.w);
  area.h += pBuf->size.h;

  /* separator */
  pBuf = create_iconlabel(NULL, pWindow->dst, NULL, WF_FREE_THEME);
    
  add_to_gui_list(ID_SEPARATOR, pBuf);
  area.h += pBuf->next->size.h;
  /* ------------------ */
  n = 0;
  city_built_iterate(pCity, pImprove) {
    if (pImprove->sabotage > 0) {
      
      create_active_iconlabel(pBuf, pWindow->dst, pStr,
	      (char *) city_improvement_name_translation(pCity, pImprove),
				      sabotage_impr_callback);
      pBuf->data.cont = pCont;
      set_wstate(pBuf , FC_WS_NORMAL);
  
      add_to_gui_list(MAX_ID - improvement_number(pImprove), pBuf);
    
      area.w = MAX(area.w , pBuf->size.w);
      imp_h += pBuf->size.h;
      
      if (!pDiplomat_Dlg->pdialog->pEndActiveWidgetList)
      {
	pDiplomat_Dlg->pdialog->pEndActiveWidgetList = pBuf;
      }
    
      if (improvement_number(pImprove) > 9)
      {
        set_wflag(pBuf, WF_HIDDEN);
      }
      
      n++;    
      /* ----------- */
    }  
  } city_built_iterate_end;

  pDiplomat_Dlg->pdialog->pBeginActiveWidgetList = pBuf;
  
  if (n > 0) {
    /* separator */
    pBuf = create_iconlabel(NULL, pWindow->dst, NULL, WF_FREE_THEME);
    
    add_to_gui_list(ID_SEPARATOR, pBuf);
    area.h += pBuf->next->size.h;
  /* ------------------ */
  }
  
  create_active_iconlabel(pBuf, pWindow->dst, pStr, _("At Spy's Discretion"),
			  sabotage_impr_callback);
  pBuf->data.cont = pCont;  
  set_wstate(pBuf, FC_WS_NORMAL);
  
  add_to_gui_list(MAX_ID - B_LAST, pBuf);
    
  area.w = MAX(area.w, pBuf->size.w);
  area.h += pBuf->size.h;
  /* ----------- */
  
  pLast = pBuf;
  pDiplomat_Dlg->pdialog->pBeginWidgetList = pLast;
  pDiplomat_Dlg->pdialog->pActiveWidgetList = pDiplomat_Dlg->pdialog->pEndActiveWidgetList;
  
  /* ---------- */
  if (n > 10)
  {
    imp_h = 10 * pBuf->size.h;
    
    n = create_vertical_scrollbar(pDiplomat_Dlg->pdialog,
		  1, 10, TRUE, TRUE);
    area.w += n;
  }
  /* ---------- */
  
  
  area.h += imp_h;

  resize_window(pWindow, NULL, NULL, 
                (pWindow->size.w - pWindow->area.w) + area.w,
                (pWindow->size.h - pWindow->area.h) + area.h);
  
  area = pWindow->area;
  
  auto_center_on_focus_unit();
  put_window_near_map_tile(pWindow, pWindow->size.w, pWindow->size.h,
                           pUnit->tile);        
  
  w = area.w;
  
  if (pDiplomat_Dlg->pdialog->pScroll)
  {
    w -= n;
    imp_h = pBuf->size.w;
  }
  else
  {
    imp_h = 0;
  }
  
  /* exit button */
  pBuf = pWindow->prev;
  pBuf->size.x = area.x + area.w - pBuf->size.w - 1;
  pBuf->size.y = pWindow->size.y + adj_size(2);
  
  /* Production sabotage */
  pBuf = pBuf->prev;
  
  pBuf->size.x = area.x;
  pBuf->size.y = area.y + 1;
  pBuf->size.w = w;
  h = pBuf->size.h;
  
  area2.x = adj_size(10);
  area2.h = adj_size(2);
  
  pBuf = pBuf->prev;
  while(pBuf)
  {
    
    if (pBuf == pDiplomat_Dlg->pdialog->pEndActiveWidgetList)
    {
      w -= imp_h;
    }
    
    pBuf->size.w = w;
    pBuf->size.x = pBuf->next->size.x;
    pBuf->size.y = pBuf->next->size.y + pBuf->next->size.h;
    
    if (pBuf->ID == ID_SEPARATOR)
    {
      FREESURFACE(pBuf->theme);
      pBuf->size.h = h;
      pBuf->theme = create_surf(w, h, SDL_SWSURFACE);
    
      area2.y = pBuf->size.h / 2 - 1;
      area2.w = pBuf->size.w - adj_size(20);
      
      SDL_FillRect(pBuf->theme , &area2, map_rgba(pBuf->theme->format, *get_game_colorRGB(COLOR_THEME_SABOTAGEDLG_SEPARATOR)));
    }
    
    if (pBuf == pLast) {
      break;
    }
    pBuf = pBuf->prev;  
  }
  
  if (pDiplomat_Dlg->pdialog->pScroll)
  {
    setup_vertical_scrollbar_area(pDiplomat_Dlg->pdialog->pScroll,
	area.x + area.w,
    	pDiplomat_Dlg->pdialog->pEndActiveWidgetList->size.y,
    	area.y - pDiplomat_Dlg->pdialog->pEndActiveWidgetList->size.y +
	    area.h, TRUE);
  }
  
  /* -------------------- */
  /* redraw */
  redraw_group(pDiplomat_Dlg->pdialog->pBeginWidgetList, pWindow, 0);

  widget_flush(pWindow);
  
}