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