当前位置: 首页>>代码示例>>C++>>正文


C++ CVideo::flip方法代码示例

本文整理汇总了C++中CVideo::flip方法的典型用法代码示例。如果您正苦于以下问题:C++ CVideo::flip方法的具体用法?C++ CVideo::flip怎么用?C++ CVideo::flip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVideo的用法示例。


在下文中一共展示了CVideo::flip方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: the_end

void the_end(CVideo &video, std::string text, unsigned int duration)
{
	//
	// Some sane defaults.
	//
	if(text.empty())
		text = _("The End");
	if(!duration)
		duration = 3500;

	SDL_Rect area = screen_area();
	sdl::fill_rect(video.getSurface(),&area,0);

	update_whole_screen();
	video.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();
		video.flip();
		CVideo::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();
		video.flip();
		CVideo::delay(10);
		--count;
	}
}
开发者ID:Heark,项目名称:wesnoth,代码行数:51,代码来源:intro.cpp

示例2: user_config


//.........这里部分代码省略.........
    const int max_landform = int(max_island);
    slider_rect.y = landform_rect.y;
    gui::slider landform_slider(screen);
    landform_slider.set_location(slider_rect);
    landform_slider.set_min(min_landform);
    landform_slider.set_max(max_landform);
    landform_slider.set_value(island_size_);

    SDL_Rect link_rect = slider_rect;
    link_rect.y = link_rect.y + link_rect.h + vertical_margin;

    gui::button link_castles(screen,_("Roads between castles"),gui::button::TYPE_CHECK);
    link_castles.set_check(link_castles_);
    link_castles.set_location(link_rect);

    SDL_Rect labels_rect = link_rect;
    labels_rect.y = labels_rect.y + labels_rect.h + vertical_margin;

    gui::button show_labels(screen,_("Show labels"),gui::button::TYPE_CHECK);
    show_labels.set_check(show_labels_);
    show_labels.set_location(labels_rect);

    while(true) {
        nplayers_ = players_slider.value();
        width_ = width_slider.value();
        height_ = height_slider.value();
        iterations_ = iterations_slider.value();
        hill_size_ = hillsize_slider.value();
        nvillages_ = villages_slider.value();
        castle_size_ = castlesize_slider.value();
        island_size_ = landform_slider.value();

        dialog_restorer.restore();
        close_button.set_dirty(true);
        if (close_button.pressed())
            break;

        players_slider.set_dirty();
        width_slider.set_dirty();
        height_slider.set_dirty();
        iterations_slider.set_dirty();
        hillsize_slider.set_dirty();
        villages_slider.set_dirty();
        castlesize_slider.set_dirty();
        landform_slider.set_dirty();
        link_castles.set_dirty();
        show_labels.set_dirty();

        width_slider.set_min(min_width+(players_slider.value()-2)*extra_size_per_player);
        height_slider.set_min(min_width+(players_slider.value()-2)*extra_size_per_player);

        f.draw();
        events::raise_process_event();
        events::raise_draw_event();

        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,players_label,players_rect.x,players_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,width_label,width_rect.x,width_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,height_label,height_rect.x,height_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,iterations_label,iterations_rect.x,iterations_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,hillsize_label,hillsize_rect.x,hillsize_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,villages_label,villages_rect.x,villages_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,castlesize_label,castlesize_rect.x,castlesize_rect.y);
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,landform_label,landform_rect.x,landform_rect.y);

        font::draw_text(&screen, screen_area(), font::SIZE_NORMAL,
                        font::NORMAL_COLOR, std::to_string(nplayers_),
                        slider_right + horz_margin, players_rect.y);

        font::draw_text(&screen, screen_area(), font::SIZE_NORMAL,
                        font::NORMAL_COLOR, std::to_string(width_),
                        slider_right + horz_margin, width_rect.y);

        font::draw_text(&screen, screen_area(), font::SIZE_NORMAL,
                        font::NORMAL_COLOR, std::to_string(height_),
                        slider_right+horz_margin,height_rect.y);

        std::stringstream villages_str;
        villages_str << nvillages_ << _("/1000 tiles");
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,villages_str.str(),
                        slider_right+horz_margin,villages_rect.y);

        font::draw_text(&screen, screen_area(), font::SIZE_NORMAL,
                        font::NORMAL_COLOR, std::to_string(castle_size_),
                        slider_right + horz_margin, castlesize_rect.y);

        std::stringstream landform_str;
        landform_str << translation::gettext(island_size_ == 0 ? N_("Inland") : (island_size_ < max_coastal ? N_("Coastal") : N_("Island")));
        font::draw_text(&screen,screen_area(),font::SIZE_NORMAL,font::NORMAL_COLOR,landform_str.str(),
                        slider_right+horz_margin,landform_rect.y);

        update_rect(xpos,ypos,width,height);

        v.flip();
        CVideo::delay(100);
        events::pump();
    }

    link_castles_ = link_castles.checked();
    show_labels_ = show_labels.checked();
}
开发者ID:CliffsDover,项目名称:wesnoth,代码行数:101,代码来源:default_map_generator.cpp

