Index: client/messagewin_common.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/messagewin_common.c,v retrieving revision 1.4 diff -u -r1.4 messagewin_common.c --- client/messagewin_common.c 2002/07/18 13:53:56 1.4 +++ client/messagewin_common.c 2002/07/18 14:37:48 @@ -23,6 +23,8 @@ #include "fcintl.h" #include "mapview_g.h" #include "citydlg_g.h" +#include "tilespec.h" +#include "graphics_g.h" #include "messagewin_common.h" @@ -146,6 +148,12 @@ game.player_ptr); } else { messages[messages_total].city_ok = FALSE; + } + + if (packet->event < E_LAST && packet->event >= 0) { + messages[messages_total].sprite = sprites.message_icons[packet->event]; + } else { + messages[messages_total].sprite = sprites.cooling[3]; } messages_total++; Index: client/messagewin_common.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/messagewin_common.h,v retrieving revision 1.2 diff -u -r1.2 messagewin_common.h --- client/messagewin_common.h 2002/07/18 09:42:27 1.2 +++ client/messagewin_common.h 2002/07/18 14:37:49 @@ -21,6 +21,7 @@ int x, y; enum event_type event; bool location_ok, city_ok; + struct Sprite *sprite; }; void meswin_freeze(void); Index: client/tilespec.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v retrieving revision 1.79 diff -u -r1.79 tilespec.c --- client/tilespec.c 2002/07/15 20:59:44 1.79 +++ client/tilespec.c 2002/07/18 14:37:50 @@ -432,6 +432,16 @@ assert(sprites.field != NULL); \ } while(FALSE) +/* Sets sprites.field to tag or (if tag isn't available) to alt, + where alt is a pre-existing sprite*/ +#define SET_SPRITE_ALT_PRE(field, tag, alt) do { \ + sprites.field = hash_lookup_data(sprite_hash, tag); \ + if (!sprites.field) { \ + sprites.field = sprites.alt; \ + } \ + assert(sprites.field != NULL); \ + } while(FALSE) + /********************************************************************** Initialize 'sprites' structure based on hardwired tags which freeciv always requires. @@ -663,6 +673,159 @@ sprites.city.tile_wall = NULL; /* no place to initialize this variable */ sprites.city.tile = NULL; /* no place to initialize this variable */ + + SET_SPRITE_ALT_PRE(message_icons[E_LOW_ON_FUNDS], + "ev.low_funds", citizen[2]); + SET_SPRITE_ALT_PRE(message_icons[E_POLLUTION], + "ev.pollution", warming[5]); + SET_SPRITE_ALT_PRE(message_icons[E_GLOBAL_ECO], + "ev.ecodisaster", warming[7]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_DISORDER], + "ev.disorder", citizen[7]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_LOVE], + "ev.celebration", citizen[5]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_NORMAL], + "ev.normal", citizen[4]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_GROWTH], + "ev.growth", upkeep.food[0]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_AQUEDUCT], + "ev.aqueduct", upkeep.food[0]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_FAMINE], + "ev.famine", upkeep.food[0]); + SET_SPRITE_ALT (message_icons[E_CITY_LOST], + "ev.citylost", "gov.fundamentalism"); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_CANTBUILD], + "ev.cantbuild", upkeep.shield); + SET_SPRITE_ALT_PRE(message_icons[E_WONDER_STARTED], + "ev.wonderstart", warming[1]); + SET_SPRITE_ALT_PRE(message_icons[E_WONDER_BUILD], + "ev.wonderbuilt", warming[3]); + SET_SPRITE_ALT_PRE(message_icons[E_IMP_BUILD], + "ev.improvementbuilt", upkeep.shield); + SET_SPRITE_ALT_PRE(message_icons[E_IMP_AUTO], + "ev.improvementautomatic", upkeep.shield); + SET_SPRITE_ALT_PRE(message_icons[E_IMP_AUCTIONED], + "ev.improvementauctioned", citizen[2]); + SET_SPRITE_ALT_PRE(message_icons[E_UNIT_UPGRADED], + "ev.unitupgraded", upkeep.shield); + SET_SPRITE_ALT_PRE(message_icons[E_UNIT_BUILD], + "ev.unitbuilt", upkeep.shield); + SET_SPRITE_ALT (message_icons[E_UNIT_LOST], + "ev.unitlost", "gov.fundamentalism"); + SET_SPRITE_ALT (message_icons[E_UNIT_WIN], + "ev.unitwon", "gov.fundamentalism"); + SET_SPRITE_ALT (message_icons[E_ANARCHY], + "ev.anarchy", "gov.anarchy"); + SET_SPRITE_ALT_PRE(message_icons[E_TECH_GAIN], + "ev.techgain", bulb[7]); + SET_SPRITE_ALT (message_icons[E_DESTROYED], + "ev.citydestroyed", "gov.fundamentalism"); + SET_SPRITE_ALT_PRE(message_icons[E_IMP_BUY], + "ev.improvementbuy", upkeep.shield); + SET_SPRITE_ALT_PRE(message_icons[E_IMP_SOLD], + "ev.improvementsold", citizen[2]); + SET_SPRITE_ALT_PRE(message_icons[E_UNIT_BUY], + "ev.unitbuy", upkeep.shield); + SET_SPRITE_ALT_PRE(message_icons[E_WONDER_STOPPED], + "ev.wonderstopped", warming[1]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_AQ_BUILDING], + "ev.aqueductbuilding", upkeep.food[1]); + SET_SPRITE_ALT (message_icons[E_UNIT_LOST_ATT], + "ev.unitlostattack", "gov.fundamentalism"); + SET_SPRITE_ALT (message_icons[E_UNIT_WIN_ATT], + "ev.unitwonattack", "gov.fundamentalism"); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_GRAN_THROTTLE], + "ev.granthrottle", upkeep.food[0]); + SET_SPRITE_ALT_PRE(message_icons[E_SPACESHIP], + "ev.spaceship", bulb[7]); + SET_SPRITE_ALT_PRE(message_icons[E_UPRISING], + "ev.uprising", citizen[7]); + SET_SPRITE_ALT_PRE(message_icons[E_WORKLIST], + "ev.worklist", citizen[4]); + SET_SPRITE_ALT_PRE(message_icons[E_FIRST_CONTACT], + "ev.firstcontact", cooling[1]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_MAY_SOON_GROW], + "ev.citymaygrow", upkeep.food[0]); + SET_SPRITE_ALT_PRE(message_icons[E_WONDER_OBSOLETE], + "ev.wonderobsolete", warming[1]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_FAMINE_FEARED], + "ev.faminefeared", upkeep.food[0]); + SET_SPRITE_ALT (message_icons[E_NEW_GOVERNMENT], + "ev.newgovernment", "gov.monarchy"); + SET_SPRITE_ALT_PRE(message_icons[E_MESSAGE_WALL], + "ev.warnall", warming[0]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_CMA_RELEASE], + "ev.CMArelease", warming[0]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_BUILD], + "ev.citybuild", upkeep.food[0]); + SET_SPRITE_ALT (message_icons[E_REVOLT_START], + "ev.revoltstart", "gov.anarchy"); + SET_SPRITE_ALT (message_icons[E_REVOLT_DONE], + "ev.revoltdone", "gov.monarchy"); + SET_SPRITE_ALT_PRE(message_icons[E_HUT_GOLD], + "ev.hutgold", citizen[2]); + SET_SPRITE_ALT_PRE(message_icons[E_HUT_TECH], + "ev.huttech", bulb[7]); + SET_SPRITE_ALT (message_icons[E_HUT_MERC], + "ev.hutmercenaries", "gov.fundamentalism"); + SET_SPRITE_ALT (message_icons[E_HUT_BARB_CITY_NEAR], + "ev.hutmercenaries", "gov.fundamentalism"); + SET_SPRITE_ALT (message_icons[E_HUT_BARB], + "ev.hutbarbarians", "gov.fundamentalism"); + SET_SPRITE_ALT (message_icons[E_HUT_BARB_KILLED], + "ev.hutcowardlybarbs", "gov.fundamentalism"); + SET_SPRITE_ALT_PRE(message_icons[E_HUT_CITY], + "ev.hutcity", upkeep.food[0]); + SET_SPRITE_ALT_PRE(message_icons[E_HUT_SETTLER], + "ev.hutnomads", upkeep.food[0]); + SET_SPRITE_ALT_PRE(message_icons[E_GAME_START], + "ev.gamestart", cooling[3]); + SET_SPRITE_ALT_PRE(message_icons[E_NEXT_YEAR], + "ev.nextyear", cooling[3]); + SET_SPRITE_ALT_PRE(message_icons[E_REPORT], + "ev.report", citizen[3]); + SET_SPRITE_ALT_PRE(message_icons[E_BROADCAST_REPORT], + "ev.broadcastreport", citizen[3]); + SET_SPRITE_ALT_PRE(message_icons[E_NATION_SELECTED], + "ev.nationselected", citizen[3]); + +#if 0 + SET_SPRITE_ALT_PRE(message_icons[E_DIPLOMATED], + "ev.diplomated", citizen[3]); + SET_SPRITE_ALT_PRE(message_icons[E_MY_DIPLOMAT], + "ev.diplomatmine", citizen[3]); + SET_SPRITE_ALT_PRE(message_icons[E_CANCEL_PACT], + "ev.cancelpact", citizen[3]); + SET_SPRITE_ALT_PRE(message_icons[E_DIPL_INCIDENT], + "ev.diplomatincident", citizen[3]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_WONDER_WILL_BE_BUILT], + "ev.wonderwillbebuilt", warming[2]); + SET_SPRITE_ALT_PRE(message_icons[E_CITY_NUKED], + "ev.citynuked", explode.iso_nuke); + SET_SPRITE_ALT_PRE(message_icons[E_NUKE], + "ev.nuke", explode.iso_nuke); +#endif + + { + int start_x, start_y, end_x, end_y; + enum event_type i; + + for (i = 0; i < E_LAST; i++) { + int width, height; + + if (!sprites.message_icons[i]) { + continue; + } + sprite_get_size(sprites.message_icons[i], &width, &height); + if (width > 15 || height > 20) { + sprite_get_bounding_box(sprites.message_icons[i], &start_x, &start_y, + &end_x, &end_y); + sprites.message_icons[i] = + crop_sprite(sprites.message_icons[i], start_x, start_y, + end_x - start_x, end_y - start_y); + } + } + } } /********************************************************************** Index: client/tilespec.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v retrieving revision 1.28 diff -u -r1.28 tilespec.h --- client/tilespec.h 2002/04/06 11:42:57 1.28 +++ client/tilespec.h 2002/07/18 14:37:50 @@ -22,6 +22,8 @@ #include "colors_g.h" +#include "events.h" + struct Sprite; /* opaque; gui-dep */ struct unit; struct player; @@ -84,6 +86,7 @@ *cooling[NUM_TILES_PROGRESS], *citizen[NUM_TILES_CITIZEN], /* internal code... */ *treaty_thumb[2], /* 0=disagree, 1=agree */ + *message_icons[E_LAST], *right_arrow, *black_tile, /* only used for isometric view */ @@ -122,6 +125,7 @@ *fortified, *fortifying, *fortress, + *fortress_back, *airbase, *go_to, /* goto is a C keyword :-) */ *irrigate, Index: client/gui-gtk/graphics.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/graphics.c,v retrieving revision 1.40 diff -u -r1.40 graphics.c --- client/gui-gtk/graphics.c 2002/07/06 20:35:21 1.40 +++ client/gui-gtk/graphics.c 2002/07/18 14:37:50 @@ -622,3 +622,9 @@ gdk_image_destroy(mask_image); } + +void sprite_get_size(struct Sprite *sprite, int *width, int *height) +{ + *width = sprite->width; + *height = sprite->height; +} Index: client/gui-gtk/gui_stuff.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_stuff.c,v retrieving revision 1.19 diff -u -r1.19 gui_stuff.c --- client/gui-gtk/gui_stuff.c 2002/02/12 09:36:46 1.19 +++ client/gui-gtk/gui_stuff.c 2002/07/18 14:37:50 @@ -132,7 +132,7 @@ int i; for(i=0; ivbox), scrolled, TRUE, TRUE, 0); - meswin_list = gtk_clist_new_with_titles(1, titles); + meswin_list = gtk_clist_new_with_titles(2, titles); gtk_container_add(GTK_CONTAINER(scrolled),meswin_list); gtk_clist_column_titles_passive(GTK_CLIST(meswin_list)); gtk_clist_set_column_auto_resize(GTK_CLIST(meswin_list), 0, TRUE); + gtk_clist_set_column_width(GTK_CLIST(meswin_list), 0, 15); meswin_close_command = gtk_accelbutton_new(_("_Close"), accel); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(meswin_dialog_shell)->action_area), @@ -216,13 +219,24 @@ void real_update_meswin_dialog(void) { int i, num = get_num_messages(); + char *row_text[2]; + row_text[0] = ""; + gtk_clist_freeze(GTK_CLIST(meswin_list)); gtk_clist_clear(GTK_CLIST(meswin_list)); for (i = 0; i < num; i++) { - gtk_clist_append(GTK_CLIST(meswin_list), &get_message(i)->descr); + int row; + struct message *message = get_message(i); + + row_text[1] = message->descr; + row = gtk_clist_append(GTK_CLIST(meswin_list), row_text); meswin_not_visited_item(i); + if (message->sprite) { + gtk_clist_set_pixmap(GTK_CLIST(meswin_list), row, 0, + message->sprite->pixmap, message->sprite->mask); + } } gtk_clist_thaw(GTK_CLIST(meswin_list)); Index: client/include/graphics_g.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/include/graphics_g.h,v retrieving revision 1.7 diff -u -r1.7 graphics_g.h --- client/include/graphics_g.h 2002/02/19 16:41:21 1.7 +++ client/include/graphics_g.h 2002/07/18 14:37:51 @@ -30,6 +30,9 @@ struct Sprite *load_gfxfile(const char *filename); struct Sprite *crop_sprite(struct Sprite *source, int x, int y, int width, int height); +void sprite_get_bounding_box(struct Sprite *sprite, int *start_x, + int *start_y, int *end_x, int *end_y); +void sprite_get_size(struct Sprite *sprite, int *width, int *height); void free_sprite(struct Sprite *s); #endif /* FC__GRAPHICS_G_H */