bool optionwin::draw() { if (!is_checkbox) { if (item->selected) vultures_put_img(abs_x, abs_y, vultures_winelem.radiobutton_on); else vultures_put_img(abs_x, abs_y, vultures_winelem.radiobutton_off); } /* otherwise we want checkboxes */ else { if (item->selected) { /* selected items can be drawn with either an 'x' (count <= 0) or an '#' otherwise */ if (item->count <= 0) vultures_put_img(abs_x, abs_y, vultures_winelem.checkbox_on); else vultures_put_img(abs_x, abs_y, vultures_winelem.checkbox_count); } else vultures_put_img(abs_x, abs_y, vultures_winelem.checkbox_off); } /* draw the option description */ vultures_put_text_shadow(V_FONT_MENU, caption, vultures_screen, abs_x + vultures_winelem.radiobutton_off->w + 4, abs_y + 2, V_COLOR_TEXT, V_COLOR_BACKGROUND); vultures_invalidate_region(abs_x, abs_y, w, h); return false; }
bool map::draw() { int map_x, map_y; int i, j; window * txt = first_child; char buffer[256]; /* Draw parchment */ vultures_put_img(abs_x, abs_y, mapbg); /* Draw the level name */ #ifdef VULTURESCLAW describe_level(buffer, TRUE); #else if (!describe_level(buffer)) sprintf(buffer, "%s, level %d ", dungeons[u.uz.dnum].dname, depth(&u.uz)); #endif txt->set_caption(buffer); txt->x = (w - vultures_text_length(V_FONT_HEADLINE, txt->caption)) / 2; txt->abs_x = abs_x + txt->x; txt->abs_y = abs_y + txt->y; vultures_put_text_shadow(V_FONT_HEADLINE, txt->caption, vultures_screen, txt->abs_x, txt->abs_y, CLR32_BROWN, CLR32_BLACK_A50); /* Find upper left corner of map on parchment */ map_x = abs_x + 39; map_y = abs_y + 91; /* Draw map on parchment, and create hotspots */ for (i = 0; i < ROWNO; i++) for (j = 1; j < COLNO; j++) { int map_glyph = map_data->get_glyph(MAP_GLYPH, j, i); bool is_dark = (map_data->get_glyph(MAP_DARKNESS, j, i) == 2); if (map_glyph != NO_GLYPH && (map_glyph != cmap_to_glyph(S_stone) || (level.locations[j][i].seenv && is_dark))) { vultures_put_img( map_x + SYMBOL_WIDTH*j, map_y + SYMBOL_HEIGHT*i, map_symbols[glyph2tile[map_glyph]]); } } vultures_invalidate_region(abs_x, abs_y, w, h); return false; }
bool statuswin::draw() { vultures_set_draw_region(abs_x, abs_y, abs_x + w - 1, abs_y + h - 1); vultures_put_img(abs_x, abs_y, statusbg); vultures_set_draw_region(0, 0, vultures_screen->w-1, vultures_screen->h-1); vultures_invalidate_region(abs_x, abs_y, w, h); return true; }
bool endingwin::draw() { int lines; int textpos_x, textpos_y; SDL_Surface *image; if (!flags.tombstone) { for (item_iterator i = items.begin(); i != items.end(); ++i) printf("%s\n", i->str.c_str()); printf("\n\n"); return false; } /* make sure the screen is cleared */ SDL_FillRect(vultures_screen, NULL, CLR32_BLACK); switch (ending_type-1) { case QUIT: image = vultures_load_graphic(V_FILENAME_ENDING_QUIT); vultures_play_event_sound("nhfe_music_end_quit"); break; case ASCENDED: image = vultures_load_graphic(V_FILENAME_ENDING_ASCENDED); vultures_play_event_sound("nhfe_music_end_ascended"); break; case ESCAPED: image = vultures_load_graphic(V_FILENAME_ENDING_ESCAPED); vultures_play_event_sound("nhfe_music_end_ascended"); break; case PANICKED: image = NULL; break; default: image = vultures_load_graphic(V_FILENAME_ENDING_DIED); vultures_play_event_sound("nhfe_music_end_died"); } if (image != NULL) { vultures_put_img((vultures_screen->w - image->w) / 2, (vultures_screen->h - image->h) / 2, image); SDL_FreeSurface(image); vultures_fade_in(0.5); } /* Count n. of rows to display */ lines = items.size(); /* Add prompt line */ lines++; /* Display the rows */ textpos_y = vultures_screen->h - (lines+1) * vultures_get_lineheight(V_FONT_INTRO); for (item_iterator i = items.begin(); i != items.end(); ++i) { textpos_x = (vultures_screen->w - vultures_text_length(V_FONT_INTRO, i->str))/2; vultures_put_text_shadow(V_FONT_INTRO, i->str, vultures_screen, textpos_x, textpos_y, V_COLOR_INTRO_TEXT, V_COLOR_BACKGROUND); textpos_y += vultures_get_lineheight(V_FONT_INTRO); } textpos_x = (vultures_screen->w - vultures_text_length(V_FONT_INTRO, "(press any key)"))/2; vultures_put_text_shadow(V_FONT_INTRO, "(press any key)", vultures_screen, textpos_x, textpos_y, V_COLOR_INTRO_TEXT, V_COLOR_BACKGROUND); vultures_refresh(); return false; }
bool objitemwin::draw() { char tmpstr[32]; int text_start_x, text_start_y, txt_height; int x = abs_x; int y = abs_y; int weight = 0; Uint32 textcolor; vultures_set_draw_region(x, y, x + w - 1, y + h - 1); /* re-set the background to prevent shadings from stacking repatedly until they become solid */ if (background) vultures_put_img(x, y, background); /* hovering gives an item a light blue frame */ if (hover) vultures_rect(x+1, y+1, x+w-2, y+h-2, CLR32_BLESS_BLUE); /* otherwise, if it is selected, the item has an orange frame */ else if (item->selected) vultures_rect(x+1, y+1, x+w-2, y+h-2, CLR32_ORANGE); /* all other items appear etched */ else { /* draw the outer edge of the frame */ vultures_draw_lowered_frame(x, y, x+w-1, y+h-1); /* Inner edge */ vultures_draw_raised_frame(x+1, y+1, x+w-2, y+h-2); } /* the item that was toggled last has a white outer frame to indicate it's special status */ if (last_toggled) vultures_rect(x, y, x+w-1, y+h-1, CLR32_WHITE); /* selected items also have yellow background shading */ if (item->selected) vultures_fill_rect(x+h-1, y+2, x+w-3, y+h-3, CLR32_GOLD_SHADE); /* use a different text color for worn objects */ if (obj && obj->owornmask) textcolor = CLR32_LIGHTGREEN; else textcolor = CLR32_WHITE; /* draw text, leaving a h by h square on the left free for the object tile */ /* line 1 and if necessary line 2 contain the item description */ vultures_put_text_multiline(V_FONT_MENU, caption, vultures_screen, x + h, y + 3, textcolor, CLR32_BLACK, w - h - 6); /* weight is in line 3 */ txt_height = vultures_text_height(V_FONT_MENU, caption); text_start_y = y + txt_height*2 + 4; /* draw the object weight */ tmpstr[0] = '\0'; if (weight) snprintf(tmpstr, 32, "w: %d", weight); text_start_x = x + (w - vultures_text_length(V_FONT_MENU, tmpstr))/2; vultures_put_text_shadow(V_FONT_MENU, tmpstr, vultures_screen, text_start_x, text_start_y, textcolor, CLR32_BLACK); if (item->selected) { tmpstr[0] = '\0'; if (item->count <= 0 || (obj && item->count > obj->quan)) snprintf(tmpstr, 32, "selected (all)"); else snprintf(tmpstr, 32, "selected (%d)", item->count); text_start_x = x + w - vultures_text_length(V_FONT_MENU, tmpstr) - 6; vultures_put_text_shadow(V_FONT_MENU, tmpstr, vultures_screen, text_start_x, text_start_y, textcolor, CLR32_BLACK); } /* draw the tile itself */ /* constrain the drawing region to the box for the object tile, so that large * tiles don't overlap */ vultures_set_draw_region(x + 2, y + 2, x + h - 3, y + h - 3); /* darken the background */ vultures_fill_rect(x + 2, y + 2, x + h - 3, y + h - 3, CLR32_BLACK_A30); /* indicate blessed/cursed visually */ if (obj && obj->bknown && obj->blessed) vultures_fill_rect(x + 2, y + 2, x + h - 3, y + h - 3, CLR32_BLESS_BLUE); if (obj && obj->bknown && obj->cursed) vultures_fill_rect(x + 2, y + 2, x + h - 3, y + h - 3, CLR32_CURSE_RED); /* draw the object tile */ if (obj) { int tile_x, tile_y; int tile = 0; tile = vultures_object_to_tile(obj->otyp, -1, -1, obj); weight = obj->owt; tile_x = x + h/2; tile_y = y + h * 3 / 4; if (TILE_IS_OBJECT(tile)) { tile = tile - OBJTILEOFFSET + ICOTILEOFFSET; tile_x = x + 2; tile_y = y + 2; } vultures_put_tile(tile_x, tile_y, tile); } /* draw the item letter on the top left corner of the object tile */ snprintf(tmpstr, 11, "%c", accelerator); vultures_put_text_shadow(V_FONT_MENU, tmpstr, vultures_screen, x + 2, y + 2, textcolor, CLR32_BLACK); /* draw the quantity on the tile */ if (obj && obj->quan > 1) { snprintf(tmpstr, 11, "%ld", obj->quan); txt_height = vultures_text_height(V_FONT_MENU, tmpstr); text_start_x = x + h - vultures_text_length(V_FONT_MENU, tmpstr) - 2; vultures_put_text_shadow(V_FONT_MENU, tmpstr, vultures_screen, text_start_x, y + h - txt_height, CLR32_WHITE, CLR32_BLACK); } /* restore the drawing region */ vultures_set_draw_region(0, 0, vultures_screen->w - 1, vultures_screen->h - 1); vultures_invalidate_region(x, y, w, h); return 0; }
bool minimap::draw() { int map_x, map_y, sym; Uint32 *pixels; SDL_Rect destrect = {0, 0, 3, 2}; Uint32 minimap_colors[V_MMTILE_MAX] = {CLR32_BLACK, V_COLOR_MINI_FLOOR, V_COLOR_MINI_STAIRS, V_COLOR_MINI_DOOR, V_COLOR_MINI_YOU, CLR32_GREEN, CLR32_RED}; if (!minimapbg) return false; if (this->background) vultures_put_img(abs_x, abs_y, background); for (map_y = 0; map_y < ROWNO; map_y++) { for (map_x = 1; map_x < COLNO; map_x++) { /* translate the contents of the map into a minimap symbol color */ switch(map_data->get_glyph(MAP_BACK, map_x, map_y)) { case V_TILE_WALL_GENERIC: case V_MISC_UNMAPPED_AREA: sym = V_MMTILE_NONE; break; default: sym = V_MMTILE_FLOOR; break; } switch(map_data->get_glyph(MAP_FURNITURE, map_x, map_y)) { case V_MISC_STAIRS_UP: case V_MISC_STAIRS_DOWN: sym = V_MMTILE_STAIRS; break; case V_MISC_VDOOR_WOOD_OPEN: case V_MISC_VDOOR_WOOD_CLOSED: case V_MISC_HDOOR_WOOD_OPEN: case V_MISC_HDOOR_WOOD_CLOSED: case V_MISC_VODBRIDGE: case V_MISC_HODBRIDGE: case V_MISC_VCDBRIDGE: case V_MISC_HCDBRIDGE: sym = V_MMTILE_DOOR; break; } if (map_data->get_glyph(MAP_TRAP, map_x, map_y) == V_MISC_MAGIC_PORTAL) sym = V_MMTILE_STAIRS; if (map_data->get_glyph(MAP_MON, map_x, map_y) != V_TILE_NONE) { if (map_data->get_glyph(MAP_PET, map_x, map_y)) sym = V_MMTILE_PET; else sym = V_MMTILE_MONSTER; } if ((map_y == u.uy) && (map_x == u.ux)) sym = V_MMTILE_YOU; /* draw symbols that changed onto the "minimap surface" */ if (sym != vultures_minimap_syms[map_y][map_x]) { vultures_minimap_syms[map_y][map_x] = sym; destrect.x = 40 + 2*map_x - 2*map_y; destrect.y = map_x + map_y; pixels = (Uint32 *)((char*)minimapbg->pixels + minimapbg->pitch * (destrect.y+6) + (destrect.x+6) * 4); /* A minimap symbol has this shape: _ C _ * C C C * where "_" is transparent and "C" is a colored pixel */ /* row 1: */ /* pixels[0] = transparent -> dont write */ pixels[1] = minimap_colors[sym]; /* pixels[2] = transparent -> dont write */ /* row 2 */ pixels = (Uint32 *)((char*)minimapbg->pixels + minimapbg->pitch * (destrect.y+7) + (destrect.x+6) * 4); pixels[0] = minimap_colors[sym]; pixels[1] = minimap_colors[sym]; pixels[2] = minimap_colors[sym]; } } } vultures_put_img(abs_x, abs_y, minimapbg); vultures_invalidate_region(abs_x, abs_y, w, h); return false; }