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


C++ CVideo类代码示例

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


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

示例1: set_fullscreen

void set_fullscreen(CVideo& video, const bool ison)
{
	_set_fullscreen(ison);

	const std::pair<int,int>& res = resolution();
	if(video.isFullScreen() != ison) {
		const int flags = ison ? FULL_SCREEN : 0;
		int bpp = video.bppForMode(res.first, res.second, flags);

		if(bpp > 0) {
			video.setMode(res.first,res.second,bpp,flags);
			if(disp) {
				disp->redraw_everything();
			}
		} else {
			int tmp_flags = flags;
			std::pair<int,int> tmp_res;
			if(detect_video_settings(video, tmp_res, bpp, tmp_flags)) {
				set_resolution(video, tmp_res.first, tmp_res.second);
			// TODO: see if below line is actually needed, possibly for displays that only support 16 bbp
			} else if(video.modePossible(1024,768,16,flags)) {
				set_resolution(video, 1024, 768);
			} else {
				gui2::show_transient_message(video,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
			}
			// We reinit color cursors, because SDL on Mac seems to forget the SDL_Cursor
			set_color_cursors(preferences::get("color_cursors", false));
		}
	}
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2:

file_dialog::file_dialog(CVideo& video, const std::string& file_path,
		const std::string& title, const std::string& default_file_name,
		bool show_directory_buttons) :
	gui::dialog(video, title, file_path, gui::OK_CANCEL),
	show_directory_buttons_(show_directory_buttons),
	files_list_(nullptr),
	last_selection_(-1),
	last_textbox_text_(),
	chosen_file_(".."),
    autocomplete_(true)
{
	files_list_ = new gui::file_menu(video, file_path);
	const unsigned file_list_height = (video.gety() / 2);
	const unsigned file_list_width = std::min<unsigned>(files_list_->width(), (video.gety() / 4));
	files_list_->set_measurements(file_list_width, file_list_height);
	files_list_->set_max_height(file_list_height);
	set_menu(files_list_);
	default_file_name_ = default_file_name;
	get_message().set_text(format_dirname(files_list_->get_directory()));
	set_textbox(_("File: "), format_filename(file_path), 100);
	if (show_directory_buttons_)
	{
		add_button( new gui::dialog_button(video, _("Delete File"),
					gui::button::TYPE_PRESS, gui::DELETE_ITEM), dialog::BUTTON_EXTRA);
		add_button( new gui::dialog_button(video, _("New Folder"),
					gui::button::TYPE_PRESS, gui::CREATE_ITEM), dialog::BUTTON_EXTRA_LEFT);
	}
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:28,代码来源:filechooser.cpp

示例3: set_resolution

bool set_resolution(CVideo& video
		, const unsigned width, const unsigned height)
{
	SDL_Rect rect;
	SDL_GetClipRect(video.getSurface(), &rect);
	if(rect.w == width && rect.h == height) {
		return true;
	}

	const int flags = fullscreen() ? FULL_SCREEN : 0;
	int bpp = video.bppForMode(width, height, flags);

	if(bpp != 0) {
		video.setMode(width, height, bpp, flags);

		if(disp) {
			disp->redraw_everything();
		}

	} else {
        // grzywacz: is this even true?
		gui2::show_transient_message(video,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
		return false;
	}

	const std::string postfix = fullscreen() ? "resolution" : "windowsize";
	preferences::set('x' + postfix, lexical_cast<std::string>(width));
	preferences::set('y' + postfix, lexical_cast<std::string>(height));

	return true;
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例4: 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

示例5: show_video_mode_dialog

bool show_video_mode_dialog(CVideo& video)
{
	const resize_lock prevent_resizing;
	// For some reason, this line prevents the dialog from being opened from GUI2...
	//const events::event_context dialog_events_context;

	std::vector<std::pair<int,int> > resolutions
			= video.get_available_resolutions();

	if(resolutions.empty()) {
		gui2::show_transient_message(
				video
				, ""
				, _("There are no alternative video modes available"));

		return false;
	}

	std::vector<std::string> options;
	unsigned current_choice = 0;

	for(size_t k = 0; k < resolutions.size(); ++k) {
		std::pair<int, int> const& res = resolutions[k];

		if (res == video.current_resolution())
			current_choice = static_cast<unsigned>(k);

		std::ostringstream option;
		option << res.first << utils::unicode_multiplication_sign << res.second;
		const int div = boost::math::gcd(res.first, res.second);
		const int ratio[2] = {res.first/div, res.second/div};
		if (ratio[0] <= 10 || ratio[1] <= 10)
			option << " (" << ratio[0] << ':' << ratio[1] << ')';
		options.push_back(option.str());
	}

	gui2::tsimple_item_selector dlg(_("Choose Resolution"), "", options);
	dlg.set_selected_index(current_choice);
	dlg.show(video);

	int choice = dlg.selected_index();

	if(choice == -1 || resolutions[static_cast<size_t>(choice)] == video.current_resolution()) {
		return false;
	}

	video.set_resolution(resolutions[static_cast<size_t>(choice)]);

	return true;
}
开发者ID:ierton,项目名称:wesnoth,代码行数:50,代码来源:preferences_display.cpp

示例6: fullscreen

static bool fullscreen(CVideo& video)
{
	video.set_fullscreen(!preferences::fullscreen());


	return true;
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:7,代码来源:title_screen.cpp

示例7: draw_cursor

void textbox::draw_cursor(int pos, CVideo &video) const
{
	if(show_cursor_ && editable_) {
		SDL_Rect rect = {location().x + pos, location().y, 1, location().h };
		surface const frame_buffer = video.getSurface();
		SDL_FillRect(frame_buffer,&rect,SDL_MapRGB(frame_buffer->format,255,255,255));
	}
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:8,代码来源:textbox.cpp

示例8: getSelectedGame

void GuiIconCarousel::OnTouchClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger)
{
    if(!controller->data.validPointer)
        return;

    bWasDragging = false;
    selectedGameOnDragStart = getSelectedGame();
    lastPosition.x = controller->data.x;
    lastPosition.y = controller->data.y;

    //! calculate ray origin and direction
    glm::vec3 rayOrigin;
    glm::vec3 rayDir;

    CVideo *video = Application::instance()->getVideo();
    video->screenPosToWorldRay(controller->data.x, controller->data.y, rayOrigin, rayDir);

    glm::vec3 rayDirFrac((rayDir.x != 0.0f) ? (1.0f / rayDir.x) : 0.0f, (rayDir.y != 0.0f) ? (1.0f / rayDir.y) : 0.0f, (rayDir.z != 0.0f) ? (1.0f / rayDir.z) : 0.0f);

    for(u32 i = 0; i < drawOrder.size(); ++i)
    {
        int idx = drawOrder[i];

        if(gameIcons[idx]->checkRayIntersection(rayOrigin, rayDirFrac))
        {
            if(buttonClickSound)
                buttonClickSound->Play();

            setSelectedGame(idx);
            gameSelectionChanged(this, idx);

            //! TODO: change this to a button assigned image
            gameIcons[idx]->setState(STATE_CLICKED);
            gameIcons[idx]->setEffect(EFFECT_SCALE, 4, 125);

            if(selectedGame == idx)
            {
                if(gameLaunchTimer < 30)
                    OnLaunchClick(button, controller, trigger);

                gameLaunchTimer = 0;
            }
        }
    }
}
开发者ID:Axel-F,项目名称:loadiine_gx2,代码行数:45,代码来源:GuiIconCarousel.cpp

示例9: detect_video_settings

bool detect_video_settings(CVideo& video, std::pair<int,int>& resolution, int& bpp, int& video_flags)
{
	video_flags = fullscreen() ? FULL_SCREEN : 0;
	resolution = preferences::resolution();

	int DefaultBPP = 24;
	const SDL_VideoInfo* const video_info = SDL_GetVideoInfo();
	if(video_info != NULL && video_info->vfmt != NULL) {
		DefaultBPP = video_info->vfmt->BitsPerPixel;
	}

	std::cerr << "Checking video mode: " << resolution.first << 'x'
		<< resolution.second << 'x' << DefaultBPP << "...\n";

	typedef std::pair<int, int> res_t;
	std::vector<res_t> res_list;
    if(fullscreen()){
        res_list.push_back(res_t(2560, 1600));
        res_list.push_back(res_t(1920, 1200));
        res_list.push_back(res_t(1920, 1080));
        res_list.push_back(res_t(1680, 1050));
        res_list.push_back(res_t(1440, 900));
        res_list.push_back(res_t(1360, 768));
    }
    res_list.push_back(res_t(1024, 768));


	bpp = video.modePossible(resolution.first, resolution.second,
		DefaultBPP, video_flags, true);

	BOOST_FOREACH(const res_t &res, res_list)
	{
		if (bpp != 0) break;
		std::cerr << "Video mode " << resolution.first << 'x'
			<< resolution.second << 'x' << DefaultBPP
			<< " is not supported; attempting " << res.first
			<< 'x' << res.second << 'x' << DefaultBPP << "...\n";
		resolution = res;
		bpp = video.modePossible(resolution.first, resolution.second,
			DefaultBPP, video_flags);
	}

	preferences::set_resolution(resolution);
	return bpp != 0;
}
开发者ID:,项目名称:,代码行数:45,代码来源:

示例10: show

bool tdialog::show(CVideo& video, const unsigned auto_close_time)
{
	if(video.faked() && !show_even_without_video_) {
		if(!allow_plugin_skip_) {
			return false;
		}

		plugins_manager* pm = plugins_manager::get();
		if (pm && pm->any_running())
		{
			plugins_context pc("Dialog");
			pc.set_callback("skip_dialog", [this](config) { retval_ = twindow::OK; }, false);
			pc.set_callback("quit", [](config) {}, false);
			pc.play_slice();
		}

		return false;
	}

	std::unique_ptr<twindow> window(build_window(video));
	assert(window.get());

	post_build(*window);

	window->set_owner(this);

	init_fields(*window);

	pre_show(*window);

	retval_ = window->show(restore_, auto_close_time);

	/*
	 * It can happen that when two clicks follow each other fast that the event
	 * handling code in events.cpp generates a DOUBLE_CLICK_EVENT. For some
	 * reason it can happen that this event gets pushed in the queue when the
	 * window is shown, but processed after the window is closed. This causes
	 * the next window to get this pending event.
	 *
	 * This caused a bug where double clicking in the campaign selection dialog
	 * directly selected a difficulty level and started the campaign. In order
	 * to avoid that problem, filter all pending DOUBLE_CLICK_EVENT events after
	 * the window is closed.
	 */
	SDL_FlushEvent(DOUBLE_CLICK_EVENT);

	finalize_fields(*window, (retval_ == twindow::OK || always_save_fields_));

	post_show(*window);

	// post_show may have updated the windoe retval. Update it here.
	retval_ = window->get_retval();

	return retval_ == twindow::OK;
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:55,代码来源:dialog.cpp

示例11: wesnothd_dialog

void tnetwork_transmission::wesnothd_dialog(CVideo& video, gui2::tnetwork_transmission::connection_data& conn, const std::string& msg1, const std::string& msg2)
{
	if (video.faked()) {
		while (!conn.finished()) {
			conn.poll();
			SDL_Delay(1);
		}
	}
	else {
		gui2::tnetwork_transmission(conn, msg1, msg2).show(video);
	}
}
开发者ID:CliffsDover,项目名称:wesnoth,代码行数:12,代码来源:network_transmission.cpp

示例12: draw_cursor

void textbox::draw_cursor(int pos, CVideo &video) const
{
	if(show_cursor_ && editable_ && enabled()) {
		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));
	}
}
开发者ID:Aishiko,项目名称:wesnoth,代码行数:12,代码来源:textbox.cpp

示例13: av_register_all

VideoPtr Video::Create(StreamPtr stream, MessageCallback messageCallback, IAudioDevicePtr audioDevice)
{
	static bool initialized = false;
	if(!initialized)
		av_register_all();

	CVideo* video = new CVideo(messageCallback);

	av_log_set_callback(CVideo::logCb);
	av_log_set_level(AV_LOG_WARNING);

	try {
		video->openFile(stream, audioDevice);
	}

	catch(VideoException e){
		delete video;
		throw e;
	}

	return VideoPtr(video);
}
开发者ID:SaferSocietyGroup,项目名称:videoplayer,代码行数:22,代码来源:Video.cpp

示例14: fullscreen

static bool fullscreen(CVideo& video)
{
	video.set_fullscreen(!preferences::fullscreen());

#if !SDL_VERSION_ATLEAST(2, 0, 0)
	// Setting to fullscreen doesn't seem to generate a resize event.
	const SDL_Rect& rect = screen_area();

	SDL_Event event;
	event.type = SDL_VIDEORESIZE;
	event.resize.type = SDL_VIDEORESIZE;
	event.resize.w = rect.w;
	event.resize.h = rect.h;

	SDL_PushEvent(&event);
#endif

	return true;
}
开发者ID:MysteryPoo,项目名称:wesnoth,代码行数:19,代码来源:title_screen.cpp

示例15: set_resolution_list

// Helper function to refresh resolution list
static void set_resolution_list(tcombobox& res_list, CVideo& video)
{
	const std::vector<std::pair<int,int> > resolutions = video.get_available_resolutions(true);

	std::vector<std::string> options;
	FOREACH(const AUTO& res, resolutions)
	{
		std::ostringstream option;
		option << res.first << utils::unicode_multiplication_sign << res.second;

		const int div = boost::math::gcd(res.first, res.second);
		const int ratio[2] = {res.first/div, res.second/div};
		if (ratio[0] <= 10 || ratio[1] <= 10) {
			option << " <span color='#777777'>("
				<< ratio[0] << ':' << ratio[1] << ")</span>";
		}

		options.push_back(option.str());
	}
开发者ID:Heark,项目名称:wesnoth,代码行数:20,代码来源:preferences_dialog.cpp


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