src/emu/uiimage.c
| r8409 | r8410 | |
| 55 | 55 | { |
| 56 | 56 | SELECTOR_ENTRY_TYPE_EMPTY, |
| 57 | 57 | SELECTOR_ENTRY_TYPE_CREATE, |
| 58 | SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, |
| 58 | 59 | SELECTOR_ENTRY_TYPE_DRIVE, |
| 59 | 60 | SELECTOR_ENTRY_TYPE_DIRECTORY, |
| 60 | 61 | SELECTOR_ENTRY_TYPE_FILE |
| r8409 | r8410 | |
| 644 | 645 | text = "[create]"; |
| 645 | 646 | break; |
| 646 | 647 | |
| 648 | case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST: |
| 649 | text = "[software list]"; |
| 650 | break; |
| 651 | |
| 647 | 652 | case SELECTOR_ENTRY_TYPE_DRIVE: |
| 648 | 653 | text = entry->basename; |
| 649 | 654 | subtext = "[DRIVE]"; |
| r8409 | r8410 | |
| 698 | 703 | append_file_selector_entry(menu, menustate, SELECTOR_ENTRY_TYPE_CREATE, NULL, NULL); |
| 699 | 704 | } |
| 700 | 705 | |
| 706 | /* add the "[software list]" entry */ |
| 707 | append_file_selector_entry(menu, menustate, SELECTOR_ENTRY_TYPE_SOFTWARE_LIST, NULL, NULL); |
| 708 | |
| 701 | 709 | /* add the drives */ |
| 702 | 710 | i = 0; |
| 703 | 711 | while((volume_name = osd_get_volume_name(i))!=NULL) |
| r8409 | r8410 | |
| 808 | 816 | child_menustate->manager_menustate = menustate->manager_menustate; |
| 809 | 817 | ui_menu_stack_push(child_menu); |
| 810 | 818 | break; |
| 811 | | |
| 819 | case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST: |
| 820 | child_menu = ui_menu_alloc(machine, render_container_get_ui(), ui_image_menu_software, menustate->manager_menustate->selected_device); |
| 821 | ui_menu_stack_push(child_menu); |
| 822 | break; |
| 812 | 823 | case SELECTOR_ENTRY_TYPE_DRIVE: |
| 813 | 824 | case SELECTOR_ENTRY_TYPE_DIRECTORY: |
| 814 | 825 | /* drive/directory - first check the path */ |
src/emu/softlist.c
| r8409 | r8410 | |
| 1312 | 1312 | struct _software_menu_state |
| 1313 | 1313 | { |
| 1314 | 1314 | char *list_name; /* currently selected list */ |
| 1315 | device_image_interface* image; |
| 1315 | 1316 | }; |
| 1316 | 1317 | |
| 1317 | 1318 | /* state of a software entry */ |
| r8409 | r8410 | |
| 1324 | 1325 | |
| 1325 | 1326 | |
| 1326 | 1327 | /* populate a specific list */ |
| 1327 | | static void ui_mess_menu_populate_software_entries(running_machine *machine, ui_menu *menu, char *list_name) |
| 1328 | static void ui_mess_menu_populate_software_entries(running_machine *machine, ui_menu *menu, char *list_name, device_image_interface* image) |
| 1328 | 1329 | { |
| 1329 | 1330 | software_list *list = software_list_open(mame_options(), list_name, FALSE, NULL); |
| 1330 | | |
| 1331 | const char *interface = image->image_config().image_interface(); |
| 1331 | 1332 | if (list) |
| 1332 | 1333 | { |
| 1333 | 1334 | for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo)) |
| r8409 | r8410 | |
| 1337 | 1338 | |
| 1338 | 1339 | software_part *part = software_find_part(swinfo, NULL, NULL); |
| 1339 | 1340 | entry->interface = ui_menu_pool_strdup(menu, part->interface_); |
| 1340 | | |
| 1341 | | ui_menu_item_append(menu, swinfo->shortname, swinfo->longname, 0, entry); |
| 1341 | if (strcmp(interface,part->interface_)==0) { |
| 1342 | ui_menu_item_append(menu, swinfo->shortname, swinfo->longname, 0, entry); |
| 1343 | } |
| 1342 | 1344 | } |
| 1343 | 1345 | |
| 1344 | 1346 | software_list_close(list); |
| r8409 | r8410 | |
| 1350 | 1352 | const ui_menu_event *event; |
| 1351 | 1353 | software_menu_state *sw_state = (software_menu_state *)state; |
| 1352 | 1354 | |
| 1353 | | if (!ui_menu_populated(menu)) |
| 1354 | | ui_mess_menu_populate_software_entries(machine, menu, sw_state->list_name); |
| 1355 | if (!ui_menu_populated(menu)) { |
| 1356 | if (sw_state->list_name) { |
| 1357 | ui_mess_menu_populate_software_entries(machine, menu, sw_state->list_name,sw_state->image); |
| 1358 | } |
| 1359 | } |
| 1355 | 1360 | |
| 1356 | 1361 | /* process the menu */ |
| 1357 | 1362 | event = ui_menu_process(machine, menu, 0); |
| 1358 | 1363 | |
| 1359 | 1364 | if (event != NULL && event->iptkey == IPT_UI_SELECT && event->itemref != NULL) |
| 1360 | 1365 | { |
| 1361 | | device_image_interface *image = NULL; |
| 1362 | | device_image_interface *sel_image = NULL; |
| 1366 | device_image_interface *sel_image = sw_state->image; |
| 1363 | 1367 | software_entry_state *entry = (software_entry_state *) event->itemref; |
| 1364 | | |
| 1365 | | /* search for a device with the right interface */ |
| 1366 | | for (bool gotone = machine->devicelist.first(image); gotone; gotone = image->next(image)) |
| 1367 | | { |
| 1368 | | const char *interface = image->image_config().image_interface(); |
| 1369 | | |
| 1370 | | if (interface != NULL) |
| 1371 | | { |
| 1372 | | if (!strcmp(interface, entry->interface)) |
| 1373 | | { |
| 1374 | | sel_image = image; |
| 1375 | | break; |
| 1376 | | } |
| 1377 | | } |
| 1378 | | } |
| 1379 | | |
| 1380 | 1368 | if (sel_image != NULL) |
| 1381 | 1369 | sel_image->load(entry->short_name); |
| 1382 | 1370 | else |
| r8409 | r8410 | |
| 1385 | 1373 | } |
| 1386 | 1374 | |
| 1387 | 1375 | /* list of available software lists - i.e. cartridges, floppies */ |
| 1388 | | static void ui_mess_menu_populate_software_list(running_machine *machine, ui_menu *menu) |
| 1376 | static void ui_mess_menu_populate_software_list(running_machine *machine, ui_menu *menu, device_image_interface* image) |
| 1389 | 1377 | { |
| 1378 | bool haveCompatible = FALSE; |
| 1379 | const char *interface = image->image_config().image_interface(); |
| 1380 | |
| 1390 | 1381 | for (const device_config *dev = machine->config->devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext()) |
| 1391 | 1382 | { |
| 1392 | 1383 | software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config(); |
| 1393 | 1384 | |
| 1394 | 1385 | for (int i = 0; i < DEVINFO_STR_SWLIST_MAX - DEVINFO_STR_SWLIST_0; i++) |
| 1395 | 1386 | { |
| 1396 | | if (swlist->list_name[i]) |
| 1387 | if (swlist->list_name[i] && (swlist->list_type == SOFTWARE_LIST_ORIGINAL_SYSTEM)) |
| 1397 | 1388 | { |
| 1398 | 1389 | software_list *list = software_list_open(mame_options(), swlist->list_name[i], FALSE, NULL); |
| 1399 | 1390 | |
| 1400 | 1391 | if (list) |
| 1401 | 1392 | { |
| 1402 | | /* todo: fix this */ |
| 1393 | bool found = FALSE; |
| 1403 | 1394 | for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo)) |
| 1404 | 1395 | { |
| 1396 | software_part *part = software_find_part(swinfo, NULL, NULL); |
| 1397 | if (strcmp(interface,part->interface_)==0) { |
| 1398 | found = TRUE; |
| 1399 | } |
| 1400 | } |
| 1401 | if (found) { |
| 1402 | ui_menu_item_append(menu, list->description, NULL, 0, swlist->list_name[i]); |
| 1405 | 1403 | } |
| 1406 | 1404 | |
| 1407 | | ui_menu_item_append(menu, list->description, NULL, 0, swlist->list_name[i]); |
| 1405 | software_list_close(list); |
| 1406 | } |
| 1407 | } |
| 1408 | } |
| 1409 | } |
| 1410 | |
| 1411 | for (const device_config *dev = machine->config->devicelist.first(SOFTWARE_LIST); dev != NULL; dev = dev->typenext()) |
| 1412 | { |
| 1413 | software_list_config *swlist = (software_list_config *)downcast<const legacy_device_config_base *>(dev)->inline_config(); |
| 1408 | 1414 | |
| 1415 | for (int i = 0; i < DEVINFO_STR_SWLIST_MAX - DEVINFO_STR_SWLIST_0; i++) |
| 1416 | { |
| 1417 | if (swlist->list_name[i] && (swlist->list_type == SOFTWARE_LIST_COMPATIBLE_SYSTEM)) |
| 1418 | { |
| 1419 | software_list *list = software_list_open(mame_options(), swlist->list_name[i], FALSE, NULL); |
| 1420 | |
| 1421 | if (list) |
| 1422 | { |
| 1423 | bool found = FALSE; |
| 1424 | for (software_info *swinfo = software_list_find(list, "*", NULL); swinfo != NULL; swinfo = software_list_find(list, "*", swinfo)) |
| 1425 | { |
| 1426 | software_part *part = software_find_part(swinfo, NULL, NULL); |
| 1427 | if (strcmp(interface,part->interface_)==0) { |
| 1428 | found = TRUE; |
| 1429 | } |
| 1430 | } |
| 1431 | if (found) { |
| 1432 | if (!haveCompatible) { |
| 1433 | ui_menu_item_append(menu, "[compatible lists]", NULL, 0, NULL); |
| 1434 | } |
| 1435 | ui_menu_item_append(menu, list->description, NULL, 0, swlist->list_name[i]); |
| 1436 | } |
| 1437 | |
| 1438 | haveCompatible = TRUE; |
| 1409 | 1439 | software_list_close(list); |
| 1410 | 1440 | } |
| 1411 | 1441 | } |
| 1412 | 1442 | } |
| 1413 | 1443 | } |
| 1444 | |
| 1414 | 1445 | } |
| 1415 | 1446 | |
| 1416 | 1447 | void ui_image_menu_software(running_machine *machine, ui_menu *menu, void *parameter, void *state) |
| 1417 | 1448 | { |
| 1418 | 1449 | const ui_menu_event *event; |
| 1419 | | |
| 1450 | device_image_interface* image = (device_image_interface*)parameter; |
| 1420 | 1451 | if (!ui_menu_populated(menu)) |
| 1421 | | ui_mess_menu_populate_software_list(machine, menu); |
| 1452 | ui_mess_menu_populate_software_list(machine, menu, image); |
| 1422 | 1453 | |
| 1423 | 1454 | /* process the menu */ |
| 1424 | 1455 | event = ui_menu_process(machine, menu, 0); |
| r8409 | r8410 | |
| 1428 | 1459 | ui_menu *child_menu = ui_menu_alloc(machine, render_container_get_ui(), ui_mess_menu_software_list, NULL); |
| 1429 | 1460 | software_menu_state *child_menustate = (software_menu_state *)ui_menu_alloc_state(child_menu, sizeof(*child_menustate), NULL); |
| 1430 | 1461 | child_menustate->list_name = (char *)event->itemref; |
| 1462 | child_menustate->image = image; |
| 1431 | 1463 | ui_menu_stack_push(child_menu); |
| 1432 | 1464 | } |
| 1433 | 1465 | } |
src/emu/softlist.h
| r8409 | r8410 | |
| 87 | 87 | struct _software_list_config |
| 88 | 88 | { |
| 89 | 89 | char *list_name[SOFTWARE_LIST_CONFIG_SIZE]; |
| 90 | UINT32 list_type; |
| 90 | 91 | }; |
| 91 | 92 | |
| 92 | 93 | |
| 93 | 94 | #define DEVINFO_STR_SWLIST_0 (DEVINFO_STR_DEVICE_SPECIFIC+0) |
| 94 | 95 | #define DEVINFO_STR_SWLIST_MAX (DEVINFO_STR_SWLIST_0 + SOFTWARE_LIST_CONFIG_SIZE - 1) |
| 95 | 96 | |
| 97 | #define SOFTWARE_LIST_ORIGINAL_SYSTEM 0 |
| 98 | #define SOFTWARE_LIST_COMPATIBLE_SYSTEM 1 |
| 96 | 99 | |
| 97 | | #define MDRV_SOFTWARE_LIST_CONFIG(_idx,_list) \ |
| 98 | | MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(software_list_config, list_name, _idx, _list) |
| 100 | #define MDRV_SOFTWARE_LIST_CONFIG(_idx,_list,_list_type) \ |
| 101 | MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(software_list_config, list_name, _idx, _list) \ |
| 102 | MDRV_DEVICE_CONFIG_DATA32(software_list_config, list_type, _list_type) |
| 99 | 103 | |
| 100 | 104 | #define MDRV_SOFTWARE_LIST_ADD( _tag, _list ) \ |
| 101 | 105 | MDRV_DEVICE_ADD( _tag, SOFTWARE_LIST, 0 ) \ |
| 102 | | MDRV_SOFTWARE_LIST_CONFIG(0,_list) |
| 106 | MDRV_SOFTWARE_LIST_CONFIG(0,_list, SOFTWARE_LIST_ORIGINAL_SYSTEM) |
| 103 | 107 | |
| 104 | 108 | |
| 109 | #define MDRV_SOFTWARE_LIST_COMPATIBLE_ADD( _tag, _list ) \ |
| 110 | MDRV_DEVICE_ADD( _tag, SOFTWARE_LIST, 0 ) \ |
| 111 | MDRV_SOFTWARE_LIST_CONFIG(0,_list, SOFTWARE_LIST_COMPATIBLE_SYSTEM) |
| 112 | |
| 113 | |
| 105 | 114 | #define MDRV_SOFTWARE_LIST_MODIFY( _tag, _list ) \ |
| 106 | 115 | MDRV_DEVICE_MODIFY( _tag ) \ |
| 107 | | MDRV_SOFTWARE_LIST_CONFIG(0,_list) |
| 116 | MDRV_SOFTWARE_LIST_CONFIG(0,_list, SOFTWARE_LIST_ORIGINAL_SYSTEM) |
| 108 | 117 | |
| 118 | #define MDRV_SOFTWARE_LIST_COMPATIBLE_MODIFY( _tag, _list ) \ |
| 119 | MDRV_DEVICE_MODIFY( _tag ) \ |
| 120 | MDRV_SOFTWARE_LIST_CONFIG(0,_list, SOFTWARE_LIST_COMPATIBLE_SYSTEM) |
| 109 | 121 | |
| 110 | 122 | #endif |