[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]
Here's the next version -- no substantive feature changes, but some code
cleanup.
On Sat, 14 Sep 2002, Mike Kaufman wrote:
> this is nice. couple of things:
>
> o follow style guide (spaces between operators, etc).
Done (or pretty close)
> o it'd be really nice if you could highlight the toggle button when a
> nation is selected from the drop down box.
AFAICT, this is already there
> 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:
>
Done, except that sprite_get_bounding_box is gtk-only, so I put it in
client/gui-gtk/graphics.c
Enjoy!
--Daniel Speyer
If you *don't* consider sharing information to be morally equivalent to
kidnapping and murder on the high seas, you probably shouldn't use the
phrase "software piracy."
> /**************************************************************************
> ...
> **************************************************************************/
> 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
>
nationDialogSync3.diff
Description: Text document
|
|