• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ display类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: img

std::vector<std::string> command_executor::get_menu_images(display& disp, const std::vector<std::string>& items) {
	std::vector<std::string> result;
	bool has_image = false;

	for (size_t i = 0; i < items.size(); ++i) {
		std::string const& item = items[i];
		const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(item);

		std::stringstream str;
		//see if this menu item has an associated image
		std::string img(get_menu_image(disp, item, i));
		if (img.empty() == false) {
			has_image = true;
			str << IMAGE_PREFIX << img << COLUMN_SEPARATOR;
		}

		if (hk == hotkey::HOTKEY_NULL) {
			const theme::menu* menu = disp.get_theme().get_menu_item(item);
			if (menu)
				str << menu->title();
			else
				str << item.substr(0, item.find_last_not_of(' ') + 1) << COLUMN_SEPARATOR;
		} else {
			std::string desc = hotkey::get_description(item);
			if (hk == HOTKEY_ENDTURN) {
				const theme::action *b = disp.get_theme().get_action_item("button-endturn");
				if (b) {
					desc = b->title();
				}
			}
			str << desc << COLUMN_SEPARATOR << hotkey::get_names(item);
		}

		result.push_back(str.str());
	}
	//If any of the menu items have an image, create an image column
	if (has_image) {
		for (std::vector<std::string>::iterator i = result.begin(); i != result.end(); ++i) {
			if (*(i->begin()) != IMAGE_PREFIX) {
				i->insert(i->begin(), COLUMN_SEPARATOR);
			}
		}
	}
	return result;
}
开发者ID:AI0867,项目名称:wesnoth,代码行数:45,代码来源:command_executor.cpp


示例2: show_theme_dialog

bool show_theme_dialog(display& disp)
{
	int action = 0;
	std::vector<std::string> options = disp.get_theme().get_known_themes();
	if(!options.empty()){
		std::string current_theme=_("Saved Theme Preference: ")+preferences::theme();
		action = gui::show_dialog(disp,NULL,"",current_theme,gui::OK_CANCEL,&options);
		if(action >= 0){
		preferences::set_theme(options[action]);
		//it would be preferable for the new theme to take effect
		//immediately, however, this will have to do for now.
		gui2::show_transient_message(disp.video(),"",_("New theme will take effect on next new or loaded game."));
		return(1);
		}
	}else{
		gui2::show_transient_message(disp.video(),"",_("No known themes. Try changing from within an existing game."));
	}
	return(0);
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:19,代码来源:game_preferences_display.cpp


示例3: update_positions

void positional_source::update_positions(unsigned int time, const display &disp)
{
	int distance_volume = DISTANCE_SILENT;
	for(std::vector<map_location>::iterator i = locations_.begin(); i != locations_.end(); ++i) {
		if(disp.shrouded(*i) || (check_fogged_ && disp.fogged(*i)))
			continue;

		int v = calculate_volume(*i, disp);
		if(v < distance_volume) {
			distance_volume = v;
		}
	}

	if(sound::is_sound_playing(id_)) {
		sound::reposition_sound(id_, distance_volume);
	} else {
		update(time, disp);
	}
}
开发者ID:dodikk,项目名称:iWesnoth,代码行数:19,代码来源:soundsource.cpp


示例4: parent

        display::scoped_state::scoped_state(display & parent, const gsgl::flags_t & flags)
            : parent(parent)
        {
            parent.bind();

            glPushAttrib(GL_ALL_ATTRIB_BITS);                                                                       CHECK_GL_ERRORS();
            glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);                                                          CHECK_GL_ERRORS();

            enable(flags);
        } // display::scoped_state::scoped_state()
开发者ID:kulibali,项目名称:periapsis,代码行数:10,代码来源:display.cpp


示例5: calculate_volume

int positional_source::calculate_volume(const map_location &loc, const display &disp)
{
	assert(range_ > 0);
	assert(faderange_ > 0);

	if((check_shrouded_ && disp.shrouded(loc)) || (check_fogged_ && disp.fogged(loc)))
		return DISTANCE_SILENT;

	SDL_Rect area = disp.map_area();
	map_location center = disp.hex_clicked_on(area.x + area.w / 2, area.y + area.h / 2);
	int distance = distance_between(loc, center);

	if(distance <= range_) {
		return 0;
	}

	return static_cast<int>((((distance - range_)
			/ static_cast<double>(faderange_)) * DISTANCE_SILENT));
}
开发者ID:Heark,项目名称:wesnoth,代码行数:19,代码来源:soundsource.cpp


