ui: re-arranged File Manager a little bit, so that image devices are grouped

by owner, like Inputs / Dips / Configs menus. nw.
This commit is contained in:
etabeta78 2015-01-16 17:14:36 +01:00
parent 74dceac837
commit de52468837
2 changed files with 67 additions and 36 deletions

View File

@ -59,57 +59,86 @@ void ui_menu_file_manager::custom_render(void *selectedref, float top, float bot
}
void ui_menu_file_manager::fill_image_line(device_image_interface *img, astring &instance, astring &filename)
{
// get the image type/id
instance.printf("%s (%s)", img->instance_name(), img->brief_instance_name());
// get the base name
if (img->basename() != NULL)
{
filename.cpy(img->basename());
// if the image has been loaded through softlist, also show the loaded part
if (img->part_entry() != NULL)
{
const software_part *tmp = img->part_entry();
if (tmp->name() != NULL)
{
filename.cat(" (");
filename.cat(tmp->name());
// also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it
if (img->get_feature("part_id") != NULL)
{
filename.cat(": ");
filename.cat(img->get_feature("part_id"));
}
filename.cat(")");
}
}
}
else
filename.cpy("---");
}
//-------------------------------------------------
// populate
//-------------------------------------------------
void ui_menu_file_manager::populate()
{
astring buffer;
bool first = true;
astring buffer, tmp_inst, tmp_name;
bool first_entry = true;
astring prev_owner;
// cycle through all devices for this system
image_interface_iterator iter(machine().root_device());
for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
device_iterator iter(machine().root_device());
tagmap_t<UINT8> devtags;
for (device_t *dev = iter.first(); dev != NULL; dev = iter.next())
{
if (first)
first = false;
else
item_append("", NULL, MENU_FLAG_DISABLE, NULL);
bool tag_appended = false;
if (devtags.add(dev->tag(), 1, FALSE) == TMERR_DUPLICATE)
continue;
// get the image type/id
buffer.printf("%s (%s)", image->instance_name(), image->brief_instance_name());
item_append(buffer, "", MENU_FLAG_DISABLE, NULL);
item_append("Device", image->device().tag(), MENU_FLAG_DISABLE, NULL);
// get the base name
if (image->basename() != NULL)
{
buffer.cpy(image->basename());
// if the image has been loaded through softlist, also show the loaded part
if (image->part_entry() != NULL)
// check whether it owns an image interface
image_interface_iterator subiter(*dev);
if (subiter.count() > 0)
{
// if so, cycle through all its image interfaces
image_interface_iterator subiter(*dev);
for (device_image_interface *scan = subiter.first(); scan != NULL; scan = subiter.next())
{
const software_part *tmp = image->part_entry();
if (tmp->name() != NULL)
{
buffer.cat(" (");
buffer.cat(tmp->name());
// also check if this part has a specific part_id (e.g. "Map Disc", "Bonus Disc", etc.), and in case display it
if (image->get_feature("part_id") != NULL)
// if it is a children device, and not something further down the device tree, we want it in the menu!
if (strcmp(scan->device().owner()->tag(), dev->tag()) == 0)
if (devtags.add(scan->device().tag(), 1, FALSE) != TMERR_DUPLICATE)
{
buffer.cat(": ");
buffer.cat(image->get_feature("part_id"));
// check whether we already had some devices with the same owner: if not, output the owner tag!
if (!tag_appended)
{
if (first_entry)
first_entry = false;
else
item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
buffer.printf("[root%s]", dev->tag());
item_append(buffer, NULL, 0, NULL);
tag_appended = true;
}
// finally, append the image interface to the menu
fill_image_line(scan, tmp_inst, tmp_name);
item_append(tmp_inst, tmp_name, 0, (void *) scan);
}
buffer.cat(")");
}
}
}
else
buffer.cpy("---");
// record the menu item
item_append("Mounted File", buffer, 0, (void *) image);
}
item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
item_append("Reset", NULL, 0, (void *)1);

View File

@ -25,6 +25,8 @@ public:
virtual void populate();
virtual void handle();
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
void fill_image_line(device_image_interface *img, astring &instance, astring &filename);
};
#endif /* __UI_FILEMNGR_H__ */