void favorite_manager::add_favorite_game() { if ((machine().system().flags & MACHINE_TYPE_ARCADE) != 0) { add_favorite_game(&machine().system()); return; } bool software_avail = false; image_interface_iterator iter(machine().root_device()); for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { if (image->exists() && image->software_entry()) { const software_info *swinfo = image->software_entry(); const software_part *part = image->part_entry(); ui_software_info tmpmatches; tmpmatches.shortname = strensure(swinfo->shortname()); tmpmatches.longname = strensure(image->longname()); tmpmatches.parentname = strensure(swinfo->parentname()); tmpmatches.year = strensure(image->year()); tmpmatches.publisher = strensure(image->manufacturer()); tmpmatches.supported = image->supported(); tmpmatches.part = strensure(part->name()); tmpmatches.driver = &machine().system(); tmpmatches.listname = strensure(image->software_list_name()); tmpmatches.interface = strensure(part->interface()); tmpmatches.instance = strensure(image->instance_name()); tmpmatches.startempty = 0; tmpmatches.parentlongname.clear(); if (swinfo->parentname()) { software_list_device *swlist = software_list_device::find_by_name(machine().config(), image->software_list_name()); for (software_info *c_swinfo = swlist->first_software_info(); c_swinfo != nullptr; c_swinfo = c_swinfo->next()) { std::string c_parent(c_swinfo->parentname()); if (!c_parent.empty() && c_parent == swinfo->shortname()) { tmpmatches.parentlongname = c_swinfo->longname(); break; } } } tmpmatches.usage.clear(); for (feature_list_item *flist = swinfo->other_info(); flist != nullptr; flist = flist->next()) if (!strcmp(flist->name(), "usage")) tmpmatches.usage = flist->value(); tmpmatches.devicetype = strensure(image->image_type_name()); tmpmatches.available = true; software_avail = true; m_list.push_back(tmpmatches); save_favorite_games(); } } if (!software_avail) add_favorite_game(&machine().system()); }
menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container &container, const game_driver *driver) : menu(mui, container) , m_actual(0) , m_driver((driver == nullptr) ? &mui.machine().system() : driver) , m_issoft(false) { for (device_image_interface &image : image_interface_iterator(mui.machine().root_device())) { if (image.filename()) { m_list = strensure(image.software_list_name()); m_short = image.software_entry()->shortname(); m_long = image.software_entry()->longname(); m_parent = image.software_entry()->parentname(); } } const char *lua_list = mame_machine_manager::instance()->lua()->call_plugin(driver ? driver->name : "", "data_list"); if(lua_list) { std::string list(lua_list); char *token = strtok((char *)list.c_str(), ","); int count = 0; while(token) { m_items_list.emplace_back(_(token), count, mame_machine_manager::instance()->lua()->call_plugin(util::string_format("%d", count).c_str(), "data_version")); count++; token = strtok(nullptr, ","); } } }
menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container &container, const game_driver *driver) : menu(mui, container) , m_actual(0) , m_driver((driver == nullptr) ? &mui.machine().system() : driver) , m_swinfo(nullptr) , m_issoft(false) { for (device_image_interface& image : image_interface_iterator(mui.machine().root_device())) { if (image.filename()) { m_list = strensure(image.software_list_name()); m_short = image.software_entry()->shortname(); m_long = image.software_entry()->longname(); m_parent = image.software_entry()->parentname(); } } std::vector<std::string> lua_list; if (mame_machine_manager::instance()->lua()->call_plugin("data_list", driver ? driver->name : "", lua_list)) { int count = 0; for (std::string& item : lua_list) { std::string version; mame_machine_manager::instance()->lua()->call_plugin("data_version", count, version); m_items_list.emplace_back(item.c_str(), count, std::move(version)); count++; } } }
ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, const game_driver *driver) : ui_menu(machine, container) { image_interface_iterator iter(machine.root_device()); for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next()) { if (image->filename()) { m_list = strensure(image->software_list_name()); m_short = strensure(image->software_entry()->shortname()); m_long = strensure(image->software_entry()->longname()); m_parent = strensure(image->software_entry()->parentname()); } } m_driver = (driver == nullptr) ? &machine.system() : driver; init_items(); }
void favorite_manager::add_favorite(running_machine &machine) { apply_running_machine( machine, [this, &machine] (game_driver const &driver, device_image_interface *imagedev, software_info const *software, bool &done) { if (imagedev) { // creating this is fairly expensive, but we'll assume this usually succeeds ui_software_info info; software_part const *const part(imagedev->part_entry()); assert(software); assert(part); // start with simple stuff that can just be copied info.shortname = software->shortname(); info.longname = imagedev->longname(); info.parentname = software->parentname(); info.year = imagedev->year(); info.publisher = imagedev->manufacturer(); info.supported = imagedev->supported(); info.part = part->name(); info.driver = &driver; info.listname = imagedev->software_list_name(); info.interface = part->interface(); info.instance = imagedev->instance_name(); info.startempty = 0; info.devicetype = strensure(imagedev->image_type_name()); info.available = true; // look up the parent in the list if necessary (eugh, O(n) walk) if (!info.parentname.empty()) { auto const listdev = software_list_device::find_by_name(machine.config(), info.listname); assert(listdev); for (software_info const &other : listdev->get_info()) { if (other.shortname() == info.parentname) { info.parentlongname = other.longname(); break; } } } // fill in with the first usage entry we find for (feature_list_item const &feature : software->other_info()) { if (feature.name() == "usage") { info.usage = feature.value(); break; } } // hooray for move semantics! add_impl(std::move(info)); } else { add_impl(driver); } }); }