void load_intro_gfx(void) { int tot, lin, y, w; char s[64]; XColor face; int have_face; const char *motto = freeciv_motto(); XFontSetExtents *exts; /* metrics */ exts = XExtentsOfFontSet(main_font_set); lin = exts->max_logical_extent.height; /* get colors */ if(XParseColor(display, cmap, COLOR_MOTTO_FACE, &face) && XAllocColor(display, cmap, &face)) { have_face = TRUE; } else { face.pixel = get_color(tileset, COLOR_OVERVIEW_VIEWRECT)->color.pixel; have_face = FALSE; } /* Main graphic */ intro_gfx_sprite = load_gfxfile(tileset_main_intro_filename(tileset)); tot = intro_gfx_sprite->width; y = intro_gfx_sprite->height - (2 * lin); w = XmbTextEscapement(main_font_set, motto, strlen(motto)); XSetForeground(display, font_gc, face.pixel); XmbDrawString(display, intro_gfx_sprite->pixmap, main_font_set, font_gc, tot / 2 - w / 2, y, motto, strlen(motto)); /* Minimap graphic */ radar_gfx_sprite = load_gfxfile(tileset_mini_intro_filename(tileset)); tot = radar_gfx_sprite->width; y = radar_gfx_sprite->height - (lin + 1.5 * (exts->max_logical_extent.height + exts->max_logical_extent.y)); w = XmbTextEscapement(main_font_set, word_version(), strlen(word_version())); XSetForeground(display, font_gc, get_color(tileset, COLOR_OVERVIEW_UNKNOWN)->color.pixel); XmbDrawString(display, radar_gfx_sprite->pixmap, main_font_set, font_gc, (tot / 2 - w / 2) + 1, y + 1, word_version(), strlen(word_version())); XSetForeground(display, font_gc, get_color(tileset, COLOR_OVERVIEW_VIEWRECT)->color.pixel); XmbDrawString(display, radar_gfx_sprite->pixmap, main_font_set, font_gc, tot / 2 - w / 2, y, word_version(), strlen(word_version())); y += lin; fc_snprintf(s, sizeof(s), "%d.%d.%d%s", MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, VERSION_LABEL); w = XmbTextEscapement(main_font_set, s, strlen(s)); XSetForeground(display, font_gc, get_color(tileset, COLOR_OVERVIEW_UNKNOWN)->color.pixel); XmbDrawString(display, radar_gfx_sprite->pixmap, main_font_set, font_gc, (tot / 2 - w / 2) + 1, y + 1, s, strlen(s)); XSetForeground(display, font_gc, get_color(tileset, COLOR_OVERVIEW_VIEWRECT)->color.pixel); XmbDrawString(display, radar_gfx_sprite->pixmap, main_font_set, font_gc, tot / 2 - w / 2, y, s, strlen(s)); /* free colors */ if (have_face) { XFreeColors(display, cmap, &(face.pixel), 1, 0); } /* done */ return; }
/**************************************************************************** Load the introductory graphics. ****************************************************************************/ void load_intro_gfx(void) { /* PORTME */ intro_gfx_sprite = load_gfxfile(tileset_main_intro_filename(tileset)); radar_gfx_sprite = load_gfxfile(tileset_mini_intro_filename(tileset)); }
/* load a map file or get it from the cache */ static struct pixmap_info *load_image_mtime(char *name,time_t *mtime /*GdkWindow *win*/) { GList *cached; struct cache_entry ce_search; struct cache_entry *ce; struct stat st; char filename[512]; #ifdef USE_IMLIB GdkPixmap *p; GdkImlibImage *im; #else struct pixmap_info *p; #endif cache_count++; ce_search.name=name; p=NULL; cached=g_list_find_custom(cache_list, &ce_search,find_cache); if (cached) { ce=(struct cache_entry *)cached->data; if (ce) { ce->count=cache_count; if (mtime) *mtime=ce->mtime; return ce->p; } } if (g_list_length(cache_list)>=MAX_CACHE) { GList *rem; cache_list=g_list_sort(cache_list,compare_cache); ce=(struct cache_entry *)g_list_nth_data(cache_list,0); if (ce->p) #ifdef USE_IMLIB gdk_imlib_free_pixmap(ce->p); #else free_pinfo(ce->p); #endif /* printf("entferne %s\n",ce->name); */ g_free(ce->name); g_free(ce); rem=g_list_first(cache_list); cache_list=g_list_remove_link(cache_list,rem); g_list_free(rem); } snprintf(filename,sizeof(filename),"%s.str", name); read_str_file(filename,name); snprintf(filename,sizeof(filename),"%s.png", name); #ifndef USE_IMLIB p=load_gfxfile(filename); if (!p) { if (!stat(filename,&st)) { if (mtime) *mtime=st.st_mtime; return NULL; } snprintf(filename,sizeof(filename),"%s.jpg", name); p=load_gfxfile(filename); } #endif #ifdef USE_IMLIB im=gdk_imlib_load_image(filename); if (im) break; snprintf(filename,sizeof(filename),"%s/%s.bmp",kartenpfad[i], name); im=gdk_imlib_load_image(filename); if (im) break; #endif #ifdef USE_IMLIB if (!im) return NULL; w=im->rgb_width; h=im->rgb_height; if (!gdk_imlib_render(im,w,h)) { gdk_imlib_destroy_image(im); return NULL; } p=gdk_imlib_move_image(im); gdk_imlib_destroy_image(im); #endif if (p) { struct stat st; ce=g_malloc(sizeof(struct cache_entry)); ce->p=p; ce->name=g_strdup(name); ce->count=cache_count; cache_list=g_list_append(cache_list,ce); stat(filename,&st); ce->mtime=st.st_mtime; if (mtime) *mtime=ce->mtime; } else { if (!stat(filename,&st)) { if (mtime) *mtime=st.st_mtime; return NULL; } } return p; }