示例3: show_help

/**
 * Open a help dialog using a toplevel other than the default.
 *
 * This allows for complete customization of the contents, although not in a
 * very easy way.
 */
void show_help(CVideo& video, const section &toplevel_sec,
			   const std::string& show_topic,
			   int xloc, int yloc)
{
	const events::event_context dialog_events_context;
	const gui::dialog_manager manager;

	CVideo& screen = video;
	const surface& scr = screen.getSurface();

	const int width  = std::min<int>(font::relative_size(1200), scr->w - font::relative_size(20));
	const int height = std::min<int>(font::relative_size(850), scr->h - font::relative_size(150));
	const int left_padding = font::relative_size(10);
	const int right_padding = font::relative_size(10);
	const int top_padding = font::relative_size(10);
	const int bot_padding = font::relative_size(10);

	// If not both locations were supplied, put the dialog in the middle
	// of the screen.
	if (yloc <= -1 || xloc <= -1) {
		xloc = scr->w / 2 - width / 2;
		yloc = scr->h / 2 - height / 2;
	}
	std::vector<gui::button*> buttons_ptr;
	gui::button close_button_(video, _("Close"));
	buttons_ptr.push_back(&close_button_);

	gui::dialog_frame f(video, _("The Battle for Wesnoth Help"), gui::dialog_frame::default_style,
					 true, &buttons_ptr);
	f.layout(xloc, yloc, width, height);
	f.draw();

    // Find all unit_types that have not been constructed yet and fill in the information
    // needed to create the help topics
	unit_types.build_all(unit_type::HELP_INDEXED);

	if (preferences::encountered_units().size() != size_t(last_num_encountered_units) ||
	    preferences::encountered_terrains().size() != size_t(last_num_encountered_terrains) ||
	    last_debug_state != game_config::debug ||
		last_num_encountered_units < 0) {
		// More units or terrains encountered, update the contents.
		last_num_encountered_units = preferences::encountered_units().size();
		last_num_encountered_terrains = preferences::encountered_terrains().size();
		last_debug_state = game_config::debug;
		generate_contents();
	}
	try {
		help_browser hb(video, toplevel_sec);
		hb.set_location(xloc + left_padding, yloc + top_padding);
		hb.set_width(width - left_padding - right_padding);
		hb.set_height(height - top_padding - bot_padding);
		if (show_topic != "") {
			hb.show_topic(show_topic);
		}
		else {
			hb.show_topic(default_show_topic);
		}
		hb.set_dirty(true);
		events::raise_draw_event();
		CKey key;
		for (;;) {
			events::pump();
			events::raise_process_event();
			f.draw();
			events::raise_draw_event();
			if (key[SDLK_ESCAPE]) {
				// Escape quits from the dialog.
				return;
			}
			for (std::vector<gui::button*>::iterator button_it = buttons_ptr.begin();
				 button_it != buttons_ptr.end(); ++button_it) {
				if ((*button_it)->pressed()) {
					// There is only one button, close.
					return;
				}
			}
			video.flip();
			CVideo::delay(10);
		}
	}
	catch (parse_error& e) {
		std::stringstream msg;
		msg << _("Parse error when parsing help text: ") << "'" << e.message << "'";
		gui2::show_transient_message(video, "", msg.str());
	}
}
开发者ID:Wedge009,项目名称:wesnoth,代码行数:92,代码来源:help.cpp

示例4: show_about