示例6:

help_browser::help_browser(display &disp, const section &toplevel) :
	gui::widget(disp.video()),
	disp_(disp),
	menu_(disp.video(),
	toplevel),
	text_area_(disp.video(), toplevel), toplevel_(toplevel),
	ref_cursor_(false),
	back_topics_(),
	forward_topics_(),
	back_button_(disp.video(), "", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_left"),
	forward_button_(disp.video(), "", gui::button::TYPE_PRESS, "button_normal/button_small_H22", gui::button::DEFAULT_SPACE, true, "icons/arrows/long_arrow_ornate_right"),
	shown_topic_(NULL)
{
	// Hide the buttons at first since we do not have any forward or
	// back topics at this point. They will be unhidden when history
	// appears.
	back_button_.hide(true);
	forward_button_.hide(true);
	// Set sizes to some default values.
	set_measurements(font::relative_size(400), font::relative_size(500));
}
开发者ID:awleffew,项目名称:wesnoth,代码行数:21,代码来源:help_browser.cpp


示例7: user_config

void lua_map_generator::user_config(display & disp)
{
	lk_.set_video(&disp.video());
	try {
		lk_.user_config(user_config_.c_str(), generator_data_);
	} catch (game::lua_error & e) {
		std::string msg = "Error when running lua_map_generator user_config.\n";
		msg += "The generator was: " + config_name_ + "\n";
		msg += e.what();
		throw mapgen_exception(msg);
	}
}
开发者ID:PositiveMD,项目名称:wesnoth,代码行数:12,代码来源:lua_map_generator.cpp


示例8: show_fail_tip

void show_fail_tip(display& disp, const std::string& item)
{
	std::stringstream err;
	utils::string_map symbols;

	symbols["mail"] = tintegrate::generate_format(game_config::service_email, "green");
	symbols["date"] = tintegrate::generate_format(format_time_local2(time(NULL)), "yellow");
	symbols["item"] = tintegrate::generate_format(item, "yellow");
	symbols["username"] = tintegrate::generate_format(preferences::login(), "yellow");
	err << vgettext2("Update database fail when execute In-App Purchase! In order to compensate data you should get, please send In-App Purchase information to $mail. In-App Purchase information include: date($date), item($item), username($username).", symbols);
	gui2::show_message(disp.video(), "", err.str());
}
开发者ID:freeors,项目名称:War-Of-Kingdom,代码行数:12,代码来源:inapp_purchase.cpp


示例9:

help_browser::help_browser(display &disp, const section &toplevel) :
	gui::widget(disp.video()),
	disp_(disp),
	menu_(disp.video(),
	toplevel),
	text_area_(disp.video(), toplevel), toplevel_(toplevel),
	ref_cursor_(false),
	back_topics_(),
	forward_topics_(),
	back_button_(disp.video(), _(" < Back"), gui::button::TYPE_PRESS),
	forward_button_(disp.video(), _("Forward >"), gui::button::TYPE_PRESS),
	shown_topic_(NULL)
{
	// Hide the buttons at first since we do not have any forward or
	// back topics at this point. They will be unhidden when history
	// appears.
	back_button_.hide(true);
	forward_button_.hide(true);
	// Set sizes to some default values.
	set_measurements(font::relative_size(400), font::relative_size(500));
}
开发者ID:PositiveMD,项目名称:wesnoth,代码行数:21,代码来源:help_browser.cpp


示例10: run_lobby_loop

static void run_lobby_loop(display& disp, mp::ui& ui)
{
	disp.video().modeChanged();
	bool first = true;
	font::cache_mode(font::CACHE_LOBBY);
	while (ui.get_result() == mp::ui::CONTINUE) {
		if (disp.video().modeChanged() || first) {
			SDL_Rect lobby_pos = { 0, 0, disp.video().getx(), disp.video().gety() };
			ui.set_location(lobby_pos);
			first = false;
		}
		// process network data first so user actions can override the result
		// or uptodate data can prevent invalid actions
		// i.e. press cancel while you receive [start_game] or press start game while someone leaves
		ui.process_network();

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

		disp.flip();
		disp.delay(20);
	}
	font::cache_mode(font::CACHE_GAME);
}
开发者ID:Yossarian,项目名称:WesnothAddonServer,代码行数:25,代码来源:multiplayer.cpp


示例11:

std::set<map_location> editor_map::set_starting_position_labels(display& disp)
{
	std::set<map_location> label_locs;
	std::string label = _("Player");
	label += " ";
	for (int i = 1; i <= gamemap::MAX_PLAYERS; i++) {
		if (startingPositions_[i].valid()) {
			disp.labels().set_label(startingPositions_[i], label + lexical_cast<std::string>(i));
			label_locs.insert(startingPositions_[i]);
		}
	}
	return label_locs;
}
开发者ID:RushilPatel,项目名称:BattleForWesnoth,代码行数:13,代码来源:editor_map.cpp


示例12:

std::set<map_location> editor_map::set_starting_position_labels(display& disp)
{
	std::set<map_location> label_locs;
	std::string label = _("Player");
	label += " ";
	for (int i = 0, size = starting_positions_.size(); i < size; ++i) {
		if (starting_positions_[i].valid()) {
			disp.labels().set_label(starting_positions_[i], label + lexical_cast<std::string>(i + 1));
			label_locs.insert(starting_positions_[i]);
		}
	}
	return label_locs;
}
开发者ID:sunny975,项目名称:wesnoth,代码行数:13,代码来源:editor_map.cpp


示例13: show

void twml_exception::show(display &disp)
{
	std::ostringstream sstr;

	// The extra spaces between the \n are needed, otherwise the dialog doesn't show
	// an empty line.
	sstr << _("An error due to possibly invalid WML occurred\nThe error message is :")
		<< "\n" << user_message << "\n \n"
		<< _("When reporting the bug please include the following error message :")
		<< "\n" << dev_message;

	gui2::show_error_message(disp.video(), sstr.str());
}
开发者ID:Martin9295,项目名称:wesnoth,代码行数:13,代码来源:wml_exception.cpp


示例14: key_event

void key_event(display& disp, const SDL_KeyboardEvent& event, command_executor* executor)
{
	if(event.keysym.sym == SDLK_ESCAPE && disp.in_game()) {
		LOG_G << "escape pressed..showing quit\n";
		const int res = gui::dialog(disp,_("Quit"),_("Do you really want to quit?"),gui::YES_NO).show();
		if(res == 0) {
			throw end_level_exception(QUIT);
		} else {
			return;
		}
	}

	key_event_execute(disp,event,executor);
}
开发者ID:oys0317,项目名称:opensanguo,代码行数:14,代码来源:hotkeys.cpp


示例15: get_menu_images

void command_executor::get_menu_images(display& disp, std::vector<config>& items)
{
	for(size_t i = 0; i < items.size(); ++i) {
		config& item = items[i];

		const std::string& item_id = item["id"];
		const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(item_id);

		//see if this menu item has an associated image
		std::string img(get_menu_image(disp, item_id, i));
		if (img.empty() == false) {
			item["icon"] = img;
		}

		const theme::menu* menu = disp.get_theme().get_menu_item(item_id);
		if(menu) {
			item["label"] = menu->title();
		} else if(hk != hotkey::HOTKEY_NULL) {
			std::string desc = hotkey::get_description(item_id);
			if(hk == HOTKEY_ENDTURN) {
				const theme::action *b = disp.get_theme().get_action_item("button-endturn");
				if (b) {
					desc = b->title();
				}
			}

			item["label"] = desc;
			item["details"] = hotkey::get_names(item_id);
		} else if(item["label"].empty()) {
			// If no matching hotkey was found and a custom label wasn't already set, treat
			// the id as a plaintext description. This is because either type of value can
			// be written to the id field by the WMI manager. The plaintext description is
			// used in the case the menu item specifies the relevant entry is *not* a hotkey.
			item["label"] = item_id;
		}
	}
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:37,代码来源:command_executor.cpp


示例16: set_fullscreen

void set_fullscreen(display& disp, const bool ison)
{
	_set_fullscreen(ison);

	CVideo& video = disp.video();
	const std::pair<int,int>& res = resolution();
	if (video.isFullScreen() != ison) {
		const int flags = ison ? SDL_WINDOW_FULLSCREEN: 0;
		int bpp = video.modePossible(res.first, res.second, 32, flags);
		VALIDATE(bpp > 0, "bpp must be large than 0!");

		video.setMode(res.first, res.second,bpp, flags);
		require_change_resolution = true;
	}
}
开发者ID:hyrio,项目名称:War-Of-Kingdom,代码行数:15,代码来源:preferences_display.cpp


示例17: the_end

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;
	}
}
开发者ID:justinzane,项目名称:wesnoth-ng,代码行数:52,代码来源:intro.cpp


