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


C++ display类代码示例

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


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


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