コード例 #1
0
ファイル: intro.cpp プロジェクト: justinzane/wesnoth-ng
void the_end(display &disp, std::string text, unsigned int duration)
{
	//
	// Some sane defaults.
	//
	if(text.empty())
		text = _("The End");
	if(!duration)
		duration = 3500;

	SDL_Rect area = screen_area();
	CVideo &video = disp.video();
	sdl_fill_rect(video.getSurface(),&area,0);

	update_whole_screen();
	disp.flip();

	const size_t font_size = font::SIZE_XLARGE;

	area = font::text_area(text,font_size);
	area.x = screen_area().w/2 - area.w/2;
	area.y = screen_area().h/2 - area.h/2;

	for(size_t n = 0; n < 255; n += 5) {
		if(n)
			sdl_fill_rect(video.getSurface(),&area,0);

		const SDL_Color col = create_color(n, n, n, n);
		font::draw_text(&video,area,font_size,col,text,area.x,area.y);
		update_rect(area);

		events::pump();
		events::raise_process_event();
		events::raise_draw_event();
		disp.flip();
		disp.delay(10);
	}

	//
	// Delay after the end of fading.
	// Rounded to multiples of 10.
	//
	unsigned int count = duration/10;
	while(count) {
		events::pump();
		events::raise_process_event();
		events::raise_draw_event();
		disp.flip();
		disp.delay(10);
		--count;
	}
}
コード例 #2
0
ファイル: sdl-video.cpp プロジェクト: riddlepl/freeserf
void
sdl_draw_rect(int x, int y, int width, int height, int color, frame_t *dest)
{
	SDL_SetClipRect(dest->surf, &dest->clip);

	x += dest->clip.x;
	y += dest->clip.y;

	/* Draw rectangle. */
	sdl_fill_rect(x, y, width, 1, color, dest);
	sdl_fill_rect(x, y+height-1, width, 1, color, dest);
	sdl_fill_rect(x, y, 1, height, color, dest);
	sdl_fill_rect(x+width-1, y, 1, height, color, dest);
}
コード例 #3
0
ファイル: minimap.c プロジェクト: Radderz81/freeserf
static void
draw_minimap_point(minimap_t *minimap, int col, int row, uint8_t color,
		   int density, frame_t *frame)
{
	int map_width = game.map.cols * minimap->scale;
	int map_height = game.map.rows * minimap->scale;

	int mm_y = row*minimap->scale - minimap->offset_y;
	col -= (game.map.rows/2) * (int)(mm_y / map_height);
	mm_y = mm_y % map_height;

	while (mm_y < minimap->obj.height) {
		if (mm_y >= -density) {
			int mm_x = col*minimap->scale -
				(row*minimap->scale)/2 - minimap->offset_x;
			mm_x = mm_x % map_width;
			while (mm_x < minimap->obj.width) {
				if (mm_x >= -density) {
					sdl_fill_rect(mm_x, mm_y, density,
						      density, color, frame);
				}
				mm_x += map_width;
			}
		}
		col -= game.map.rows/2;
		mm_y += map_height;
	}
}
コード例 #4
0
ファイル: minimap.c プロジェクト: Radderz81/freeserf
static void
minimap_draw(minimap_t *minimap, frame_t *frame)
{
	if (BIT_TEST(minimap->flags, 1)) {
		sdl_fill_rect(0, 0, 128, 128, 1, frame);
		draw_minimap_ownership(minimap, 2, frame);
	} else {
		draw_minimap_map(minimap, frame);
		if (BIT_TEST(minimap->flags, 0)) {
			draw_minimap_ownership(minimap, 1, frame);
		}
	}

	if (BIT_TEST(minimap->flags, 2)) {
		draw_minimap_roads(minimap, frame);
	}

	if (BIT_TEST(minimap->flags, 3)) {
		draw_minimap_buildings(minimap, frame);
	}

	if (BIT_TEST(minimap->flags, 4)) {
		draw_minimap_grid(minimap, frame);
	}

	if (minimap->advanced > 0) {
		draw_minimap_traffic(minimap, frame);
	}

	draw_minimap_rect(minimap, frame);
}
コード例 #5
0
ファイル: slider.cpp プロジェクト: blackberry/Wesnoth
void slider::draw_contents()
{
	surface image(state_ != NORMAL ? highlightedImage_ : image_);
	if (image == NULL)
		return;
	SDL_Color line_color = font::NORMAL_COLOR;
	if (!enabled()) {
		image = greyscale_image(image);
		line_color = font::DISABLED_COLOR;
	}

	SDL_Rect const &loc = location();
	if (image->w >= loc.w)
		return;

	surface screen = video().getSurface();

	SDL_Rect line_rect = create_rect(loc.x + image->w / 2
			, loc.y + loc.h / 2
			, loc.w - image->w
			, 1);

	sdl_fill_rect(screen, &line_rect, SDL_MapRGB(screen->format,
		line_color.r, line_color.g, line_color.b));

	SDL_Rect const &slider = slider_area();
	video().blit_surface(slider.x, slider.y, image);
}
コード例 #6
0
ファイル: widget.cpp プロジェクト: AI0867/wesnoth
void
twidget::draw_debug_border(surface& frame_buffer, int x_offset, int y_offset)
{
	SDL_Rect r = redraw_action_ == tredraw_action::partly
						 ? calculate_clipping_rectangle(x_offset, y_offset)
						 : calculate_blitting_rectangle(x_offset, y_offset);

	switch(debug_border_mode_) {
		case 0:
			/* DO NOTHING */
			break;

		case 1:
			draw_rectangle(
					r.x, r.y, r.w, r.h, debug_border_colour_, frame_buffer);
			break;

		case 2:
			sdl_fill_rect(frame_buffer, &r, debug_border_colour_);
			break;

		default:
			assert(false);
	}
}
コード例 #7
0
ファイル: loadscreen.cpp プロジェクト: hyrio/War-Of-Kingdom
void loadscreen::clear_screen()
{
	int scrx = screen_.getx();                     //< Screen width.
	int scry = screen_.gety();                     //< Screen height.
	SDL_Rect area = create_rect(0, 0, scrx, scry); // Screen area.
	surface disp(screen_.getSurface());      // Screen surface.
	// Make everything black.
	sdl_fill_rect(disp,&area,SDL_MapRGB(disp->format,0,0,0));
	screen_.flip();
}
コード例 #8
0
void textbox::draw_cursor(int pos, CVideo &video) const
{
	if(show_cursor_ && editable_) {
		SDL_Rect rect = create_rect(location().x + pos
				, location().y
				, 1
				, location().h);

		surface frame_buffer = video.getSurface();
		sdl_fill_rect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
	}
}
コード例 #9
0
ファイル: mouse_action.cpp プロジェクト: AG-Dev/wesnoth_ios
void mouse_action::set_terrain_mouse_overlay(editor_display& disp, t_translation::t_terrain fg,
		t_translation::t_terrain bg)
{
	surface image_fg(image::get_image("terrain/"
		+ disp.get_map().get_terrain_info(fg).editor_image() + ".png"));
	surface image_bg(image::get_image("terrain/"
		+ disp.get_map().get_terrain_info(bg).editor_image() + ".png"));

	if (image_fg == NULL || image_bg == NULL) {
		ERR_ED << "Missing terrain icon\n";
		disp.set_mouseover_hex_overlay(NULL);
		return;
	}

	// Create a transparent surface of the right size.
	surface image = create_compatible_surface(image_fg, image_fg->w, image_fg->h);
	sdl_fill_rect(image,NULL,SDL_MapRGBA(image->format,0,0,0, 0));

	// For efficiency the size of the tile is cached.
	// We assume all tiles are of the same size.
	// The zoom factor can change, so it's not cached.
	// NOTE: when zooming and not moving the mouse, there are glitches.
	// Since the optimal alpha factor is unknown, it has to be calculated
	// on the fly, and caching the surfaces makes no sense yet.
	static const Uint8 alpha = 196;
	static const int size = image_fg->w;
	static const int half_size = size / 2;
	static const int quarter_size = size / 4;
	static const int offset = 2;
	static const int new_size = half_size - 2;
	const int zoom = static_cast<int>(size * disp.get_zoom_factor());

	// Blit left side
	image_fg = scale_surface(image_fg, new_size, new_size);
	SDL_Rect rcDestLeft = create_rect(offset, quarter_size, 0, 0);
	sdl_blit ( image_fg, NULL, image, &rcDestLeft );

	// Blit left side
	image_bg = scale_surface(image_bg, new_size, new_size);
	SDL_Rect rcDestRight = create_rect(half_size, quarter_size, 0, 0);
	sdl_blit ( image_bg, NULL, image, &rcDestRight );

	//apply mask so the overlay is contained within the mouseover hex
	image = mask_surface(image, image::get_hexmask());

	// Add the alpha factor and scale the image
	image = scale_surface(adjust_surface_alpha(image, alpha), zoom, zoom);

	// Set as mouseover
	disp.set_mouseover_hex_overlay(image);
}
コード例 #10
0
void create::draw_level_image()
{
    boost::scoped_ptr<surface> image(
        engine_.current_level().create_image_surface(image_rect_));

    if (image.get() != NULL) {
        SDL_Color back_color = {0,0,0,255};
        draw_centered_on_background(*image, image_rect_, back_color,
                                    video().getSurface());
    } else {
        surface display(disp_.get_screen_surface());
        sdl_fill_rect(display, &image_rect_,
                      SDL_MapRGB(display->format, 0, 0, 0));
        update_rect(image_rect_);

    }
}
コード例 #11
0
ファイル: widget.cpp プロジェクト: hyrio/War-Of-Kingdom
void twidget::draw_debug_border(surface& frame_buffer)
{
	SDL_Rect r = drawing_action_ == PARTLY_DRAWN
		? clip_rect_
		: get_rect();
	switch(debug_border_mode_) {
		case 0:
			/* DO NOTHING */
			break;
		case 1:
			draw_rectangle(r.x, r.y, r.w, r.h
					, debug_border_color_, frame_buffer);
			break;
		case 2:
			sdl_fill_rect(frame_buffer, &r, debug_border_color_);
			break;
		default:
			assert(false);
	}
}
コード例 #12
0
static void enter_lobby_mode(game_display& disp, const config& game_config, hero_map& heros, hero_map& heros_start, 
		card_map& cards, config& gamelist)
{


	mp::ui::result res;

	while (true) {
		const config &cfg = game_config.child("lobby_music");
		if (cfg) {
			foreach (const config &i, cfg.child_range("music")) {
				sound::play_music_config(i);
			}
			sound::commit_music_changes();
		} else {
			sound::empty_playlist();
			sound::stop_music();
		}
		lobby_info li(game_config);

		// Force a black background
		const Uint32 color = SDL_MapRGBA(disp.video().getSurface()->format
				, 0
				, 0
				, 0
				, 255);

		sdl_fill_rect(disp.video().getSurface(), NULL, color);

		{
			gui2::tlobby_main dlg(game_config, li, disp);
			dlg.set_preferences_callback(
				boost::bind(do_preferences_dialog,
					boost::ref(disp), boost::ref(game_config)));
			dlg.show(disp.video());
			//ugly kludge for launching other dialogs like the old lobby
			switch (dlg.get_legacy_result()) {
				case gui2::tlobby_main::CREATE:
					res = mp::ui::CREATE;
					break;
				case gui2::tlobby_main::JOIN:
					res = mp::ui::JOIN;
					break;
				case gui2::tlobby_main::OBSERVE:
					res = mp::ui::OBSERVE;
					break;
				default:
					res = mp::ui::QUIT;
			}
		}

		switch (res) {
		case mp::ui::JOIN:
			try {
				enter_wait_mode(disp, game_config, heros, heros_start, cards, gamelist, false);
			} catch(config::error& error) {
				if(!error.message.empty()) {
					gui2::show_error_message(disp.video(), error.message);
				}
				//update lobby content
				network::send_data(config("refresh_lobby"), 0);
			}
			break;
		case mp::ui::OBSERVE:
			try {
				enter_wait_mode(disp, game_config, heros, heros_start, cards, gamelist, true);
			} catch(config::error& error) {
				if(!error.message.empty()) {
					gui2::show_error_message(disp.video(), error.message);
				}
			}
			// update lobby content unconditionally because we might have left only after the
			// game ended in which case we ignored the gamelist and need to request it again
			network::send_data(config("refresh_lobby"), 0);
			break;
		case mp::ui::CREATE:
			try {
				enter_create_mode(disp, game_config, heros, heros_start, cards, gamelist, mp::CNTR_NETWORK);
			} catch(config::error& error) {
				if (!error.message.empty())
					gui2::show_error_message(disp.video(), error.message);
				//update lobby content
				network::send_data(config("refresh_lobby"), 0);
			}
			break;
		case mp::ui::QUIT:
			return;
		case mp::ui::PREFERENCES:
			{
				do_preferences_dialog(disp, game_config);
				//update lobby content
				network::send_data(config("refresh_lobby"), 0);
			}
			break;
		default:
			return;
		}
	}
コード例 #13
0
void loadscreen::draw_screen(const std::string &text)
{
	// Set progress bar parameters:
	//
	// RGB-values for finished piece.
	int fcr =  21, fcg =  53, fcb =  80;
	// Groove.
	int lcr =  21, lcg =  22, lcb =  24;
	// Border color.
	int bcr = 188, bcg = 176, bcb = 136;
	// Border width.
	int bw = 1;
	// Border inner spacing width.
	int bispw = 1;
	bw = 2*(bw+bispw) > screen_.getx() ? 0: 2*(bw+bispw) > screen_.gety() ? 0: bw;
	// Available width.
	int scrx = screen_.getx() - 2*(bw+bispw);
	// Available height.
	int scry = screen_.gety() - 2*(bw+bispw);
	// Used width.
	int pbw = scrx/2;
	// Used height.
	int pbh = scry/16;
	// Height of the lighting line.
	int	lightning_thickness = 2;

	surface gdis = screen_.getSurface();
	SDL_Rect area;

	// Pump events and make sure to redraw the logo if there's a chance that it's been obscured
	SDL_Event ev;
	while(SDL_PollEvent(&ev)) {
		if(ev.type == SDL_VIDEORESIZE || ev.type == SDL_VIDEOEXPOSE) {
			logo_drawn_ = false;
		}
	}

	// Draw logo if it was successfully loaded.
	if (logo_surface_ && !logo_drawn_) {
		area.x = (screen_.getx () - logo_surface_->w) / 2;
		area.y = ((scry - logo_surface_->h) / 2) - pbh;
		area.w = logo_surface_->w;
		area.h = logo_surface_->h;
		// Check if we have enough pixels to display it.
		if (area.x > 0 && area.y > 0) {
			pby_offset_ = (pbh + area.h)/2;
			sdl_blit(logo_surface_, 0, gdis, &area);
		} else {
			ERR_DP << "loadscreen: Logo image is too big." << std::endl;
		}
		logo_drawn_ = true;
		update_rect(area.x, area.y, area.w, area.h);
	}
	int pbx = (scrx - pbw)/2;					// Horizontal location.
	int pby = (scry - pbh)/2 + pby_offset_;		// Vertical location.

	// Draw top border.
	area.x = pbx; area.y = pby;
	area.w = pbw + 2*(bw+bispw); area.h = bw;
	sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
	// Draw bottom border.
	area.x = pbx; area.y = pby + pbh + bw + 2*bispw;
	area.w = pbw + 2*(bw+bispw); area.h = bw;
	sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
	// Draw left border.
	area.x = pbx; area.y = pby + bw;
	area.w = bw; area.h = pbh + 2*bispw;
	sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
	// Draw right border.
	area.x = pbx + pbw + bw + 2*bispw; area.y = pby + bw;
	area.w = bw; area.h = pbh + 2*bispw;
	sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,bcr,bcg,bcb));
	// Draw the finished bar area.
	area.x = pbx + bw + bispw; area.y = pby + bw + bispw;
	area.w = (prcnt_ * pbw) / 100; area.h = pbh;
	sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,fcr,fcg,fcb));

	SDL_Rect lightning = area;
	lightning.h = lightning_thickness;
	//we add 25% of white to the color of the bar to simulate a light effect
	sdl_fill_rect(gdis,&lightning,SDL_MapRGB(gdis->format,(fcr*3+255)/4,(fcg*3+255)/4,(fcb*3+255)/4));
	lightning.y = area.y+area.h-lightning.h;
	//remove 50% of color to simulate a shadow effect
	sdl_fill_rect(gdis,&lightning,SDL_MapRGB(gdis->format,fcr/2,fcg/2,fcb/2));

	// Draw the leftover bar area.
	area.x = pbx + bw + bispw + (prcnt_ * pbw) / 100; area.y = pby + bw + bispw;
	area.w = ((100 - prcnt_) * pbw) / 100; area.h = pbh;
	sdl_fill_rect(gdis,&area,SDL_MapRGB(gdis->format,lcr,lcg,lcb));

	// Clear the last text and draw new if text is provided.
	if (!text.empty())
	{
		SDL_Rect oldarea = textarea_;
		sdl_fill_rect(gdis,&textarea_,SDL_MapRGB(gdis->format,0,0,0));
		textarea_ = font::line_size(text, font::SIZE_NORMAL);
		textarea_.x = scrx/2 + bw + bispw - textarea_.w / 2;
		textarea_.y = pby + pbh + 4*(bw + bispw);
		textarea_ = font::draw_text(&screen_,textarea_,font::SIZE_NORMAL,font::NORMAL_COLOR,text,textarea_.x,textarea_.y);
		SDL_Rect refresh = union_rects(oldarea, textarea_);
		update_rect(refresh.x, refresh.y, refresh.w, refresh.h);
	}
	// Update the rectangle.
	update_rect(pbx, pby, pbw + 2*(bw + bispw), pbh + 2*(bw + bispw));
	screen_.flip();
}
void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<int, double> >& hp_prob_vector,
													const battle_context_unit_stats& stats,
													const battle_context_unit_stats& opp_stats,
													surface& surf, int& width, int& height)
{
	// Font size. If you change this, you must update the separator space.
	int fs = font::SIZE_SMALL;

	// Space before HP separator.
	int hp_sep = 24 + 6;

	// Bar space between both separators.
	int bar_space = 150;

	// Space after percentage separator.
	int percent_sep = 43 + 6;

	// Surface width and height.
	width = 30 + 2 + bar_space + 2 + percent_sep;
	height = 5 + (fs + 2) * hp_prob_vector.size();

	// Create the surface.
	surf = create_neutral_surface(width, height);

	// Dsiable alpha channel to avoid problem with sdl_blit
	SDL_SetAlpha(surf, 0, SDL_ALPHA_OPAQUE);

	SDL_Rect clip_rect = create_rect(0, 0, width, height);
	Uint32 grey_color = SDL_MapRGBA(surf->format, 0xb7, 0xc1, 0xc1, 255);

	Uint32 background_color = SDL_MapRGBA(surf->format, 25, 25, 25, 255);
	sdl_fill_rect(surf, &clip_rect, background_color);

	// Draw the surrounding borders and separators.
	SDL_Rect top_border_rect = create_rect(0, 0, width, 2);
	sdl_fill_rect(surf, &top_border_rect, grey_color);

	SDL_Rect bottom_border_rect = create_rect(0, height - 2, width, 2);
	sdl_fill_rect(surf, &bottom_border_rect, grey_color);

	SDL_Rect left_border_rect = create_rect(0, 0, 2, height);
	sdl_fill_rect(surf, &left_border_rect, grey_color);

	SDL_Rect right_border_rect = create_rect(width - 2, 0, 2, height);
	sdl_fill_rect(surf, &right_border_rect, grey_color);

	SDL_Rect hp_sep_rect = create_rect(hp_sep, 0, 2, height);
	sdl_fill_rect(surf, &hp_sep_rect, grey_color);

	SDL_Rect percent_sep_rect = create_rect(width - percent_sep - 2, 0, 2, height);
	sdl_fill_rect(surf, &percent_sep_rect, grey_color);

	// Draw the rows (lower HP values are at the bottom).
	for(int i = 0; i < static_cast<int>(hp_prob_vector.size()); i++) {
		char str_buf[10];

		// Get the HP and probability.
		int hp = hp_prob_vector[hp_prob_vector.size() - i - 1].first;
		double prob = hp_prob_vector[hp_prob_vector.size() - i - 1].second;

		SDL_Color row_color;

		// Death line is red.
		if(hp == 0) {
			SDL_Color color = {0xe5, 0, 0, 0};
			row_color = color;
		}

		// Below current hitpoints value is orange.
		else if(hp < static_cast<int>(stats.hp)) {
			// Stone is grey.
			if(opp_stats.petrifies) {
				SDL_Color color = {0x9a, 0x9a, 0x9a, 0};
				row_color = color;
			} else {
				SDL_Color color = {0xf4, 0xc9, 0, 0};
				row_color = color;
			}
		}

		// Current hitpoints value and above is green.
		else {
			SDL_Color color = {0x08, 0xca, 0, 0};
			row_color = color;
		}

		// Print HP, aligned right.
		snprintf(str_buf, 10, "%d", hp);
		str_buf[9] = '\0';  //prevents _snprintf error
		int hp_width = font::line_width(str_buf, fs);

		// Draw bars.
		font::draw_text_line(surf, clip_rect, fs, font::NORMAL_COLOR, str_buf,
							 hp_sep - hp_width - 2, 2 + (fs + 2) * i, 0, TTF_STYLE_NORMAL);

		int bar_len = std::max<int>(static_cast<int>((prob * (bar_space - 4)) + 0.5), 2);

		SDL_Rect bar_rect_1 = create_rect(hp_sep + 4, 6 + (fs + 2) * i, bar_len, 8);
		sdl_fill_rect(surf, &bar_rect_1, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 100));

		SDL_Rect bar_rect_2 = create_rect(hp_sep + 4, 7 + (fs + 2) * i, bar_len, 6);
		sdl_fill_rect(surf, &bar_rect_2, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 66));

		SDL_Rect bar_rect_3 = create_rect(hp_sep + 4, 8 + (fs + 2) * i, bar_len, 4);
		sdl_fill_rect(surf, &bar_rect_3, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 33));

		SDL_Rect bar_rect_4 = create_rect(hp_sep + 4, 9 + (fs + 2) * i, bar_len, 2);
		sdl_fill_rect(surf, &bar_rect_4, blend_rgb(surf, row_color.r, row_color.g, row_color.b, 0));

		// Draw probability percentage, aligned right.
		format_prob(str_buf, prob);
		int prob_width = font::line_width(str_buf, fs);
		font::draw_text_line(surf, clip_rect, fs, font::NORMAL_COLOR, str_buf,
						 width - prob_width - 4, 2 + (fs + 2) * i, 0, TTF_STYLE_NORMAL);
	}
}
コード例 #15
0
void progress_bar::draw_contents()
{
	surface surf = video().getSurface();
	SDL_Rect area = location();

	if(area.w >= 2 && area.h >= 2) {
		int fcr =  21, fcg =  53, fcb =  80;		// RGB-values for finished piece.
		int bcr =   0, bcg =   0, bcb =   0;		// Border color.
		int gcr = 255, gcg = 255, gcb = 255;		// Groove color.
		int	lightning_thickness = 2;
		static const SDL_Color selected_text_color = {0xCC,0xCC,0xCC,0};

		SDL_Rect inner_area = create_rect(area.x + 1
				, area.y + 1
				, area.w - 2
				, area.h - 2);

		sdl_fill_rect(surf,&area,SDL_MapRGB(surf->format,bcr,bcg,bcb));
		sdl_fill_rect(surf,&inner_area,SDL_MapRGB(surf->format,gcr,gcg,gcb));

		inner_area.w = (inner_area.w*progress_)/100;
		sdl_fill_rect(surf,&inner_area,SDL_MapRGB(surf->format,fcr,fcg,fcb));

		SDL_Rect lightning = inner_area;
		lightning.h = lightning_thickness;
		//we add 25% of white to the color of the bar to simulate a light effect
		sdl_fill_rect(surf,&lightning,SDL_MapRGB(surf->format,(fcr*3+255)/4,(fcg*3+255)/4,(fcb*3+255)/4));
		lightning.y = inner_area.y+inner_area.h-lightning.h;
		//remove 50% of color to simulate a shadow effect
		sdl_fill_rect(surf,&lightning,SDL_MapRGB(surf->format,fcr/2,fcg/2,fcb/2));

		const std::string text = text_.empty() ? str_cast(progress_) + "%" :
		                         text_ + " (" + str_cast(progress_) + "%)";
		SDL_Rect text_area = font::text_area(text,font::SIZE_NORMAL);

		text_area.x = area.x + area.w/2 - text_area.w/2;
		text_area.y = area.y + area.h/2 - text_area.h/2;

		font::draw_text(
			&video(),
			location(),
			font::SIZE_NORMAL,
			font::BLACK_COLOR,
			text,
			text_area.x,
			text_area.y
		);

		// Draw a white text section for the highlighted area
		// of the bar
		SDL_Rect selected_text_location = location();
		selected_text_location.w = inner_area.w;
		selected_text_location.h = inner_area.h;
		{
			clip_rect_setter clippy(surf, &selected_text_location);
			font::draw_text(
				&video(),
				selected_text_location,
				font::SIZE_NORMAL,
				selected_text_color,
				text,
				text_area.x,
				text_area.y
			);
		}
	}

	update_rect(location());
}
コード例 #16
0
ファイル: gfx.cpp プロジェクト: riddlepl/freeserf
/* Fill a rectangle with color at x, y in the dest frame. */
void
gfx_fill_rect(int x, int y, int width, int height, int color, frame_t *dest)
{
	sdl_fill_rect(x, y, width, height, color, dest);
}