示例18:

unit_drawer::unit_drawer(display & thedisp, std::map<surface,SDL_Rect> & bar_rects) :
	disp(thedisp),
	dc(disp.get_disp_context()),
	map(dc.map()),
	teams(dc.teams()),
	halo_man(thedisp.get_halo_manager()),
	energy_bar_rects_(bar_rects),
	viewing_team(disp.viewing_team()),
	playing_team(disp.playing_team()),
	viewing_team_ref(teams[viewing_team]),
	playing_team_ref(teams[playing_team]),
	is_blindfolded(disp.is_blindfolded()),
	show_everything(disp.show_everything()),
	sel_hex(disp.selected_hex()),
	mouse_hex(disp.mouseover_hex()),
	zoom_factor(disp.get_zoom_factor()),
	hex_size(disp.hex_size()),
	hex_size_by_2(disp.hex_size()/2)
{}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:19,代码来源:drawer.cpp


示例19: get_menu_image

std::string command_executor::get_menu_image(display& disp, const std::string& command, int index) const {

	// TODO: Find a way to do away with the fugly special markup
	if(command[0] == '&') {
		size_t n = command.find_first_of('=');
		if(n != std::string::npos)
			return command.substr(1, n - 1);
	}

	const std::string base_image_name = "icons/action/" + command + "_25.png";
	const std::string pressed_image_name = "icons/action/" + command + "_25-pressed.png";

	const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(command);
	const hotkey::ACTION_STATE state = get_action_state(hk, index);

	const theme::menu* menu = disp.get_theme().get_menu_item(command);
	if (menu) {
		return "icons/arrows/short_arrow_right_25.png~CROP(3,3,18,18)"; // TODO should not be hardcoded
	}

	if (filesystem::file_exists(game_config::path + "/images/" + base_image_name)) {
		switch (state) {
			case ACTION_ON:
			case ACTION_SELECTED:
				return pressed_image_name + "~CROP(3,3,18,18)";
			default:
				return base_image_name + "~CROP(3,3,18,18)";
		}
	}

	switch (get_action_state(hk, index)) {
		case ACTION_ON:
			return game_config::images::checked_menu;
		case ACTION_OFF:
			return game_config::images::unchecked_menu;
		case ACTION_SELECTED:
			return game_config::images::selected_menu;
		case ACTION_DESELECTED:
			return game_config::images::deselected_menu;
		default: return get_action_image(hk, index);
	}
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:42,代码来源:command_executor.cpp


示例20: playsingle_scenario

static LEVEL_RESULT playsingle_scenario(const config& game_config,
		const config* level, display& disp, game_state& state_of_game, hero_map& heros, hero_map& heros_start,
		card_map& cards,
		const config::const_child_itors &story,
		bool skip_replay, end_level_data &end_level)
{
	const int ticks = SDL_GetTicks();
	int num_turns = (*level)["turns"].to_int();

	playsingle_controller playcontroller(*level, state_of_game, heros, heros_start, cards, ticks, num_turns, game_config, disp.video(), skip_replay);

	LEVEL_RESULT res = playcontroller.play_scenario(story, skip_replay);
	playcontroller.get_end_level_data().result = res;
	end_level = playcontroller.get_end_level_data();

	if (res == DEFEAT) {
		if (resources::persist != NULL) {
			resources::persist->end_transaction();
		}
		gui2::show_transient_message(disp.video(),
				    _("Defeat"),
				    _("You have been defeated!")
				    );
	}

	if (res != QUIT && end_level.linger_mode)
	{
		try {
			playcontroller.linger();
		} catch(end_level_exception& e) {
			if (e.result == QUIT) {
				return QUIT;
			}
		}
	}

	return res;
}
开发者ID:coolsee,项目名称:War-Of-Kingdom,代码行数:38,代码来源:playcampaign.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ display_t类代码示例发布时间:2022-05-31
下一篇:
C++ dimensionedScalar类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap