Пример #1
0
void ui_menu_add_change_folder::populate()
{
	// open a path
	const char *volume_name;
	file_enumerator path(m_current_path.c_str());
	const osd_directory_entry *dirent;
	int folders_count = 0;

	// add the drives
	for (int i = 0; (volume_name = osd_get_volume_name(i)) != nullptr; i++)
		item_append(volume_name, "[DRIVE]", 0, (void *)(FPTR)++folders_count);

	// add the directories
	while ((dirent = path.next()) != nullptr)
	{
		if (dirent->type == ENTTYPE_DIR && strcmp(dirent->name, ".") != 0)
			item_append(dirent->name, "[DIR]", 0, (void *)(FPTR)++folders_count);
	}

	item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);

	// configure the custom rendering
	customtop = 2.0f * machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
	custombottom = 1.0f * machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
Пример #2
0
void menu_add_change_folder::populate(float &customtop, float &custombottom)
{
	// open a path
	const char *volume_name = nullptr;
	file_enumerator path(m_current_path.c_str());
	const osd::directory::entry *dirent;
	int folders_count = 0;

	// add the drives
	for (int i = 0; (volume_name = osd_get_volume_name(i)) != nullptr; ++i)
		item_append(volume_name, "[DRIVE]", 0, (void *)(uintptr_t)++folders_count);

	// add the directories
	while ((dirent = path.next()) != nullptr)
	{
		if (dirent->type == osd::directory::entry::entry_type::DIR && strcmp(dirent->name, ".") != 0)
			item_append(dirent->name, "[DIR]", 0, (void *)(uintptr_t)++folders_count);
	}

	item_append(menu_item_type::SEPARATOR);

	// configure the custom rendering
	customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
	custombottom = 1.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
Пример #3
0
void ui_menu_file_selector::populate()
{
	zippath_directory *directory = NULL;
	file_error err;
	const osd_directory_entry *dirent;
	const file_selector_entry *entry;
	const file_selector_entry *selected_entry = NULL;
	int i;
	const char *volume_name;
	const char *path = m_current_directory.c_str();

	// open the directory
	err = zippath_opendir(path, &directory);

	// clear out the menu entries
	m_entrylist = NULL;

	if (m_has_empty)
	{
		// add the "[empty slot]" entry
		append_entry(SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL);
	}

	if (m_has_create)
	{
		// add the "[create]" entry
		append_entry(SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL);
	}

	if (m_has_softlist)
	{
		// add the "[software list]" entry
		entry = append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL);
		selected_entry = entry;
	}

	// add the drives
	i = 0;
	while((volume_name = osd_get_volume_name(i))!=NULL)
	{
		append_entry(SELECTOR_ENTRY_TYPE_DRIVE,
			volume_name, volume_name);
		i++;
	}

	// build the menu for each item
	if (err == FILERR_NONE)
	{
		while((dirent = zippath_readdir(directory)) != NULL)
		{
			// append a dirent entry
			entry = append_dirent_entry(dirent);

			if (entry != NULL)
			{
				// set the selected item to be the first non-parent directory or file
				if ((selected_entry == NULL) && strcmp(dirent->name, ".."))
					selected_entry = entry;

				// do we have to select this file?
				if (!core_stricmp(m_current_file.c_str(), dirent->name))
					selected_entry = entry;
			}
		}
	}

	// append all of the menu entries
	for (entry = m_entrylist; entry != NULL; entry = entry->next)
		append_entry_menu_item(entry);

	// set the selection (if we have one)
	if (selected_entry != NULL)
		set_selection((void *) selected_entry);

	// set up custom render proc
	customtop = machine().ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;

	if (directory != NULL)
		zippath_closedir(directory);
}
Пример #4
0
void menu_file_selector::populate()
{
	util::zippath_directory *directory = nullptr;
	osd_file::error err;
	const osd::directory::entry *dirent;
	const file_selector_entry *entry;
	const file_selector_entry *selected_entry = nullptr;
	int i;
	const char *volume_name;

	// open the directory
	err = util::zippath_opendir(m_current_directory, &directory);

	// clear out the menu entries
	m_entrylist.clear();

	if (m_has_empty)
	{
		// add the "[empty slot]" entry
		append_entry(SELECTOR_ENTRY_TYPE_EMPTY, "", "");
	}

	if (m_has_create && !util::zippath_is_zip(directory))
	{
		// add the "[create]" entry
		append_entry(SELECTOR_ENTRY_TYPE_CREATE, "", "");
	}

	if (m_has_softlist)
	{
		// add the "[software list]" entry
		entry = &append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, "", "");
		selected_entry = entry;
	}

	// add the drives
	i = 0;
	while((volume_name = osd_get_volume_name(i))!=nullptr)
	{
		append_entry(SELECTOR_ENTRY_TYPE_DRIVE,
			volume_name, volume_name);
		i++;
	}

	// build the menu for each item
	if (err == osd_file::error::NONE)
	{
		while((dirent = util::zippath_readdir(directory)) != nullptr)
		{
			// append a dirent entry
			entry = append_dirent_entry(dirent);

			if (entry != nullptr)
			{
				// set the selected item to be the first non-parent directory or file
				if ((selected_entry == nullptr) && strcmp(dirent->name, ".."))
					selected_entry = entry;

				// do we have to select this file?
				if (!core_stricmp(m_current_file.c_str(), dirent->name))
					selected_entry = entry;
			}
		}
	}

	// append all of the menu entries
	for (auto &entry : m_entrylist)
		append_entry_menu_item(&entry);

	// set the selection (if we have one)
	if (selected_entry != nullptr)
		set_selection((void *) selected_entry);

	// set up custom render proc
	customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;

	if (directory != nullptr)
		util::zippath_closedir(directory);
}
Пример #5
0
void menu_file_selector::populate(float &customtop, float &custombottom)
{
	const file_selector_entry *selected_entry = nullptr;


	// clear out the menu entries
	m_entrylist.clear();

	// open the directory
	util::zippath_directory::ptr directory;
	osd_file::error const err = util::zippath_directory::open(m_current_directory, directory);

	// add the "[empty slot]" entry if available
	if (m_has_empty)
		append_entry(SELECTOR_ENTRY_TYPE_EMPTY, "", "");

	// add the "[create]" entry
	if (m_has_create && !directory->is_archive())
		append_entry(SELECTOR_ENTRY_TYPE_CREATE, "", "");

	// add and select the "[software list]" entry if available
	if (m_has_softlist)
		selected_entry = &append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, "", "");

	// add the drives
	int i = 0;
	for (char const *volume_name = osd_get_volume_name(i); volume_name; volume_name = osd_get_volume_name(++i))
		append_entry(SELECTOR_ENTRY_TYPE_DRIVE, volume_name, volume_name);

	// mark first filename entry
	std::size_t const first = m_entrylist.size() + 1;

	// build the menu for each item
	if (osd_file::error::NONE != err)
	{
		osd_printf_verbose("menu_file_selector::populate: error opening directory '%s' (%d)\n", m_current_directory.c_str(), int(err));
	}
	else
	{
		for (osd::directory::entry const *dirent = directory->readdir(); dirent; dirent = directory->readdir())
		{
			// append a dirent entry
			file_selector_entry const *entry = append_dirent_entry(dirent);
			if (entry)
			{
				// set the selected item to be the first non-parent directory or file
				if (!selected_entry && strcmp(dirent->name, ".."))
					selected_entry = entry;

				// do we have to select this file?
				if (!core_stricmp(m_current_file.c_str(), dirent->name))
					selected_entry = entry;
			}
		}
	}
	directory.reset();

	// sort the menu entries
	const std::collate<wchar_t> &coll = std::use_facet<std::collate<wchar_t>>(std::locale());
	std::sort(
			m_entrylist.begin() + first,
			m_entrylist.end(),
			[&coll] (file_selector_entry const &x, file_selector_entry const &y)
			{
				std::wstring const xstr = wstring_from_utf8(x.basename);
				std::wstring const ystr = wstring_from_utf8(y.basename);
				return coll.compare(xstr.data(), xstr.data()+xstr.size(), ystr.data(), ystr.data()+ystr.size()) < 0;
			});

	// append all of the menu entries
	for (file_selector_entry const &entry : m_entrylist)
		append_entry_menu_item(&entry);

	// set the selection (if we have one)
	if (selected_entry)
		set_selection((void *)selected_entry);

	// set up custom render proc
	customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
}
Пример #6
0
void ui_menu_file_selector::populate()
{
    zippath_directory *directory = NULL;
    file_error err = FILERR_NONE;
    const osd_directory_entry *dirent;
    const file_selector_entry *entry;
    const file_selector_entry *selected_entry = NULL;
    int i;
    const char *volume_name;
    const char *path = current_directory;

    /* open the directory */
    err = zippath_opendir(path, &directory);
    if (err != FILERR_NONE)
        goto done;

    /* clear out the menu entries */
    entrylist = NULL;

    if (has_empty)
    {
        /* add the "[empty slot]" entry */
        append_entry(SELECTOR_ENTRY_TYPE_EMPTY, NULL, NULL);
    }

    if (has_create)
    {
        /* add the "[create]" entry */
        append_entry(SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL);
    }

    if (has_softlist)
        /* add the "[software list]" entry */
        append_entry(SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL);

    /* add the drives */
    i = 0;
    while((volume_name = osd_get_volume_name(i))!=NULL)
    {
        append_entry(SELECTOR_ENTRY_TYPE_DRIVE,
                     volume_name, volume_name);
        i++;
    }

    /* build the menu for each item */
    while((dirent = zippath_readdir(directory)) != NULL)
    {
        /* append a dirent entry */
        entry = append_dirent_entry(dirent);

        if (entry != NULL)
        {
            /* set the selected item to be the first non-parent directory or file */
            if ((selected_entry == NULL) && strcmp(dirent->name, ".."))
                selected_entry = entry;

            /* do we have to select this file? */
            if (!mame_stricmp(current_file, dirent->name))
                selected_entry = entry;
        }
    }

    /* append all of the menu entries */
    for (entry = entrylist; entry != NULL; entry = entry->next)
        append_entry_menu_item(entry);

    /* set the selection (if we have one) */
    if (selected_entry != NULL)
        set_selection((void *) selected_entry);

    /* set up custom render proc */
    customtop = ui_get_line_height(machine()) + 3.0f * UI_BOX_TB_BORDER;

done:
    if (directory != NULL)
        zippath_closedir(directory);
}