//.........这里部分代码省略.........
			text_rect = f.layout(frame_area).interior;

			// update the text area
			text_rect.x += text_left_padding;
			text_rect.w -= text_left_padding;
			text_rect_blit = text_rect;

			text_surf = create_compatible_surface(screen, text_rect.w, text_rect.h);
			SDL_SetAlpha(text_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE);

			// relocate the close button
			close.set_location((screen->w/2)-(close.width()/2), screen->h - 30);

			update_dimensions = false;
		}

		if (redraw_mapimage) {
			// draw map to screen, thus erasing all text
			sdl_blit(map_image_scaled, nullptr, screen, nullptr);
			update_rect(screen_rect);

			// redraw the dialog
			f.draw_background();
			f.draw_border();
			// cache the dialog background (alpha blending + blurred map)
			sdl_blit(screen, &text_rect, text_surf, nullptr);
			redraw_mapimage = false;
		} else {
			// redraw the saved part of the dialog where text scrolled
			// thus erasing all text
			SDL_Rect modified = sdl::create_rect(0, 0, max_text_width, text_rect.h);
			sdl_blit(text_surf, &modified, screen, &text_rect_blit);
			update_rect(text_rect);
		}

		int y = text_rect.y - offset;
		int line = startline;
		max_text_width = 0;

		{
			// clip to keep text into the frame (thus the new code block)
			clip_rect_setter set_clip_rect(screen, &text_rect);

			const int line_spacing = 5;
			do {
				// draw the text (with ellipsis if needed)
				// update the max_text_width for future cleaning
				int w = font::draw_text(&video, text_rect, def_size, def_color,
										text[line], text_rect.x, y).w;
				max_text_width = std::max<int>(max_text_width, w);
				// since the real drawing on screen is clipped,
				// we do a dummy one to get the height of the not clipped line.
				// (each time because special format characters may change it)
				const int line_height = font::draw_text(nullptr, text_rect, def_size, def_color,
										text[line], 0,0).h;

				if(is_new_line) {
					is_new_line = false;
					first_line_height = line_height + line_spacing;
				}
				line++;
				if(size_t(line) > text.size()-1)
					line = 0;
				y += line_height + line_spacing;
			} while(y < text_rect.y + text_rect.h);
		}

		// performs the actual scrolling
		offset += scroll_speed;
		if (offset>=first_line_height) {
			offset -= first_line_height;
			is_new_line = true;
			startline++;
			if(size_t(startline) == text.size()){
				startline = 0;
				image_count = -1;
			}
		}

		// handle events
		if (key[SDLK_UP] && scroll_speed < 20) {
			++scroll_speed;
		}
		if (key[SDLK_DOWN] && scroll_speed > 0) {
			--scroll_speed;
		}
		if (screen->w != screen_rect.w || screen->h != screen_rect.h) {
			update_dimensions = true;
		}

		events::pump();
		events::raise_process_event();
		events::raise_draw_event();

		// flip screen and wait, so the text does not scroll too fast
		video.flip();
		CVideo::delay(20);

	} while(!close.pressed() && (last_escape || !key[SDLK_ESCAPE]));
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:101,代码来源:about.cpp

示例5: show_variation_help

/**
 * Open the help browser, show the variation of the unit matching.
 */
void show_variation_help(CVideo& video, const std::string& unit, const std::string &variation, bool hidden, int xloc, int yloc)
{
	show_help(video, toplevel, hidden_symbol(hidden) + variation_prefix + unit + "_" + variation, xloc, yloc);
	video.flip();
}
开发者ID:MysteryPoo,项目名称:wesnoth,代码行数:8,代码来源:help.cpp

示例6: show_terrain_help

/**
 * Open the help browser, show terrain with id terrain_id.
 *
 * If show_topic is the empty string, the default topic will be shown.
 */
void show_terrain_help(CVideo& video, const std::string& show_topic, bool hidden, int xloc, int yloc)
{
	show_help(video, toplevel, hidden_symbol(hidden) + terrain_prefix + show_topic, xloc, yloc);
	video.flip();
}
开发者ID:MysteryPoo,项目名称:wesnoth,代码行数:10,代码来源:help.cpp

示例7: show_unit_help

/**
 * Open the help browser, show unit with id unit_id.
 *
 * If show_topic is the empty string, the default topic will be shown.
 */
void show_unit_help(CVideo& video, const std::string& show_topic, bool has_variations, bool hidden, int xloc, int yloc)
{
	show_help(video, toplevel,
			  hidden_symbol(hidden) + (has_variations ? ".." : "") + unit_prefix + show_topic, xloc, yloc);
	video.flip();
}
开发者ID:MysteryPoo,项目名称:wesnoth,代码行数:11,代码来源:help.cpp

示例8: show_help

/**
 * Open the help browser, show topic with id show_topic.
 *
 * If show_topic is the empty string, the default topic will be shown.
 */
void show_help(CVideo& video, const std::string& show_topic, int xloc, int yloc)
{
	show_help(video, toplevel, show_topic, xloc, yloc);
	video.flip();
}
开发者ID:MysteryPoo,项目名称:wesnoth,代码行数:10,代码来源:help.cpp


注:本文中的CVideo::flip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。