示例#1
0
文件: datfile.cpp 项目: bmunger/mame
//-------------------------------------------------
//  load_data_info
//-------------------------------------------------
void datfile_manager::load_data_info(const game_driver *drv, std::string &buffer, int type)
{
	dataindex const *index_idx = nullptr;
	drvindex const *driver_idx = nullptr;
	std::string const *tag;
	std::string filename;

	switch (type)
	{
	case UI_HISTORY_LOAD:
		filename = "history.dat";
		tag = &TAG_BIO;
		index_idx = &m_histidx;
		break;
	case UI_MAMEINFO_LOAD:
		filename = "mameinfo.dat";
		tag = &TAG_MAME;
		index_idx = &m_mameidx;
		driver_idx = &m_drvidx;
		break;
	case UI_SYSINFO_LOAD:
		filename = "sysinfo.dat";
		tag = &TAG_BIO;
		index_idx = &m_sysidx;
		break;
	case UI_MESSINFO_LOAD:
		filename = "messinfo.dat";
		tag = &TAG_MAME;
		index_idx = &m_messidx;
		driver_idx = &m_messdrvidx;
		break;
	case UI_STORY_LOAD:
		filename = "story.dat";
		tag = &TAG_STORY;
		index_idx = &m_storyidx;
		break;
	case UI_GINIT_LOAD:
		filename = "gameinit.dat";
		tag = &TAG_MAME;
		index_idx = &m_ginitidx;
		break;
	default:
		assert(false);
		return;
	}

	fileptr const datfile = parseopen(filename.c_str());
	if (datfile)
	{
		load_data_text(datfile.get(), drv, buffer, *index_idx, *tag);

		// load driver info
		if (driver_idx && !driver_idx->empty())
			load_driver_text(datfile.get(), drv, buffer, *driver_idx, TAG_DRIVER);

		// cleanup mameinfo and sysinfo double line spacing
		if (((*tag == TAG_MAME) && (type != UI_GINIT_LOAD)) || (type == UI_SYSINFO_LOAD))
			strreplace(buffer, "\n\n", "\n");
	}
}
示例#2
0
文件: inifile.cpp 项目: NULUSIOS/mame
void inifile_manager::directory_scan()
{
	// open extra INIs folder
	file_enumerator path(mame_machine_manager::instance()->ui().options().extraini_path());
	const osd_directory_entry *dir;

	// loop into folder's file
	while ((dir = path.next()) != nullptr)
	{
		int length = strlen(dir->name);
		std::string filename(dir->name);

		// check .ini file ending
		if ((length > 4) && dir->name[length - 4] == '.' && tolower((UINT8)dir->name[length - 3]) == 'i' &&
			tolower((UINT8)dir->name[length - 2]) == 'n' && tolower((UINT8)dir->name[length - 1]) == 'i')
		{
			// try to open file and indexing
			if (parseopen(filename.c_str()))
			{
				init_category(filename);
				parseclose();
			}
		}
	}

	// sort
	std::stable_sort(ini_index.begin(), ini_index.end());
}
示例#3
0
void inifile_manager::directory_scan()
{
	// open extra INIs folder
	file_enumerator path(machine().ui().options().extraini_path());
	const osd_directory_entry *dir;

	// loop into folder's file
	while ((dir = path.next()) != nullptr)
	{
		int length = strlen(dir->name);
		std::string filename(dir->name);

		// skip ui_favorite file
		if (!core_stricmp("ui_favorite.ini", filename.c_str()))
			continue;

		// check .ini file ending
		if ((length > 4) && dir->name[length - 4] == '.' && tolower((UINT8)dir->name[length - 3]) == 'i' &&
			tolower((UINT8)dir->name[length - 2]) == 'n' && tolower((UINT8)dir->name[length - 1]) == 'i')
		{
			// try to open file and indexing
			if (parseopen(filename.c_str()))
			{
				init_category(filename);
				parseclose();
			}
		}
	}
}
示例#4
0
文件: datfile.cpp 项目: bmunger/mame
//-------------------------------------------------
//  load command text into the buffer
//-------------------------------------------------
void datfile_manager::load_command_info(std::string &buffer, std::string const &sel)
{
	fileptr const datfile = parseopen("command.dat");
	if (datfile)
	{
		// open and seek to correct point in datafile
		auto const offset = m_menuidx.at(sel);
		std::fseek(datfile.get(), offset, SEEK_SET);
		char rbuf[64 * 1024];
		std::string readbuf;
		while (std::fgets(rbuf, 64 * 1024, datfile.get()) != nullptr)
		{
			readbuf = chartrimcarriage(rbuf);

			// skip separator lines
			if (readbuf == TAG_COMMAND_SEPARATOR)
				continue;

			// end entry when a tag is encountered
			if (readbuf == TAG_END)
				break;

			// add this string to the buffer
			buffer.append(readbuf).append("\n");;
		}
	}
}
示例#5
0
文件: datfile.cpp 项目: bmunger/mame
//-------------------------------------------------
//  load software info
//-------------------------------------------------
void datfile_manager::load_software_info(std::string const &softlist, std::string &buffer, std::string const &softname, std::string const &parentname)
{
	if (m_swindex.empty())
		return;

	// Load history text
	fileptr const datfile = parseopen("history.dat");
	if (datfile)
	{
		// Find software in software list index
		long const *const s_offset = find_software(softlist, softname, parentname);
		if (!s_offset)
			return;

		char rbuf[64 * 1024];
		std::fseek(datfile.get(), *s_offset, SEEK_SET);
		std::string readbuf;
		while (std::fgets(rbuf, 64 * 1024, datfile.get()) != nullptr)
		{
			readbuf = chartrimcarriage(rbuf);

			// end entry when a end tag is encountered
			if (readbuf == TAG_END)
				break;

			// add this string to the buffer
			buffer.append(readbuf).append("\n");
		}
	}
}
示例#6
0
//-------------------------------------------------
//  load software info
//-------------------------------------------------
void datfile_manager::load_software_info(std::string &softlist, std::string &buffer, std::string &softname, std::string &parentname)
{
	// Load history text
	if (!m_swindex.empty() && parseopen("history.dat"))
	{
		// Find software in software list index
		if (m_swindex.find(softlist) == m_swindex.end())
			return;

		drvindex::iterator itemsiter;
		itemsiter = m_swindex[softlist].find(softname);
		if (itemsiter == m_swindex[softlist].end() && !parentname.empty())
			itemsiter = m_swindex[softlist].find(parentname);

		if (itemsiter == m_swindex[softlist].end())
			return;

		long s_offset = (*itemsiter).second;
		char rbuf[64 * 1024];
		fseek(fp, s_offset, SEEK_SET);
		std::string readbuf;
		while (fgets(rbuf, 64 * 1024, fp) != nullptr)
		{
			readbuf = chartrimcarriage(rbuf);

			// end entry when a end tag is encountered
			if (readbuf == TAG_END)
				break;

			// add this string to the buffer
			buffer.append(readbuf).append("\n");
		}
		parseclose();
	}
}
示例#7
0
//-------------------------------------------------
//  load submenu item for command.dat
//-------------------------------------------------
void datfile_manager::command_sub_menu(const game_driver *drv, std::vector<std::string> &menuitems)
{
	if (parseopen("command.dat"))
	{
		m_menuidx.clear();
		index_menuidx(drv, m_cmdidx, m_menuidx);
		for (auto & elem : m_menuidx)
			menuitems.push_back(elem.first);
		parseclose();
	}
}
示例#8
0
文件: datfile.cpp 项目: bmunger/mame
//-------------------------------------------------
//  load submenu item for command.dat
//-------------------------------------------------
void datfile_manager::command_sub_menu(const game_driver *drv, std::vector<std::string> &menuitems)
{
	fileptr datfile = parseopen("command.dat");
	if (datfile)
	{
		m_menuidx.clear();
		index_menuidx(std::move(datfile), drv, m_cmdidx, m_menuidx);
		menuitems.reserve(m_menuidx.size());
		for (auto const &elem : m_menuidx)
			menuitems.push_back(elem.first);
	}
}
示例#9
0
//-------------------------------------------------
//  load_data_info
//-------------------------------------------------
void datfile_manager::load_data_info(const game_driver *drv, std::string &buffer, int type)
{
	dataindex index_idx;
	drvindex driver_idx;
	std::string tag;
	std::string filename;

	switch (type)
	{
		case UI_HISTORY_LOAD:
			filename = "history.dat";
			tag = TAG_BIO;
			index_idx = m_histidx;
			break;
		case UI_MAMEINFO_LOAD:
			filename = "mameinfo.dat";
			tag = TAG_MAME;
			index_idx = m_mameidx;
			driver_idx = m_drvidx;
			break;
		case UI_SYSINFO_LOAD:
			filename = "sysinfo.dat";
			tag = TAG_BIO;
			index_idx = m_sysidx;
			break;
		case UI_MESSINFO_LOAD:
			filename = "messinfo.dat";
			tag = TAG_MAME;
			index_idx = m_messidx;
			driver_idx = m_messdrvidx;
			break;
		case UI_STORY_LOAD:
			filename = "story.dat";
			tag = TAG_STORY;
			index_idx = m_storyidx;
			break;
	}

	if (parseopen(filename.c_str()))
	{
		load_data_text(drv, buffer, index_idx, tag);

		// load driver info
		if (!driver_idx.empty())
			load_driver_text(drv, buffer, driver_idx, TAG_DRIVER);

		// cleanup mameinfo and sysinfo double line spacing
		if (tag == TAG_MAME || type == UI_SYSINFO_LOAD)
			strreplace(buffer, "\n\n", "\n");

		parseclose();
	}
}
示例#10
0
文件: inifile.cpp 项目: NULUSIOS/mame
void inifile_manager::load_ini_category(std::vector<int> &temp_filter)
{
	if (ini_index.empty())
		return;

	bool search_clones = false;
	std::string filename(ini_index[c_file].first);
	long offset = ini_index[c_file].second[c_cat].second;

	if (!core_stricmp(filename.c_str(), "category.ini") || !core_stricmp(filename.c_str(), "alltime.ini"))
		search_clones = true;

	if (parseopen(filename.c_str()))
	{
		fseek(fp, offset, SEEK_SET);
		int num_game = driver_list::total();
		char rbuf[MAX_CHAR_INFO];
		std::string readbuf;
		while (fgets(rbuf, MAX_CHAR_INFO, fp) != nullptr)
		{
			readbuf = chartrimcarriage(rbuf);

			if (readbuf.empty() || readbuf[0] == '[')
				break;

			int dfind = driver_list::find(readbuf.c_str());
			if (dfind != -1 && search_clones)
			{
				temp_filter.push_back(dfind);
				int clone_of = driver_list::non_bios_clone(dfind);
				if (clone_of == -1)
				{
					for (int x = 0; x < num_game; x++)
						if (readbuf == driver_list::driver(x).parent && readbuf != driver_list::driver(x).name)
							temp_filter.push_back(x);
				}
			}
			else if (dfind != -1)
				temp_filter.push_back(dfind);
		}
		parseclose();
	}
}
示例#11
0
//-------------------------------------------------
// ctor
//-------------------------------------------------
datfile_manager::datfile_manager(running_machine &machine) : m_machine(machine)
{
	if (machine.options().enabled_dats() && first_run)
	{
		first_run = false;
		if (parseopen("mameinfo.dat"))
		{
			init_mameinfo();
			parseclose();
		}

		if (parseopen("command.dat"))
		{
			init_command();
			parseclose();
		}

		if (parseopen("story.dat"))
		{
			init_storyinfo();
			parseclose();
		}

		if (parseopen("messinfo.dat"))
		{
			init_messinfo();
			parseclose();
		}

		if (parseopen("sysinfo.dat"))
		{
			init_sysinfo();
			parseclose();
		}

		if (parseopen("history.dat"))
		{
			init_history();
			parseclose();
		}
	}
}