/* $Id: menuimages.c,v 1.1 2004/02/07 13:35:28 stpohle Exp $ * Menuhandling: labels */ #include "basic.h" #include "bomberclone.h" #include "menu.h" #include "menugui.h" /* draw the menuitem label * menuitem->pos.[x|y] - Position inside the menu * pos.w - Fontsize * label - Text of the label */ void menu_draw_image (_menuitem *mi) { SDL_Rect src, dest; if (mi->type != MENU_image) return; if (mi->pos.x == -1) dest.x = (menu.oldscreenpos.w - 2*menu.images[0]->w - mi->rect.w) / 2; else dest.x = mi->pos.x; if (mi->pos.y == -1) dest.y = (menu.oldscreenpos.h - 2*menu.images[0]->h - mi->rect.h) / 2; else dest.y = mi->pos.y; src.w = dest.w = mi->rect.w; src.h = dest.h = mi->rect.h; src.x = mi->rect.x; src.y = mi->rect.y; dest.x += menu.oldscreenpos.x + menu.images[0]->w; dest.y += menu.oldscreenpos.y + menu.images[0]->h; gfx_blit ((SDL_Surface *) mi->ptrdata, &src, gfx.screen, &dest, 10000+mi->pos.w); }; void menu_create_image (char *name, int x, int y, int layer, SDL_Surface *img, SDL_Rect *rect) { int i = menu_getlastitem(menu.items); if (i == -1) { /* first entry in the itemslist */ menu.items = &menuitems[0]; i = 0; } else if (i >= MENU_MAXENTRYS) { /* max items reached, ignore new item */ d_fatal ("menu_create_image: MENU_MAXENTRYS reached. Item Ignored\n"); return; } else { /* add new item to the list */ menuitems[i].next = &menuitems[i+1]; i++; } menuitems[i].pos.x = x; menuitems[i].pos.y = y; menuitems[i].pos.w = layer; menuitems[i].type = MENU_image; menuitems[i].ptrdata = (char *) img; menuitems[i].rect = *rect; strncpy (menuitems[i].label, name, MENU_TITLELEN); };