Exemplo n.º 1
0
bool FeRomList::set_tag( FeRomInfo &rom, FeDisplayInfo &display, const std::string &tag, bool flag )
{
	std::string curr_tags = rom.get_info(FeRomInfo::Tags);
	size_t pos = curr_tags.find( FE_TAGS_SEP + tag + FE_TAGS_SEP );

	std::map<std::string, bool>::iterator itt = m_tags.begin();

	if ( flag == true )
	{
		if ( pos == std::string::npos )
		{
			rom.append_tag( tag );
			m_tags_changed = true;

			itt = m_tags.find( tag );
			if ( itt != m_tags.end() )
				(*itt).second = true;
			else
				itt = m_tags.insert( itt, std::pair<std::string,bool>( tag, true ) );
		}
	}
	else if ( pos != std::string::npos )
	{
		pos++; // because we searched for the preceeding FE_TAGS_SEP as well
		int len = tag.size();

		if (( ( pos + len ) < curr_tags.size() )
				&& ( curr_tags.at( pos + len ) == FE_TAGS_SEP ))
			len++;

		curr_tags.erase( pos, len );

		//
		// Clean up our leading FE_TAGS_SEP if there are no tags left
		//
		if (( curr_tags.size() == 1 ) && (curr_tags[0] == FE_TAGS_SEP ))
			curr_tags.clear();

		rom.set_info( FeRomInfo::Tags, curr_tags );
		m_tags_changed = true;

		itt = m_tags.find( tag );
		if ( itt != m_tags.end() )
			(*itt).second = true;
		else
			itt = m_tags.insert( itt, std::pair<std::string,bool>( tag, true ) );
	}

	return fix_filters( display, FeRomInfo::Tags );
}
Exemplo n.º 2
0
void FeRomList::get_tags_list( FeRomInfo &rom,
		std::vector< std::pair<std::string, bool> > &tags_list ) const
{
	std::string curr_tags = rom.get_info(FeRomInfo::Tags);

	std::set<std::string> my_set;
	size_t pos=0;
	do
	{
		std::string one_tag;
		const char sep[] = { FE_TAGS_SEP, 0 };
		token_helper( curr_tags, pos, one_tag, sep );
		if ( !one_tag.empty() )
		{
			my_set.insert( one_tag );
		}
	} while ( pos < curr_tags.size() );

	for ( std::map<std::string, bool>::const_iterator itr=m_tags.begin(); itr!=m_tags.end(); ++itr )
	{
		tags_list.push_back(
				std::pair<std::string, bool>((*itr).first,
						( my_set.find( (*itr).first ) != my_set.end() ) ) );
	}
}
Exemplo n.º 3
0
bool FeRomList::set_fav( FeRomInfo &r, FeDisplayInfo &display, bool fav )
{
	r.set_info( FeRomInfo::Favourite, fav ? "1" : "" );
	m_fav_changed=true;

	return fix_filters( display, FeRomInfo::Favourite );
}
Exemplo n.º 4
0
bool FeRomListSorter::operator()( const FeRomInfo &one_obj, const FeRomInfo &two_obj ) const
{
	const std::string &one = one_obj.get_info( m_comp );
	const std::string &two = two_obj.get_info( m_comp );

	if (( m_comp == FeRomInfo::Title ) && m_rex )
	{
		size_t one_begin( 0 ), one_len( one.size() ), two_begin( 0 ), two_len( two.size() );

		const SQChar *one_begin_ptr( NULL );
		const SQChar *one_end_ptr( NULL );
		const SQChar *two_begin_ptr( NULL );
		const SQChar *two_end_ptr( NULL );

		//
		// I couldn't get Squirrel's no capture regexp (?:) working the way I would expect it to.
		// I'm probably doing something dumb but I can't figure it out and docs seem nonexistent
		//
		// So we do this kind of backwards, instead of defining what we want to compare based on,
		// the regexp instead defines the part of the string we want to strip out up front
		//
		if ( sqstd_rex_search( m_rex, one.c_str(), &one_begin_ptr, &one_end_ptr ) == SQTrue )
		{
			one_begin = one_end_ptr - one.c_str();
			one_len -= one_begin;
		}

		if ( sqstd_rex_search( m_rex, two.c_str(), &two_begin_ptr, &two_end_ptr ) == SQTrue )
		{
			two_begin = two_end_ptr - two.c_str();
			two_len -= two_begin;
		}

		return ( one.compare( one_begin, one_len, two, two_begin, two_len ) < 0 );
	}
	else if (( m_comp == FeRomInfo::PlayedCount )
				|| ( m_comp == FeRomInfo::PlayedTime ))
	{
		return ( as_int( one ) > as_int( two ) );
	}

	if ( m_reverse )
		return ( one.compare( two ) > 0 );
	else
		return ( one.compare( two ) < 0 );
}
Exemplo n.º 5
0
bool FeRule::apply_rule( const FeRomInfo &rom ) const
{
	if (( m_filter_target == FeRomInfo::LAST_INDEX )
		|| ( m_filter_comp == FeRule::LAST_COMPARISON )
		|| ( m_rex == NULL ))
		return true;

	const SQChar *begin( NULL );
	const SQChar *end( NULL );
	const std::string &target = rom.get_info( m_filter_target );

	switch ( m_filter_comp )
	{
	case FilterEquals:
		if ( target.empty() )
			return ( m_filter_what.empty() );

		return ( sqstd_rex_match(
					m_rex,
					(const SQChar *)target.c_str() ) == SQTrue );

	case FilterNotEquals:
		if ( target.empty() )
			return ( !m_filter_what.empty() );

		return ( sqstd_rex_match(
					m_rex,
					(const SQChar *)target.c_str() ) != SQTrue );

	case FilterContains:
		if ( target.empty() )
			return false;

		return ( sqstd_rex_search(
					m_rex,
					(const SQChar *)target.c_str(),
					&begin,
					&end ) == SQTrue );

	case FilterNotContains:
		if ( target.empty() )
			return true;

		return ( sqstd_rex_search(
					m_rex,
					(const SQChar *)target.c_str(),
					&begin,
					&end ) != SQTrue );

	default:
		return true;
	}
}
Exemplo n.º 6
0
void FeMessXMLParser::set_info_values( FeRomInfo &r )
{
	r.set_info( FeRomInfo::Title, m_description );
	r.set_info( FeRomInfo::Year, m_year );
	r.set_info( FeRomInfo::Manufacturer, m_man );
	r.set_info( FeRomInfo::Cloneof, m_cloneof );
	r.set_info( FeRomInfo::AltRomname, m_altname );
	r.set_info( FeRomInfo::AltTitle, m_alttitle );
}
Exemplo n.º 7
0
bool FeRomListCompare::cmp( const FeRomInfo &one_info, const FeRomInfo &two_info )
{
	const std::string &one = one_info.get_info( FeRomInfo::Title );
	const std::string &two = two_info.get_info( FeRomInfo::Title );

	size_t one_begin( 0 ), one_len( one.size() ), two_begin( 0 ), two_len( two.size() );

	if ( m_rex )
	{
		const SQChar *one_begin_ptr;
		const SQChar *one_end_ptr;
		const SQChar *two_begin_ptr;
		const SQChar *two_end_ptr;

		//
		// I couldn't get Squirrel's no capture regexp (?:) working the way I would expect it to.
		// I'm probably doing something dumb but I can't figure it out and docs seem nonexistent
		//
		// So we do this kind of backwards, instead of defining what we want to compare based on,
		// the regexp instead defines the part of the string we want to strip out up front
		//
		if ( sqstd_rex_search( m_rex, one.c_str(), &one_begin_ptr, &one_end_ptr ) == SQTrue )
		{
			one_begin = one_end_ptr - one.c_str();
			one_len -= one_begin;
		}

		if ( sqstd_rex_search( m_rex, two.c_str(), &two_begin_ptr, &two_end_ptr ) == SQTrue )
		{
			two_begin = two_end_ptr - two.c_str();
			two_len -= two_begin;
		}
	}

	return ( one.compare( one_begin, one_len, two, two_begin, two_len ) < 0 );
}
Exemplo n.º 8
0
const char FeRomListCompare::get_first_letter( const FeRomInfo &one_info )
{
	const std::string &name = one_info.get_info( FeRomInfo::Title );
	if ( name.empty() )
		return '0';

	size_t b( 0 );

	if ( m_rex )
	{
		const SQChar *bp;
		const SQChar *ep;
		if ( sqstd_rex_search( m_rex, name.c_str(), &bp, &ep ) == SQTrue )
			b = ep - name.c_str();
	}

	return name.at( b );
}
Exemplo n.º 9
0
void FeTextureContainer::internal_update_selection( FeSettings *feSettings )
{
	int filter_index = feSettings->get_filter_index_from_offset( m_filter_offset );
	int rom_index = feSettings->get_rom_index( filter_index, m_index_offset );

	//
	// Optimization opportunity: We could already be showing the artwork for rom_index if the
	// layout uses the image swap() function... if we are, then there is no need to do anything...
	//
	if (( m_current_rom_index == rom_index )
				&& ( m_current_filter_index == filter_index ))
	{
#ifdef FE_DEBUG
		std::cout << "Optimization: " << m_file_name << " not loaded." << std::endl;
#endif
		return;
	}

	m_current_rom_index = rom_index;
	m_current_filter_index = filter_index;

	std::vector<std::string> vid_list;
	std::vector<std::string> image_list;
	std::string archive_name; // empty if no archive

	if ( m_type == IsArtwork )
	{
		FeRomInfo *rom	= feSettings->get_rom_absolute( filter_index, rom_index );
		if ( !rom )
			return;

		if ( !feSettings->get_best_artwork_file( *rom,
			m_art_name,
			vid_list,
			image_list,
			(m_video_flags & VF_DisableVideo) ) )
		{
			// check for layout fallback images/videos
			std::string layout_path;
			feSettings->get_path( FeSettings::Current,
				layout_path );

			if ( !layout_path.empty() )
			{
				const std::string &emu_name = rom->get_info(
					FeRomInfo::Emulator );

				if ( is_supported_archive( layout_path ) )
				{
					archive_name = layout_path;

					// check for "[emulator-[artlabel]" artworks first
					if ( !gather_artwork_filenames_from_archive(
							layout_path, emu_name + "-" + m_art_name,
							vid_list, image_list ) )
					{
						// then "[artlabel]"
						gather_artwork_filenames_from_archive( layout_path,
							m_art_name, vid_list, image_list );
					}
				}
				else
				{
					std::vector<std::string> layout_paths;
					layout_paths.push_back( layout_path );

					// check for "[emulator-[artlabel]" artworks first
					if ( !gather_artwork_filenames( layout_paths,
							emu_name + "-" + m_art_name,
							vid_list, image_list ) )
					{
						// then "[artlabel]"
						gather_artwork_filenames( layout_paths,
							m_art_name, vid_list, image_list );
					}
				}
			}
		}
	}
	else if ( m_type == IsDynamic )
	{
		std::string work = m_art_name;
		FePresent::script_process_magic_strings( work,
				m_filter_offset,
				m_index_offset );

		feSettings->get_best_dynamic_image_file( filter_index,
			rom_index,
			work,
			vid_list,
			image_list );
	}

	// Load any found videos/images now
	//
	bool loaded=false;
	std::vector<std::string>::iterator itr;

#ifndef NO_MOVIE
	if ( m_video_flags & VF_DisableVideo )
		vid_list.clear();

	for ( itr=vid_list.begin(); itr != vid_list.end(); ++itr )
	{
		std::string path = archive_name;
		std::string filename = *itr;

		if ( path.empty() )
		{
			// test for artwork in an archive
			// format of filename is "<archivename>|<filename>"
			size_t pos = (*itr).find( "|" );
			if ( pos != std::string::npos )
			{
				path = (*itr).substr( 0, pos );
				filename = (*itr).substr( pos+1 );
			}
		}

		if ( try_to_load( path, filename ) )
		{
			loaded = true;
			break;
		}
	}
#endif

	if ( !loaded )
	{
		if ( image_list.empty() )
			clear();
		else
		{
			for ( itr=image_list.begin();
				itr != image_list.end(); ++itr )
			{
				std::string path = archive_name;
				std::string filename = *itr;

				if ( path.empty() )
				{
					// test for artwork in an archive
					// format of filename is "<archivename>|<filename>"
					size_t pos = (*itr).find( "|" );
					if ( pos != std::string::npos )
					{
						path = (*itr).substr( 0, pos );
						filename = (*itr).substr( pos+1 );
					}
				}

				if ( try_to_load( path, filename, true ) )
				{
					loaded = true;
					break;
				}
			}
		}
	}

	//
	// Texture was replaced, so notify the attached images
	//
	notify_texture_change();
}