Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2002:
[Freeciv-Dev] Re: Nation Selection Dialog (Resubmit) [Patch] (PR#2057)
Home

[Freeciv-Dev] Re: Nation Selection Dialog (Resubmit) [Patch] (PR#2057)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Daniel L Speyer <dspeyer@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Nation Selection Dialog (Resubmit) [Patch] (PR#2057)
From: Mike Kaufman <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 14 Sep 2002 08:35:04 -0500

this is nice. couple of things:

o follow style guide (spaces between operators, etc).
o it'd be really nice if you could highlight the toggle button when a
  nation is selected from the drop down box.
o could you take the flag code and put it in a separate function?
  right now it's in 3 different places (4 when gtk2 gets it)

add a client/gui_stuff_common.c and put it there. I did a very similar
thing for civworld, here's the function:

/**************************************************************************
...
**************************************************************************/
void build_flag_sprite(SPRITE **flag, struct player *pplayer, int height)
{
  int start_x, start_y, end_x, end_y, flag_h, flag_w, newflag_h, newflag_w;
  SPRITE *origflag, *croped, *scaled;

  origflag = get_nation_by_plr(pplayer)->flag_sprite;
  if (!origflag) {
    flag = NULL;
    return;
  }

  /* calculate the bounding box ... */
  sprite_get_bounding_box(origflag, &start_x, &start_y, &end_x, &end_y);

  assert(start_x != -1);
  assert(start_y != -1);
  assert(end_x != -1);
  assert(end_y != -1);

  flag_w = (end_x - start_x) + 1;
  flag_h = (end_y - start_y) + 1;

  /* if the flag is smaller then 5 x 5, something is wrong */
  assert(flag_w >= MIN_DIMENSION && flag_h >= MIN_DIMENSION);

  /* croping */
  croped = crop_sprite(origflag, start_x, start_y, flag_w, flag_h);

  /* scaling */
  newflag_h = height;
  newflag_w = ((double) newflag_h / flag_h) * flag_w;

  scaled = sprite_scale(croped, newflag_w, newflag_h);
  free_sprite(croped);

  sprite_draw_black_border(scaled);

  /* and finaly store the scaled flagsprite in the static flags array */
  *flag = scaled;
}

-mike


[Prev in Thread] Current Thread [Next in Thread]