コード例 #1
0
ファイル: hotkeys.cpp プロジェクト: oys0317/opensanguo
std::vector<std::string> command_executor::get_menu_images(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_item hk = hotkey::get_hotkey(item);

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

		if (hk.get_id() == hotkey::HOTKEY_NULL) {
			str << item.substr(0, item.find_last_not_of(' ') + 1) << COLUMN_SEPARATOR;
		} else {
			str << hk.get_description() << COLUMN_SEPARATOR << hk.get_name();
		}

		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;
}
コード例 #2
0
ファイル: hotkeys.cpp プロジェクト: bjrnt/littlebobbytables
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_item hk = hotkey::get_hotkey(item);

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

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

		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;
}