trunk/src/emu/ui/filemngr.c
| r242928 | r242929 | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | void ui_menu_file_manager::fill_image_line(device_image_interface *img, astring &instance, astring &filename) |
| 63 | { |
| 64 | // get the image type/id |
| 65 | instance.printf("%s (%s)", img->instance_name(), img->brief_instance_name()); |
| 66 | |
| 67 | // get the base name |
| 68 | if (img->basename() != NULL) |
| 69 | { |
| 70 | filename.cpy(img->basename()); |
| 71 | |
| 72 | // if the image has been loaded through softlist, also show the loaded part |
| 73 | if (img->part_entry() != NULL) |
| 74 | { |
| 75 | const software_part *tmp = img->part_entry(); |
| 76 | if (tmp->name() != NULL) |
| 77 | { |
| 78 | filename.cat(" ("); |
| 79 | filename.cat(tmp->name()); |
| 80 | // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it |
| 81 | if (img->get_feature("part_id") != NULL) |
| 82 | { |
| 83 | filename.cat(": "); |
| 84 | filename.cat(img->get_feature("part_id")); |
| 85 | } |
| 86 | filename.cat(")"); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | else |
| 91 | filename.cpy("---"); |
| 92 | } |
| 93 | |
| 62 | 94 | //------------------------------------------------- |
| 63 | 95 | // populate |
| 64 | 96 | //------------------------------------------------- |
| 65 | 97 | |
| 66 | 98 | void ui_menu_file_manager::populate() |
| 67 | 99 | { |
| 68 | | astring buffer; |
| 69 | | bool first = true; |
| 100 | astring buffer, tmp_inst, tmp_name; |
| 101 | bool first_entry = true; |
| 102 | astring prev_owner; |
| 70 | 103 | |
| 71 | 104 | // cycle through all devices for this system |
| 72 | | image_interface_iterator iter(machine().root_device()); |
| 73 | | for (device_image_interface *image = iter.first(); image != NULL; image = iter.next()) |
| 105 | device_iterator iter(machine().root_device()); |
| 106 | tagmap_t<UINT8> devtags; |
| 107 | for (device_t *dev = iter.first(); dev != NULL; dev = iter.next()) |
| 74 | 108 | { |
| 75 | | if (first) |
| 76 | | first = false; |
| 77 | | else |
| 78 | | item_append("", NULL, MENU_FLAG_DISABLE, NULL); |
| 109 | bool tag_appended = false; |
| 110 | if (devtags.add(dev->tag(), 1, FALSE) == TMERR_DUPLICATE) |
| 111 | continue; |
| 79 | 112 | |
| 80 | | // get the image type/id |
| 81 | | buffer.printf("%s (%s)", image->instance_name(), image->brief_instance_name()); |
| 82 | | item_append(buffer, "", MENU_FLAG_DISABLE, NULL); |
| 83 | | item_append("Device", image->device().tag(), MENU_FLAG_DISABLE, NULL); |
| 84 | | |
| 85 | | // get the base name |
| 86 | | if (image->basename() != NULL) |
| 87 | | { |
| 88 | | buffer.cpy(image->basename()); |
| 89 | | |
| 90 | | // if the image has been loaded through softlist, also show the loaded part |
| 91 | | if (image->part_entry() != NULL) |
| 113 | // check whether it owns an image interface |
| 114 | image_interface_iterator subiter(*dev); |
| 115 | if (subiter.count() > 0) |
| 116 | { |
| 117 | // if so, cycle through all its image interfaces |
| 118 | image_interface_iterator subiter(*dev); |
| 119 | for (device_image_interface *scan = subiter.first(); scan != NULL; scan = subiter.next()) |
| 92 | 120 | { |
| 93 | | const software_part *tmp = image->part_entry(); |
| 94 | | if (tmp->name() != NULL) |
| 95 | | { |
| 96 | | buffer.cat(" ("); |
| 97 | | buffer.cat(tmp->name()); |
| 98 | | // also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it |
| 99 | | if (image->get_feature("part_id") != NULL) |
| 121 | // if it is a children device, and not something further down the device tree, we want it in the menu! |
| 122 | if (strcmp(scan->device().owner()->tag(), dev->tag()) == 0) |
| 123 | if (devtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE) |
| 100 | 124 | { |
| 101 | | buffer.cat(": "); |
| 102 | | buffer.cat(image->get_feature("part_id")); |
| 125 | // check whether we already had some devices with the same owner: if not, output the owner tag! |
| 126 | if (!tag_appended) |
| 127 | { |
| 128 | if (first_entry) |
| 129 | first_entry = false; |
| 130 | else |
| 131 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 132 | buffer.printf("[root%s]", dev->tag()); |
| 133 | item_append(buffer, NULL, 0, NULL); |
| 134 | tag_appended = true; |
| 135 | } |
| 136 | // finally, append the image interface to the menu |
| 137 | fill_image_line(scan, tmp_inst, tmp_name); |
| 138 | item_append(tmp_inst, tmp_name, 0, (void *) scan); |
| 103 | 139 | } |
| 104 | | buffer.cat(")"); |
| 105 | | } |
| 106 | 140 | } |
| 107 | 141 | } |
| 108 | | else |
| 109 | | buffer.cpy("---"); |
| 110 | | |
| 111 | | // record the menu item |
| 112 | | item_append("Mounted File", buffer, 0, (void *) image); |
| 113 | 142 | } |
| 114 | 143 | item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); |
| 115 | 144 | item_append("Reset", NULL, 0, (void *)1); |